Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
    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)