Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nicer model initialisation #132

Open
picciama opened this issue Mar 4, 2022 · 2 comments
Open

Nicer model initialisation #132

picciama opened this issue Mar 4, 2022 · 2 comments
Assignees
Labels

Comments

@picciama
Copy link
Collaborator

picciama commented Mar 4, 2022

Need to discuss how we handle this:

def extract_input_data(self, input_data: InputDataGLM):
self._design_loc = input_data.design_loc
self._design_scale = input_data.design_scale
self._size_factors = input_data.size_factors
self._constraints_loc = input_data.constraints_loc
self._constraints_scale = input_data.constraints_scale
self._design_loc_names = input_data.design_loc_names
self._design_scale_names = input_data.design_scale_names
self._loc_names = input_data.loc_names
self._scale_names = input_data.scale_names
self._x = input_data.x
self._size_factors = input_data.size_factors
self._cast_dtype = input_data.cast_dtype
self._chunk_size_genes = input_data.chunk_size_genes
self._chunk_size_cells = input_data.chunk_size_cells
self._xh_loc = np.matmul(self.design_loc, self.constraints_loc)
self._xh_scale = np.matmul(self.design_scale, self.constraints_scale)

There are basically three options in my opinion:

  1. Remove InputDataGLM entirely: We only use it as a container now that does some type checks in the beginning which we could do statically in utils anyway.
  2. Keep InputDataGLM and reference the attributes in the model properties, i.e. model.input_data.<attribute> when calling model.attribute
  3. override model.__getattr__ like so:
    def __getattr__(self, attr: str):
        return self.input_data.__getattribute__(attr)

I'm in favour of 2 but as a way in between to keep this support, maybe 3 would be an elegant solution for now.

Please advise @ilan-gold @davidsebfischer

@ilan-gold
Copy link
Collaborator

What does 2 allow that 3 doesn't? Not sure I follow the what you mean by "keep this support"

@picciama
Copy link
Collaborator Author

picciama commented Mar 5, 2022

Sorry I meant 1. 2 would probably be cleaner than 3 but other than that not really a different as in both casese input_data is a model attribute

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants