Skip to content

Commit aa48c71

Browse files
committed
_replace_nan_no_mask should not copy if a is not of inexact type
1 parent 2a24c4a commit aa48c71

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

dpnp/dpnp_iface_nanfunctions.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ def _replace_nan_no_mask(a, val):
6565
Replace NaNs in array `a` with `val`.
6666
6767
If `a` is of inexact type, make a copy of `a`, replace NaNs with
68-
the `val` value, and return the copy together. If `a` is not of
69-
inexact type, do nothing and return `a`.
68+
the `val` value, and return the copy. If `a` is not of inexact type,
69+
do nothing and return `a`.
7070
7171
Parameters
7272
----------
@@ -83,7 +83,11 @@ def _replace_nan_no_mask(a, val):
8383
8484
"""
8585

86-
return dpnp.nan_to_num(a, nan=val, posinf=dpnp.inf, neginf=-dpnp.inf)
86+
dpnp.check_supported_arrays_type(a)
87+
if dpnp.issubdtype(a.dtype, dpnp.inexact):
88+
return dpnp.nan_to_num(a, nan=val, posinf=dpnp.inf, neginf=-dpnp.inf)
89+
else:
90+
return a
8791

8892

8993
def _replace_nan(a, val):

0 commit comments

Comments
 (0)