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 fixes for summary, show, and map for non-1 indices #17729

Merged
merged 3 commits into from
Aug 2, 2016

Conversation

timholy
Copy link
Member

@timholy timholy commented Jul 31, 2016

Previously I specialized this in the tests, but it's better to just make this do the right thing out of the box.

@@ -195,6 +194,9 @@ show(io, v)
str = takebuf_string(io)
show(io, parent(v))
@test str == takebuf_string(io)
smry = summary(v)
@test contains(smry, "OffsetArray{Float64,1")
Copy link
Member

Choose a reason for hiding this comment

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

Closing } omission intentional?

Copy link
Member Author

@timholy timholy Jul 31, 2016

Choose a reason for hiding this comment

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

Yes. The third parameter is the "parent" array type, and I don't care about that here.

@timholy timholy changed the title Implement a generic solution for summary with unconventional indices Some fixes for summary, show, and map for non-1 indices Aug 1, 2016
@@ -40,7 +40,7 @@ indices{T,N}(A::AbstractArray{T,N}, d) = d <= N ? indices(A)[d] : OneTo(1)

Returns the tuple of valid indices for array `A`.
"""
function indices{T,N}(A::AbstractArray{T,N})
function indices(A)
@_inline_pure_meta
Copy link
Member

Choose a reason for hiding this comment

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

this isn't pure

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, I should take the pure out of the fallback.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hah, incidentally "fixed" #17126, that was unexpected.

for n = 0:4
a = OffsetArray(rand(ntuple(d->3,n)), ntuple(identity,n))
show(IOContext(io, limit=true), MIME("text/plain"), a)
show(IOContext(io, limit=true), MIME("text/plain"), (a,a))
Copy link
Contributor

Choose a reason for hiding this comment

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

should the outputs here be tested?

@timholy
Copy link
Member Author

timholy commented Aug 1, 2016

Seem OK now?

@tkelman
Copy link
Contributor

tkelman commented Aug 1, 2016

are you about to push something? should probably read from io and check that the outputs are as expected instead of just "anything that isn't an error is fine"

@timholy timholy force-pushed the teh/summary_indices branch from 6001540 to c3e71d4 Compare August 1, 2016 22:28
@@ -207,6 +209,23 @@ cmp_showf(Base.print_matrix, io, OffsetArray(rand(5,5), (10,-9))) # rows&c
cmp_showf(Base.print_matrix, io, OffsetArray(rand(10^3,5), (10,-9))) # columns fit
cmp_showf(Base.print_matrix, io, OffsetArray(rand(5,10^3), (10,-9))) # rows fit
cmp_showf(Base.print_matrix, io, OffsetArray(rand(10^3,10^3), (10,-9))) # neither fits
targets1 = ["0-dimensional OAs.OffsetArray{Int64,0,Array{Int64,0}}:\n1",
Copy link
Contributor

Choose a reason for hiding this comment

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

will this need to be $Int on 32 bit systems?

@timholy timholy force-pushed the teh/summary_indices branch from c3e71d4 to 81c1b0b Compare August 2, 2016 09:19
@tkelman tkelman merged commit b27039f into master Aug 2, 2016
@tkelman tkelman deleted the teh/summary_indices branch August 2, 2016 21:00
@tkelman
Copy link
Contributor

tkelman commented Aug 2, 2016

This passed when CI was run on the PR build, but CI failed after it was merged to master. Going to propose reverting, unless you can come up with a better fix. mistaken

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.

4 participants