Skip to content

Commit

Permalink
Add deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Dec 16, 2023
1 parent 4fd1855 commit 205d911
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
6 changes: 3 additions & 3 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ PyDL Changelog
1.0.0 (unreleased)
------------------

* Update testing infrastructure (PR `#67`_).
* Update links to documentation (PR `#64`_).
* Remove support for 2-dimensional B-spline, which is better supported in
* Deprecate support for 2-dimensional B-spline, which is better supported in
other packages such as PypeIt_ or specreduce_ (PR `#73`_).
* Use specutils_ as an informal template for Python packaging boilerplate (PR `#73`_).
* Change Harris Geospatial to NV5 Geospatial.
* Update testing infrastructure (PR `#67`_).
* Update links to documentation (PR `#64`_).

.. _`#64`: https://github.com/weaverba137/pydl/pull/64
.. _`#67`: https://github.com/weaverba137/pydl/pull/67
Expand Down
5 changes: 5 additions & 0 deletions pydl/pydlutils/bspline.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,9 @@ def iterfit(xdata, ydata, invvar=None, upper=5, lower=5, x2=None,
maxiter=10, **kwargs):
"""Iteratively fit a B-spline set to data, with rejection.
Additional keyword parameters are passed to
:class:`~pydl.pydlutils.bspline.bspline`.
Parameters
----------
xdata : :class:`numpy.ndarray`
Expand Down Expand Up @@ -626,6 +629,8 @@ def iterfit(xdata, ydata, invvar=None, upper=5, lower=5, x2=None,
ywork = ydata[xsort]
invwork = invvar[xsort]
if x2 is not None:
warn('2D bspline fits may be buggy and will be fully removed in the future.',
DeprecationWarning)
x2work = x2[xsort]
else:
x2work = None
Expand Down
32 changes: 32 additions & 0 deletions pydl/pydlutils/tests/test_bspline.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,38 @@ def test_iterfit():
# print(yfit)
# pylab.plot(x, y, 'k-', x, yfit, 'r-')

def test_iterfit_2d():
y0 = np.array([0.661984, 0.134913, 0.0410350, 0.940134, 0.411034,
0.484675, 0.169943, 0.325046, 0.269194, 0.552381,
0.797177, 0.971658, 0.251765, 0.531675, 0.854556,
0.411237, 0.694380, 0.499562, 0.437242, 0.362451,
0.343206, 0.524099, 0.158634, 0.728597, 0.198340,
0.571210, 0.477527, 0.962797, 0.973921, 0.413651,
0.736380, 0.516366, 0.104283, 0.675993, 0.467053,
0.230112, 0.866994, 0.469885, 0.964392, 0.541084,
0.332984, 0.581252, 0.422322, 0.872555, 0.803636,
0.520998, 0.918942, 0.241564, 0.169263, 0.686649,
0.708284, 0.707858, 0.00113957, 0.827920, 0.845985,
0.416961, 0.553842, 0.526549, 0.501051, 0.337514,
0.700873, 0.152816, 0.762935, 0.650039, 0.483321,
0.708600, 0.410033, 0.507671, 0.596956, 0.177692,
0.498112, 0.422037, 0.788333, 0.856578, 0.941245,
0.432411, 0.356469, 0.341916, 0.0331059, 0.641100,
0.690452, 0.168667, 0.915178, 0.158406, 0.701508,
0.841774, 0.434161, 0.153123, 0.420066, 0.0499331,
0.947241, 0.0768818, 0.410540, 0.843788, 0.0640255,
0.513463, 0.511104, 0.680434, 0.762480, 0.0563867])
assert y0.size == 100
y = smooth(y0, 10)
assert y.size == 100
x = np.arange(y0.size, dtype='d')
x2 = x.copy()
with pytest.warns(DeprecationWarning) as w:
sset, outmask = iterfit(x, y, x2=x2, maxiter=0, nord=3, bkspace=10)
assert len(w) > 0
assert str(w[0].message) == '2D bspline fits may be buggy and will be fully removed in the future.'
assert sset.npoly == 1
assert sset.funcname == 'legendre'

def test_cholesky_band():
ab = np.array([[8., 9., 10., 11., 12., 13., 14., 0., 0., 0.],
Expand Down
6 changes: 5 additions & 1 deletion pydl/tests/test_pydl.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,11 @@ def test_smooth():
def test_uniq():
items = np.array([1, 2, 3, 1, 5, 6, 1, 7, 3, 2, 5, 9, 11, 1])
items_sorted = np.sort(items)
items_argsorted = np.argsort(items)
#
# On some systems, kind='quicksort', which is the default, gives different
# results depending on numpy version.
#
items_argsorted = np.argsort(items, kind='stable')
#
# Test pre-sorted array.
#
Expand Down

0 comments on commit 205d911

Please sign in to comment.