Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

Type piracy in minimum, maximum, extrema & isnan #207

Closed
yha opened this issue Jun 14, 2020 · 2 comments
Closed

Type piracy in minimum, maximum, extrema & isnan #207

yha opened this issue Jun 14, 2020 · 2 comments

Comments

@yha
Copy link

yha commented Jun 14, 2020

These methods are pirated for StaticArray types:

julia> using StaticArrays
julia> v = SVector.([2,1,3],[1,2,3]);
julia> minimum(v)
2-element SArray{Tuple{2},Int64,1,2} with indices SOneTo(2):
 1
 2
julia> isnan(v[1])
ERROR: MethodError: no method matching isnan(::SArray{Tuple{2},Int64,1,2})
[...]
julia> using GeometryTypes
julia> minimum(v)
ERROR: DimensionMismatch("No precise constructor for SArray{Tuple{2},Int64,1,2} found. Length of input was 1.")
[...]
julia> isnan(v[1])
false

Looking at the code, it looks likes the new minimum is supposed to compute dimension-wise minimum but is failing.
I feel these minimum and isnan implementations are a bit questionable for points too. They don't really do what these functions are supposed to be doing. But they definitely shouldn't change the definition for StaticArrays.

@SimonDanisch
Copy link
Member

GeometryTypes is deprecated...
GeometryBasics doesn't pirate minimum/maximum anymore...But still isnan ... I would mind restricting isnan to only work for GeometryBasic types ;)
https://github.com/JuliaGeometry/GeometryBasics.jl/blob/master/src/fixed_arrays.jl#L117

@yha
Copy link
Author

yha commented Jun 16, 2020

Oh, I missed that deprecation.
I guess I'll try migrating my code to GeometryBasics, and open a PR there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants