Skip to content

Commit

Permalink
style: pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Oct 23, 2023
1 parent a510698 commit acba884
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 34 deletions.
12 changes: 3 additions & 9 deletions dev/generate-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,7 @@ def genspectests(specdict):
if isinstance(val, list):
f.write(
" " * 4
+ "assert {0}[:len(pytest_{0})] == pytest.approx(pytest_{0})\n".format(
arg
)
+ f"assert {arg}[:len(pytest_{arg})] == pytest.approx(pytest_{arg})\n"
)
else:
f.write(" " * 4 + f"assert {arg} == pytest_{arg}\n")
Expand Down Expand Up @@ -516,9 +514,7 @@ def gencpukerneltests(specdict):
if isinstance(val, list):
f.write(
" " * 4
+ "assert {0}[:len(pytest_{0})] == pytest.approx(pytest_{0})\n".format(
arg
)
+ f"assert {arg}[:len(pytest_{arg})] == pytest.approx(pytest_{arg})\n"
)
else:
f.write(" " * 4 + f"assert {arg} == pytest_{arg}\n")
Expand Down Expand Up @@ -735,9 +731,7 @@ def gencudakerneltests(specdict):
if isinstance(val, list):
f.write(
" " * 4
+ "assert cupy.array_equal({0}[:len(pytest_{0})], cupy.array(pytest_{0}))\n".format(
arg
)
+ f"assert cupy.array_equal({arg}[:len(pytest_{arg})], cupy.array(pytest_{arg}))\n"
)
else:
f.write(" " * 4 + f"assert {arg} == pytest_{arg}\n")
Expand Down
6 changes: 2 additions & 4 deletions src/awkward/_connect/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,8 @@ def action(inputs, **ignore):
for x in contents
):
raise TypeError(
"{}.{} is not implemented for string types. "
"To register an implementation, add a name to these string(s) and register a behavior overload".format(
type(ufunc).__module__, ufunc.__name__
)
f"{type(ufunc).__module__}.{ufunc.__name__} is not implemented for string types. "
"To register an implementation, add a name to these string(s) and register a behavior overload"
)

if ufunc is numpy.matmul:
Expand Down
18 changes: 6 additions & 12 deletions src/awkward/_do.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,8 @@ def unique(layout: Content, axis=None):
)
if negaxis > depth:
raise AxisError(
"cannot use axis={} on a nested list structure that splits into "
"different depths, the minimum of which is depth={} from the leaves".format(
axis, depth
)
f"cannot use axis={axis} on a nested list structure that splits into "
f"different depths, the minimum of which is depth={depth} from the leaves"
)
else:
if negaxis <= 0:
Expand Down Expand Up @@ -368,10 +366,8 @@ def argsort(
)
if negaxis > depth:
raise ValueError(
"cannot use axis={} on a nested list structure that splits into "
"different depths, the minimum of which is depth={} from the leaves".format(
axis, depth
)
f"cannot use axis={axis} on a nested list structure that splits into "
f"different depths, the minimum of which is depth={depth} from the leaves"
)
else:
if negaxis <= 0:
Expand Down Expand Up @@ -409,10 +405,8 @@ def sort(
)
if negaxis > depth:
raise ValueError(
"cannot use axis={} on a nested list structure that splits into "
"different depths, the minimum of which is depth={} from the leaves".format(
axis, depth
)
f"cannot use axis={axis} on a nested list structure that splits into "
f"different depths, the minimum of which is depth={depth} from the leaves"
)
else:
if negaxis <= 0:
Expand Down
6 changes: 2 additions & 4 deletions src/awkward/_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,14 +410,12 @@ def deprecate(
date = ""
else:
date = " (target date: " + date + ")"
warning = """In version {}{}, this will be {}.
warning = f"""In version {version}{date}, this will be {will_be}.
To raise these warnings as errors (and get stack traces to find out where they're called), run
import warnings
warnings.filterwarnings("error", module="awkward.*")
after the first `import awkward` or use `@pytest.mark.filterwarnings("error:::awkward.*")` in pytest.
Issue: {}.""".format(
version, date, will_be, message
)
Issue: {message}."""
warnings.warn(warning, category, stacklevel=stacklevel + 1)


Expand Down
4 changes: 1 addition & 3 deletions src/awkward/contents/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,7 @@ def _getitem_next_missing(
)
else:
raise NotImplementedError(
"FIXME: unhandled case of SliceMissing with RecordArray containing {}".format(
content
)
f"FIXME: unhandled case of SliceMissing with RecordArray containing {content}"
)

return ak.contents.RecordArray(
Expand Down
4 changes: 2 additions & 2 deletions src/awkward/operations/ak_unflatten.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def unflatten_this_layout(layout):
):
raise ValueError(
"structure imposed by 'counts' does not fit in the array or partition "
"at axis={}".format(axis)
f"at axis={axis}"
)

offsets = current_offsets[: position + 1]
Expand Down Expand Up @@ -214,7 +214,7 @@ def apply(layout, depth, **kwargs):
):
raise ValueError(
"structure imposed by 'counts' does not fit in the array or partition "
"at axis={}".format(axis)
f"at axis={axis}"
)
positions[0] = 0

Expand Down

0 comments on commit acba884

Please sign in to comment.