From f4018a3822bd8e79591d5d430f51a44902a2dc52 Mon Sep 17 00:00:00 2001 From: Irina Demeshko Date: Wed, 22 May 2024 09:16:34 -0700 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Manolis Papadakis --- cunumeric/module.py | 14 +++----------- install.py | 2 +- tests/integration/test_gradient.py | 2 +- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/cunumeric/module.py b/cunumeric/module.py index 37fbd03d3..b8b6018e2 100644 --- a/cunumeric/module.py +++ b/cunumeric/module.py @@ -6745,7 +6745,7 @@ def gradient( Return the gradient of an N-dimensional array. The gradient is computed using second order accurate central differences - in the interior points and either first or second order accurate one-sides + in the interior points and either first or second order accurate one-sided (forward or backwards) differences at the boundaries. The returned gradient hence has the same shape as the input array. @@ -6768,13 +6768,11 @@ def gradient( edge_order : {1, 2}, optional Gradient is calculated using N-th order accurate differences at the boundaries. Default: 1. - .. versionadded:: 1.9.1 axis : None or int or tuple of ints, optional Gradient is calculated only along the given axis or axes The default (axis = None) is to calculate the gradient for all the axes of the input array. axis may be negative, in which case it counts from the last to the first axis. - .. versionadded:: 1.11.0 Returns ------- @@ -6843,7 +6841,7 @@ def gradient( if edge_order > 2: raise ValueError("'edge_order' greater than 2 not supported") if edge_order < 0: - raise ValueError(" invalid 'edge_order'") + raise ValueError("invalid 'edge_order'") # use central differences on interior and one-sided differences on the # endpoints. This preserves second order-accuracy over the full domain. @@ -6857,13 +6855,7 @@ def gradient( slice4 = [slice(None)] * N otype = f.dtype - if otype.type is np.datetime64: - raise TypeError("datetime64 is not supported by gradient in cuNumeric") - elif otype.type is np.timedelta64: - pass - elif np.issubdtype(otype, np.inexact): - pass - else: + if not np.issubdtype(otype, np.inexact): # All other types convert to floating point. # First check if f is a numpy integer type; if so, convert f to float64 # to avoid modular arithmetic when computing the changes in f. diff --git a/install.py b/install.py index 3940b71b4..30e4f3a36 100755 --- a/install.py +++ b/install.py @@ -338,7 +338,7 @@ def validate_path(path): "Debug" if debug else "RelWithDebInfo" if debug_release else "Release" ) cmake_flags += f"""\ --DCMAKE_BUILD_TYPE=build_type +-DCMAKE_BUILD_TYPE={build_type} -DBUILD_SHARED_LIBS=ON -DCMAKE_CUDA_ARCHITECTURES={str(arch)} -DLegion_MAX_DIM={str(maxdim)} diff --git a/tests/integration/test_gradient.py b/tests/integration/test_gradient.py index cbd8c5700..d5b4804fb 100644 --- a/tests/integration/test_gradient.py +++ b/tests/integration/test_gradient.py @@ -29,7 +29,7 @@ def test_gradient_with_scalar_dx(): assert np.allclose(res_np, res_cn) -def test_fradient_1d(): +def test_gradient_1d(): a_np = np.array(np.random.random(size=1000), dtype=float) f_np = np.sort(a_np) f_cn = cn.array(f_np)