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
« prev ^ index » next coverage.py v7.6.12, created at 2025-02-27 10:39 -0600
1"""
2Type definitions for SeqRule.
4This module contains common type definitions used throughout the library.
5Centralizing these definitions improves consistency and makes type annotations
6more maintainable.
7"""
9from enum import Enum
10from typing import Any, Callable, Dict, TypeVar
12# Core type variables for generic functions
13T = TypeVar("T")
14K = TypeVar("K")
15V = TypeVar("V")
17# Property type definitions
18PropertyKey = str
19PropertyValue = Any
20Properties = Dict[PropertyKey, PropertyValue]
22# Function type definitions
23PredicateFunction = Callable[[Any], bool]
24TransformFunction = Callable[[Any], Any]
27class RuleRelationship(Enum):
28 """Relationship between two rules."""
30 EQUIVALENT = "equivalent"
31 STRICTER = "stricter"
32 LOOSER = "looser"
33 INCOMPARABLE = "incomparable"
36class ComplexityOrder(Enum):
37 """Ordering of algorithmic complexity classes."""
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!)