You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When get_points_in_sphere() is called with zip_results=False, it returns a tuple of numpy arrays:
return frac_coords, distances, indices, images
However, if it found no point in the requested radius, then… the return type changes:
return [] if zip_results else [()] * 4
So now it's returning four empty tuples. It is very surprising to the use, because using numpy functions of those will raise a type error. For example, I was doing things like np.any(distances < 1.0): that would work perfectly as expected with an empty numpy array, but will crash with an empty tuple.
Expected Behavior
I don't see what is gained by returning () instead of np.array([]) and it would be less surprising to users (I just spent half an hour understanding this weird behavior).
Minimal example
No response
Relevant files to reproduce this bug
No response
The text was updated successfully, but these errors were encountered:
Python version
3.11.5
Pymatgen version
2024.4.13
Operating system version
No response
Current behavior
When
get_points_in_sphere()
is called withzip_results=False
, it returns a tuple of numpy arrays:However, if it found no point in the requested radius, then… the return type changes:
So now it's returning four empty tuples. It is very surprising to the use, because using numpy functions of those will raise a type error. For example, I was doing things like
np.any(distances < 1.0)
: that would work perfectly as expected with an empty numpy array, but will crash with an empty tuple.Expected Behavior
I don't see what is gained by returning
()
instead ofnp.array([])
and it would be less surprising to users (I just spent half an hour understanding this weird behavior).Minimal example
No response
Relevant files to reproduce this bug
No response
The text was updated successfully, but these errors were encountered: