Coverage for src/seqrule/types.py: 100%

24 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-02-27 10:39 -0600

1""" 

2Type definitions for SeqRule. 

3 

4This module contains common type definitions used throughout the library. 

5Centralizing these definitions improves consistency and makes type annotations 

6more maintainable. 

7""" 

8 

9from enum import Enum 

10from typing import Any, Callable, Dict, TypeVar 

11 

12# Core type variables for generic functions 

13T = TypeVar("T") 

14K = TypeVar("K") 

15V = TypeVar("V") 

16 

17# Property type definitions 

18PropertyKey = str 

19PropertyValue = Any 

20Properties = Dict[PropertyKey, PropertyValue] 

21 

22# Function type definitions 

23PredicateFunction = Callable[[Any], bool] 

24TransformFunction = Callable[[Any], Any] 

25 

26 

27class RuleRelationship(Enum): 

28 """Relationship between two rules.""" 

29 

30 EQUIVALENT = "equivalent" 

31 STRICTER = "stricter" 

32 LOOSER = "looser" 

33 INCOMPARABLE = "incomparable" 

34 

35 

36class ComplexityOrder(Enum): 

37 """Ordering of algorithmic complexity classes.""" 

38 

39 CONSTANT = 1 # O(1) 

40 LOGARITHMIC = 2 # O(log n) 

41 LINEAR = 3 # O(n) 

42 LINEARITHMIC = 4 # O(n log n) 

43 QUADRATIC = 5 # O(n²) 

44 POLYNOMIAL = 6 # O(n^k) for k > 2 

45 EXPONENTIAL = 7 # O(2^n) 

46 FACTORIAL = 8 # O(n!)