I've recently added a bunch of tests to the Time object, and found a couple bugs in the process.
But a number of questions came up to keep in mind for refactoring.
1) The constant_time class method -- produced a Time object with one arbitrary datetime in it, and does some magic to make sure that you get a singleton. which I guess is good 'cause then equality testing will work, but:
Maybe a subclass for constant time -- then you don't need to check for length-one in various places, and equality wouldn't require the singleton.
And/or simply create one at module init, and then use that.
2) Would it make sense to use a numpy datetime array, rather than an array of datetime objects?
3) tz_offset and displacement are the same thing -- any reason to have them both? If both, maybe tz_ofset would be in hours, rather than a timedelta? -- OK, added this :-) -- you can now pass either a timedelta or a number of hours.
4) Interpolation: This is about how it fits inot the rest of the system, but shouldn't the interp_alpha return the index as well -- to make sure it's consistent? and/or return two indices and alphas.?
5) There is logic inthe __init__ about trying to decode the netcdf time variable -- that logic should be in the netcdf loading code, not the main Time init.
I've recently added a bunch of tests to the Time object, and found a couple bugs in the process.
But a number of questions came up to keep in mind for refactoring.
1) The
constant_time
class method -- produced a Time object with one arbitrary datetime in it, and does some magic to make sure that you get a singleton. which I guess is good 'cause then equality testing will work, but:2) Would it make sense to use a numpy datetime array, rather than an array of datetime objects?
3)
tz_offset
and displacement are the same thing -- any reason to have them both? If both, maybe tz_ofset would be in hours, rather than a timedelta? -- OK, added this :-) -- you can now pass either a timedelta or a number of hours.4) Interpolation: This is about how it fits inot the rest of the system, but shouldn't the
interp_alpha
return the index as well -- to make sure it's consistent? and/or return two indices and alphas.?5) There is logic inthe
__init__
about trying to decode the netcdf time variable -- that logic should be in the netcdf loading code, not the main Time init.