-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore scalar pysplinetable_searchcenters (#40)
* ENH: accept os.PathLike in ctor Enabling more laziness * Restore scalar searchcenters Fixes #39. * Bump version to 2.2.1 * Work with python < 3.10 in which Py_XDECREF is a macro * Clip stray import * tests: add local photospline to pythonpath * tests: set PYTHONPATH for ctest * Add a test for evaluate and adjust annotations to cover the vector case
- Loading branch information
1 parent
99e7021
commit 5b4ff89
Showing
5 changed files
with
106 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env python | ||
|
||
import unittest | ||
import photospline | ||
|
||
import numpy as np | ||
|
||
from pathlib import Path | ||
|
||
|
||
class TestEvaluation(unittest.TestCase): | ||
def setUp(self): | ||
self.testdata = Path(__file__).parent / "test_data" | ||
self.spline = photospline.SplineTable(self.testdata / "test_spline_4d.fits") | ||
extents = np.array(self.spline.extents) | ||
loc = extents[:, :1] | ||
scale = np.diff(extents, axis=1) | ||
self.x = (np.random.uniform(0, 1, size=(self.spline.ndim, 10)) + loc) * scale | ||
|
||
def test_vector(self): | ||
centers = self.spline.search_centers(self.x) | ||
self.assertIsInstance(centers, np.ndarray) | ||
self.assertEqual(centers.shape, (self.spline.ndim, self.x.shape[1])) | ||
v = self.spline.evaluate(self.x, centers=centers) | ||
self.assertIsInstance(v, np.ndarray) | ||
self.assertEqual(v.shape, (self.x.shape[1],)) | ||
|
||
def test_scalar(self): | ||
centers = self.spline.search_centers([x[0] for x in self.x]) | ||
self.assertIsInstance(centers, tuple) | ||
self.assertEqual(len(centers), self.spline.ndim) | ||
v = self.spline.evaluate([x[0] for x in self.x], centers=centers) | ||
self.assertIsInstance(v, float) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,4 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys, os | ||
|
||
sys.path.append(os.getcwd()) | ||
import numpy | ||
import photospline | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters