batchglm icon indicating copy to clipboard operation
batchglm copied to clipboard

Nicer model initialisation

Open picciama opened this issue 3 years ago • 2 comments

Need to discuss how we handle this: https://github.com/theislab/batchglm/blob/604823001e81fdab232fe27dc59dab8d506ea020/batchglm/models/base_glm/model.py#L66-L82

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

picciama avatar Mar 04 '22 21:03 picciama

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

ilan-gold avatar Mar 04 '22 22:03 ilan-gold

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

picciama avatar Mar 05 '22 08:03 picciama