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

Create #1

Merged
merged 19 commits into from
Apr 16, 2019
Merged

Create #1

merged 19 commits into from
Apr 16, 2019

Conversation

oxinabox
Copy link
Member

@oxinabox oxinabox commented Apr 11, 2019

Checklist from JuliaCollections/AxisArraysFuture#1 (comment)

  • Wrapper Type, that wraps an AbstractArray giving names to the indexes. The index named can go in the type params
  • Mapping function: name2dim(::NamedDimsArray, ::Symbol)::Int that will take an array with named dimentsions and dimention name, and return its dimension index.
  • Overloads for common functions that take a dims argument. Like sum and mean
    - that return NamedDimArrays
  • kwarg style indexing feature request: kwargs for getindex JuliaLang/julia#25631
  • Optional AbstractArray methods see docs

@oxinabox
Copy link
Member Author

probably want to implement a bunch of the optional AbstractArray stuff

src/name2dim.jl Outdated Show resolved Hide resolved
src/name2dim.jl Outdated Show resolved Hide resolved
@oxinabox oxinabox mentioned this pull request Apr 11, 2019
5 tasks
@oxinabox
Copy link
Member Author

Julia 1.1 is noticable better at constant propergation such that things happen at compile time.

@codecov
Copy link

codecov bot commented Apr 12, 2019

Codecov Report

Merging #1 into master will increase coverage by 91.66%.
The diff coverage is 91.54%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master       #1       +/-   ##
===========================================
+ Coverage       0%   91.66%   +91.66%     
===========================================
  Files           1        5        +4     
  Lines           1       72       +71     
===========================================
+ Hits            0       66       +66     
- Misses          1        6        +5
Impacted Files Coverage Δ
src/NamedDims.jl 100% <ø> (+100%) ⬆️
src/functions_dims.jl 100% <100%> (ø)
src/wrapper_array.jl 88.46% <88.46%> (ø)
src/functions.jl 91.66% <91.66%> (ø)
src/name_core.jl 93.1% <93.1%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f167597...c4082dd. Read the comment docs.

@oxinabox oxinabox changed the title [WIP] Ox/create Create Apr 12, 2019
src/name_core.jl Outdated Show resolved Hide resolved
src/name_core.jl Outdated Show resolved Hide resolved
src/name_core.jl Outdated Show resolved Hide resolved
src/name_core.jl Outdated Show resolved Hide resolved
Copy link
Member

@iamed2 iamed2 left a comment

Choose a reason for hiding this comment

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

I feel like you would want to return a NamedDimsArray from operations on a NamedDimsArray

src/name_core.jl Outdated Show resolved Hide resolved
src/name_core.jl Outdated Show resolved Hide resolved
src/name_core.jl Outdated Show resolved Hide resolved
src/name_core.jl Outdated Show resolved Hide resolved
src/wrapper_array.jl Outdated Show resolved Hide resolved
src/wrapper_array.jl Outdated Show resolved Hide resolved
Copy link
Member

@rofinn rofinn left a comment

Choose a reason for hiding this comment

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

This seems mostly fine, but the inconsistent conventions bugs me a little. There appears to be a mixture of _s, combined and shortened names. It'd be good to pick one convention for the package.

src/NamedDims.jl Outdated

greet() = print("Hello World!")
export NamedDimsArray, name2dim, dim_names
Copy link
Member

Choose a reason for hiding this comment

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

Seems weird to only partially follow the _ convention.

Copy link
Contributor

@nickrobinson251 nickrobinson251 Apr 12, 2019

Choose a reason for hiding this comment

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

i prefer a2b naming only for Dicts but I don't have a good alternative

Although if name2dim is part of the public API i'd like to try finding a better name :)

Is dim[s] or dimension[s] better or worse?

Copy link
Member Author

@oxinabox oxinabox Apr 12, 2019

Choose a reason for hiding this comment

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

so name_to_dim?
I am ok with that.

Copy link
Member Author

@oxinabox oxinabox Apr 12, 2019

Choose a reason for hiding this comment

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

get_dim?
dim?

Copy link
Contributor

@nickrobinson251 nickrobinson251 Apr 12, 2019

Choose a reason for hiding this comment

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

i quite to like dims(names) and dims(names, name) ...but maybe it's scarily short?

plus NamedDims.dims goes nicely with NamedDims.names

edit: think dims better than dim :)

Copy link
Member Author

Choose a reason for hiding this comment

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

We have axes it is only slightly shorter.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can't do dims,
it is a kwarg on functions that want to call this.

e.g.
sum(xs::NamedDimArray; dims)=sum(parent(xs), dims(xs, dims))
does not work; and
sum(xs::NamedDimArray; dims)=sum(parent(xs), NamedDimArray.dims(xs, dims))
is ugly.

src/name_core.jl Outdated Show resolved Hide resolved
src/name_core.jl Outdated Show resolved Hide resolved
src/wrapper_array.jl Show resolved Hide resolved
src/wrapper_array.jl Outdated Show resolved Hide resolved
rofinn and others added 5 commits April 12, 2019 22:25
Co-Authored-By: oxinabox <oxinabox@ucc.asn.au>
Co-Authored-By: oxinabox <oxinabox@ucc.asn.au>
Co-Authored-By: oxinabox <oxinabox@ucc.asn.au>
@oxinabox
Copy link
Member Author

I feel like you would want to return a NamedDimsArray from operations on a NamedDimsArray

Ah yes, indeed I do.
Did not think sum etc through fully.

Looks like I will have to implement more functions for working out dimensions, after operations
but that should make #2 #3 #4 easier at least

@oxinabox
Copy link
Member Author

Added dropdims, because I implemented the code for it by mistake (I thought summing over a dimension dropped that dimension, but apparently not (did it used to?))

This is ready for another round of review.

@nickrobinson251
Copy link
Contributor

LGTM (bar very minor style things)

I'd quite like to test on both the 1d and Nd case, but extra tests can always be added later :)

Good work!

Co-Authored-By: oxinabox <oxinabox@ucc.asn.au>
test/name_core.jl Outdated Show resolved Hide resolved
Co-Authored-By: oxinabox <oxinabox@ucc.asn.au>
@oxinabox oxinabox merged commit 57de32b into master Apr 16, 2019
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.

5 participants