Skip to content

Commit

Permalink
Adding endpoint selection for buildgrid function
Browse files Browse the repository at this point in the history
  • Loading branch information
ifilot committed Jan 17, 2024
1 parent ed75fb7 commit 1a13bb2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: "pyqint"
version: "0.16.0"
version: "0.16.1"

source:
path: .
Expand Down
2 changes: 1 addition & 1 deletion pyqint/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "0.16.0"
__version__ = "0.16.1"

5 changes: 3 additions & 2 deletions pyqint/pyqint.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -596,18 +596,19 @@ cdef class PyQInt:
return S, T, V, teints
def build_rectgrid3d(self, xmin:float, xmax:float, npts:int) -> npt.NDArray[np.float64]:
def build_rectgrid3d(self, xmin:float, xmax:float, npts:int, endpoint:bool=False) -> npt.NDArray[np.float64]:
"""Build three-dimensional grid

Args:
xmin (float): negative coordinate
xmax (float): positive coordinate
npts (int): number of sampling points per Cartesian direction
endpoint (bool): whether to include the endpoint for the grid spacing

Returns:
npt.NDArray[np.float64]: array containing grid points
"""
x = np.linspace(xmin, xmax, npts, endpoint=False)
x = np.linspace(xmin, xmax, npts, endpoint=endpoint)
grid = np.flipud(np.vstack(np.meshgrid(x, x, x, indexing='ij')).reshape(3,-1)).T
return grid
Expand Down
5 changes: 4 additions & 1 deletion tests/test_plot_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def test_plot_gradient(self):

# construct integrator object
integrator = PyQInt()

c = np.array([0.54893397, 0.54893397])

# test couple of single points
Expand All @@ -66,7 +67,9 @@ def test_plot_gradient(self):
np.testing.assert_almost_equal(grad, res, 4)

# test grid of points
coord = integrator.build_rectgrid3d(-2, 2, 6)
# x = np.linspace(-2, 2, 6, endpoint=True)
# coord = np.flipud(np.vstack(np.meshgrid(x, x, x, indexing='ij')).reshape(3,-1)).T
coord = integrator.build_rectgrid3d(-2, 2, 6, endpoint=True)
grad = integrator.plot_gradient(coord, c, cgfs)
self.assertEqual(grad.shape[0], 6*6*6)
self.assertEqual(grad.shape[1], 3)
Expand Down

0 comments on commit 1a13bb2

Please sign in to comment.