Atlas-Download-Tools icon indicating copy to clipboard operation
Atlas-Download-Tools copied to clipboard

Implement norm with `np.hypot`

Open jankrepl opened this issue 4 years ago • 2 comments

Would be nice to check whether it is faster:)

jankrepl avatar Aug 16 '21 13:08 jankrepl

I think np.linalg.norm and np.hypot have slightly different interfaces that correspond to different usecases:

  • np.linalg.norm(vecs, axis=1) - all coordinates in the same array
  • np.hypot(xs, ys) - coordinates in separate arrays, more like a mesh-grid; only 2D.

By in the case of DisplacementField.norm

https://github.com/BlueBrain/Atlas-Download-Tools/blob/8386f2bd0baf4d549dea48b00dae72379f5c6fbf/src/atldld/base.py#L215-L218

we could definitely improve by using np.hypot(self.delta_x, self.delta_y)

Stannislav avatar Aug 16 '21 19:08 Stannislav

Heh, for some reason I thought we had np.norm in the code but it is clearly not the case. I will adjust the name of this issue.

jankrepl avatar Aug 17 '21 07:08 jankrepl