Skip to content

Commit

Permalink
pass the shape as a tuple to reshape (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
keewis authored Jun 11, 2024
1 parent 8a377e6 commit c937a0f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions healpix_convolution/kernels/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@


def create_sparse(cell_ids, neighbours, weights, shape):
neighbours_ = np.reshape(neighbours, -1)
neighbours_ = np.reshape(neighbours, (-1,))
mask = neighbours_ != -1

n_neighbours = neighbours.shape[-1]
cell_ids_ = np.reshape(
np.repeat(cell_ids[..., None], repeats=n_neighbours, axis=-1), -1
np.repeat(cell_ids[..., None], repeats=n_neighbours, axis=-1), (-1,)
)

coords = np.reshape(np.stack([cell_ids_, neighbours_], axis=0), (2, -1))

weights_ = np.reshape(weights, -1)[mask]
weights_ = np.reshape(weights, (-1,))[mask]
coords_ = coords[..., mask]

return sparse.COO(coords=coords_, data=weights_, shape=shape, fill_value=0)
2 changes: 1 addition & 1 deletion healpix_convolution/kernels/gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def gaussian_kernel(
f"cell ids must be 1-dimensional, but shape is: {cell_ids.shape}"
)

cell_ids = np.reshape(cell_ids, -1)
cell_ids = np.reshape(cell_ids, (-1,))

# TODO: figure out whether there is a better way of defining the units of `sigma`
if kernel_size is not None:
Expand Down

0 comments on commit c937a0f

Please sign in to comment.