def test_time_classes(inputs, time_ref): data = write_read_buffer({"root": inputs}) assert np.all(data["root"] == inputs) if isinstance(inputs, pd.Index) and not inputs.is_monotonic: # this is not valid for the time class, hence cancel here return t1 = Time(inputs, time_ref) t2 = write_read_buffer({"root": t1})["root"] assert t1.equals(t2)
def test_convert_util(): """Test basic conversion functions from/to xarray/pint.""" t = pd.date_range("2020", periods=10, freq="1s") ts = t[0] arr = xr.DataArray( np.arange(10), dims=["time"], coords={"time": t - ts}, ) arr.time.weldx.time_ref = ts time = Time(arr) assert len(time) == len(t) assert time.equals(Time(t)) time_q = time.as_quantity() assert np.all(time_q == Q_(range(10), "s")) assert time_q.time_ref == ts arr2 = time.as_data_array() assert arr.time.identical(arr2.time)