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

RFC: deprecate cartesianmap #12716

Merged
merged 1 commit into from
Aug 28, 2015
Merged

RFC: deprecate cartesianmap #12716

merged 1 commit into from
Aug 28, 2015

Conversation

JeffBezanson
Copy link
Sponsor Member

This function is redundant with CartesianRange, and is also a performance trap. We could eventually fix the performance, but I think there are enough other problems with this function. It's not really a map, but more like a cartesian_foreach, so it's misnamed plus its behavior is a bit odd. I think in the future we will want to use product iterators and/or CartesianRange instead.

It's a bit awkward that CartesianRange provides a CartesianIndex instead of a tuple. I'm not sure what to do about that, but it seems OK for now.

@stevengj
Copy link
Member

cartesianmap is currently used in four packages: Blocks, DistributedArrays, ZipFile, and Zlib. Might be worth looking at what they are using it for and how replaceable it is in those contexts.

@JeffBezanson
Copy link
Sponsor Member Author

The commit contains a 1-line proof-by-@deprecate that it can be replaced :)

@timholy
Copy link
Sponsor Member

timholy commented Aug 21, 2015

👍 from me.

Cartesian iteration was developed before #10380, which is why it doesn't use tuples. We can change that now, but I suspect it's better as 0.5 material.

@JeffBezanson
Copy link
Sponsor Member Author

Agreed. Actually there are 2 interesting issues there. First, tuples don't have the correct sort order: (2,1) should come before (1,2) in CartesianIndex space. Second, indexing an array with a tuple might be ambiguous. We'll have to decide whether all n-d indexing should be based on tuples.

@StefanKarpinski
Copy link
Sponsor Member

Life would be so much easier if mathematics weren't column-major.

@carnaval
Copy link
Contributor

does this "mathematics" thing have an upstream bugtracker we can report to ?

@StefanKarpinski
Copy link
Sponsor Member

if only

@Jutho
Copy link
Contributor

Jutho commented Aug 21, 2015

+1

@@ -1132,7 +1132,8 @@ function show_nd(io::IO, a::AbstractArray, limit, print_matrix, label_slices)
end
tail = size(a)[3:end]
nd = ndims(a)-2
function print_slice(idxs...)
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

You'll want to change the returns in this function to continue since it's now a for loop.

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

Right you are, thanks.

@mbauman
Copy link
Sponsor Member

mbauman commented Aug 22, 2015

👍

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.

None yet

7 participants