def _append_empty(self, num_obs, memo): empty = TimeDelta([timedelta(seconds=0)] * num_obs, scale="utc", fmt="timedelta") empty_id = id(empty) self.data = TimeDeltaArray.insert(self.data, self.num_obs, empty, memo) memo.pop(empty_id, None)
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 = TimeDeltaArray._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 = TimeDeltaArray.insert(self.data, self.num_obs, other_field.data, memo)