From f9a4edf3748b10e7c6bf30533744ec7f492f1c02 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Sat, 29 Jan 2022 17:06:58 -0500 Subject: [PATCH] style: update to first non-pre-release black! --- .pre-commit-config.yaml | 2 +- src/awkward/_v2/_slicing.py | 11 +- src/awkward/_v2/contents/unionarray.py | 4 +- .../_v2/operations/reducers/ak_corr.py | 8 +- .../_v2/operations/reducers/ak_linear_fit.py | 4 +- .../_v2/operations/reducers/ak_moment.py | 2 +- src/awkward/_v2/tmp_for_testing.py | 57 +++---- src/awkward/operations/convert.py | 2 +- src/awkward/operations/reducers.py | 14 +- .../test_0388-abstract-all-uses-of-numpy.py | 30 ++-- tests/test_0011-listarray.py | 146 +++++++----------- tests/test_0020-support-unsigned-indexes.py | 146 +++++++----------- tests/test_0025-record-array.py | 17 +- tests/test_0056-partitioned-array.py | 52 +++---- tests/test_0111-jagged-and-masked-getitem.py | 123 ++++++--------- tests/test_0118-numba-cpointers.py | 27 ++-- tests/test_0120-autograd-support.py | 2 +- tests/test_0138-emptyarray-type.py | 13 +- tests/test_0198-tutorial-documentation-1.py | 36 ++--- tests/test_0348-form-keys.py | 27 ++-- tests/test_0355-mixins.py | 2 +- tests/test_0393-fix-bitmaskedarray-mask.py | 76 ++++----- tests/test_0494-numba-array-contains.py | 38 ++--- tests/test_0501-string-comparison-bug.py | 35 ++--- ...st_0628-accept-numpy-integers-in-slices.py | 27 ++-- tests/test_0793-jax-element-wise-ops.py | 2 +- tests/test_1030-mixin-class-name.py | 2 +- tests/v2/test_0011-listarray.py | 146 +++++++----------- .../v2/test_0020-support-unsigned-indexes.py | 146 +++++++----------- tests/v2/test_0025-record-array.py | 17 +- .../v2/test_0111-jagged-and-masked-getitem.py | 66 +++----- tests/v2/test_0138-emptyarray-type.py | 13 +- tests/v2/test_0348-form-keys.py | 27 ++-- .../v2/test_0652-tests-of-complex-numbers.py | 26 +--- ...st_1192-iterables-in-__array_function__.py | 19 +-- 35 files changed, 549 insertions(+), 816 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aa6da31002..dbd9d649dd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,7 @@ repos: args: ["--py36-plus"] - repo: https://github.com/psf/black - rev: 21.12b0 + rev: 22.1.0 hooks: - id: black diff --git a/src/awkward/_v2/_slicing.py b/src/awkward/_v2/_slicing.py index 60ec04b5a9..c1354338c1 100644 --- a/src/awkward/_v2/_slicing.py +++ b/src/awkward/_v2/_slicing.py @@ -172,13 +172,10 @@ def prepare_tuple_nested(item): next = prepare_tuple_RegularArray_toListOffsetArray64(next) return next - elif ( - isinstance( - item, - ak._v2.contents.ListOffsetArray, - ) - and issubclass(item.offsets.dtype.type, np.int64) - ): + elif isinstance( + item, + ak._v2.contents.ListOffsetArray, + ) and issubclass(item.offsets.dtype.type, np.int64): return ak._v2.contents.ListOffsetArray( item.offsets, prepare_tuple_nested(item.content), diff --git a/src/awkward/_v2/contents/unionarray.py b/src/awkward/_v2/contents/unionarray.py index 5bc29032b8..29ddb25220 100644 --- a/src/awkward/_v2/contents/unionarray.py +++ b/src/awkward/_v2/contents/unionarray.py @@ -548,7 +548,7 @@ def simplify_uniontype(self, merge=True, mergebool=False): ) contents.append(self._contents[i]) - if len(contents) > 2 ** 7: + if len(contents) > 2**7: raise NotImplementedError( "FIXME: handle UnionArray with more than 127 contents" ) @@ -755,7 +755,7 @@ def _reverse_merge(self, other): ) ) - if len(contents) > 2 ** 7: + if len(contents) > 2**7: raise AssertionError("FIXME: handle UnionArray with more than 127 contents") parameters = ak._v2._util.merge_parameters(self._parameters, other._parameters) diff --git a/src/awkward/_v2/operations/reducers/ak_corr.py b/src/awkward/_v2/operations/reducers/ak_corr.py index 69501ea7aa..310205f8bf 100644 --- a/src/awkward/_v2/operations/reducers/ak_corr.py +++ b/src/awkward/_v2/operations/reducers/ak_corr.py @@ -80,23 +80,23 @@ def corr( ydiff = y - ymean if weight is None: sumwxx = ak._v2.operations.reducers.sum( - xdiff ** 2, axis=axis, keepdims=keepdims, mask_identity=mask_identity + xdiff**2, axis=axis, keepdims=keepdims, mask_identity=mask_identity ) sumwyy = ak._v2.operations.reducers.sum( - ydiff ** 2, axis=axis, keepdims=keepdims, mask_identity=mask_identity + ydiff**2, axis=axis, keepdims=keepdims, mask_identity=mask_identity ) sumwxy = ak._v2.operations.reducers.sum( xdiff * ydiff, axis=axis, keepdims=keepdims, mask_identity=mask_identity ) else: sumwxx = ak._v2.operations.reducers.sum( - (xdiff ** 2) * weight, + (xdiff**2) * weight, axis=axis, keepdims=keepdims, mask_identity=mask_identity, ) sumwyy = ak._v2.operations.reducers.sum( - (ydiff ** 2) * weight, + (ydiff**2) * weight, axis=axis, keepdims=keepdims, mask_identity=mask_identity, diff --git a/src/awkward/_v2/operations/reducers/ak_linear_fit.py b/src/awkward/_v2/operations/reducers/ak_linear_fit.py index 1f307436d0..ef8e4f8064 100644 --- a/src/awkward/_v2/operations/reducers/ak_linear_fit.py +++ b/src/awkward/_v2/operations/reducers/ak_linear_fit.py @@ -95,7 +95,7 @@ def linear_fit( y, axis=axis, keepdims=keepdims, mask_identity=mask_identity ) sumwxx = ak._v2.operations.reducers.sum( - x ** 2, axis=axis, keepdims=keepdims, mask_identity=mask_identity + x**2, axis=axis, keepdims=keepdims, mask_identity=mask_identity ) sumwxy = ak._v2.operations.reducers.sum( x * y, axis=axis, keepdims=keepdims, mask_identity=mask_identity @@ -114,7 +114,7 @@ def linear_fit( y * weight, axis=axis, keepdims=keepdims, mask_identity=mask_identity ) sumwxx = ak._v2.operations.reducers.sum( - (x ** 2) * weight, + (x**2) * weight, axis=axis, keepdims=keepdims, mask_identity=mask_identity, diff --git a/src/awkward/_v2/operations/reducers/ak_moment.py b/src/awkward/_v2/operations/reducers/ak_moment.py index 0395b6a451..1800e8a525 100644 --- a/src/awkward/_v2/operations/reducers/ak_moment.py +++ b/src/awkward/_v2/operations/reducers/ak_moment.py @@ -74,7 +74,7 @@ def moment( x, axis=axis, keepdims=keepdims, mask_identity=mask_identity ) sumwxn = ak._v2.operations.reducers.sum( - x ** n, axis=axis, keepdims=keepdims, mask_identity=mask_identity + x**n, axis=axis, keepdims=keepdims, mask_identity=mask_identity ) else: sumw = ak._v2.operations.reducers.sum( diff --git a/src/awkward/_v2/tmp_for_testing.py b/src/awkward/_v2/tmp_for_testing.py index b2da6d5ebf..e95ddea70f 100644 --- a/src/awkward/_v2/tmp_for_testing.py +++ b/src/awkward/_v2/tmp_for_testing.py @@ -55,17 +55,14 @@ def v1v2_equal(v1, v2): and v1_stops.dtype == v2_stops.dtype ) - elif ( - isinstance( - v1, - ( - ak.layout.ListOffsetArray32, - ak.layout.ListOffsetArrayU32, - ak.layout.ListOffsetArray64, - ), - ) - and isinstance(v2, ak._v2.contents.ListOffsetArray) - ): + elif isinstance( + v1, + ( + ak.layout.ListOffsetArray32, + ak.layout.ListOffsetArrayU32, + ak.layout.ListOffsetArray64, + ), + ) and isinstance(v2, ak._v2.contents.ListOffsetArray): v1_offsets = np.asarray(v1.offsets) v2_offsets = v2.offsets.data return ( @@ -82,17 +79,14 @@ def v1v2_equal(v1, v2): for i in range(v1.numfields) ) - elif ( - isinstance( - v1, - ( - ak.layout.IndexedArray32, - ak.layout.IndexedArrayU32, - ak.layout.IndexedArray64, - ), - ) - and isinstance(v2, ak._v2.contents.IndexedArray) - ): + elif isinstance( + v1, + ( + ak.layout.IndexedArray32, + ak.layout.IndexedArrayU32, + ak.layout.IndexedArray64, + ), + ) and isinstance(v2, ak._v2.contents.IndexedArray): v1_index = np.asarray(v1.index) v2_index = v2.index.data return ( @@ -142,17 +136,14 @@ def v1v2_equal(v1, v2): ): return v1v2_equal(v1.content, v2.content) - elif ( - isinstance( - v1, - ( - ak.layout.UnionArray8_32, - ak.layout.UnionArray8_U32, - ak.layout.UnionArray8_64, - ), - ) - and isinstance(v2, ak._v2.contents.UnionArray) - ): + elif isinstance( + v1, + ( + ak.layout.UnionArray8_32, + ak.layout.UnionArray8_U32, + ak.layout.UnionArray8_64, + ), + ) and isinstance(v2, ak._v2.contents.UnionArray): v1_tags = np.asarray(v1.tags) v2_tags = v2.tags.data v1_index = np.asarray(v1.index) diff --git a/src/awkward/operations/convert.py b/src/awkward/operations/convert.py index 93732574d1..b4811d156a 100644 --- a/src/awkward/operations/convert.py +++ b/src/awkward/operations/convert.py @@ -1016,7 +1016,7 @@ def to_list(array): _maybe_json_str = re.compile(r"^\s*(\[|\{|\"|[0-9]|true|false|null)") -_maybe_json_bytes = re.compile(br"^\s*(\[|\{|\"|[0-9]|true|false|null)") +_maybe_json_bytes = re.compile(rb"^\s*(\[|\{|\"|[0-9]|true|false|null)") def from_json( diff --git a/src/awkward/operations/reducers.py b/src/awkward/operations/reducers.py index 6c97b69d9c..4b9d33a5b0 100644 --- a/src/awkward/operations/reducers.py +++ b/src/awkward/operations/reducers.py @@ -887,7 +887,7 @@ def moment(x, n, weight=None, axis=None, keepdims=False, mask_identity=True): if weight is None: sumw = count(x, axis=axis, keepdims=keepdims, mask_identity=mask_identity) sumwxn = sum( - x ** n, axis=axis, keepdims=keepdims, mask_identity=mask_identity + x**n, axis=axis, keepdims=keepdims, mask_identity=mask_identity ) else: sumw = sum( @@ -1242,23 +1242,23 @@ def corr(x, y, weight=None, axis=None, keepdims=False, mask_identity=True): ydiff = y - ymean if weight is None: sumwxx = sum( - xdiff ** 2, axis=axis, keepdims=keepdims, mask_identity=mask_identity + xdiff**2, axis=axis, keepdims=keepdims, mask_identity=mask_identity ) sumwyy = sum( - ydiff ** 2, axis=axis, keepdims=keepdims, mask_identity=mask_identity + ydiff**2, axis=axis, keepdims=keepdims, mask_identity=mask_identity ) sumwxy = sum( xdiff * ydiff, axis=axis, keepdims=keepdims, mask_identity=mask_identity ) else: sumwxx = sum( - (xdiff ** 2) * weight, + (xdiff**2) * weight, axis=axis, keepdims=keepdims, mask_identity=mask_identity, ) sumwyy = sum( - (ydiff ** 2) * weight, + (ydiff**2) * weight, axis=axis, keepdims=keepdims, mask_identity=mask_identity, @@ -1333,7 +1333,7 @@ def linear_fit(x, y, weight=None, axis=None, keepdims=False, mask_identity=True) sumwx = sum(x, axis=axis, keepdims=keepdims, mask_identity=mask_identity) sumwy = sum(y, axis=axis, keepdims=keepdims, mask_identity=mask_identity) sumwxx = sum( - x ** 2, axis=axis, keepdims=keepdims, mask_identity=mask_identity + x**2, axis=axis, keepdims=keepdims, mask_identity=mask_identity ) sumwxy = sum( x * y, axis=axis, keepdims=keepdims, mask_identity=mask_identity @@ -1352,7 +1352,7 @@ def linear_fit(x, y, weight=None, axis=None, keepdims=False, mask_identity=True) y * weight, axis=axis, keepdims=keepdims, mask_identity=mask_identity ) sumwxx = sum( - (x ** 2) * weight, + (x**2) * weight, axis=axis, keepdims=keepdims, mask_identity=mask_identity, diff --git a/tests-cuda/test_0388-abstract-all-uses-of-numpy.py b/tests-cuda/test_0388-abstract-all-uses-of-numpy.py index 0d2beaa6de..10f4e04b97 100644 --- a/tests-cuda/test_0388-abstract-all-uses-of-numpy.py +++ b/tests-cuda/test_0388-abstract-all-uses-of-numpy.py @@ -345,24 +345,18 @@ def test_stack(): def test_vstack(): # arrays - assert ( - numpy.vstack( - [ - numpy.array([[0, 1, 2], [3, 4, 5]]), - numpy.array([[0.0, 1.1, 2.2], [3.3, 4.4, 5.5]]), - ] - ).tolist() - == [[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [0.0, 1.1, 2.2], [3.3, 4.4, 5.5]] - ) - assert ( - cupy.vstack( - [ - cupy.array([[0, 1, 2], [3, 4, 5]]), - cupy.array([[0.0, 1.1, 2.2], [3.3, 4.4, 5.5]]), - ] - ).tolist() - == [[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [0.0, 1.1, 2.2], [3.3, 4.4, 5.5]] - ) + assert numpy.vstack( + [ + numpy.array([[0, 1, 2], [3, 4, 5]]), + numpy.array([[0.0, 1.1, 2.2], [3.3, 4.4, 5.5]]), + ] + ).tolist() == [[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [0.0, 1.1, 2.2], [3.3, 4.4, 5.5]] + assert cupy.vstack( + [ + cupy.array([[0, 1, 2], [3, 4, 5]]), + cupy.array([[0.0, 1.1, 2.2], [3.3, 4.4, 5.5]]), + ] + ).tolist() == [[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [0.0, 1.1, 2.2], [3.3, 4.4, 5.5]] def test_packbits(): diff --git a/tests/test_0011-listarray.py b/tests/test_0011-listarray.py index 846693d17c..3a8486ce20 100644 --- a/tests/test_0011-listarray.py +++ b/tests/test_0011-listarray.py @@ -61,14 +61,11 @@ def test_listoffsetarray_basic(): def test_listarray_at(): array1 = ak.layout.ListArray64(starts1, stops1, content) assert ak.to_list(array1[2]) == [4.4, 5.5] - assert ( - ak.to_list( - array1[ - 2, - ] - ) - == [4.4, 5.5] - ) + assert ak.to_list( + array1[ + 2, + ] + ) == [4.4, 5.5] assert ak.to_list(array1[2, 1:]) == [5.5] assert ak.to_list(array1[2:, 0]) == [4.4, 6.6, 7.7] assert ak.to_list(array1[2:, -1]) == [5.5, 6.6, 9.9] @@ -76,14 +73,11 @@ def test_listarray_at(): def test_listoffsetarray_at(): array1 = ak.layout.ListOffsetArray64(offsets1, content) - assert ( - ak.to_list( - array1[ - 2, - ] - ) - == [4.4, 5.5] - ) + assert ak.to_list( + array1[ + 2, + ] + ) == [4.4, 5.5] assert ak.to_list(array1[2, 1:]) == [5.5] assert ak.to_list(array1[2:, 0]) == [4.4, 6.6, 7.7] assert ak.to_list(array1[2:, -1]) == [5.5, 6.6, 9.9] @@ -93,46 +87,34 @@ def test_listarray_slice(): array1 = ak.layout.ListArray64(starts1, stops1, content) array2 = ak.layout.ListArray64(starts2, stops2, array1) assert ak.to_list(array1[1:-1]) == [[], [4.4, 5.5], [6.6]] - assert ( - ak.to_list( - array1[ - 1:-1, - ] - ) - == [[], [4.4, 5.5], [6.6]] - ) + assert ak.to_list( + array1[ + 1:-1, + ] + ) == [[], [4.4, 5.5], [6.6]] assert ak.to_list(array2[1:-1]) == [[[4.4, 5.5]], []] - assert ( - ak.to_list( - array2[ - 1:-1, - ] - ) - == [[[4.4, 5.5]], []] - ) + assert ak.to_list( + array2[ + 1:-1, + ] + ) == [[[4.4, 5.5]], []] def test_listoffsetarray_slice(): array1 = ak.layout.ListOffsetArray64(offsets1, content) array2 = ak.layout.ListOffsetArray64(offsets2, array1) assert ak.to_list(array1[1:-1]) == [[], [4.4, 5.5], [6.6]] - assert ( - ak.to_list( - array1[ - 1:-1, - ] - ) - == [[], [4.4, 5.5], [6.6]] - ) + assert ak.to_list( + array1[ + 1:-1, + ] + ) == [[], [4.4, 5.5], [6.6]] assert ak.to_list(array2[1:-1]) == [[[4.4, 5.5]], []] - assert ( - ak.to_list( - array2[ - 1:-1, - ] - ) - == [[[4.4, 5.5]], []] - ) + assert ak.to_list( + array2[ + 1:-1, + ] + ) == [[[4.4, 5.5]], []] def test_listarray_slice_slice(): @@ -284,28 +266,22 @@ def test_listarray_array(): [[6, 60], [7, 70], [8, 80]], ] s = (np.array([2, 0, 0, -1]), np.array([1, 1, 0, 0]), np.array([0, 1, 0, 1])) - assert ( - np.array( - [ - [[0, 0], [1, 10], [2, 20]], - [[3, 30], [4, 40], [5, 50]], - [[6, 60], [7, 70], [8, 80]], - ] - )[s].tolist() - == ak.to_list(array1_deep[s]) - ) + assert np.array( + [ + [[0, 0], [1, 10], [2, 20]], + [[3, 30], [4, 40], [5, 50]], + [[6, 60], [7, 70], [8, 80]], + ] + )[s].tolist() == ak.to_list(array1_deep[s]) s = (np.array([2, 0, 0, -1]), np.array([1, 1, 0, 0]), slice(1, None)) - assert ( - np.array( - [ - [[0, 0], [1, 10], [2, 20]], - [[3, 30], [4, 40], [5, 50]], - [[6, 60], [7, 70], [8, 80]], - ] - )[s].tolist() - == ak.to_list(array1_deep[s]) - ) + assert np.array( + [ + [[0, 0], [1, 10], [2, 20]], + [[3, 30], [4, 40], [5, 50]], + [[6, 60], [7, 70], [8, 80]], + ] + )[s].tolist() == ak.to_list(array1_deep[s]) def test_listoffsetarray_array(): @@ -349,25 +325,19 @@ def test_listoffsetarray_array(): [[6, 60], [7, 70], [8, 80]], ] s = (np.array([2, 0, 0, -1]), np.array([1, 1, 0, 0]), np.array([0, 1, 0, 1])) - assert ( - np.array( - [ - [[0, 0], [1, 10], [2, 20]], - [[3, 30], [4, 40], [5, 50]], - [[6, 60], [7, 70], [8, 80]], - ] - )[s].tolist() - == ak.to_list(array1_deep[s]) - ) + assert np.array( + [ + [[0, 0], [1, 10], [2, 20]], + [[3, 30], [4, 40], [5, 50]], + [[6, 60], [7, 70], [8, 80]], + ] + )[s].tolist() == ak.to_list(array1_deep[s]) s = (np.array([2, 0, 0, -1]), np.array([1, 1, 0, 0]), slice(1, None)) - assert ( - np.array( - [ - [[0, 0], [1, 10], [2, 20]], - [[3, 30], [4, 40], [5, 50]], - [[6, 60], [7, 70], [8, 80]], - ] - )[s].tolist() - == ak.to_list(array1_deep[s]) - ) + assert np.array( + [ + [[0, 0], [1, 10], [2, 20]], + [[3, 30], [4, 40], [5, 50]], + [[6, 60], [7, 70], [8, 80]], + ] + )[s].tolist() == ak.to_list(array1_deep[s]) diff --git a/tests/test_0020-support-unsigned-indexes.py b/tests/test_0020-support-unsigned-indexes.py index 853fefae58..8f33aab81f 100644 --- a/tests/test_0020-support-unsigned-indexes.py +++ b/tests/test_0020-support-unsigned-indexes.py @@ -163,14 +163,11 @@ def test_listoffsetarray_basic(): def test_listarray_at(): array1 = ak.layout.ListArrayU32(starts1, stops1, content) assert ak.to_list(array1[2]) == [4.4, 5.5] - assert ( - ak.to_list( - array1[ - 2, - ] - ) - == [4.4, 5.5] - ) + assert ak.to_list( + array1[ + 2, + ] + ) == [4.4, 5.5] assert ak.to_list(array1[2, 1:]) == [5.5] assert ak.to_list(array1[2:, 0]) == [4.4, 6.6, 7.7] assert ak.to_list(array1[2:, -1]) == [5.5, 6.6, 9.9] @@ -178,14 +175,11 @@ def test_listarray_at(): def test_listoffsetarray_at(): array1 = ak.layout.ListOffsetArrayU32(offsets1, content) - assert ( - ak.to_list( - array1[ - 2, - ] - ) - == [4.4, 5.5] - ) + assert ak.to_list( + array1[ + 2, + ] + ) == [4.4, 5.5] assert ak.to_list(array1[2, 1:]) == [5.5] assert ak.to_list(array1[2:, 0]) == [4.4, 6.6, 7.7] assert ak.to_list(array1[2:, -1]) == [5.5, 6.6, 9.9] @@ -195,46 +189,34 @@ def test_listarray_slice(): array1 = ak.layout.ListArrayU32(starts1, stops1, content) array2 = ak.layout.ListArrayU32(starts2, stops2, array1) assert ak.to_list(array1[1:-1]) == [[], [4.4, 5.5], [6.6]] - assert ( - ak.to_list( - array1[ - 1:-1, - ] - ) - == [[], [4.4, 5.5], [6.6]] - ) + assert ak.to_list( + array1[ + 1:-1, + ] + ) == [[], [4.4, 5.5], [6.6]] assert ak.to_list(array2[1:-1]) == [[[4.4, 5.5]], []] - assert ( - ak.to_list( - array2[ - 1:-1, - ] - ) - == [[[4.4, 5.5]], []] - ) + assert ak.to_list( + array2[ + 1:-1, + ] + ) == [[[4.4, 5.5]], []] def test_listoffsetarray_slice(): array1 = ak.layout.ListOffsetArrayU32(offsets1, content) array2 = ak.layout.ListOffsetArrayU32(offsets2, array1) assert ak.to_list(array1[1:-1]) == [[], [4.4, 5.5], [6.6]] - assert ( - ak.to_list( - array1[ - 1:-1, - ] - ) - == [[], [4.4, 5.5], [6.6]] - ) + assert ak.to_list( + array1[ + 1:-1, + ] + ) == [[], [4.4, 5.5], [6.6]] assert ak.to_list(array2[1:-1]) == [[[4.4, 5.5]], []] - assert ( - ak.to_list( - array2[ - 1:-1, - ] - ) - == [[[4.4, 5.5]], []] - ) + assert ak.to_list( + array2[ + 1:-1, + ] + ) == [[[4.4, 5.5]], []] def test_listarray_slice_slice(): @@ -386,28 +368,22 @@ def test_listarray_array(): [[6, 60], [7, 70], [8, 80]], ] s = (np.array([2, 0, 0, -1]), np.array([1, 1, 0, 0]), np.array([0, 1, 0, 1])) - assert ( - np.array( - [ - [[0, 0], [1, 10], [2, 20]], - [[3, 30], [4, 40], [5, 50]], - [[6, 60], [7, 70], [8, 80]], - ] - )[s].tolist() - == ak.to_list(array1_deep[s]) - ) + assert np.array( + [ + [[0, 0], [1, 10], [2, 20]], + [[3, 30], [4, 40], [5, 50]], + [[6, 60], [7, 70], [8, 80]], + ] + )[s].tolist() == ak.to_list(array1_deep[s]) s = (np.array([2, 0, 0, -1]), np.array([1, 1, 0, 0]), slice(1, None)) - assert ( - np.array( - [ - [[0, 0], [1, 10], [2, 20]], - [[3, 30], [4, 40], [5, 50]], - [[6, 60], [7, 70], [8, 80]], - ] - )[s].tolist() - == ak.to_list(array1_deep[s]) - ) + assert np.array( + [ + [[0, 0], [1, 10], [2, 20]], + [[3, 30], [4, 40], [5, 50]], + [[6, 60], [7, 70], [8, 80]], + ] + )[s].tolist() == ak.to_list(array1_deep[s]) def test_listoffsetarray_array(): @@ -451,25 +427,19 @@ def test_listoffsetarray_array(): [[6, 60], [7, 70], [8, 80]], ] s = (np.array([2, 0, 0, -1]), np.array([1, 1, 0, 0]), np.array([0, 1, 0, 1])) - assert ( - np.array( - [ - [[0, 0], [1, 10], [2, 20]], - [[3, 30], [4, 40], [5, 50]], - [[6, 60], [7, 70], [8, 80]], - ] - )[s].tolist() - == ak.to_list(array1_deep[s]) - ) + assert np.array( + [ + [[0, 0], [1, 10], [2, 20]], + [[3, 30], [4, 40], [5, 50]], + [[6, 60], [7, 70], [8, 80]], + ] + )[s].tolist() == ak.to_list(array1_deep[s]) s = (np.array([2, 0, 0, -1]), np.array([1, 1, 0, 0]), slice(1, None)) - assert ( - np.array( - [ - [[0, 0], [1, 10], [2, 20]], - [[3, 30], [4, 40], [5, 50]], - [[6, 60], [7, 70], [8, 80]], - ] - )[s].tolist() - == ak.to_list(array1_deep[s]) - ) + assert np.array( + [ + [[0, 0], [1, 10], [2, 20]], + [[3, 30], [4, 40], [5, 50]], + [[6, 60], [7, 70], [8, 80]], + ] + )[s].tolist() == ak.to_list(array1_deep[s]) diff --git a/tests/test_0025-record-array.py b/tests/test_0025-record-array.py index aad7e67d9b..4f3dd89a05 100644 --- a/tests/test_0025-record-array.py +++ b/tests/test_0025-record-array.py @@ -147,17 +147,14 @@ def test_type(): == "(int32, float64)" ) - assert ( - str( - ak.types.RecordType( - { - "one": ak.types.PrimitiveType("int32"), - "two": ak.types.PrimitiveType("float64"), - } - ) + assert str( + ak.types.RecordType( + { + "one": ak.types.PrimitiveType("int32"), + "two": ak.types.PrimitiveType("float64"), + } ) - in ('{"one": int32, "two": float64}', '{"two": float64, "one": int32}') - ) + ) in ('{"one": int32, "two": float64}', '{"two": float64, "one": int32}') assert ak.type(recordarray) == ak.types.RecordType( { diff --git a/tests/test_0056-partitioned-array.py b/tests/test_0056-partitioned-array.py index d62dcb6a70..744c8886bc 100644 --- a/tests/test_0056-partitioned-array.py +++ b/tests/test_0056-partitioned-array.py @@ -368,42 +368,30 @@ def test_getitem_first_dimension_int(): two = ak.from_iter([[6.6], [], [], [], [7.7, 8.8, 9.9]], highlevel=False) array = ak.partition.IrregularlyPartitionedArray([one, two]) - assert ( - ak.to_list( - array[ - 0, - ] - ) - == [1.1, 2.2, 3.3] - ) - assert ( - ak.to_list( - array[ - -8, - ] - ) - == [1.1, 2.2, 3.3] - ) + assert ak.to_list( + array[ + 0, + ] + ) == [1.1, 2.2, 3.3] + assert ak.to_list( + array[ + -8, + ] + ) == [1.1, 2.2, 3.3] assert array[0, 1] == 2.2 assert array[-8, 1] == 2.2 assert ak.to_list(array[0, [-1, 0]]) == [3.3, 1.1] assert ak.to_list(array[0, [False, True, True]]) == [2.2, 3.3] - assert ( - ak.to_list( - array[ - 7, - ] - ) - == [7.7, 8.8, 9.9] - ) - assert ( - ak.to_list( - array[ - -1, - ] - ) - == [7.7, 8.8, 9.9] - ) + assert ak.to_list( + array[ + 7, + ] + ) == [7.7, 8.8, 9.9] + assert ak.to_list( + array[ + -1, + ] + ) == [7.7, 8.8, 9.9] assert array[7, 1] == 8.8 assert array[-1, 1] == 8.8 assert ak.to_list(array[7, [-1, 0]]) == [9.9, 7.7] diff --git a/tests/test_0111-jagged-and-masked-getitem.py b/tests/test_0111-jagged-and-masked-getitem.py index eb2fbe2d1d..c8dc9253ba 100644 --- a/tests/test_0111-jagged-and-masked-getitem.py +++ b/tests/test_0111-jagged-and-masked-getitem.py @@ -92,15 +92,12 @@ def test_array_slice(): np.array([[0.0, 1.1, 2.2, 3.3, 4.4], [5.5, 6.6, 7.7, 8.8, 9.9]]), check_valid=True, ) - assert ( - ak.to_list( - array[ - ak.layout.NumpyArray(np.array([[0, 1], [1, 0]])), - ak.layout.NumpyArray(np.array([[2, 4], [3, 3]])), - ] - ) - == [[2.2, 9.9], [8.8, 3.3]] - ) + assert ak.to_list( + array[ + ak.layout.NumpyArray(np.array([[0, 1], [1, 0]])), + ak.layout.NumpyArray(np.array([[2, 4], [3, 3]])), + ] + ) == [[2.2, 9.9], [8.8, 3.3]] assert ak.to_list(array[ak.layout.NumpyArray(np.array([[0, 1], [1, 0]]))]) == [ [[0.0, 1.1, 2.2, 3.3, 4.4], [5.5, 6.6, 7.7, 8.8, 9.9]], [[5.5, 6.6, 7.7, 8.8, 9.9], [0.0, 1.1, 2.2, 3.3, 4.4]], @@ -227,17 +224,12 @@ def test_missing(): [6.6, 5.5, 5.5, None, 7.7], [10.0, 9.9, 9.9, None, 11.1], ] - assert ( - ak.to_list( - regulararray[ - 1:, - np.ma.MaskedArray( - [2, 1, 1, 999, -1], [False, False, False, True, False] - ), - ] - ) - == [[6.6, 5.5, 5.5, None, 7.7], [10.0, 9.9, 9.9, None, 11.1]] - ) + assert ak.to_list( + regulararray[ + 1:, + np.ma.MaskedArray([2, 1, 1, 999, -1], [False, False, False, True, False]), + ] + ) == [[6.6, 5.5, 5.5, None, 7.7], [10.0, 9.9, 9.9, None, 11.1]] content = ak.layout.NumpyArray( np.array([[0.0, 1.1, 2.2, 3.3], [4.4, 5.5, 6.6, 7.7], [8.8, 9.9, 10.0, 11.1]]) @@ -279,17 +271,12 @@ def test_missing(): [6.6, 5.5, 5.5, None, 7.7], [10.0, 9.9, 9.9, None, 11.1], ] - assert ( - ak.to_list( - content[ - 1:, - np.ma.MaskedArray( - [2, 1, 1, 999, -1], [False, False, False, True, False] - ), - ] - ) - == [[6.6, 5.5, 5.5, None, 7.7], [10.0, 9.9, 9.9, None, 11.1]] - ) + assert ak.to_list( + content[ + 1:, + np.ma.MaskedArray([2, 1, 1, 999, -1], [False, False, False, True, False]), + ] + ) == [[6.6, 5.5, 5.5, None, 7.7], [10.0, 9.9, 9.9, None, 11.1]] content = ak.layout.NumpyArray( np.array([0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, 10.0, 11.1, 999]) @@ -321,17 +308,12 @@ def test_missing(): [6.6, 5.5, 5.5, None, 7.7], [10.0, 9.9, 9.9, None, 11.1], ] - assert ( - ak.to_list( - listoffsetarray[ - 1:, - np.ma.MaskedArray( - [2, 1, 1, 999, -1], [False, False, False, True, False] - ), - ] - ) - == [[6.6, 5.5, 5.5, None, 7.7], [10.0, 9.9, 9.9, None, 11.1]] - ) + assert ak.to_list( + listoffsetarray[ + 1:, + np.ma.MaskedArray([2, 1, 1, 999, -1], [False, False, False, True, False]), + ] + ) == [[6.6, 5.5, 5.5, None, 7.7], [10.0, 9.9, 9.9, None, 11.1]] def test_bool_missing(): @@ -551,29 +533,23 @@ def test_regular_regular(): regulararray1 = ak.layout.RegularArray(content, 5, zeros_length=0) regulararray2 = ak.layout.RegularArray(regulararray1, 3, zeros_length=0) - assert ( - ak.to_list( - regulararray2[ - ak.Array( - [[[2], [1, -2], [-1, 2, 0]], [[-3], [-4, 3], [-5, -3, 4]]], - check_valid=True, - ) - ] - ) - == [[[2], [6, 8], [14, 12, 10]], [[17], [21, 23], [25, 27, 29]]] - ) + assert ak.to_list( + regulararray2[ + ak.Array( + [[[2], [1, -2], [-1, 2, 0]], [[-3], [-4, 3], [-5, -3, 4]]], + check_valid=True, + ) + ] + ) == [[[2], [6, 8], [14, 12, 10]], [[17], [21, 23], [25, 27, 29]]] - assert ( - ak.to_list( - regulararray2[ - ak.Array( - [[[2], [1, -2], [-1, None, 0]], [[-3], [-4, 3], [-5, None, 4]]], - check_valid=True, - ) - ] - ) - == [[[2], [6, 8], [14, None, 10]], [[17], [21, 23], [25, None, 29]]] - ) + assert ak.to_list( + regulararray2[ + ak.Array( + [[[2], [1, -2], [-1, None, 0]], [[-3], [-4, 3], [-5, None, 4]]], + check_valid=True, + ) + ] + ) == [[[2], [6, 8], [14, None, 10]], [[17], [21, 23], [25, None, 29]]] def test_masked_of_jagged_of_whatever(): @@ -589,17 +565,14 @@ def test_masked_of_jagged_of_whatever(): ] ) == [[[2], None, [14, 12, 10]], [[17], None, [25, 27, 29]]] - assert ( - ak.to_list( - regulararray2[ - ak.Array( - [[[2], None, [-1, None, 0]], [[-3], None, [-5, None, 4]]], - check_valid=True, - ) - ] - ) - == [[[2], None, [14, None, 10]], [[17], None, [25, None, 29]]] - ) + assert ak.to_list( + regulararray2[ + ak.Array( + [[[2], None, [-1, None, 0]], [[-3], None, [-5, None, 4]]], + check_valid=True, + ) + ] + ) == [[[2], None, [14, None, 10]], [[17], None, [25, None, 29]]] def test_emptyarray(): diff --git a/tests/test_0118-numba-cpointers.py b/tests/test_0118-numba-cpointers.py index d4a4b1a9c0..38b0383af1 100644 --- a/tests/test_0118-numba-cpointers.py +++ b/tests/test_0118-numba-cpointers.py @@ -38,21 +38,18 @@ def test_views(): ).toarray() ) == [1.1, 2.2, None, 3.3, None, 4.4, 5.5] - assert ( - ak.to_list( - ak_numba_arrayview.ArrayView.fromarray( - ak.Array( - [ - {"x": 0.0, "y": []}, - {"x": 1.1, "y": [1, 1]}, - {"x": 2.2, "y": [2, 2, 2]}, - ], - check_valid=True, - ) - ).toarray() - ) - == [{"x": 0.0, "y": []}, {"x": 1.1, "y": [1, 1]}, {"x": 2.2, "y": [2, 2, 2]}] - ) + assert ak.to_list( + ak_numba_arrayview.ArrayView.fromarray( + ak.Array( + [ + {"x": 0.0, "y": []}, + {"x": 1.1, "y": [1, 1]}, + {"x": 2.2, "y": [2, 2, 2]}, + ], + check_valid=True, + ) + ).toarray() + ) == [{"x": 0.0, "y": []}, {"x": 1.1, "y": [1, 1]}, {"x": 2.2, "y": [2, 2, 2]}] assert ak.to_list( ak_numba_arrayview.ArrayView.fromarray( diff --git a/tests/test_0120-autograd-support.py b/tests/test_0120-autograd-support.py index b07544265a..9e86669b58 100644 --- a/tests/test_0120-autograd-support.py +++ b/tests/test_0120-autograd-support.py @@ -64,7 +64,7 @@ def test_flat(): def parabola(x): - return 3 * x ** 2 + return 3 * x**2 def test_jagged(): diff --git a/tests/test_0138-emptyarray-type.py b/tests/test_0138-emptyarray-type.py index 978f3a0678..fa5cce9703 100644 --- a/tests/test_0138-emptyarray-type.py +++ b/tests/test_0138-emptyarray-type.py @@ -29,11 +29,8 @@ def test(): == [] ) assert ak.to_list(array[empty2]) == [[], [], []] - assert ( - ak.to_list( - array[ - empty2, - ] - ) - == [[], [], []] - ) + assert ak.to_list( + array[ + empty2, + ] + ) == [[], [], []] diff --git a/tests/test_0198-tutorial-documentation-1.py b/tests/test_0198-tutorial-documentation-1.py index 7e1212addb..d9c50cecad 100644 --- a/tests/test_0198-tutorial-documentation-1.py +++ b/tests/test_0198-tutorial-documentation-1.py @@ -38,30 +38,22 @@ def test_firsts(): ak.singletons(ak.Array([1.1, 2.2, None, 3.3, None, None, 4.4, 5.5])), axis=1 ) ) == [1.1, 2.2, None, 3.3, None, None, 4.4, 5.5] - assert ( - ak.to_list( - ak.firsts( - ak.singletons( - ak.Array([[1.1, 2.2, None], [3.3, None], [None], [4.4, 5.5]]) - ), - axis=2, - ) + assert ak.to_list( + ak.firsts( + ak.singletons( + ak.Array([[1.1, 2.2, None], [3.3, None], [None], [4.4, 5.5]]) + ), + axis=2, ) - == [[1.1, 2.2, None], [3.3, None], [None], [4.4, 5.5]] - ) - assert ( - ak.to_list( - ak.firsts( - ak.singletons( - ak.Array( - [[[1.1, 2.2, None]], [[3.3, None]], [[None]], [[4.4, 5.5]]] - ) - ), - axis=3, - ) + ) == [[1.1, 2.2, None], [3.3, None], [None], [4.4, 5.5]] + assert ak.to_list( + ak.firsts( + ak.singletons( + ak.Array([[[1.1, 2.2, None]], [[3.3, None]], [[None]], [[4.4, 5.5]]]) + ), + axis=3, ) - == [[[1.1, 2.2, None]], [[3.3, None]], [[None]], [[4.4, 5.5]]] - ) + ) == [[[1.1, 2.2, None]], [[3.3, None]], [[None]], [[4.4, 5.5]]] def test_allow_missing(): diff --git a/tests/test_0348-form-keys.py b/tests/test_0348-form-keys.py index 5ffc88146f..04a3d32520 100644 --- a/tests/test_0348-form-keys.py +++ b/tests/test_0348-form-keys.py @@ -186,21 +186,18 @@ def test_record(): assert pickle.loads( pickle.dumps(ak.Record({"x": 2.2, "y": [1, 2]}), -1) ).tolist() == {"x": 2.2, "y": [1, 2]} - assert ( - pickle.loads( - pickle.dumps( - ak.Array( - [ - {"x": 1.1, "y": [1]}, - {"x": 2.2, "y": [1, 2]}, - {"x": 3.3, "y": [1, 2, 3]}, - ] - )[1], - -1, - ) - ).tolist() - == {"x": 2.2, "y": [1, 2]} - ) + assert pickle.loads( + pickle.dumps( + ak.Array( + [ + {"x": 1.1, "y": [1]}, + {"x": 2.2, "y": [1, 2]}, + {"x": 3.3, "y": [1, 2, 3]}, + ] + )[1], + -1, + ) + ).tolist() == {"x": 2.2, "y": [1, 2]} def test_regulararray(): diff --git a/tests/test_0355-mixins.py b/tests/test_0355-mixins.py index b145e9a5b7..e44fc19290 100644 --- a/tests/test_0355-mixins.py +++ b/tests/test_0355-mixins.py @@ -18,7 +18,7 @@ def point_equal(self, other): @ak.mixin_class_method(np.abs) def point_abs(self): - return np.sqrt(self.x ** 2 + self.y ** 2) + return np.sqrt(self.x**2 + self.y**2) @ak.mixin_class_method(np.add, {"Point"}) def point_add(self, other): diff --git a/tests/test_0393-fix-bitmaskedarray-mask.py b/tests/test_0393-fix-bitmaskedarray-mask.py index a934e8c0d7..20fa188d3a 100644 --- a/tests/test_0393-fix-bitmaskedarray-mask.py +++ b/tests/test_0393-fix-bitmaskedarray-mask.py @@ -7,50 +7,38 @@ def test(): - assert ( - np.asarray( - ak.layout.ByteMaskedArray( - ak.layout.Index8(np.array([1, 1, 1, 1, 1], np.int8)), - ak.layout.NumpyArray(np.array([0, 1, 2, 3, 4])), - valid_when=True, - ).bytemask() - ).tolist() - == [0, 0, 0, 0, 0] - ) + assert np.asarray( + ak.layout.ByteMaskedArray( + ak.layout.Index8(np.array([1, 1, 1, 1, 1], np.int8)), + ak.layout.NumpyArray(np.array([0, 1, 2, 3, 4])), + valid_when=True, + ).bytemask() + ).tolist() == [0, 0, 0, 0, 0] - assert ( - np.asarray( - ak.layout.ByteMaskedArray( - ak.layout.Index8(np.array([1, 1, 1, 1, 1], np.int8)), - ak.layout.NumpyArray(np.array([0, 1, 2, 3, 4])), - valid_when=False, - ).bytemask() - ).tolist() - == [1, 1, 1, 1, 1] - ) + assert np.asarray( + ak.layout.ByteMaskedArray( + ak.layout.Index8(np.array([1, 1, 1, 1, 1], np.int8)), + ak.layout.NumpyArray(np.array([0, 1, 2, 3, 4])), + valid_when=False, + ).bytemask() + ).tolist() == [1, 1, 1, 1, 1] - assert ( - np.asarray( - ak.layout.BitMaskedArray( - ak.layout.IndexU8(np.array([31], np.uint8)), - ak.layout.NumpyArray(np.array([0, 1, 2, 3, 4])), - valid_when=True, - length=5, - lsb_order=True, - ).bytemask() - ).tolist() - == [0, 0, 0, 0, 0] - ) + assert np.asarray( + ak.layout.BitMaskedArray( + ak.layout.IndexU8(np.array([31], np.uint8)), + ak.layout.NumpyArray(np.array([0, 1, 2, 3, 4])), + valid_when=True, + length=5, + lsb_order=True, + ).bytemask() + ).tolist() == [0, 0, 0, 0, 0] - assert ( - np.asarray( - ak.layout.BitMaskedArray( - ak.layout.IndexU8(np.array([31], np.uint8)), - ak.layout.NumpyArray(np.array([0, 1, 2, 3, 4])), - valid_when=False, - length=5, - lsb_order=True, - ).bytemask() - ).tolist() - == [1, 1, 1, 1, 1] - ) + assert np.asarray( + ak.layout.BitMaskedArray( + ak.layout.IndexU8(np.array([31], np.uint8)), + ak.layout.NumpyArray(np.array([0, 1, 2, 3, 4])), + valid_when=False, + length=5, + lsb_order=True, + ).bytemask() + ).tolist() == [1, 1, 1, 1, 1] diff --git a/tests/test_0494-numba-array-contains.py b/tests/test_0494-numba-array-contains.py index eeb1867911..260ef8d09e 100644 --- a/tests/test_0494-numba-array-contains.py +++ b/tests/test_0494-numba-array-contains.py @@ -65,36 +65,30 @@ def f3(array): True, False, ) - assert ( - f1( - ak.Array( - [ - [], - [{"x": 0, "y": 999}], - [{"x": 1, "y": 999}, {"x": 2, "y": 999}, {"x": 3, "y": 999}], - ] - ) + assert f1( + ak.Array( + [ + [], + [{"x": 0, "y": 999}], + [{"x": 1, "y": 999}, {"x": 2, "y": 999}, {"x": 3, "y": 999}], + ] ) - == (True, True, False) - ) + ) == (True, True, False) assert f2(ak.Array([[], [{"x": 0}], [{"x": 1}, {"x": 2}, {"x": 3}]])) == ( False, False, True, True, ) - assert ( - f2( - ak.Array( - [ - [], - [{"x": 0, "y": 999}], - [{"x": 1, "y": 999}, {"x": 2, "y": 999}, {"x": 3, "y": 999}], - ] - ) + assert f2( + ak.Array( + [ + [], + [{"x": 0, "y": 999}], + [{"x": 1, "y": 999}, {"x": 2, "y": 999}, {"x": 3, "y": 999}], + ] ) - == (False, False, True, True) - ) + ) == (False, False, True, True) assert f1(ak.Array([[], [{"x": [0]}], [{"x": []}, {"x": [2]}, {"x": [3]}]])) == ( True, diff --git a/tests/test_0501-string-comparison-bug.py b/tests/test_0501-string-comparison-bug.py index aeda37e5b6..7ce42331e6 100644 --- a/tests/test_0501-string-comparison-bug.py +++ b/tests/test_0501-string-comparison-bug.py @@ -36,26 +36,23 @@ def test(): False, ] assert ak.to_list(one == np.array(["UNO", "dos", "tres"])) == [False, True, True] - assert ( - ak.to_list( - merged - == np.array( - [ - "UNO", - "dos", - "tres", - "one", - "two", - "three", - "quatre", - "onay", - "two", - "three", - ] - ) + assert ak.to_list( + merged + == np.array( + [ + "UNO", + "dos", + "tres", + "one", + "two", + "three", + "quatre", + "onay", + "two", + "three", + ] ) - == [False, True, True, False, False, False, True, True, False, False] - ) + ) == [False, True, True, False, False, False, True, True, False, False] def test_fromnumpy(): diff --git a/tests/test_0628-accept-numpy-integers-in-slices.py b/tests/test_0628-accept-numpy-integers-in-slices.py index 4a2feb9411..ca67bfac01 100644 --- a/tests/test_0628-accept-numpy-integers-in-slices.py +++ b/tests/test_0628-accept-numpy-integers-in-slices.py @@ -9,32 +9,23 @@ def test(): array = ak.Array([[1, 2, 3], [], [4, 5]]) assert array[2].tolist() == [4, 5] - assert ( - array[ - 2, - ].tolist() - == [4, 5] - ) + assert array[ + 2, + ].tolist() == [4, 5] assert array[2, 1] == 5 assert array[np.int64(2)].tolist() == [4, 5] - assert ( - array[ - np.int64(2), - ].tolist() - == [4, 5] - ) + assert array[ + np.int64(2), + ].tolist() == [4, 5] assert array[np.int64(2), 1] == 5 assert array[2, np.int64(1)] == 5 assert array[np.int64(2), np.int64(1)] == 5 assert array[np.int64([2]).reshape(())].tolist() == [4, 5] - assert ( - array[ - np.int64([2]).reshape(()), - ].tolist() - == [4, 5] - ) + assert array[ + np.int64([2]).reshape(()), + ].tolist() == [4, 5] assert array[np.int64([2]).reshape(()), 1] == 5 assert array[2, np.int64([1]).reshape(())] == 5 assert array[np.int64([2]).reshape(()), np.int64([1]).reshape(())] == 5 diff --git a/tests/test_0793-jax-element-wise-ops.py b/tests/test_0793-jax-element-wise-ops.py index 8b4d2e8082..8f1bf8ed71 100644 --- a/tests/test_0793-jax-element-wise-ops.py +++ b/tests/test_0793-jax-element-wise-ops.py @@ -348,7 +348,7 @@ def func_recordarray_5(x): def test_recordarray_6(): def func_recordarray_6(x): - return 2 * x.y ** 2 + return 2 * x.y**2 value_jvp, jvp_grad = jax.jvp( func_recordarray_6, (test_recordarray,), (test_recordarray_tangent,) diff --git a/tests/test_1030-mixin-class-name.py b/tests/test_1030-mixin-class-name.py index 69ca9d600d..d457b55e3e 100644 --- a/tests/test_1030-mixin-class-name.py +++ b/tests/test_1030-mixin-class-name.py @@ -13,7 +13,7 @@ class AVeryVeryVeryLargeClassName: @property def mag2(self): - return self.x ** 2 + self.y ** 2 + return self.x**2 + self.y**2 def test(): diff --git a/tests/v2/test_0011-listarray.py b/tests/v2/test_0011-listarray.py index 6fb139bc5d..911dc3fc8e 100644 --- a/tests/v2/test_0011-listarray.py +++ b/tests/v2/test_0011-listarray.py @@ -77,14 +77,11 @@ def test_listarray_at(): assert to_list(array1[2]) == [4.4, 5.5] assert array1.typetracer[2].form == array1[2].form - assert ( - to_list( - array1[ - 2, - ] - ) - == [4.4, 5.5] - ) + assert to_list( + array1[ + 2, + ] + ) == [4.4, 5.5] assert to_list(array1[2, 1:]) == [5.5] assert array1.typetracer[2, 1:].form == array1[2, 1:].form assert to_list(array1[2:, 0]) == [4.4, 6.6, 7.7] @@ -96,14 +93,11 @@ def test_listarray_at(): def test_listoffsetarray_at(): array1 = ak._v2.contents.ListOffsetArray(offsets1, content) - assert ( - to_list( - array1[ - 2, - ] - ) - == [4.4, 5.5] - ) + assert to_list( + array1[ + 2, + ] + ) == [4.4, 5.5] assert to_list(array1[2, 1:]) == [5.5] assert array1.typetracer[2, 1:].form == array1[2, 1:].form assert to_list(array1[2:, 0]) == [4.4, 6.6, 7.7] @@ -118,14 +112,11 @@ def test_listarray_slice(): assert to_list(array1[1:-1]) == [[], [4.4, 5.5], [6.6]] assert array1.typetracer[1:-1].form == array1[1:-1].form - assert ( - to_list( - array1[ - 1:-1, - ] - ) - == [[], [4.4, 5.5], [6.6]] - ) + assert to_list( + array1[ + 1:-1, + ] + ) == [[], [4.4, 5.5], [6.6]] assert ( array1.typetracer[ 1:-1, @@ -136,14 +127,11 @@ def test_listarray_slice(): ) assert to_list(array2[1:-1]) == [[[4.4, 5.5]], []] assert array2.typetracer[1:-1].form == array2[1:-1].form - assert ( - to_list( - array2[ - 1:-1, - ] - ) - == [[[4.4, 5.5]], []] - ) + assert to_list( + array2[ + 1:-1, + ] + ) == [[[4.4, 5.5]], []] assert ( array2.typetracer[ 1:-1, @@ -160,14 +148,11 @@ def test_listoffsetarray_slice(): assert to_list(array1[1:-1]) == [[], [4.4, 5.5], [6.6]] assert array1.typetracer[1:-1].form == array1[1:-1].form - assert ( - to_list( - array1[ - 1:-1, - ] - ) - == [[], [4.4, 5.5], [6.6]] - ) + assert to_list( + array1[ + 1:-1, + ] + ) == [[], [4.4, 5.5], [6.6]] assert ( array1.typetracer[ 1:-1, @@ -178,14 +163,11 @@ def test_listoffsetarray_slice(): ) assert to_list(array2[1:-1]) == [[[4.4, 5.5]], []] assert array2.typetracer[1:-1].form == array2[1:-1].form - assert ( - to_list( - array2[ - 1:-1, - ] - ) - == [[[4.4, 5.5]], []] - ) + assert to_list( + array2[ + 1:-1, + ] + ) == [[[4.4, 5.5]], []] assert ( array2.typetracer[ 1:-1, @@ -378,28 +360,22 @@ def test_listarray_array(): [[6, 60], [7, 70], [8, 80]], ] s = (np.array([2, 0, 0, -1]), np.array([1, 1, 0, 0]), np.array([0, 1, 0, 1])) - assert ( - np.array( - [ - [[0, 0], [1, 10], [2, 20]], - [[3, 30], [4, 40], [5, 50]], - [[6, 60], [7, 70], [8, 80]], - ] - )[s].tolist() - == to_list(array1_deep[s]) - ) + assert np.array( + [ + [[0, 0], [1, 10], [2, 20]], + [[3, 30], [4, 40], [5, 50]], + [[6, 60], [7, 70], [8, 80]], + ] + )[s].tolist() == to_list(array1_deep[s]) s = (np.array([2, 0, 0, -1]), np.array([1, 1, 0, 0]), slice(1, None)) - assert ( - np.array( - [ - [[0, 0], [1, 10], [2, 20]], - [[3, 30], [4, 40], [5, 50]], - [[6, 60], [7, 70], [8, 80]], - ] - )[s].tolist() - == to_list(array1_deep[s]) - ) + assert np.array( + [ + [[0, 0], [1, 10], [2, 20]], + [[3, 30], [4, 40], [5, 50]], + [[6, 60], [7, 70], [8, 80]], + ] + )[s].tolist() == to_list(array1_deep[s]) def test_listoffsetarray_array(): @@ -442,28 +418,22 @@ def test_listoffsetarray_array(): [[6, 60], [7, 70], [8, 80]], ] s = (np.array([2, 0, 0, -1]), np.array([1, 1, 0, 0]), np.array([0, 1, 0, 1])) - assert ( - np.array( - [ - [[0, 0], [1, 10], [2, 20]], - [[3, 30], [4, 40], [5, 50]], - [[6, 60], [7, 70], [8, 80]], - ] - )[s].tolist() - == to_list(array1_deep[s]) - ) + assert np.array( + [ + [[0, 0], [1, 10], [2, 20]], + [[3, 30], [4, 40], [5, 50]], + [[6, 60], [7, 70], [8, 80]], + ] + )[s].tolist() == to_list(array1_deep[s]) s = (np.array([2, 0, 0, -1]), np.array([1, 1, 0, 0]), slice(1, None)) - assert ( - np.array( - [ - [[0, 0], [1, 10], [2, 20]], - [[3, 30], [4, 40], [5, 50]], - [[6, 60], [7, 70], [8, 80]], - ] - )[s].tolist() - == to_list(array1_deep[s]) - ) + assert np.array( + [ + [[0, 0], [1, 10], [2, 20]], + [[3, 30], [4, 40], [5, 50]], + [[6, 60], [7, 70], [8, 80]], + ] + )[s].tolist() == to_list(array1_deep[s]) def test_listarray_listoffsetarray_array(): diff --git a/tests/v2/test_0020-support-unsigned-indexes.py b/tests/v2/test_0020-support-unsigned-indexes.py index 4da9a2570d..54f2c7d66d 100644 --- a/tests/v2/test_0020-support-unsigned-indexes.py +++ b/tests/v2/test_0020-support-unsigned-indexes.py @@ -77,14 +77,11 @@ def test_listarray_at(): assert to_list(array1[2]) == [4.4, 5.5] assert array1.typetracer[2].form == array1[2].form - assert ( - to_list( - array1[ - 2, - ] - ) - == [4.4, 5.5] - ) + assert to_list( + array1[ + 2, + ] + ) == [4.4, 5.5] assert ( array1.typetracer[ 2, @@ -103,14 +100,11 @@ def test_listarray_at(): def test_listoffsetarray_at(): array1 = ak._v2.contents.ListOffsetArray(offsets1, content) - assert ( - to_list( - array1[ - 2, - ] - ) - == [4.4, 5.5] - ) + assert to_list( + array1[ + 2, + ] + ) == [4.4, 5.5] assert ( array1.typetracer[ 2, @@ -133,14 +127,11 @@ def test_listarray_slice(): assert to_list(array1[1:-1]) == [[], [4.4, 5.5], [6.6]] assert array1.typetracer[1:-1].form == array1[1:-1].form - assert ( - to_list( - array1[ - 1:-1, - ] - ) - == [[], [4.4, 5.5], [6.6]] - ) + assert to_list( + array1[ + 1:-1, + ] + ) == [[], [4.4, 5.5], [6.6]] assert ( array1.typetracer[ 1:-1, @@ -151,14 +142,11 @@ def test_listarray_slice(): ) assert to_list(array2[1:-1]) == [[[4.4, 5.5]], []] assert array2.typetracer[1:-1].form == array2[1:-1].form - assert ( - to_list( - array2[ - 1:-1, - ] - ) - == [[[4.4, 5.5]], []] - ) + assert to_list( + array2[ + 1:-1, + ] + ) == [[[4.4, 5.5]], []] assert ( array2.typetracer[ 1:-1, @@ -175,14 +163,11 @@ def test_listoffsetarray_slice(): assert to_list(array1[1:-1]) == [[], [4.4, 5.5], [6.6]] assert array1.typetracer[1:-1].form == array1[1:-1].form - assert ( - to_list( - array1[ - 1:-1, - ] - ) - == [[], [4.4, 5.5], [6.6]] - ) + assert to_list( + array1[ + 1:-1, + ] + ) == [[], [4.4, 5.5], [6.6]] assert ( array1.typetracer[ 1:-1, @@ -193,14 +178,11 @@ def test_listoffsetarray_slice(): ) assert to_list(array2[1:-1]) == [[[4.4, 5.5]], []] assert array2.typetracer[1:-1].form == array2[1:-1].form - assert ( - to_list( - array2[ - 1:-1, - ] - ) - == [[[4.4, 5.5]], []] - ) + assert to_list( + array2[ + 1:-1, + ] + ) == [[[4.4, 5.5]], []] assert ( array2.typetracer[ 1:-1, @@ -403,29 +385,23 @@ def test_listarray_array(): [[6, 60], [7, 70], [8, 80]], ] s = (np.array([2, 0, 0, -1]), np.array([1, 1, 0, 0]), np.array([0, 1, 0, 1])) - assert ( - np.array( - [ - [[0, 0], [1, 10], [2, 20]], - [[3, 30], [4, 40], [5, 50]], - [[6, 60], [7, 70], [8, 80]], - ] - )[s].tolist() - == to_list(array1_deep[s]) - ) + assert np.array( + [ + [[0, 0], [1, 10], [2, 20]], + [[3, 30], [4, 40], [5, 50]], + [[6, 60], [7, 70], [8, 80]], + ] + )[s].tolist() == to_list(array1_deep[s]) assert array1_deep.typetracer[s].form == array1_deep[s].form s = (np.array([2, 0, 0, -1]), np.array([1, 1, 0, 0]), slice(1, None)) - assert ( - np.array( - [ - [[0, 0], [1, 10], [2, 20]], - [[3, 30], [4, 40], [5, 50]], - [[6, 60], [7, 70], [8, 80]], - ] - )[s].tolist() - == to_list(array1_deep[s]) - ) + assert np.array( + [ + [[0, 0], [1, 10], [2, 20]], + [[3, 30], [4, 40], [5, 50]], + [[6, 60], [7, 70], [8, 80]], + ] + )[s].tolist() == to_list(array1_deep[s]) assert array1_deep.typetracer[s].form == array1_deep[s].form @@ -479,27 +455,21 @@ def test_listoffsetarray_array(): [[6, 60], [7, 70], [8, 80]], ] s = (np.array([2, 0, 0, -1]), np.array([1, 1, 0, 0]), np.array([0, 1, 0, 1])) - assert ( - np.array( - [ - [[0, 0], [1, 10], [2, 20]], - [[3, 30], [4, 40], [5, 50]], - [[6, 60], [7, 70], [8, 80]], - ] - )[s].tolist() - == to_list(array1_deep[s]) - ) + assert np.array( + [ + [[0, 0], [1, 10], [2, 20]], + [[3, 30], [4, 40], [5, 50]], + [[6, 60], [7, 70], [8, 80]], + ] + )[s].tolist() == to_list(array1_deep[s]) assert array1_deep.typetracer[s].form == array1_deep[s].form s = (np.array([2, 0, 0, -1]), np.array([1, 1, 0, 0]), slice(1, None)) - assert ( - np.array( - [ - [[0, 0], [1, 10], [2, 20]], - [[3, 30], [4, 40], [5, 50]], - [[6, 60], [7, 70], [8, 80]], - ] - )[s].tolist() - == to_list(array1_deep[s]) - ) + assert np.array( + [ + [[0, 0], [1, 10], [2, 20]], + [[3, 30], [4, 40], [5, 50]], + [[6, 60], [7, 70], [8, 80]], + ] + )[s].tolist() == to_list(array1_deep[s]) assert array1_deep.typetracer[s].form == array1_deep[s].form diff --git a/tests/v2/test_0025-record-array.py b/tests/v2/test_0025-record-array.py index eb432d4c21..49cc3a3469 100644 --- a/tests/v2/test_0025-record-array.py +++ b/tests/v2/test_0025-record-array.py @@ -283,17 +283,14 @@ def test_recordtype(): ak._v2.types.ListType(ak._v2.types.NumpyType("float64")), ) ) - assert ( - str( - ak._v2.types.RecordType( - { - "one": ak._v2.types.NumpyType("int32"), - "two": ak._v2.types.NumpyType("float64"), - } - ) + assert str( + ak._v2.types.RecordType( + { + "one": ak._v2.types.NumpyType("int32"), + "two": ak._v2.types.NumpyType("float64"), + } ) - in ('{"one": int32, "two": float64}', '{"two": float64, "one": int32}') - ) + ) in ('{"one": int32, "two": float64}', '{"two": float64, "one": int32}') assert ak._v2.operations.describe.type(recordarray) == ak._v2.types.RecordType( { diff --git a/tests/v2/test_0111-jagged-and-masked-getitem.py b/tests/v2/test_0111-jagged-and-masked-getitem.py index 600ef62fe0..a18db5f320 100644 --- a/tests/v2/test_0111-jagged-and-masked-getitem.py +++ b/tests/v2/test_0111-jagged-and-masked-getitem.py @@ -146,15 +146,12 @@ def test_array_slice(): numpyarray1 = ak._v2.contents.NumpyArray(np.array([[0, 1], [1, 0]])) numpyarray2 = ak._v2.contents.NumpyArray(np.array([[2, 4], [3, 3]])) - assert ( - to_list( - array[ - numpyarray1, - numpyarray2, - ] - ) - == [[2.2, 9.9], [8.8, 3.3]] - ) + assert to_list( + array[ + numpyarray1, + numpyarray2, + ] + ) == [[2.2, 9.9], [8.8, 3.3]] assert ( array.typetracer[ numpyarray1, @@ -342,17 +339,12 @@ def test_missing(): ].form ) - assert ( - to_list( - regulararray[ - 1:, - np.ma.MaskedArray( - [2, 1, 1, 999, -1], [False, False, False, True, False] - ), - ] - ) - == [[6.6, 5.5, 5.5, None, 7.7], [10.0, 9.9, 9.9, None, 11.1]] - ) + assert to_list( + regulararray[ + 1:, + np.ma.MaskedArray([2, 1, 1, 999, -1], [False, False, False, True, False]), + ] + ) == [[6.6, 5.5, 5.5, None, 7.7], [10.0, 9.9, 9.9, None, 11.1]] assert ( regulararray.typetracer[ 1:, @@ -426,17 +418,12 @@ def test_missing(): np.ma.MaskedArray([2, 1, 1, 999, -1], [False, False, False, True, False]), ].form ) - assert ( - to_list( - content[ - 1:, - np.ma.MaskedArray( - [2, 1, 1, 999, -1], [False, False, False, True, False] - ), - ] - ) - == [[6.6, 5.5, 5.5, None, 7.7], [10.0, 9.9, 9.9, None, 11.1]] - ) + assert to_list( + content[ + 1:, + np.ma.MaskedArray([2, 1, 1, 999, -1], [False, False, False, True, False]), + ] + ) == [[6.6, 5.5, 5.5, None, 7.7], [10.0, 9.9, 9.9, None, 11.1]] assert ( content.typetracer[ 1:, @@ -493,17 +480,12 @@ def test_missing(): np.ma.MaskedArray([2, 1, 1, 999, -1], [False, False, False, True, False]), ].form ) - assert ( - to_list( - listoffsetarray[ - 1:, - np.ma.MaskedArray( - [2, 1, 1, 999, -1], [False, False, False, True, False] - ), - ] - ) - == [[6.6, 5.5, 5.5, None, 7.7], [10.0, 9.9, 9.9, None, 11.1]] - ) + assert to_list( + listoffsetarray[ + 1:, + np.ma.MaskedArray([2, 1, 1, 999, -1], [False, False, False, True, False]), + ] + ) == [[6.6, 5.5, 5.5, None, 7.7], [10.0, 9.9, 9.9, None, 11.1]] assert ( listoffsetarray.typetracer[ 1:, diff --git a/tests/v2/test_0138-emptyarray-type.py b/tests/v2/test_0138-emptyarray-type.py index ee1b3b2ab5..ef50049a6b 100644 --- a/tests/v2/test_0138-emptyarray-type.py +++ b/tests/v2/test_0138-emptyarray-type.py @@ -31,11 +31,8 @@ def test(): == [] ) assert to_list(array[empty2]) == [[], [], []] - assert ( - to_list( - array[ - empty2, - ] - ) - == [[], [], []] - ) + assert to_list( + array[ + empty2, + ] + ) == [[], [], []] diff --git a/tests/v2/test_0348-form-keys.py b/tests/v2/test_0348-form-keys.py index 59016c0d58..c4c3699285 100644 --- a/tests/v2/test_0348-form-keys.py +++ b/tests/v2/test_0348-form-keys.py @@ -194,21 +194,18 @@ def test_record(): assert pickle.loads( pickle.dumps(ak_Record({"x": 2.2, "y": [1, 2]}), -1) ).tolist() == {"x": 2.2, "y": [1, 2]} - assert ( - pickle.loads( - pickle.dumps( - ak_Array( - [ - {"x": 1.1, "y": [1]}, - {"x": 2.2, "y": [1, 2]}, - {"x": 3.3, "y": [1, 2, 3]}, - ] - )[1], - -1, - ) - ).tolist() - == {"x": 2.2, "y": [1, 2]} - ) + assert pickle.loads( + pickle.dumps( + ak_Array( + [ + {"x": 1.1, "y": [1]}, + {"x": 2.2, "y": [1, 2]}, + {"x": 3.3, "y": [1, 2, 3]}, + ] + )[1], + -1, + ) + ).tolist() == {"x": 2.2, "y": [1, 2]} def test_regulararray(): diff --git a/tests/v2/test_0652-tests-of-complex-numbers.py b/tests/v2/test_0652-tests-of-complex-numbers.py index 6bc896129b..922962fd72 100644 --- a/tests/v2/test_0652-tests-of-complex-numbers.py +++ b/tests/v2/test_0652-tests-of-complex-numbers.py @@ -190,24 +190,14 @@ def test_reducers(): True, True, ] - assert ( - ak._v2.operations.reducers.any( - ak._v2.operations.convert.from_iter( - [[1 + 1j, 2 + 2j, 0 + 0j], [], [3 + 3j]] - ), - axis=1, - ).tolist() - == [True, False, True] - ) - assert ( - ak._v2.operations.reducers.all( - ak._v2.operations.convert.from_iter( - [[1 + 1j, 2 + 2j, 0 + 0j], [], [3 + 3j]] - ), - axis=1, - ).tolist() - == [False, True, True] - ) + assert ak._v2.operations.reducers.any( + ak._v2.operations.convert.from_iter([[1 + 1j, 2 + 2j, 0 + 0j], [], [3 + 3j]]), + axis=1, + ).tolist() == [True, False, True] + assert ak._v2.operations.reducers.all( + ak._v2.operations.convert.from_iter([[1 + 1j, 2 + 2j, 0 + 0j], [], [3 + 3j]]), + axis=1, + ).tolist() == [False, True, True] def test_minmax(): diff --git a/tests/v2/test_1192-iterables-in-__array_function__.py b/tests/v2/test_1192-iterables-in-__array_function__.py index 58878b5c82..62a42857e5 100644 --- a/tests/v2/test_1192-iterables-in-__array_function__.py +++ b/tests/v2/test_1192-iterables-in-__array_function__.py @@ -11,14 +11,11 @@ def test(): first = ak._v2.operations.convert.from_numpy(np.array([1, 2, 3])) deltas = ak._v2.highlevel.Array([[1, 2], [1, 2], [1, 2, 3]]) - assert ( - np.hstack( - ( - first[:, np.newaxis], - ak._v2.operations.structure.fill_none( - ak.operations.structure.pad_none(deltas, 3, axis=-1), 999 - ), - ) - ).tolist() - == [[1, 1, 2, 999], [2, 1, 2, 999], [3, 1, 2, 3]] - ) + assert np.hstack( + ( + first[:, np.newaxis], + ak._v2.operations.structure.fill_none( + ak.operations.structure.pad_none(deltas, 3, axis=-1), 999 + ), + ) + ).tolist() == [[1, 1, 2, 999], [2, 1, 2, 999], [3, 1, 2, 3]]