Open barche opened 8 years ago
Area
and Pressure
are abstract types, so you're actually making abstractly-typed arrays (Array{Area,1}
objects). If you leave off the Area
, you're letting Julia type the array. Unitful has some logic to figure out an appropriate concrete type for the array if you try to make an array with mixed units, but same dimensionality:
julia> [1.0u"μm", 1.0u"mm"]
2-element Array{Quantity{Float64, Dimensions:{𝐋}, Units:{m}},1}:
1.0e-6 m
0.001 m
That logic can be customized by the user if needed. Avoiding abstractly-typed arrays is important for performance reasons, see http://docs.julialang.org/en/release-0.5/manual/performance-tips/.
It would be nice if what you tried still worked or had an informative error message, I'll see what I can do when I have some time.
OK, just to add some context as to why I tried this:
It would be nice if the axes could be labeled automatically in this example as Area (m²) and Pressure (Pa). That way the unit does not have to be repeated at every number on the axes, reducing clutter. The ultimate reason I want this to work with derived quantities is so I can plot things like enhalpy and heat, which all have the same unit but different names. It would be awesome if just plot(s,T)
would produce a correctly labeled T-s diagram.
Ah, I see. I think it could still be possible without the array being typed abstractly. I can work with dimension(eltype(A))
or something similar.
Hi,
This package is a great idea, thanks. I tried plotting some derived units:
But this results in the error:
If I leave out the
Area
andPressure
it works.