Skip to content

Commit

Permalink
Merge pull request #267 from ajhynes7/fix_warnings
Browse files Browse the repository at this point in the history
Fix warnings
  • Loading branch information
ajhynes7 committed Mar 26, 2021
2 parents 6106909 + 806794c commit e663c7b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
9 changes: 9 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
History
=======

6.0.1 (2021-03-25)
------------------

Fixes
~~~~~
* Wrap `filterwarnings("error")` in a `catch_warnings` context manager, in `__BaseArray.__new__()`.
Now the warning level is reset at the end of the context manager.


6.0.0 (2021-03-21)
------------------

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]

name = "scikit-spatial"
version = "6.0.0"
version = "6.0.1"
description = "Spatial objects and computations based on NumPy arrays."
license = "BSD"

Expand Down
2 changes: 1 addition & 1 deletion src/skspatial/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__author__ = "Andrew Hynes"
__email__ = 'andrewjhynes@gmail.com'
__version__ = '6.0.0'
__version__ = '6.0.1'
12 changes: 7 additions & 5 deletions src/skspatial/objects/_base_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ class _BaseArray(np.ndarray, _BaseSpatial):

def __new__(cls: Type[Array], array: array_like) -> Array:

try:
with warnings.catch_warnings():

warnings.filterwarnings("error")
np.array(array)

except np.VisibleDeprecationWarning as error:
try:
np.array(array)

if str(error).startswith("Creating an ndarray from ragged nested sequences"):
raise ValueError("The array must not contain sequences with different lengths.")
except np.VisibleDeprecationWarning as error:
if str(error).startswith("Creating an ndarray from ragged nested sequences"):
raise ValueError("The array must not contain sequences with different lengths.")

if np.size(array) == 0:
raise ValueError("The array must not be empty.")
Expand Down

0 comments on commit e663c7b

Please sign in to comment.