Skip to content
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

style: update to first non-pre-release black! #1267

Merged
merged 1 commit into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ repos:
args: ["--py36-plus"]

- repo: https://github.com/psf/black
rev: 21.12b0
rev: 22.1.0
hooks:
- id: black

Expand Down
11 changes: 4 additions & 7 deletions src/awkward/_v2/_slicing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions src/awkward/_v2/contents/unionarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/awkward/_v2/operations/reducers/ak_corr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/awkward/_v2/operations/reducers/ak_linear_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/_v2/operations/reducers/ak_moment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
57 changes: 24 additions & 33 deletions src/awkward/_v2/tmp_for_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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 (
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
14 changes: 7 additions & 7 deletions src/awkward/operations/reducers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down
30 changes: 12 additions & 18 deletions tests-cuda/test_0388-abstract-all-uses-of-numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
Loading