Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

porting: update deprecated numpy functionality #8

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions test/test_function_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ def test_harmonic_extension_exterior_3d(ctx_factory):
density_discr = qbx.density_discr

ntgts = 200
rho = np.random.rand(ntgts) * 3 + radius + 0.05
theta = np.random.rand(ntgts) * 2 * np.pi
phi = (np.random.rand(ntgts) - 0.5) * np.pi
rng = np.random.default_rng(seed=42)
rho = rng.random(ntgts) * 3 + radius + 0.05
theta = rng.random(ntgts) * 2 * np.pi
phi = (rng.random(ntgts) - 0.5) * np.pi

nodes = density_discr.nodes().with_queue(queue)
source = np.array([0, 1, 2])
Expand Down
5 changes: 2 additions & 3 deletions test/test_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@
def random_polynomial_func(dim, degree, seed=None):
"""Makes a random polynomial function.
"""
if seed is not None:
np.random.seed(seed)
coefs = np.random.rand(*((degree + 1, ) * dim))
rng = np.random.default_rng(seed=seed)
coefs = rng.random((degree + 1,) * dim)

def poly_func(pts):
if dim == 1 and len(pts.shape) == 1:
Expand Down
3 changes: 2 additions & 1 deletion test/test_nearfield_potential_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def drive_test_modes_cheb_coeffs(dim, q, cheb_order):
if not cheb_order >= q:
raise RuntimeError("Insufficient cheb_order to fully resolve the modes")

sample_mode = np.random.randint(q**dim)
rng = np.random.default_rng(seed=42)
sample_mode = rng.integers(q**dim)
table = npt.NearFieldInteractionTable(quad_order=q, dim=dim, progress_bar=False)
ccoefs = table.get_mode_cheb_coeffs(sample_mode, cheb_order)
shape = (cheb_order, ) * dim
Expand Down
5 changes: 3 additions & 2 deletions test/test_volume_fmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ def test_cl_ctx_getter(ctx_factory):
ctx = ctx_factory()
queue = cl.CommandQueue(ctx)

a_np = np.random.rand(50000).astype(np.float32)
b_np = np.random.rand(50000).astype(np.float32)
rng = np.random.default_rng(seed=42)
a_np = rng.random(50000, dtype=np.float32)
b_np = rng.random(50000, dtype=np.float32)

mf = cl.mem_flags
a_g = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=a_np)
Expand Down
2 changes: 1 addition & 1 deletion volumential/expansion_wrangler_fpnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ def eval_direct(
mode_coefs,
):
pot = self.output_zeros()
if pot.dtype != np.object:
if pot.dtype != object:
pot = make_obj_array([pot, ])
events = []
for i in range(len(self.code.target_kernels)):
Expand Down
2 changes: 1 addition & 1 deletion volumential/list1_gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def build_tree(dimensions):
nlevels = 4
root_radius = 2 ** (nlevels - 1)
root = TreeBox(
center=np.array(dimensions * [root_radius], np.int),
center=np.array(dimensions * [root_radius], np.int64),
radius=root_radius,
child_nlevels=nlevels - 1,
)
Expand Down
2 changes: 1 addition & 1 deletion volumential/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def __call__(self, queue, target_points, **kwargs):
"""
# handle target_points given as an obj_array of coords
if (isinstance(target_points, np.ndarray)
and target_points.dtype == np.object
and target_points.dtype == object
and isinstance(target_points[0], cl.array.Array)):
target_points = cl.array.concatenate(
target_points).reshape([self.dim, -1])
Expand Down
Loading