What is the recommended way to convert DeltaQuantity to Quantity? #407
benhutchison
started this conversation in
General
Replies: 1 comment 1 reply
-
extension [VL, UL, B] (d: DeltaQuantity[VL, UL, B])
def toQuantity: Quantity[VL, UL] = d.value.withUnit[UL] |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a bunch of millisecond timestamps modeled as
DeltaQuantity
s.I need to bin them into groups n seconds wide. That is, all timestamps within a time period of n seconds should be mapped to the same group (ie index).
To do this requires dividing the timestamp quantities by the window width. But I can't divide a DeltaQuantity by a Quantity directly. Rather, I ought to convert the DeltaQuantity into a Quantity.
I found myself wanting a
toQuantity
operation forDeltaQuantity
that yields a quantity using whatever origin/zero is defined naturally by that DeltaQuantity. Making a separate zero value and subtracting it from each timestamp feels like quite a lot of bother..Beta Was this translation helpful? Give feedback.
All reactions