Skip to content

Making AxisArrays compatible with new core traits.#33

Draft
Tokazama wants to merge 1 commit into
JuliaImages:masterfrom
Tokazama:master
Draft

Making AxisArrays compatible with new core traits.#33
Tokazama wants to merge 1 commit into
JuliaImages:masterfrom
Tokazama:master

Conversation

@Tokazama
Copy link
Copy Markdown

The goal here is to make AxisArrays compatible with the new traits added to ImageCore. This adds 3 methods to AxisArrays.

Comment thread src/ImageAxes.jl

ImageCore.HasDimNames(::Type{A}) where {A<:AxisArray} = HasDimNames{true}()
ImageCore.namedaxes(a::AxisArray) = NamedTuple{axisnames(a)}(axisvalues(a))
Base.names(a::AxisArray) = axisnames(a)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is kind of iffy but it is necessary to really fulfill the intended meaning of HasDimNames.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remind me why the name of this function needs to be names? (Link to other package, for example?) The reason I ask:

julia> t = (x = 1, y = 2)
(x = 1, y = 2)

julia> typeof(t)
NamedTuple{(:x, :y),Tuple{Int64,Int64}}

julia> names(t)
ERROR: MethodError: no method matching names(::NamedTuple{(:x, :y),Tuple{Int64,Int64}})
Closest candidates are:
  names(::Module; all, imported) at reflection.jl:98
Stacktrace:
 [1] top-level scope at REPL[3]:1

struct, for example, uses fieldnames rather than just names. axisnames seems like a really good name for this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It's what NamedDims uses to access the axis names https://github.com/invenia/NamedDims.jl/blob/master/src/wrapper_array.jl#L77.

But hadn't even considered using a different name. axisnames would certainly be more descriptive.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's see what happens in invenia/NamedDims.jl#22

@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 16, 2019

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.61%. Comparing base (e6f7a61) to head (bcaf598).
⚠️ Report is 35 commits behind head on master.

Files with missing lines Patch % Lines
src/ImageAxes.jl 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #33      +/-   ##
==========================================
- Coverage   81.95%   81.61%   -0.34%     
==========================================
  Files           1        1              
  Lines         133      136       +3     
==========================================
+ Hits          109      111       +2     
- Misses         24       25       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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