-
Notifications
You must be signed in to change notification settings - Fork 314
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
Zero axis lengths? #731
Comments
I think just like zero-length Vecs and slices appear in various situations, we have these. ArrayBase uses the same model for axes, shapes and strides for all its storage types, so since zero-width slices (views) are naturally occurring when slicing and splitting, we can see such shapes for owned arrays too. |
Just briefly, there are many ways to use tables of numbers in this world, but let's say we have a model with data like this:
We can store it in a n × 3 table for our n observations. It's a valid situation in the program that we can have 0 observations at any given time. Then we have a matrix of 0 × 3 values:
The shape of the empty table is important! The 0 × 3 matrix can be split into three columns of 0 entries each etc, which is consistent with the model. (Table headers "not yet" implemented in ndarray.) |
Yeah, ok, that makes sense. I had trouble imagining it for 2D arrays, but I'm perfectly ok with empty 1D array. Thank you for taking the time to answer. |
While working on ndarray-stats, I discovered that it's possible to have "zero axis lengths".
There's some issues #579, #693 and some panic information about them in the doc, for example
fn default
:Panics if the product of non-zero axis lengths overflows isize.
but I can't find any useful information on them. It seems to me that they're overly-complex empty arrays and that you can do nothing useful with them. I'm probably wrong?I think it's right to say that nobody will create such an array deliberately so I guess one of the method in ArrayBase can create one? Can someonie explain me why they exist? What's their use-cases?
The text was updated successfully, but these errors were encountered: