Skip to content

Commit

Permalink
Patch 0.16.1 (#33)
Browse files Browse the repository at this point in the history
* Fixing bug in build3dgrid module and putting check for this function in test suite

* Adding endpoint selection for buildgrid function
  • Loading branch information
ifilot authored Jan 17, 2024
1 parent bb63fae commit f76adce
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 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"

7 changes: 4 additions & 3 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, sz:float) -> 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
sz (float): number of values
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, sz, 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
9 changes: 4 additions & 5 deletions tests/test_plot_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ def test_plot_gradient(self):

# construct integrator object
integrator = PyQInt()

# build grid points
x = np.linspace(-2, 2, 6, endpoint=True)
coord = np.flipud(np.vstack(np.meshgrid(x, x, x, indexing='ij')).reshape(3,-1)).T


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

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

# test grid of points
# 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 f76adce

Please sign in to comment.