Skip to content

Commit

Permalink
fixed utils.printoptions
Browse files Browse the repository at this point in the history
FloatFormat was marked as deprecated in numpy 1.14.0 and its deprecation expired in numpy 1.18.0.

Furthermore, FloatingFormat.__call__ takes only 2 positional arguments so it would crash when passing strip_zeros.

After a quick grep in the files, turns out that nor printoptions(True, **kwargs) nor printoptions(strip_zeros=True) was used anywhere, therefore the keyword was removed.

This now works with numpy 1.22.4.
  • Loading branch information
Sciancisco committed Jun 17, 2022
1 parent 7249749 commit e76fb3e
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions yeadon/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


@contextlib.contextmanager
def printoptions(strip_zeros=False, **kwargs):
def printoptions(**kwargs):
"""Allows you to set NumPy array print formatting locally.
Taken from:
Expand All @@ -16,14 +16,7 @@ def printoptions(strip_zeros=False, **kwargs):
"""

origcall = arrayprint.FloatFormat.__call__

def __call__(self, x, strip_zeros=strip_zeros):
return origcall.__call__(self, x, strip_zeros)

arrayprint.FloatFormat.__call__ = __call__
original = np.get_printoptions()
np.set_printoptions(**kwargs)
yield
np.set_printoptions(**original)
arrayprint.FloatFormat.__call__ = origcall

0 comments on commit e76fb3e

Please sign in to comment.