Skip to content

Commit

Permalink
rewrote pixel_fn in nd_coords to do operations on start/end rather th…
Browse files Browse the repository at this point in the history
…an array (#261)

Small optimisation to `nd_coords`
  • Loading branch information
maxecharles authored Jul 5, 2024
1 parent 74facf6 commit 5089344
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/dLux/utils/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,9 @@ def nd_coords(
offsets = (offsets,) * len(npixels)

def pixel_fn(n, offset, scale):
# TODO: calculate the start and end points first and then use linspace
# so that ops are done on floats not arrays
# scale = diam / n
pix = np.arange(n) - (n - 1) / 2.0
pix *= scale
pix -= offset
return pix
start = -(n - 1) / 2 * scale - offset
end = (n - 1) / 2 * scale - offset
return np.linspace(start, end, n)

# Generate the linear edges of each axes
# TODO: tree_flatten()[0] to avoid squeeze?
Expand Down

0 comments on commit 5089344

Please sign in to comment.