-
Notifications
You must be signed in to change notification settings - Fork 41
Closed
Description
I would suggest defining:
Base.one(::Type{Measurement{T}}) where T = one(T)
which still a correct answer since it is still a multiplicative identity for a Measurement
(type promotion takes care of the rest). In general, one(x)
need not return the same type as x
in Julia — if the caller wants the same type, they should use oneunit(x)
.
one(x)
is commonly used to "strip the units" from a quantity, and it would provide a nice generic way to extract the underlying scalar type from a measurement. For example, this code in QuadGK.jl should work as-is for Measurement
if you define one
, and you should no longer need to implement specialized QuadGK methods. (Hopefully you can eliminate your QuadGK dependency completely and it will just work.)
Metadata
Metadata
Assignees
Labels
No labels