Skip to content

Commit e390226

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 90729b7 commit e390226

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/hist/basehist.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import functools
2-
import inspect
2+
import inspect
33
import operator
44
import warnings
55
from typing import (
@@ -211,7 +211,6 @@ def fill(
211211
total_data = tuple(args) + tuple(data) # Python 2 can't unpack twice
212212
return super().fill(*total_data, weight=weight, sample=sample, threads=threads)
213213

214-
215214
def sort(
216215
self: T,
217216
axis: Union[int, str],
@@ -222,29 +221,34 @@ def sort(
222221
name = axis
223222
pos = [i for i in range(len(self.axes)) if self.axes[name] == self.axes[i]][0]
224223
ixes = sorted(range(len(self.axes[name])), key=lambda k: self.axes[name][k])
225-
224+
226225
def copy_traits(axis, instance=hist.axis.StrCategory):
227226
trait_dict = vars(axis.traits)
228227
for key in list(trait_dict.keys()):
229228
if key not in inspect.signature(instance).parameters.keys():
230229
del trait_dict[key]
231-
trait_dict['name'] = axis.name
232-
trait_dict['label'] = axis.label
230+
trait_dict["name"] = axis.name
231+
trait_dict["label"] = axis.label
233232
return trait_dict
234233

235234
labels = [list(self.axes[pos])[i] for i in ixes]
236235
if isinstance(self.axes[pos], hist.axis.IntCategory):
237-
new_ax = hist.axis.IntCategory(labels, **copy_traits(self.axes[pos], hist.axis.IntCategory))
236+
new_ax = hist.axis.IntCategory(
237+
labels, **copy_traits(self.axes[pos], hist.axis.IntCategory)
238+
)
238239
elif isinstance(self.axes[pos], hist.axis.StrCategory):
239-
new_ax = hist.axis.StrCategory(labels, **copy_traits(self.axes[pos], hist.axis.StrCategory))
240+
new_ax = hist.axis.StrCategory(
241+
labels, **copy_traits(self.axes[pos], hist.axis.StrCategory)
242+
)
240243
else:
241244
raise RuntimeError("Expected a categorical axis")
242-
243-
new_h = hist.Hist(*self.axes[:pos], new_ax, *self.axes[pos+1:])
244245

245-
new_h[...] = self.view(flow=True)[(slice(None),) * pos + (ixes,) + (slice(None),) * (len(self.axes) - pos - 1)]
246-
return new_h
246+
new_h = hist.Hist(*self.axes[:pos], new_ax, *self.axes[pos + 1 :])
247247

248+
new_h[...] = self.view(flow=True)[
249+
(slice(None),) * pos + (ixes,) + (slice(None),) * (len(self.axes) - pos - 1)
250+
]
251+
return new_h
248252

249253
def _loc_shortcut(self, x: Any) -> Any:
250254
"""

0 commit comments

Comments
 (0)