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

Value with integers/indices in select param does not reduce dimensions #88

Closed
loichuder opened this issue Apr 30, 2021 · 4 comments
Closed

Comments

@loichuder
Copy link
Contributor

loichuder commented Apr 30, 2021

When fetching a slice with select with integers/indices, I would expect the number of dimensions to be reduced.

Ex: I want to fetch the first row 0,: from a 2D array of dimensions [2, 3]. Currently, the fetch gives me a 2D array of dimensions [1, 3] while I would expect a 1D array of dimensions [3].

Looking at my fix at #85, I understand the behaviour: integers are converted in slices of 1 elements.

Do you think it would be possible to not make this conversion and treat indices apart ?

@jreadey
Copy link
Member

jreadey commented May 14, 2021

Sure, it's actually pretty easy to do from the server side. Take a look at this commit: 71f342f.

I didn't want to break any existing clients, so to get the reduce dim effect, you need to add a parameter: "reduce_dim" in the request.

@jreadey
Copy link
Member

jreadey commented Jun 3, 2021

I've merged this change into master.

@jreadey
Copy link
Member

jreadey commented Jun 22, 2021

closing issue - please reopen if you run into any problems.

@jreadey jreadey closed this as completed Jun 22, 2021
@loichuder
Copy link
Contributor Author

I tried and it works but the behaviour is different from what I would expect (which would be NumPy like).

For example, let's consider the dataset of dimensions (2, 3) and say I want the slice :, 0. The dimensions of the resulting slice will be:

  • NumPy: (2)
  • HSDS (without reduce_dim): (2, 1)
  • HSDS (with reduce_dim): (2)

All is well here.

Now imagine the dimensions of the original dataset are (1, 3) and I want the slice :,0. In this case, I will get:

  • NumPy: (1)
  • HSDS (without reduce_dim): (1, 1)
  • HSDS (with reduce_dim): ()

In this case, the result with reduce_dim is not consistent with NumPy... Same problem if I want to get the original dataset:

  • NumPy: (1, 3)
  • HSDS (without reduce_dim): (1, 3)
  • HSDS (with reduce_dim): (3)

As for #87, we worked around this in h5web. We do not make use of reduce_dim and flat the slice according to the original dataset shape when getting the response.

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