Skip to content
Snippets Groups Projects
Commit eab2792f authored by Marek Wiesner's avatar Marek Wiesner
Browse files

Fix typos

parent a099a066
No related branches found
No related tags found
No related merge requests found
......@@ -106,12 +106,12 @@ To read the indices of measured states from the PCOMP file and write them to a J
./scripts/get_indices_of_measured_states.py DATASET_DIRECTORY MODELS_DIRECTORY OUTPUT_FILE
```
### Read initial state infos from the model files and write to JSON
### Read initial state info from the model files and write to JSON
To read infos regarding the initial states from the PCOMP file and write them to a JSON file, use the program `scripts/get_initial_state_infos.py`:
To read info regarding the initial states from the PCOMP file and write them to a JSON file, use the program `scripts/get_initial_state_info.py`:
```Bash
./scripts/get_initial_state_infos.py DATASET_DIRECTORY MODELS_DIRECTORY OUTPUT_FILE
./scripts/get_initial_state_info.py DATASET_DIRECTORY MODELS_DIRECTORY OUTPUT_FILE
```
### Read constraint status from the model files and write to JSON
......
......@@ -61,7 +61,7 @@ class InitialStateInfo:
return json.dumps(self.to_dict(), indent=2)
def get_initial_state_infos(modelFileName: Path, dataset: Dataset) -> tuple[bool, list[InitialStateInfo]]:
def get_initial_state_info(modelFileName: Path, dataset: Dataset) -> tuple[bool, list[InitialStateInfo]]:
try:
pcompModel = read_pcomp_model(modelFileName, get_pcomp_model_dimensions_from(dataset))
except VariablesDimensionError as err:
......@@ -73,7 +73,7 @@ def get_initial_state_infos(modelFileName: Path, dataset: Dataset) -> tuple[bool
readingPcompModelWasSuccessful = True
initialStateInfos: list[InitialStateInfo] = []
initialStateInfo: list[InitialStateInfo] = []
for function in pcompModel.functions.initialValues:
if len(function.body) != 1:
......@@ -88,7 +88,7 @@ def get_initial_state_infos(modelFileName: Path, dataset: Dataset) -> tuple[bool
if is_number(returnStatement):
value = float(returnStatement)
logging.info(f"Found initial state value to be a fixed number: {value}")
initialStateInfos.append(
initialStateInfo.append(
InitialStateInfo(
isParameter=False,
isFixed=True,
......@@ -100,7 +100,7 @@ def get_initial_state_infos(modelFileName: Path, dataset: Dataset) -> tuple[bool
constantIndex = [c.name.lower() for c in pcompModel.constants].index(returnStatement)
value = pcompModel.constants[constantIndex].value
logging.info(f"Found initial state value to be a constant: {value}")
initialStateInfos.append(
initialStateInfo.append(
InitialStateInfo(
isParameter=False,
isFixed=True,
......@@ -115,7 +115,7 @@ def get_initial_state_infos(modelFileName: Path, dataset: Dataset) -> tuple[bool
logging.info(
f"Found initial state value to be a model parameter of the model: {dataset.modelParameterInfos[modelParameterIndex].name}")
initialStateInfos.append(
initialStateInfo.append(
InitialStateInfo(
isParameter=True,
isFixed=False,
......@@ -135,9 +135,9 @@ def get_initial_state_infos(modelFileName: Path, dataset: Dataset) -> tuple[bool
newline = '\n'
logging.info(
f"{dataset.name}: Found initial state infos: [\n{f',{newline}'.join([f'{info}' for info in initialStateInfos])}\n]")
f"{dataset.name}: Found initial state info: [\n{f',{newline}'.join([f'{info}' for info in initialStateInfo])}\n]")
return readingPcompModelWasSuccessful, initialStateInfos
return readingPcompModelWasSuccessful, initialStateInfo
def read_broken_models() -> list[str]:
......@@ -146,7 +146,7 @@ def read_broken_models() -> list[str]:
def main() -> int:
parser = ArgumentParser(description='Read initial state infos from PCOMP file and write to JSON')
parser = ArgumentParser(description='Read initial state info from PCOMP file and write to JSON')
parser.add_argument('datasetFolder', type=str, help='Path to dataset folder')
parser.add_argument('modelFolder', type=str, help='Path to model folder')
parser.add_argument('outputFilePath', type=str, help='Path to output file')
......@@ -157,7 +157,7 @@ def main() -> int:
datasets = read_datasets_from_directory(args.datasetFolder)
brokenModels = read_broken_models()
initialStateInfos: dict[str, object] = {}
initialStateInfo: dict[str, object] = {}
for dataset in datasets:
if not dataset.modelType == ModelType.OrdinaryDifferentialEquations:
......@@ -169,9 +169,9 @@ def main() -> int:
continue
correspondingModeFileName = Path(args.modelFolder) / f"{dataset.name}.fun"
readingModelSucceeded, initialStateInfo = get_initial_state_infos(correspondingModeFileName, dataset)
readingModelSucceeded, initialStateInfo = get_initial_state_info(correspondingModeFileName, dataset)
initialStateInfos[dataset.name] = {
initialStateInfo[dataset.name] = {
"readingModelSucceeded": readingModelSucceeded,
"initialStateInfo": [info.to_dict() for info in initialStateInfo]
}
......@@ -180,7 +180,7 @@ def main() -> int:
outputFolder.mkdir(parents=True, exist_ok=True)
with Path(args.outputFilePath).open("w") as outfile:
outfile.write(json.dumps(initialStateInfos, indent=4))
outfile.write(json.dumps(initialStateInfo, indent=4))
return 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment