I think this is the pure numpy solution but it doesn't pass the 2nd test :-(
def get_indices_at_coords(self, x: float, y: float, z: float) -> Tuple[int]:
"""Finds the index of the mesh voxel at the specified x,y,z coordinates.
Parameters
----------
x : float
The x axis value
y : float
The y axis value
z : float
The z axis value
Returns
-------
Tuple[int]
The r, phi, z indices
"""
distances = np.sum((self.centroids-(x,y,z))**2, axis=3)
min_distance = np.min(distances)
r_index, phi_index, z_index = np.argwhere(distances == min_distance).flatten()
return (r_index, phi_index, z_index)
I think this is the pure numpy solution but it doesn't pass the 2nd test :-(