Curious why in the below code you are setting the default of the parameters to None and then checking for None before assigning properties to the self object? Why not just set the defaults within the method definition? For example instead of setting time=None, just set def add_data(self, time=np.arange(0,10,0.0188),...) and then in the body of the method set self.time = time. If the user doesn't put in a time value it will default as expected, otherwise self.time will be set to whatever the user entered for time.
def add_data(self, time=None, itime=None,
ntt=None, tobs=None, omc=None,
datatype=None):
"""
Add data after all the planets are added!!
"""
if time is None:
self.time = np.arange(0,10,0.0188)
else:
self.time = time
npt = len(self.time)
nmax = 1500000
if itime is None:
default_cadence = 1625.3 / 86400.
self.itime = np.zeros(npt) + default_cadence
else:
self.itime = itime
if ntt is None:
self.ntt = np.zeros(self.nplanets)
else:
self.ntt = ntt
if tobs is None:
self.tobs = np.empty([self.nplanets,nmax])
else:
self.tobs = tobs
if omc is None:
self.omc = np.empty([self.nplanets,nmax])
else:
self.omc = omc
if datatype is None:
self.datatype = np.zeros(npt)
else:
self.datatype = datatype
Curious why in the below code you are setting the default of the parameters to None and then checking for None before assigning properties to the self object? Why not just set the defaults within the method definition? For example instead of setting
time=None
, just setdef add_data(self, time=np.arange(0,10,0.0188),...)
and then in the body of the method setself.time = time
. If the user doesn't put in a time value it will default as expected, otherwiseself.time
will be set to whatever the user entered for time.