Skip to content

Commit 2ae6247

Browse files
authored
Merge pull request #282 from ing-bank/develop
Release
2 parents f2a0f93 + d10054a commit 2ae6247

File tree

6 files changed

+18
-39
lines changed

6 files changed

+18
-39
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: 23.3.0
3+
rev: 23.7.0
44
hooks:
55
- id: black
66
- repo: https://github.com/charliermarsh/ruff-pre-commit
7-
rev: 'v0.0.277'
7+
rev: 'v0.0.278'
88
hooks:
99
- id: ruff
1010
args: [--fix]
1111
- repo: https://github.com/asottile/blacken-docs
12-
rev: 1.14.0
12+
rev: 1.15.0
1313
hooks:
1414
- id: blacken-docs
1515
- repo: local

popmon/analysis/hist_numpy.py

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,7 @@ def check_similar_hists(
382382
return True
383383
for hist in hist_list:
384384
if not isinstance(hist, assert_type):
385-
raise TypeError(
386-
"Input histogram type {htype} not of {htypes}.".format(
387-
htype=type(hist), htypes=assert_type
388-
)
389-
)
385+
raise TypeError(f"Input histogram type {type(hist)} not of {assert_type}.")
390386
# perform similarity checks on:
391387
# - number of dimensions
392388
# - histogram type
@@ -411,37 +407,27 @@ def check_similar_hists(
411407
# Make this consistent first.
412408
types = [get_contentType(hist) for hist in hist_list]
413409
if types.count(types[0]) != len(types):
414-
warnings.warn(
415-
"Input histograms have inconsistent class types: {types}".format(
416-
types=types
417-
)
418-
)
410+
warnings.warn(f"Input histograms have inconsistent class types: {types}")
419411
return False
420412

421413
# Check Bin attributes
422414
if isinstance(hist_list[0], histogrammar.Bin):
423415
nums = [hist.num for hist in hist_list]
424416
if nums.count(nums[0]) != len(nums):
425417
warnings.warn(
426-
"Input Bin histograms have inconsistent num attributes: {types}".format(
427-
types=nums
428-
)
418+
f"Input Bin histograms have inconsistent num attributes: {nums}"
429419
)
430420
return False
431421
lows = [hist.low for hist in hist_list]
432422
if lows.count(lows[0]) != len(lows):
433423
warnings.warn(
434-
"Input Bin histograms have inconsistent low attributes: {types}".format(
435-
types=lows
436-
)
424+
f"Input Bin histograms have inconsistent low attributes: {lows}"
437425
)
438426
return False
439427
highs = [hist.high for hist in hist_list]
440428
if highs.count(highs[0]) != len(highs):
441429
warnings.warn(
442-
"Input histograms have inconsistent high attributes: {types}".format(
443-
types=highs
444-
)
430+
f"Input histograms have inconsistent high attributes: {highs}"
445431
)
446432
return False
447433

@@ -450,17 +436,13 @@ def check_similar_hists(
450436
origins = [hist.origin for hist in hist_list]
451437
if origins.count(origins[0]) != len(origins):
452438
warnings.warn(
453-
"Input SparselyBin histograms have inconsistent origin attributes: {types}".format(
454-
types=origins
455-
)
439+
f"Input SparselyBin histograms have inconsistent origin attributes: {origins}"
456440
)
457441
return False
458442
bws = [hist.binWidth for hist in hist_list]
459443
if bws.count(bws[0]) != len(bws):
460444
warnings.warn(
461-
"Input SparselyBin histograms have inconsistent binWidth attributes: {types}".format(
462-
types=bws
463-
)
445+
f"Input SparselyBin histograms have inconsistent binWidth attributes: {bws}"
464446
)
465447
return False
466448

popmon/resources.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ def _resource(resource_type, name: str) -> str:
9494
return str(full_path)
9595

9696
raise FileNotFoundError(
97-
'Could not find {resource_type} "{name!s}"! Does it exist?'.format(
98-
resource_type=resource_type, name=name
99-
)
97+
f'Could not find {resource_type} "{name!s}"! Does it exist?'
10098
)
10199

102100

popmon/visualization/histogram_section.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def transform(self, data_obj: dict, sections: list | None = None):
119119
)
120120
continue
121121

122-
# base64 heatmap plot for each metric
122+
# heatmap plot for each metric
123123
dates = [short_date(date) for date in df.index[:]]
124124
hists = [
125125
df[hist_names].iloc[-i].values
@@ -233,14 +233,14 @@ def _plot_histograms(feature, date, hc_list, hist_names, top_n, max_nbins: int =
233233
hist_names = [hn for i, hn in enumerate(hist_names) if i not in none_hists]
234234
# more basic checks
235235
if len(hc_list) == 0:
236-
return {"name": date, "description": "", "plot": ""}
236+
return {}
237237
assert_similar_hists(hc_list)
238238

239239
# make plot. note: slow!
240240
if hc_list[0].n_dim == 1:
241241
if all(h.entries == 0 for h in hc_list):
242242
# triviality checks, skip all histograms empty
243-
return {"name": date, "description": "", "plot": ""}
243+
return {}
244244

245245
props = get_hist_props(hc_list[0])
246246
is_num = props["is_num"]
@@ -259,7 +259,7 @@ def _plot_histograms(feature, date, hc_list, hist_names, top_n, max_nbins: int =
259259

260260
# skip histograms with too many bins to plot (default more than 1000)
261261
if len(bins) > max_nbins:
262-
return {"name": date, "description": "", "plot": ""}
262+
return {}
263263

264264
# normalize histograms for plotting (comparison!) in case there is more than one.
265265
if len(hc_list) >= 2:

popmon/visualization/utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -762,9 +762,7 @@ def plot_heatmap(
762762
values = hist_values
763763
assert len(labels) == len(
764764
values
765-
), "labels and values have different array lengths: {:d} vs {:d}. {}".format(
766-
len(labels), len(values), x_label
767-
)
765+
), f"labels and values have different array lengths: {len(labels):d} vs {len(values):d}. {x_label}"
768766

769767
# plot histogram
770768
fig = px.imshow(

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ ignore = [
164164
]
165165

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

170171
# Notebooks & NBQA

0 commit comments

Comments
 (0)