Skip to content

Commit

Permalink
style: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrugman committed Jul 18, 2023
1 parent 93553b2 commit d10054a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Expand Up @@ -4,7 +4,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.277'
rev: 'v0.0.278'
hooks:
- id: ruff
args: [--fix]
Expand Down
32 changes: 7 additions & 25 deletions popmon/analysis/hist_numpy.py
Expand Up @@ -382,11 +382,7 @@ def check_similar_hists(
return True
for hist in hist_list:
if not isinstance(hist, assert_type):
raise TypeError(
"Input histogram type {htype} not of {htypes}.".format(
htype=type(hist), htypes=assert_type
)
)
raise TypeError(f"Input histogram type {type(hist)} not of {assert_type}.")
# perform similarity checks on:
# - number of dimensions
# - histogram type
Expand All @@ -411,37 +407,27 @@ def check_similar_hists(
# Make this consistent first.
types = [get_contentType(hist) for hist in hist_list]
if types.count(types[0]) != len(types):
warnings.warn(
"Input histograms have inconsistent class types: {types}".format(
types=types
)
)
warnings.warn(f"Input histograms have inconsistent class types: {types}")
return False

# Check Bin attributes
if isinstance(hist_list[0], histogrammar.Bin):
nums = [hist.num for hist in hist_list]
if nums.count(nums[0]) != len(nums):
warnings.warn(
"Input Bin histograms have inconsistent num attributes: {types}".format(
types=nums
)
f"Input Bin histograms have inconsistent num attributes: {nums}"
)
return False
lows = [hist.low for hist in hist_list]
if lows.count(lows[0]) != len(lows):
warnings.warn(
"Input Bin histograms have inconsistent low attributes: {types}".format(
types=lows
)
f"Input Bin histograms have inconsistent low attributes: {lows}"
)
return False
highs = [hist.high for hist in hist_list]
if highs.count(highs[0]) != len(highs):
warnings.warn(
"Input histograms have inconsistent high attributes: {types}".format(
types=highs
)
f"Input histograms have inconsistent high attributes: {highs}"
)
return False

Expand All @@ -450,17 +436,13 @@ def check_similar_hists(
origins = [hist.origin for hist in hist_list]
if origins.count(origins[0]) != len(origins):
warnings.warn(
"Input SparselyBin histograms have inconsistent origin attributes: {types}".format(
types=origins
)
f"Input SparselyBin histograms have inconsistent origin attributes: {origins}"
)
return False
bws = [hist.binWidth for hist in hist_list]
if bws.count(bws[0]) != len(bws):
warnings.warn(
"Input SparselyBin histograms have inconsistent binWidth attributes: {types}".format(
types=bws
)
f"Input SparselyBin histograms have inconsistent binWidth attributes: {bws}"
)
return False

Expand Down
4 changes: 1 addition & 3 deletions popmon/resources.py
Expand Up @@ -94,9 +94,7 @@ def _resource(resource_type, name: str) -> str:
return str(full_path)

raise FileNotFoundError(
'Could not find {resource_type} "{name!s}"! Does it exist?'.format(
resource_type=resource_type, name=name
)
f'Could not find {resource_type} "{name!s}"! Does it exist?'
)


Expand Down
4 changes: 1 addition & 3 deletions popmon/visualization/utils.py
Expand Up @@ -762,9 +762,7 @@ def plot_heatmap(
values = hist_values
assert len(labels) == len(
values
), "labels and values have different array lengths: {:d} vs {:d}. {}".format(
len(labels), len(values), x_label
)
), f"labels and values have different array lengths: {len(labels):d} vs {len(values):d}. {x_label}"

# plot histogram
fig = px.imshow(
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Expand Up @@ -164,7 +164,8 @@ ignore = [
]

"popmon/config.py" = [
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`,
"FA100", # Missing `from __future__ import annotations`
]

# Notebooks & NBQA
Expand Down

0 comments on commit d10054a

Please sign in to comment.