Skip to content

Commit e07ae31

Browse files
dcherianIllviljan
andauthored
moar dataclass
Co-authored-by: Illviljan <[email protected]>
1 parent f271d1b commit e07ae31

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

xarray/core/groupby.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import warnings
55
from abc import ABC, abstractmethod
66
from collections.abc import Hashable, Iterator, Mapping, Sequence
7-
from dataclasses import dataclass
7+
from dataclasses import dataclass, field
88
from typing import (
99
TYPE_CHECKING,
1010
Any,
@@ -519,17 +519,14 @@ class UniqueGrouper(Grouper):
519519
pass
520520

521521

522-
@dataclass(init=False)
522+
@dataclass
523523
class BinGrouper(Grouper):
524-
def __init__(self, bins, cut_kwargs: Mapping | None):
525-
if duck_array_ops.isnull(bins).all():
526-
raise ValueError("All bin edges are NaN.")
524+
bins: Any # TODO: What is the typing?
525+
cut_kwargs: Mapping = field(default_factory=dict)
527526

528-
if cut_kwargs is None:
529-
cut_kwargs = {}
530-
531-
self.bins = bins
532-
self.cut_kwargs = cut_kwargs
527+
def __post_init__(self):
528+
if duck_array_ops.isnull(self.bins).all():
529+
raise ValueError("All bin edges are NaN.")
533530

534531

535532
@dataclass

0 commit comments

Comments
 (0)