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

similar() of ArrayPartition involving primitives fails #292

Open
davidschlegel opened this issue Nov 17, 2023 · 3 comments
Open

similar() of ArrayPartition involving primitives fails #292

davidschlegel opened this issue Nov 17, 2023 · 3 comments

Comments

@davidschlegel
Copy link

If I have an ArrayPartition involving a primitive type, such as a regular number, creating a similar through similar array fails.
Example:

using RecursiveArrayTools
a = randn()
b = randn(5,5)
arr_part = ArrayPartition(a,b)
similar(arr_part) # fails

ArrayPartitions are not designed for single numbers, but it would be nice if it also works for these types.

@ChrisRackauckas
Copy link
Member

I'm not entirely sure what this would give. Given similar generates a mutable object, it cannot be an ArrayPartition of numbers since that's not mutable. But it needs the tuples to be an array partition, and putting things in arrays would change the underlying structure.

@davidschlegel
Copy link
Author

I was already guessing that primitives being immutable are at the heart of the problem. Could one then just disallow ArrayPartition involving primitives? Of course, one could always wrap them into an array, where it always works (ArrayPartition([a], b) in my example)...

@ChrisRackauckas
Copy link
Member

There's some dispatches and type signatures that rely on it being a tuple right now, so that would need some word to be fully generalized.

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

No branches or pull requests

2 participants