Coverage for src/ipyvizzustory/storylib/animation.py: 100%
6 statements
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-25 13:56 +0100
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-25 13:56 +0100
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 `ipyvizzu.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 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"]}