Skip to content

Commit

Permalink
BUG: Fix discovered MachAr (still used within valgrind)
Browse files Browse the repository at this point in the history
This fixes the missing attributes.  I tested the warning and fix
on valgrind itself.
These attributes were added in numpygh-18536 but the fallback path was
not checked there.

Replaces numpygh-21813, although something more like it may make sense
if it allows us to just delete MachAr completely.
  • Loading branch information
seberg committed Jun 21, 2022
1 parent 70026c4 commit 4756c54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions numpy/core/_machar.py
Expand Up @@ -326,7 +326,9 @@ def _do_init(self, float_conv, int_conv, float_to_float, float_to_str, title):
self.tiny = self.xmin
self.huge = self.xmax
self.smallest_normal = self.xmin
self._str_smallest_normal = float_to_str(self.xmin)
self.smallest_subnormal = float_to_float(smallest_subnormal)
self._str_smallest_subnormal = float_to_str(smallest_subnormal)

import math
self.precision = int(-math.log10(float_to_float(self.eps)))
Expand Down
5 changes: 3 additions & 2 deletions numpy/core/getlimits.py
Expand Up @@ -343,8 +343,9 @@ def _get_machar(ftype):
return ma_like
# Fall back to parameter discovery
warnings.warn(
'Signature {} for {} does not match any known type: '
'falling back to type probe function'.format(key, ftype),
f'Signature {key} for {ftype} does not match any known type: '
'falling back to type probe function.\n'
'This warnings indicates broken support for the dtype!',
UserWarning, stacklevel=2)
return _discovered_machar(ftype)

Expand Down

0 comments on commit 4756c54

Please sign in to comment.