Coverage for cvpack/path/path.py: 94%

16 statements  

« prev     ^ index     » next       coverage.py v7.5.1, created at 2024-05-09 16:14 +0000

1""" 

2.. module:: path 

3 :platform: Linux, MacOS, Windows 

4 :synopsis: Specifications for Path Collective Variables 

5 

6.. classauthor:: Charlles Abreu <craabreu@gmail.com> 

7 

8""" 

9 

10from ..serialization import Serializable 

11 

12 

13class Metric(Serializable): 

14 """ 

15 A measure of progress or deviation with respect to a path in CV space 

16 """ 

17 

18 yaml_tag = "!cvpack.path.Metric" 

19 

20 def __init__(self, name: str) -> None: 

21 self.name = name 

22 

23 def __repr__(self) -> str: 

24 return f"{self.__class__.__name__}({self.name!r})" 

25 

26 def __eq__(self, other: object) -> bool: 

27 return isinstance(other, Metric) and self.name == other.name 

28 

29 def __getstate__(self) -> dict: 

30 return {"name": self.name} 

31 

32 def __setstate__(self, state: dict) -> None: 

33 self.name = state["name"] 

34 

35 

36Metric.registerTag("!cvpack.path.Metric") 

37 

38 

39progress: Metric = Metric("progress") 

40deviation: Metric = Metric("deviation")