Skip to content

Commit

Permalink
Fix according to the Review
Browse files Browse the repository at this point in the history
  • Loading branch information
hongyuchen1030 committed Aug 9, 2023
1 parent 29809cb commit e2c1eb7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions test/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import uxarray as ux

from uxarray.grid.connectivity import _replace_fill_values
from uxarray.constants import INT_DTYPE, INT_FILL_VALUE
from uxarray.constants import INT_DTYPE, INT_FILL_VALUE, ERROR_TOLERANCE

from uxarray.grid.coordinates import node_lonlat_rad_to_xyz
from uxarray.grid.lines import point_within_GCA
Expand All @@ -26,8 +26,6 @@
gridfile_exo_CSne8 = current_path / "meshfiles" / "exodus" / "outCSne8" / "outCSne8.g"
gridfile_scrip_CSne8 = current_path / 'meshfiles' / "scrip" / "outCSne8" / 'outCSne8.nc'

err_tolerance = 1.0e-12


class TestIntegrate(TestCase):

Expand Down Expand Up @@ -106,7 +104,7 @@ def test_normalize_in_place(self):
random.random()])

self.assertLessEqual(np.absolute(np.sqrt(x * x + y * y + z * z) - 1),
err_tolerance)
ERROR_TOLERANCE)

def test_node_xyz_to_lonlat_rad(self):
[x, y, z] = ux.grid.coordinates.normalize_in_place([
Expand All @@ -119,9 +117,9 @@ def test_node_xyz_to_lonlat_rad(self):
[new_x, new_y,
new_z] = ux.grid.coordinates.node_lonlat_rad_to_xyz([lon, lat])

self.assertLessEqual(np.absolute(new_x - x), err_tolerance)
self.assertLessEqual(np.absolute(new_y - y), err_tolerance)
self.assertLessEqual(np.absolute(new_z - z), err_tolerance)
self.assertLessEqual(np.absolute(new_x - x), ERROR_TOLERANCE)
self.assertLessEqual(np.absolute(new_y - y), ERROR_TOLERANCE)
self.assertLessEqual(np.absolute(new_z - z), ERROR_TOLERANCE)

def test_node_latlon_rad_to_xyz(self):
[lon, lat] = [
Expand All @@ -134,8 +132,8 @@ def test_node_latlon_rad_to_xyz(self):
[new_lon,
new_lat] = ux.grid.coordinates.node_xyz_to_lonlat_rad([x, y, z])

self.assertLessEqual(np.absolute(new_lon - lon), err_tolerance)
self.assertLessEqual(np.absolute(new_lat - lat), err_tolerance)
self.assertLessEqual(np.absolute(new_lon - lon), ERROR_TOLERANCE)
self.assertLessEqual(np.absolute(new_lat - lat), ERROR_TOLERANCE)


class TestConstants(TestCase):
Expand Down
2 changes: 1 addition & 1 deletion uxarray/grid/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def normalize_in_place(node):
if len(node) != 3:
raise RuntimeError("Input array should have a length of 3: [x, y, z]")

return np.array(node) / np.linalg.norm(np.array(node), ord=2)
return np.asarray(node) / np.linalg.norm(np.array(node), ord=2)


def grid_center_lat_lon(ds):
Expand Down

0 comments on commit e2c1eb7

Please sign in to comment.