JuliaPhysics / JuliaPhysics/Unitful.jl
isapprox bug, and doubts regarding container methods
- Dominant language
- Julia
- Stars
- 675
- Forks
- 124
- Avg merge
- 3h 38m
- Merged PRs (30d)
- 1
Description
On Julia 1.8.1 (and also on 1.7.3)
```
using Unitful; using Unitful:kg
julia> A = [1 2kg; 3/kg 4]
2×2 Matrix{Quantity{Int64}}:
1 2 kg
3 kg^-1 4
julia> A == A
true
julia> A ≈ A
false
julia> A ≈ 2A
ERROR: DimensionError: and kg^-1 are not dimensionally compatible.
...
julia> A .≈ A
2×2 BitMatrix:
1 1
1 1
```
I'm not able to figure out the reason for quantity.jl:327 at all. Is it a temporary placeholder introduced with AbstractQuantity? Is it a fallback which should never be fallen back on?
```
isapprox(x::AbstractArray{S}, y::AbstractArray{T};
kwargs...) where {S <: AbstractQuantity,T <: AbstractQuantity} = false
```
Generally on methods for containers:
Defining methods on containers opens for a large number of potential errors. E.g. are two containers similar when the contents are similar and container types differ? (note that `typeof(2A) ≠ typeof(A)` ? There's no definite and expected behaviour to questions like that.
When dealing with quantities and dimensionality, strictly speaking, this (or something like a potential UnitfulCore.jl) is the authorative package. But containers of quantities have zillions of different meanings depending on context and preferences, and should behave differently according to context. Sometimes, there's no obvious definition covering all use cases, like for 'norm', 'zero' or 'approx'.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.