Skip to content
forked from pydata/xarray

Commit

Permalink
moar dataclass
Browse files Browse the repository at this point in the history
Co-authored-by: Illviljan <[email protected]>
  • Loading branch information
dcherian and Illviljan authored Apr 2, 2023
1 parent f271d1b commit e07ae31
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions xarray/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import warnings
from abc import ABC, abstractmethod
from collections.abc import Hashable, Iterator, Mapping, Sequence
from dataclasses import dataclass
from dataclasses import dataclass, field
from typing import (
TYPE_CHECKING,
Any,
Expand Down Expand Up @@ -519,17 +519,14 @@ class UniqueGrouper(Grouper):
pass


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

if cut_kwargs is None:
cut_kwargs = {}

self.bins = bins
self.cut_kwargs = cut_kwargs
def __post_init__(self):
if duck_array_ops.isnull(self.bins).all():
raise ValueError("All bin edges are NaN.")


@dataclass
Expand Down

0 comments on commit e07ae31

Please sign in to comment.