-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create ScientificTypes.jl extension #31
Conversation
a13fb84
to
4ecd4d4
Compare
Benchmark Results
Benchmark PlotsA plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. |
@MilesCranmer I don't see anything wrong with your idea. While your idea is fine. The implementations isn't quite right. |
Yep, it basically inherits all behaviour from the value type. So if it stores a float, then it acts exactly like a float with functions in
My only question would be: is it better I extend (The main reason I’m doing this is to get SymbolicRegression working with units) |
d58f9f5
to
f4f3082
Compare
Okay I think I fixed the interface: import ScientificTypes as ST
import ScientificTypesBase as STB
STB.scitype(x::AbstractQuantity, C::ST.DefaultConvention) = STB.scitype(ustrip(x), C)
STB.Scitype(::Type{<:AbstractQuantity{T}}, C::ST.DefaultConvention) where {T} = STB.Scitype(T, C) |
Merging now so I can get quantities working in SymbolicRegression.jl. But we can change this in the future if need be. |
@OkonSamuel @ablaom might one of you have some time to perhaps look at this and let me know if this is the correct way to forward
scitype
traits? It's a pretty lightweight interface; it basically just forwards thescitype
call on the value of a physical quantity, while ignore the units.The tricky part about this is integration that the units of
Quantity{...,Dimensions{...}}
objects are in SI base units, so as an example: you technically could not have aCount
number of femtometers. It would need to be represented as a float, and therefore would beContinuous
. This is a limitation of DynamicQuantities.jl perhaps, although you could create a customAbstractDimensions
that uses femtometers as a base.I'm also opening to simply declaring
scitype(::AbstractQuantity) = Continuous
in all cases if that is better semantics, as physical quantities usually are measured continuously. Then again, perhaps someone has a customscitype
for the values they are working with – and it wouldn't make sense to override their chosen trait.Hre are the current tests which illustrate the usage: