Пример #1
0
def test_ventilation_dict_methods():
    """Test the to/from dict methods."""
    ventilation = VentilationOpening(0.25, 0.5, 0.25, True)

    vent_dict = ventilation.to_dict()
    print(vent_dict)
    new_ventilation = VentilationOpening.from_dict(vent_dict)
    assert new_ventilation == ventilation
    assert vent_dict == new_ventilation.to_dict()

    # Test with afn
    ventilation_afn = VentilationOpening(1, 1, 0.17, False, 0.001, 0.667, 1e-3)
    vent_afn_dict = ventilation_afn.to_dict()
    vent_afn_dict['flow_coefficient_closed'] == pytest.approx(0.002, abs=1e-10)
    vent_afn_dict['flow_exponent_closed'] == pytest.approx(0.667, abs=1e-10)
    vent_afn_dict['two_way_threshold'] == pytest.approx(0.0001)
    new_ventilation_afn = VentilationOpening.from_dict(vent_afn_dict)
    assert new_ventilation_afn == ventilation_afn
    assert vent_afn_dict == new_ventilation_afn.to_dict()
Пример #2
0
    def _deserialize_window_vent(new_prop, data):
        """Re-serialize window ventilation objects from a dict and apply to new_prop.

        Args:
            new_prop: A Room2DEnergyProperties to apply the window ventilation to.
            data: A dictionary representation of Room2DEnergyProperties.
        """
        if 'window_vent_control' in data and data[
                'window_vent_control'] is not None:
            new_prop.window_vent_control = \
                VentilationControl.from_dict_abridged(data['window_vent_control'], {})
        if 'window_vent_opening' in data and data[
                'window_vent_opening'] is not None:
            new_prop.window_vent_opening = \
                VentilationOpening.from_dict(data['window_vent_opening'])