Comments (7)
As I said, I'm not very happy about point 1. Subtypying AbstractFloat
instead of Real
has several advantages, you get many more methods for free with that instead of <: Real
, and point 2 would require having this package depend on Symbolics
(assuming that the constraint you want to put would be placed in an inner constructor of the Measurement
type), which is also not something I'm very happy about.
from measurements.jl.
Making Measurement <: AbstractFloat
instead of <: Real
was a decision taken very early on in #1 (as you can tell from the very low number). I'm not going to reverse that decision.
from measurements.jl.
Thank you for replying!
Yes, i have seen that issue when looking at git blame
for some of the affected lines of code.
I understand that during the computation, the result inevitably ends up being non-integral,
so excluding Integer
types and promoting to AbstractFloat
upfront makes sense.
I guess, if someone really wants to avoid FP precision issues, they'd use BigFloat
's?
However, it is not so clear-cut given symbolic inputs, because there the result will still be symbolic.
Note that i'm not arguing for allowing everything that is a Real
!
Perhaps, could something like this be done instead?
- Make
Measurement{T <: Real} <: Real
- Prohibit
T
that is neitherAbstractFloat
norSymbolics::Num
(i.e. as compared to now, allowSymbolics::Num
) - At contruction time, promote
Real
's toAbstractFloat
's if they are notSymbolics::Num
.
from measurements.jl.
... does that make sense?
from measurements.jl.
Thank you for taking a look!
As I said, I'm not very happy about point 1. Subtypying
AbstractFloat
instead ofReal
has several advantages, you get many more methods for free with that instead of<: Real
To be honest, i'm not as familiar with julia, so i'm not fully //sure// doing so is necessary,
i'm only guessing that it is. If it works with just Measurement{T <: Real} <: AbstractFloat
,
with Measurement{Num}
, then great, no need for Measurement{T <: Real} <: Real
...
and point 2 would require having this package depend on
Symbolics
(assuming that the constraint you want to put would be placed in an inner constructor of theMeasurement
type), which is also not something I'm very happy about.
Yes indeed, i have thought about that issue, and i fully agree with that pain point,
although i was waiting for you to also point it out before filing JuliaSymbolics/Symbolics.jl#898
from measurements.jl.
Rough proof of concept in #144, with all tests passing, but insufficient test coverage.
As I said, I'm not very happy about point 1. Subtypying
AbstractFloat
instead ofReal
has several advantages, you get many more methods for free with that instead of<: Real
To be honest, i'm not as familiar with julia, so i'm not fully //sure// doing so is necessary, i'm only guessing that it is. If it works with just
Measurement{T <: Real} <: AbstractFloat
, withMeasurement{Num}
, then great, no need forMeasurement{T <: Real} <: Real
...
So far it appears that Measurement{T<:Real} <: AbstractFloat
is sufficient.
and point 2 would require having this package depend on
Symbolics
(assuming that the constraint you want to put would be placed in an inner constructor of theMeasurement
type), which is also not something I'm very happy about.Yes indeed, i have thought about that issue, and i fully agree with that pain point, although i was waiting for you to also point it out before filing JuliaSymbolics/Symbolics.jl#898
It turns out, we can't depend on Symbolics
in the first place, because that creates a dependency cycle.
SciML/RecursiveArrayTools.jl#265 should deal with it.
from measurements.jl.
@giordano ok, i have a question.
From the library's perspective, which one of two possible compromises would be preferred:
1. Separating the functions to support symbolic-typed measurements into separate source files, and only loading them when the Symbolics
package is also present, via @require
in function __init__()
.
2. or, depending on //some//, hopefully tiny, package, and being able to have all the functions altogether.
I would guess 2. would result in best code, but will require cooperation from either SciML/RecursiveArrayTools.jl#264 or (preferrably )JuliaSymbolics/Symbolics.jl#898.
Edit: found a way to mix both of these in a nice way.
from measurements.jl.
Related Issues (20)
- Error when hashing Measurement{Float64} HOT 5
- Adding measurement components back to a measurement after iteratively solving for a value HOT 7
- [FR] Plot recipe: ribbon plots option beside error bars HOT 11
- tryparse for Measurement type
- Can't use unique with measurements HOT 1
- Measurements with missing errors HOT 4
- Measurements.value(x::Missing) = missing HOT 1
- Integration with Zygote
- `weightedmean()` returns `NaN ± 0`? HOT 1
- Use auto-differentiation engine
- Bad integration with Plots' boxplot HOT 2
- Move to pkgextensions for Julia v1.9+
- one(measurement) should return 1, not 1 ± 0 HOT 8
- Plotting mixture of measurements and missing data HOT 1
- Trying to use Measurements to differentiate respect to a unitful quantity. HOT 12
- Is there an autodiff package that is compatible? HOT 3
- Broken `MeasurementsJunoExt.jl` HOT 1
- Julia 1.6 incompatibility from stdlib compat bounds HOT 2
- Wrong values when multiplication with scalar? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from measurements.jl.