Skip to content

Commit 6621cac

Browse files
committed
Run pre-commit on all files
1 parent 3797b81 commit 6621cac

25 files changed

+70
-98
lines changed

autogen/_binary_ufuncs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# this file is autogenerated via gen_ufuncs.py
22
# do not edit manually!
33

4-
import torch
5-
64
import _util
5+
import torch
76
from _ndarray import asarray_replacer
87

98

autogen/_unary_ufuncs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# this file is autogenerated via gen_ufuncs.py
22
# do not edit manually!
33

4-
import torch
5-
64
import _util
5+
import torch
76
from _ndarray import asarray_replacer
87

98

autogen/dump_namespace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from collections import defaultdict
21
import inspect
2+
from collections import defaultdict
33

44
import numpy as np
55

autogen/gen_mapping.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# The default is autopopulated, apply manual tweaks on the result, if needed.
44

55
import numpy as np
6-
76
import wrapper
87

98
_all = set(name for name in dir(wrapper) if not name.startswith("_"))

autogen/gen_ufuncs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
from dump_namespace import grab_namespace, get_signature
2-
31
import numpy as np
2+
from dump_namespace import get_signature, grab_namespace
43

54
namespace = np
65

autogen/gen_ufuncs_2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
from dump_namespace import grab_namespace, get_signature
2-
31
import numpy as np
2+
from dump_namespace import get_signature, grab_namespace
43

54
namespace = np
65

autogen/test_binary_ufuncs.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
# this file is autogenerated via gen_ufuncs.py
22
# do not edit manually!
33

4-
import torch
5-
64
import _util
7-
from _ndarray import asarray_replacer
8-
95
import numpy as np
106
import torch
11-
127
from _binary_ufuncs import *
8+
from _ndarray import asarray_replacer
139
from testing import assert_allclose
1410

1511

autogen/test_unary_ufuncs.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
# this file is autogenerated via gen_ufuncs.py
22
# do not edit manually!
33

4-
import torch
5-
64
import _util
7-
from _ndarray import asarray_replacer
8-
95
import numpy as np
106
import torch
11-
7+
from _ndarray import asarray_replacer
128
from _unary_ufuncs import *
139
from testing import assert_allclose
1410

torch_np/__init__.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1+
from ._binary_ufuncs import *
12
from ._dtypes import *
3+
from ._getlimits import errstate, finfo, iinfo
4+
from ._ndarray import can_cast, newaxis, result_type
25
from ._scalar_types import *
6+
from ._unary_ufuncs import *
7+
from ._util import AxisError, UFuncTypeError
38
from ._wrapper import *
49

510
# from . import testing
611

7-
from ._unary_ufuncs import *
8-
from ._binary_ufuncs import *
9-
from ._ndarray import can_cast, result_type, newaxis
10-
from ._util import AxisError, UFuncTypeError
11-
from ._getlimits import iinfo, finfo
12-
from ._getlimits import errstate
1312

1413
inf = float("inf")
1514
nan = float("nan")

torch_np/_binary_ufuncs.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import functools
2-
import torch
32

4-
from . import _util
3+
import torch
54

5+
from . import _dtypes, _helpers, _ufunc_impl, _util
66
from ._ndarray import asarray
7-
from . import _dtypes
8-
from . import _helpers
9-
10-
from . import _ufunc_impl
117

128
#
139
# Functions in _ufunc_impl receive arrays, implement common tasks with ufunc args

torch_np/_dtypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
# 3. convert from python types: np.ones(3, dtype=float) etc
77

88
import builtins
9+
910
import torch
1011

1112
from . import _scalar_types
1213

13-
1414
__all__ = ["dtype_from_torch", "dtype", "typecodes", "issubdtype"]
1515

1616

torch_np/_getlimits.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import torch
2+
23
from . import _dtypes
34

45

@@ -14,6 +15,7 @@ def iinfo(dtyp):
1415

1516
import contextlib
1617

18+
1719
# FIXME: this is only a stub
1820
@contextlib.contextmanager
1921
def errstate(*args, **kwds):

torch_np/_helpers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import operator
22

33
import torch
4-
from . import _dtypes
5-
from ._ndarray import can_cast, ndarray, asarray
6-
from . import _util
4+
5+
from . import _dtypes, _util
6+
from ._ndarray import asarray, can_cast, ndarray
77

88

99
def cast_and_broadcast(arrays, out, casting):

torch_np/_ndarray.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
import torch
44

5-
from . import _util
6-
from . import _helpers
7-
from . import _dtypes
8-
from . import _ufunc_impl
5+
from . import _dtypes, _helpers, _ufunc_impl, _util
96

107
NoValue = None
118
newaxis = None

torch_np/_scalar_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""
33

44
import abc
5+
56
import torch
67

78

@@ -15,8 +16,7 @@ def __new__(self, value):
1516
#
1617
# Yes, a call to np.float32(4) produces a zero-dim array.
1718
#
18-
from . import _dtypes
19-
from . import _ndarray
19+
from . import _dtypes, _ndarray
2020

2121
torch_dtype = _dtypes.torch_dtype_from(self.name)
2222

torch_np/_ufunc_impl.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import torch
22

3-
from . import _util
4-
from . import _helpers
3+
from . import _helpers, _util
54

65

76
def deco_binary_ufunc(torch_func):

torch_np/_unary_ufuncs.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import functools
2-
import torch
32

4-
from . import _util
3+
import torch
54

5+
from . import _dtypes, _helpers, _ufunc_impl, _util
66
from ._ndarray import asarray
7-
from . import _dtypes
8-
from . import _helpers
9-
10-
from . import _ufunc_impl
117

128
__all__ = [
139
"abs",

torch_np/_wrapper.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77

88
import torch
99

10-
from . import _util
11-
from . import _dtypes
12-
from . import _helpers
13-
from ._ndarray import ndarray, asarray, array, asarray_replacer, newaxis
14-
from ._ndarray import can_cast, result_type
15-
10+
from . import _dtypes, _helpers, _util
11+
from ._ndarray import (
12+
array,
13+
asarray,
14+
asarray_replacer,
15+
can_cast,
16+
ndarray,
17+
newaxis,
18+
result_type,
19+
)
1620

1721
# Things to decide on (punt for now)
1822
#

torch_np/testing/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from .utils import (
2-
assert_equal,
3-
assert_array_equal,
4-
assert_almost_equal,
5-
assert_warns,
2+
_gen_alignment_data,
63
assert_,
74
assert_allclose,
5+
assert_almost_equal,
6+
assert_array_equal,
7+
assert_equal,
8+
assert_warns,
89
)
9-
from .utils import _gen_alignment_data
1010

1111
# from .testing import assert_allclose # FIXME

torch_np/testing/utils.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,27 @@
22
Utility function to facilitate testing.
33
44
"""
5+
import contextlib
6+
import gc
7+
import operator
58
import os
6-
import sys
79
import platform
10+
import pprint
811
import re
9-
import gc
10-
import operator
11-
import warnings
12-
from functools import partial, wraps
1312
import shutil
14-
import contextlib
13+
import sys
14+
import warnings
15+
from functools import wraps
16+
from io import StringIO
1517
from tempfile import mkdtemp, mkstemp
1618
from warnings import WarningMessage
17-
import pprint
18-
19-
import torch_np as np
20-
from torch_np import intp, float32, empty, arange, ndarray, array
21-
from torch_np import asarray as asanyarray
22-
23-
from io import StringIO
2419

2520
from pytest import raises as assert_raises
2621

22+
import torch_np as np
23+
from torch_np import arange, array
24+
from torch_np import asarray as asanyarray
25+
from torch_np import empty, float32, intp, ndarray
2726

2827
__all__ = [
2928
"assert_equal",
@@ -201,8 +200,7 @@ def assert_equal(actual, desired, err_msg="", verbose=True):
201200
for k in range(len(desired)):
202201
assert_equal(actual[k], desired[k], f"item={k!r}\n{err_msg}", verbose)
203202
return
204-
from torch_np import ndarray, isscalar, signbit
205-
from torch_np import iscomplexobj, real, imag
203+
from torch_np import imag, iscomplexobj, isscalar, ndarray, real, signbit
206204

207205
if isinstance(actual, ndarray) or isinstance(desired, ndarray):
208206
return assert_array_equal(actual, desired, err_msg, verbose)
@@ -384,8 +382,7 @@ def assert_almost_equal(actual, desired, decimal=7, err_msg="", verbose=True):
384382
385383
"""
386384
__tracebackhide__ = True # Hide traceback for py.test
387-
from torch_np import ndarray
388-
from torch_np import iscomplexobj, real, imag
385+
from torch_np import imag, iscomplexobj, ndarray, real
389386

390387
# Handle complex numbers: separate into real/imag to handle
391388
# nan/inf/negative zero correctly
@@ -555,7 +552,7 @@ def assert_array_compare(
555552
strict=False,
556553
):
557554
__tracebackhide__ = True # Hide traceback for py.test
558-
from torch_np import asarray, array, isnan, inf, all, max, bool_
555+
from torch_np import all, array, asarray, bool_, inf, isnan, max
559556

560557
x = asarray(x)
561558
y = asarray(y)
@@ -928,9 +925,8 @@ def assert_array_almost_equal(x, y, decimal=6, err_msg="", verbose=True):
928925
929926
"""
930927
__tracebackhide__ = True # Hide traceback for py.test
931-
from torch_np import number, float_, result_type, array
932-
from torch_np import issubdtype
933928
from torch_np import any as npany
929+
from torch_np import array, float_, issubdtype, number, result_type
934930

935931
def compare(x, y):
936932
try:
@@ -1217,6 +1213,7 @@ def _assert_valid_refcount(op):
12171213
return True
12181214

12191215
import gc
1216+
12201217
import numpy as np
12211218

12221219
b = np.arange(100 * 100).reshape(100, 100)
@@ -1758,7 +1755,6 @@ def _gen_alignment_data(dtype=float32, type="binary", max_size=24):
17581755

17591756
class IgnoreException(Exception):
17601757
"Ignoring this exception due to disabled feature"
1761-
pass
17621758

17631759

17641760
@contextlib.contextmanager

torch_np/tests/test_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import functools
2-
import pytest
32

43
import numpy as np
4+
import pytest
55
import torch
66

77
import torch_np as w

torch_np/tests/test_function_base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import pytest
2-
32
from pytest import raises as assert_raises
43

54
import torch_np as np
6-
from torch_np.testing import assert_equal, assert_array_equal
5+
from torch_np.testing import assert_array_equal, assert_equal
76

87

98
class TestCopy:

torch_np/tests/test_ndarray_methods.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
# import numpy as np
77
import torch_np as np
8-
98
from torch_np.testing import assert_equal
109

1110

0 commit comments

Comments
 (0)