Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 5, 2024
1 parent 51e7503 commit 6782a2f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/grid/basegrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ def integrate(self, *value_arrays):
*(array for array in value_arrays),
)


def get_localgrid(self, center, radius):
"""Create a grid contain points within the given radius of center.
Expand Down
17 changes: 8 additions & 9 deletions src/grid/tests/test_ngrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import numpy as np
from numpy.testing import assert_allclose


class TestNgrid(TestCase):
"""Ngrid tests class."""

Expand All @@ -44,10 +45,9 @@ def setUp(self):
# create a 3D grid with n equally spaced points between 0 and 1 along each axis
self.ngrid = Ngrid([self.linear_grid], 3)
ref_points = np.array([np.linspace(0, 1, 500)] * 3).T
#ref_points = np.random.uniform(0, 1, size=(100, 3))
ref_weights = np.ones(len(ref_points)) /len(ref_points)
# ref_points = np.random.uniform(0, 1, size=(100, 3))
ref_weights = np.ones(len(ref_points)) / len(ref_points)
self.grid_3d = Grid(ref_points, ref_weights)


def test_init_raises(self):
"""Assert that the init raises the correct error."""
Expand Down Expand Up @@ -127,13 +127,13 @@ def test_3d_double_grid_integration(self):

# define a function to integrate (x**2+y**2)
def f(x, y):
return x**2+y**2
return x**2 + y**2

# define a Ngrid with two grids
ngrid = Ngrid(grid_list=[self.grid_3d],n=2)
ngrid = Ngrid(grid_list=[self.grid_3d], n=2)
# integrate it
result = ngrid.integrate(f)
result=np.sum(result)/3
result = np.sum(result) / 3
# check that the result is correct
self.assertAlmostEqual(result, 2.0 / 3.0, places=2)

Expand All @@ -145,10 +145,9 @@ def f(x, y, z):
return x * y * z

# define a Ngrid with two grids
ngrid = Ngrid(grid_list=[self.grid_3d],n=3)
ngrid = Ngrid(grid_list=[self.grid_3d], n=3)
# integrate it
result = ngrid.integrate(f)
result=np.sum(result)/3
result = np.sum(result) / 3
# check that the result is correct
self.assertAlmostEqual(result, 1.0 / 8.0, places=2)

0 comments on commit 6782a2f

Please sign in to comment.