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

Allow slicing not only on all array axes sharing the same dimension, but also on a specific array axis #528

Open
giovannipizzi opened this issue Jun 14, 2024 · 0 comments

Comments

@giovannipizzi
Copy link
Contributor

In PR #481, we are adding the definition to slice array properties with a syntax similar to:

property_slices=dim_sites:3:5:1

to get only values where the index of the axes with dimension name dim_sites is 3, 4 or 5.

This means that if two different arrays sharing that dimension are requested via response_fields, e.g. cartesian_site_positions and species_at_sites, the query above will slice both arrays.

This is typically what one wants and covers most (if not all) current usecases.

However, there are some corner cases where this is too strict.
E.g., let us consider a matrix of interactions between atoms in a molecule (let's call it _exmpl_sites_interactions), therefore with dimensions [dim_sites, dim_sites].
One might then want to slice only on the first axis (to obtain the iterations of one atom, say atom with index 4, with all other atoms in the molecule).
With the current syntax, instead, one can only either ask the whole matrix, or specifying property_slices=dim_sites:4:4:1 will only return a 1x1 block, the interaction of atom with index 4 with itself.

This is already sub-optimal, because then the only way is to get the whole matrix, that might be very big (imagine a big protein).
In addition, this is even more problematic if the server only declares one of the two axes as sliceable and not the other: then, even in the case where requesting a square sub-block would be sufficient, the query might actually return an error.

We therefore suggest to extend, in the future, the property_slices definition to allow also to query for a specific index of a specific array property.

With the current proposed syntax of property_slices=dim_sites:3:5:1, this could e.g. be
property_slices=dim_sites:2:10:1,_exmpl_sites_iteractions[0]:4:4:1

This means that in general I only want information on atoms with indices from 2 to 10 (e.g. for arrays cartesian_site_positions), but for the _exmpl_sites_iteractions I want the sub-block where the index for the first axis (0) of the array is 4 (while the second, being unspecified, gets the slice from dim_sites: therefore we are requesting a 1x9 block: a dimension is overridden by this array-index-specific specification).

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

1 participant