Skip to content

Grid.moments with Cartesian orders fails on 1D grids #334

Description

@SajalDevX

Grid.moments(..., type_mom="cartesian") raises on a grid whose points have shape (N, 1):

import numpy as np
from grid.basegrid import Grid

pts = np.linspace(-1, 1, 5)[:, None]
grid = Grid(pts, np.full(5, 0.4))
grid.moments(2, np.array([[0.0]]), pts[:, 0] ** 2, "cartesian")
# AttributeError: module 'numpy' has no attribute 'int'.

The dim == 1 branch of generate_orders_horton_order returns np.arange(0, order + 1, dtype=np.int), and np.int was removed in NumPy 1.24. Even with a valid dtype, it returns every order from 0 to n, not the single row [n] that the 2D and 3D branches return, so the np.vstack in Grid.moments can't stack the rows.

I'd like to fix this by returning [[order]] for dim=1, with tests for both the function and a 1D Grid.moments call. I have a small patch ready.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions