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

1"""A module for working with chart animations.""" 

2 

3from ipyvizzu import Data 

4 

5 

6class DataFilter(Data): 

7 """A class for representing a data filter.""" 

8 

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. 

13 

14 Returns: 

15 A dictionary contains the filter key with the filter expression. 

16 

17 Raises: 

18 ValueError: If `DataFilter` does not contain a filter or contains anything else. 

19 """ 

20 

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"]}