You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similarly to what happens with Algorithms here we have a method set_up that is used to set-up the reader/writer class.
While it can be argued that with a simple class that requires just a file name to be passed, all the rest might be overkill, I see that having a single function to configure the class is not nice.
For example the TIFFStackReader may accept just a file name, but it allows the user to do more advanced stuff as defining a roi (with roi and mode parameters) and also transpose the data.
Currently one needs to either pass everything in the initialisation or with set_up:
The obvious advantage being that the user does not need to reinstantiate a class when just the roi has changed, for instance.
Additionally or better primarily, it is much more maintainable if set_up refers to smaller methods that do the small bits. The docstrings will also be smaller and clearer:
Good points. A few quick questions:
1. Is there a special reason to have a "setup" function instead of
"__init__"? It seems simpler to me that we specify the parameters we want
directly when we initialise the object, instead of in multiple lines after
that.
2. Is it not possible to combine the two approaches of passing as keyword
arguments and using the "self.roi = roi" style? For example you can
initialise your object with on choice of ROI and then update it later,
without calling any setup or init function but just do obj.roi = roi, for
an object called obj.
Good points. A few quick questions: 1. Is there a special reason to have a "setup" function instead of "init"? It seems simpler to me that we specify the parameters we want directly when we initialise the object, instead of in multiple lines after that.
I believe the choice here was to try to simplify the __init__ so that it would refer to other functions which do the job
Is it not possible to combine the two approaches of passing as keyword arguments and using the "self.roi = roi" style? For example you can initialise your object with on choice of ROI and then update it later, without calling any setup or init function but just do obj.roi = roi, for an object called obj.
It is possible when self.roi is not a member but a property of the class:
@propertydefroi(self):
returnself._roi@roi.setterdefroi(self, roi):
# do some checks then save the reference in the classself._roi=roi
Of course we have our usual discussion where you like to specify everything in the initialisation and I prefer more verbose, yet clearer IMHO, and more object oriented approaches.
Similarly to what happens with
Algorithm
s here we have a methodset_up
that is used to set-up the reader/writer class.While it can be argued that with a simple class that requires just a file name to be passed, all the rest might be overkill, I see that having a single function to configure the class is not nice.
For example the
TIFFStackReader
may accept just a file name, but it allows the user to do more advanced stuff as defining a roi (withroi
andmode
parameters) and alsotranspose
the data.Currently one needs to either pass everything in the initialisation or with
set_up
:In fact, I find both not good enough. One should use a more Object oriented (though more verbose) form:
The obvious advantage being that the user does not need to reinstantiate a class when just the
roi
has changed, for instance.Additionally or better primarily, it is much more maintainable if
set_up
refers to smaller methods that do the small bits. The docstrings will also be smaller and clearer:The text was updated successfully, but these errors were encountered: