Comments (6)
Hi @cadojo,
Thanks for the report. Excited to hear about the package you are making!
Is this Julia 1.10? Does it go away on Julia 1.9?
One thing to note is that the SymbolicDimensions symbols (e.g., us"m"
) don’t exist during precompilation. The reason for this is that there are so many, it makes startup time slow unless you are using them. So I wonder if it’s related to that.
Best,
Miles
from dynamicquantities.jl.
The quick fix would be to change
+ flux_distance(m, M) = 10^((m - M + 5) // 5) * u"Constants.pc"
- flux_distance(m, M) = 10^((m - M + 5) // 5) * us"Constants.pc"
us
(SymbolicDimensions) is intended to be for display, whereas u
(Dimensions) is intended to be for calculations.
us
would not be available during precompilation because the variables are created upon first call. But maybe we can change that.
from dynamicquantities.jl.
Thanks Miles! I did change all instances of us"Constants.pc"
to just Constants.pc
, and that worked also. I'm using Julia 1.9 — my versioninfo()
is shown below.
Julia Version 1.9.3
Commit bed2cd540a1 (2023-08-24 14:43 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (arm64-apple-darwin22.4.0)
CPU: 8 × Apple M1
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-14.0.6 (ORCJIT, apple-m1)
Threads: 1 on 4 virtual cores
from dynamicquantities.jl.
Awesome. Okay I think we should go with that, what do you think? Then for display, I think @gaurav-arya has a good strategy proposed in #48
Basically, one can display units with as_u
(name pending) e.g.,
u"Constants.pc" / 0.05 |> as_u(us"Constants.kpc)
which would display 0.02 kpc
, even though the calculation happens with the faster Dimensions
.
from dynamicquantities.jl.
Works for me, and I like the unit conversion feature and syntax. The |>
is convenient. I also like the Unitful.uconvert
syntax, I see some benefit to having multiple different methods for as_u
so there are different options for converting one quantity's units to another: as_u(u"km", 100u"m")
or 100u"m" |> as_u(u"km")
.
So all of this is good for display and for my purposes, but could this issue pop up again? If I understand correctly, symbolic units can't be used in any Julia package, because they're created on-the-fly. With native code cacheing in Julia v1.9 and later, I wonder how much slower the package would be if all of the symbolic units are created at once? If no one has done that experiment yet, and if there's interest in the future, I'd be interested in trying that out.
from dynamicquantities.jl.
Okay now this issue is fixed for real – please try it out! You can do, e.g.,
const my_unit = us"ohm"
just fine, and precompilation should be good
from dynamicquantities.jl.
Related Issues (20)
- u"Ω" errors in precompilation HOT 6
- Base.isapprox fails for Vector{Quantity} HOT 14
- Meshes.jl test failure HOT 10
- Round tripping Quantities through String HOT 3
- `bionomial` and `factorial` functions not defined? HOT 5
- Molar units not supported HOT 7
- Why `one(1u"kg")` no dimension? HOT 2
- Pretty print element types of `QuantityArray` HOT 2
- Logo HOT 7
- Immutable constants for symbolic dimensions
- Registering custom unit propagation rules
- Choosing type of quantity value based on type used in construction HOT 1
- Further improvements to startup time HOT 1
- Behavior with `missing` HOT 6
- Adding "missing" units HOT 4
- Compatibility with `zero(::Type{T})` HOT 6
- Unitful conversion fails for symbolic units HOT 7
- Sweep: Define `NoDims` for indicating something is not a quantity HOT 2
- `reduce(vcat` returns corrupted result HOT 1
- `map` fails with `QuantityArray` 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 dynamicquantities.jl.