New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible Solutions to Issues 26216, 25677, and 25589 #26276
base: main
Are you sure you want to change the base?
Changes from 9 commits
335a079
04352cd
3c69b48
50f45e9
7964310
d06cb8b
60ae351
65331d0
6a9bd92
cf5b304
34d1984
b2990c5
684d6c3
ba7514f
da160ee
bcc9f36
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,6 +165,7 @@ class MaskError(MAError): | |
|
||
|
||
# b: boolean - c: complex - f: floats - i: integer - O: object - S: string | ||
""" | ||
default_filler = {'b': True, | ||
'c': 1.e20 + 0.0j, | ||
'f': 1.e20, | ||
|
@@ -175,6 +176,31 @@ class MaskError(MAError): | |
'V': b'???', | ||
'U': 'N/A' | ||
} | ||
""" | ||
|
||
""" | ||
Addressing issue 25677 | ||
Added different custom fill values for different ints and floats. | ||
""" | ||
default_filler = {'b': True, | ||
'c': 1.e20 + 0.0j, | ||
"float16": 65504, | ||
"float32": pow(2, 31) - 1, | ||
"float64": pow(2, 63) - 1, | ||
"int8": 127, | ||
"uint8": 255, | ||
'int16': 32767, | ||
"uint16": 65535, | ||
"int32": 2147483647, | ||
"uint32": 4294967295, | ||
"int64": 9223372036854775807, | ||
"uint64": pow(2, 64) - 1, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think all of the integer dtypes that can represent There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, thanks for letting me know. I reverted the int types back as follows:
However, float16 remains 65504 to avoid the inf value per the original issue (#25677). Does this make sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #25677 is still unresolved for the smaller integer types. Write out the unit tests that test for the behavior that you want. Demonstrate (to yourself) that they fail without your changes, then add your changes until the tests pass. |
||
"i": 999999, | ||
'O': '?', | ||
'S': b'N/A', | ||
'V': b'???', | ||
'U': 'N/A' | ||
} | ||
|
||
# Add datetime64 and timedelta64 types | ||
for v in ["Y", "M", "W", "D", "h", "m", "s", "ms", "us", "ns", "ps", | ||
|
@@ -298,7 +324,18 @@ def _scalar_fill_value(dtype): | |
if dtype.kind in 'Mm': | ||
return default_filler.get(dtype.str[1:], '?') | ||
else: | ||
return default_filler.get(dtype.kind, '?') | ||
""" | ||
Addressing issue 25677 | ||
Using str(dtype) acts as the key in the default_filler dictionary to retrieve the | ||
custom value. | ||
|
||
If this key does not exist in default_filler, then dtype.kind is used as the key instead. | ||
""" | ||
if default_filler.get(str(dtype)) is not None: | ||
return default_filler.get(str(dtype), '?') | ||
else: | ||
return default_filler.get(dtype.kind, '?') | ||
# return default_filler.get(dtype.kind, '?') | ||
|
||
dtype = _get_dtype_of(obj) | ||
return _recursive_fill_value(dtype, _scalar_fill_value) | ||
|
@@ -7085,7 +7122,12 @@ def power(a, b, third=None): | |
# Get the masks | ||
ma = getmask(a) | ||
mb = getmask(b) | ||
m = mask_or(ma, mb) | ||
# m = mask_or(ma, mb) | ||
""" | ||
Addressing issue 25589 | ||
Added shrink = False on line 7130 to preserve the existing mask. | ||
20revsined marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
m = mask_or(ma, mb, shrink=False) | ||
# Get the rawdata | ||
fa = getdata(a) | ||
fb = getdata(b) | ||
|
@@ -7112,6 +7154,7 @@ def power(a, b, third=None): | |
elif result._mask is nomask: | ||
result._mask = invalid | ||
result._data[invalid] = result.fill_value | ||
# result.mask = a.mask | ||
return result | ||
|
||
argmin = _frommethod('argmin') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't take into account any of the
keepdims
,axis
,out
oroverwrite_input
arguments.