Coverage for src/ipyvizzustory/storylib/animation.py: 100%
6 statements
« prev ^ index » next coverage.py v7.5.4, created at 2024-07-10 10:22 +0000
« prev ^ index » next coverage.py v7.5.4, created at 2024-07-10 10:22 +0000
1"""A module for working with chart animations."""
3from ipyvizzu import Data
6class DataFilter(Data):
7 """A class for representing a data filter."""
9 def build(self) -> dict:
10 """
11 A method for overwriting [Data.build][ipyvizzu.animation.Data.build] method.
12 Data initialized with a `DataFilter` must contain only a filter.
14 Returns:
15 A dictionary contains the filter key with the filter expression.
17 Raises:
18 ValueError: If `DataFilter` does not contain a filter or contains anything else.
19 """
21 if len(self.keys()) != 1 or "filter" not in self:
22 raise KeyError("Data must contain filter and only that.")
23 return {"filter": self["filter"]}