- extract, isolate and package it in a completely independent Python module, versioned and in a way that allows releases on PyPI.org - fixed error in placeholder for secondary school (data registry defaults) - added restriction in pytest version to install - expected number of new cases fix - data registry update (schema v2.1.1) - github update - deprecate ExpertApplication and CO2Application - changes to reflect schema update 2.0.2 - version update - Fixed error with f_inf (short-range) - new folder layout - Conditional probability data update - General fixes - Fitting results in L/S/person - CO2 fitting algorithm refinement
39 lines
850 B
Python
39 lines
850 B
Python
import dataclasses
|
|
|
|
from caimira.calculator.models.dataclass_utils import nested_replace, walk_dataclass
|
|
|
|
|
|
@dataclasses.dataclass(frozen=True)
|
|
class Four:
|
|
four: float
|
|
|
|
|
|
@dataclasses.dataclass(frozen=True)
|
|
class Two:
|
|
three: int
|
|
four: Four
|
|
|
|
|
|
@dataclasses.dataclass(frozen=True)
|
|
class One:
|
|
one: int
|
|
two: Two
|
|
|
|
|
|
|
|
def test_nested_replace():
|
|
inst = One(1, two=Two(3, Four(4)))
|
|
new_inst = nested_replace(inst, {'two.four': Four(5)})
|
|
assert new_inst == One(1, two=Two(3, Four(5)))
|
|
|
|
|
|
def test_walk():
|
|
inst = One(1, two=Two(3, Four(4)))
|
|
expected = [
|
|
('inst.one', inst.one),
|
|
('inst.two', inst.two),
|
|
('inst.two.three', inst.two.three),
|
|
('inst.two.four', inst.two.four),
|
|
('inst.two.four.four', inst.two.four.four),
|
|
]
|
|
assert list(walk_dataclass(inst, name='inst')) == expected
|