Beispiel #1
0
 def __init__(self, config: StudyConfig, area: str):
     section = {
         "name": str,
         "group": str,
         "unitcount": int,
         "nominalcapacity": float,
         "market-bid-cost": float,
     }
     types = {ther: section for ther in config.get_thermal_names(area)}
     IniFileNode.__init__(self, config, types)
Beispiel #2
0
    def __init__(self, config: StudyConfig):
        types = {
            ".shellclassinfo": {
                "iconfile": str,
                "iconindex": int,
                "infotip": str,
            }
        }

        IniFileNode.__init__(self, config, types=types)
def test_get_depth(tmp_path: str) -> None:
    path, types = build_dataset(tmp_path)

    expected_json = {
        "part1": {},
        "part2": {},
    }
    node = IniFileNode(
        StudyConfig(path, areas=dict(), outputs=dict()), types=types
    )
    assert node.get(depth=1) == expected_json
Beispiel #4
0
 def __init__(self, config: StudyConfig):
     types = {
         "antares": {
             "version": int,
             "caption": str,
             "created": int,
             "lastsave": int,
             "author": str,
         }
     }
     IniFileNode.__init__(self, config, types)
Beispiel #5
0
    def __init__(self, config: StudyConfig):
        self.config = config

        rules: Dict[str, Type[int]] = dict()
        for area in self.config.areas:
            for mode in ["l", "s", "w", "h"]:
                rules[f"{mode},{area},0"] = int
            self._add_thermal(area, rules)

        IniFileNode.__init__(self,
                             config=config,
                             types={"Default Ruleset": rules})
def test_get(tmp_path: str) -> None:
    path, types = build_dataset(tmp_path)

    expected_json = {
        "part1": {"key_int": 1, "key_str": "value1", "key_float": 2.1},
        "part2": {"key_bool": True, "key_bool2": False},
    }
    node = IniFileNode(
        StudyConfig(path, areas=dict(), outputs=dict()), types=types
    )
    assert node.get([]) == expected_json
    assert node.get(["part2"]) == {"key_bool": True, "key_bool2": False}
    assert node.get(["part2", "key_bool"])
    def __init__(self, config: StudyConfig):
        types = {
            "general": {
                "version": int,
                "name": str,
                "mode": str,
                "date": str,
                "title": str,
                "timestamp": int,
            }
        }

        IniFileNode.__init__(self, config, types=types)
Beispiel #8
0
    def __init__(self, config: StudyConfig):
        sections = [
            "inter-daily-breakdown",
            "intra-daily-modulation",
            "inter-monthly-breakdown",
            "initialize reservoir date",
            "leeway low",
            "leeway up",
            "pumping efficiency",
        ]
        section = {a: (int, float) for a in config.area_names()}
        types = {name: section for name in sections}

        IniFileNode.__init__(self, config, types)
Beispiel #9
0
 def __init__(self, config: StudyConfig):
     types = {
         "nodal optimization": {
             "non-dispatchable-power": bool,
             "dispatchable-hydro-power": bool,
             "other-dispatchable-power": bool,
             "spread-unsupplied-energy-cost": (int, float),
             "spread-spilled-energy-cost": (int, float),
         },
         "filtering": {
             "filter-synthesis": str,
             "filter-year-by-year": str
         },
     }
     IniFileNode.__init__(self, config, types)
 def __init__(self, config: StudyConfig):
     types = {
         "general": {"mode": str},
         "0": {},
         "1": {},
         "2": {},
         "3": {},
         "4": {},
         "5": {},
         "6": {},
         "7": {},
         "8": {},
         "9": {},
         "10": {},
         "11": {},
     }
     IniFileNode.__init__(self, config, types)
    def __init__(self, config: StudyConfig, area: str):
        section = {
            "hurdles-cost": bool,
            "loop-flow": bool,
            "use-phase-shifter": bool,
            "transmission-capacities": str,
            "asset-type": str,
            "link-style": str,
            "link-width": int,
            "colorr": int,
            "colorg": int,
            "colorb": int,
            "display-comments": bool,
            "filter-synthesis": str,
            "filter-year-by-year": str,
        }

        types = {link: section for link in config.get_links(area)}
        IniFileNode.__init__(self, config, types)
Beispiel #12
0
 def __init__(self, config: StudyConfig):
     types = {
         "ui": {
             "x": int,
             "y": int,
             "color_r": int,
             "color_g": int,
             "color_b": int,
             "layers": int,
         },
         "layerX": {
             "0": int
         },
         "layerY": {
             "0": int
         },
         "layerColor": {
             "0": str
         },
     }
     IniFileNode.__init__(self, config, types)
def test_save(tmp_path: str) -> None:
    path = Path(tmp_path) / "test.ini"

    ini_content = """[part1]
key_int = 1
key_float = 2.1
key_str = value1
    """
    path.write_text(ini_content)

    exp = """[part1]
key_int = 10
key_str = value10
key_float = 3.14

"""

    types = {"part1": {"key_int": int, "key_float": float, "key_str": str}}

    node = IniFileNode(
        StudyConfig(path, areas=dict(), outputs=dict()), types=types
    )
    data = {
        "part1": {"key_int": 10, "key_str": "value10", "key_float": 2.1},
    }
    node.save(data)
    node.save(3.14, url=["part1", "key_float"])
    assert exp == path.read_text()
 def __init__(self, config: StudyConfig):
     types = {
         "layers": {},
         "activeLayer": {"activeLayerID": int, "showAllLayer": bool},
     }
     IniFileNode.__init__(self, config, types=types)
def test_validate_section():
    data = {"section": {"params": 42}}

    node = IniFileNode(config=StudyConfig(Path()), types={"wrong-section": {}})
    assert node.check_errors(data=data) == [
        "section wrong-section not in IniFileNode"
    ]
    with pytest.raises(ValueError):
        node.check_errors(data, raising=True)

    node = IniFileNode(
        config=StudyConfig(Path()), types={"section": {"wrong-params": 42}}
    )
    assert node.check_errors(data=data) == [
        "param wrong-params of section section not in IniFileNode"
    ]
    with pytest.raises(ValueError):
        node.check_errors(data, raising=True)

    node = IniFileNode(
        config=StudyConfig(Path()), types={"section": {"params": str}}
    )
    assert node.check_errors(data=data) == [
        "param params of section section in IniFileNode bad type"
    ]
Beispiel #16
0
 def __init__(self, config: StudyConfig):
     IniFileNode.__init__(self, config, types={})
Beispiel #17
0
 def __init__(self, config: StudyConfig):
     # TODO Implements writer sets.ini
     IniFileNode.__init__(self, config, types={}, reader=SetsIniReader())
Beispiel #18
0
 def __init__(self, config: StudyConfig):
     IniFileNode.__init__(self, config, GeneralData.TYPES)
Beispiel #19
0
 def __init__(self, config: StudyConfig):
     types = {"prepro": {"intermonthly-correlation": float}}
     IniFileNode.__init__(self, config, types)
Beispiel #20
0
 def __init__(self, config: StudyConfig):
     section = {a: float for a in config.area_names()}
     types = {"unserverdenergycost": section, "spilledenergycost": {}}
     IniFileNode.__init__(self, config, types)