Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some quiet type cleanup #124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

iamed2
Copy link
Collaborator

@iamed2 iamed2 commented Sep 21, 2017

I was staring at the AxisArrays code and this was bothering me so I changed it 🙃

  1. Now the bounds on D and Ax are enforced in the type itself. Only one change was required to remove ambiguities.
  2. NTuple{N, _} is now consistently used instead of Tuple{Vararg{_, N}}. Tuple{Vararg{_}} remains to indicate actual possible variation.

@@ -143,10 +143,10 @@ A[ClosedInterval(0.,.3), [:a, :c]] # select an interval and two columns
```

"""
struct AxisArray{T,N,D,Ax} <: AbstractArray{T,N}
struct AxisArray{T,N,D<:AbstractArray{T,N},Ax<:NTuple{N,Axis}} <: AbstractArray{T,N}
Copy link
Member

@mbauman mbauman Sep 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long time ago there were some very subtle and surprising dispatch issues in doing this. Looks like at least the minimal case I reported still exists:

julia> struct Foo{A<:Real}; end
       f(x::Foo{A}) where A = 1 # Method sorting doesn't take into account `A <: Real`
       f(x::Foo, y...) = 2      # Implicitly assumes `A <: Real`
f (generic function with 2 methods)

julia> f(Foo{Int}())
2

Not sure if any other methods still depend on that behavior.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, the ambiguity no longer occurs but that still happens.

Do you know if there is a Julia issue for this behaviour?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Successfully merging this pull request may close these issues.

2 participants