Relative Content

Tag Archive for pythonpython-3.xvalidationgenerics

Paramerize a type annotation in a dataclass for validation purposes

The problem I have a common dataclass that contains two numpy arrays: @dataclass class VectorCovariancePair: data: np.ndarray[np.float64] # expected size: N covariance: np.ndarray[np.float64] # expected size: N * N Multiple other classes use this to represent values of different sizes, for example: @dataclass class Pose: position: VectorCovariancePair # expected size: 3 orientation: VectorCovariancePair # expected […]