Skip to content

Commit ef799ed

Browse files
committed
Fix linting
1 parent cfaab8b commit ef799ed

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

src/array_api_extra/_delegation.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,10 @@ def nan_to_num(
118118
/,
119119
*,
120120
fill_value: int | float | complex = 0.0,
121-
xp: ModuleType | None = None
121+
xp: ModuleType | None = None,
122122
) -> Array:
123123
"""
124-
Replace NaN with zero and infinity with large finite numbers (default
125-
behaviour).
124+
Replace NaN with zero and infinity with large finite numbers (default behaviour).
126125
127126
If `x` is inexact, NaN is replaced by zero or by the user defined value in
128127
`nan` keyword, infinity is replaced by the largest finite floating point
@@ -141,6 +140,8 @@ def nan_to_num(
141140
fill_value : int, float, complex, optional
142141
Value to be used to fill NaN values. If no value is passed
143142
then NaN values will be replaced with 0.0.
143+
xp : array_namespace, optional
144+
The standard-compatible namespace for `x`. Default: infer.
144145
145146
Returns
146147
-------

src/array_api_extra/_lib/_funcs.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,17 +738,16 @@ def kron(
738738
return xp.reshape(result, res_shape)
739739

740740

741-
def nan_to_num(
741+
def nan_to_num( # numpydoc ignore=PR01,RT01
742742
x: Array,
743743
/,
744744
fill_value: int | float | complex = 0.0,
745745
*,
746746
xp: ModuleType,
747747
) -> Array:
748748
"""See docstring in `array_api_extra._delegation.py`."""
749-
xp = array_namespace(x) if xp is None else xp
750749

751-
def perform_replacements(
750+
def perform_replacements( # numpydoc ignore=PR01,RT01
752751
x: Array,
753752
fill_value: int | float | complex,
754753
xp: ModuleType,

tests/conftest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,10 @@ def device(
233233
return xp.device("cpu")
234234
return get_device(xp.empty(0))
235235

236+
236237
@pytest.fixture
237238
def infinity(library: Backend) -> float:
238239
"""Retrieve the positive infinity value for the given backend."""
239240
if library in (Backend.TORCH, Backend.TORCH_GPU):
240-
return 3.4028235e+38
241-
return 1.7976931348623157e+308
241+
return 3.4028235e38
242+
return 1.7976931348623157e308

tests/test_funcs.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -985,13 +985,7 @@ def test_complex(self, xp: ModuleType, infinity: float) -> None:
985985
)
986986
xp_assert_equal(
987987
nan_to_num(a),
988-
xp.asarray(
989-
[
990-
infinity + 0j,
991-
0 + 0j,
992-
0 + 1j * infinity
993-
]
994-
),
988+
xp.asarray([infinity + 0j, 0 + 0j, 0 + 1j * infinity]),
995989
)
996990

997991

0 commit comments

Comments
 (0)