def _read(cls, h5_group, memo) -> "TimeField": """Read a TimeField from a HDF5 data source""" name = h5_group.attrs["fieldname"] if name in memo: time = memo[name] else: time = TimeArray._read(h5_group, memo) return cls(num_obs=len(time), name=name.split(".")[-1], val=time)
def _extend(self, other_field, memo) -> None: """Add observations from another field""" if other_field.data.ndim != self.data.ndim: raise ValueError( f"Field '{self.name}' cannot be extended. Dimensions must be equal. ({other_field.data.ndim} != {self.data.ndim})" ) self.data = TimeArray.insert(self.data, self.num_obs, other_field.data, memo)
def _append_empty(self, num_obs, memo): # Use datetime.min as "empty" value empty = Time([datetime.min] * num_obs, scale="utc", fmt="datetime") empty_id = id(empty) self.data = TimeArray.insert(self.data, self.num_obs, empty, memo) memo.pop(empty_id, None)