Skip to content

Commit 57d05df

Browse files
authored
Merge pull request #27 from BuildingEnergySimulationTools/corrai_adaptations
New version release Compatible with corrai 1.0.0 and OMPython 4.0.0
2 parents a7598b1 + 13db443 commit 57d05df

11 files changed

Lines changed: 582 additions & 715 deletions

File tree

.github/workflows/build.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@ jobs:
1414
include:
1515
- { name: '3.10', python: '3.10', tox: py310 }
1616
- { name: '3.11', python: '3.11', tox: py311 }
17+
- { name: '3.12', python: '3.12', tox: py312 }
1718
- { name: 'min', python: '3.10', tox: min }
1819
steps:
1920
- name: "Set up OpenModelica Compiler"
20-
uses: OpenModelica/setup-openmodelica@v1.0
21+
uses: OpenModelica/setup-openmodelica@v1.0.5
2122
with:
22-
version: 'stable'
23+
version: '1.25.4'
2324
packages: |
24-
omc
25+
'omc'
26+
'omsimulator'
2527
libraries: |
2628
'Modelica 4.0.0'
29+
'Modelica 3.2.3+maint.om'
2730
2831
- run: "omc --version"
2932
- uses: actions/checkout@v4
@@ -47,7 +50,7 @@ jobs:
4750
- uses: actions/checkout@v4
4851
- uses: actions/setup-python@v5
4952
with:
50-
python-version: "3.11"
53+
python-version: "3.12"
5154
- name: Install pypa/build
5255
run: python -m pip install build
5356
- name: Build a binary wheel and a source tarball
@@ -70,7 +73,7 @@ jobs:
7073
- uses: actions/checkout@v4
7174
- uses: actions/setup-python@v5
7275
with:
73-
python-version: "3.11"
76+
python-version: "3.12"
7477
- run: python -m pip install tox
7578
- run: python -m tox -e lint
7679
publish-to-pypi:

modelitool/combitabconvert.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import datetime as dt
2+
from pathlib import Path
23

34
import pandas as pd
45

@@ -33,7 +34,7 @@ def get_dymo_time_index(df):
3334
return list(pd.Series(sec_dt).cumsum())
3435

3536

36-
def df_to_combitimetable(df, filename):
37+
def write_combitt_from_df(df: pd.DataFrame, file_path: Path | str):
3738
"""
3839
Write a text file compatible with modelica Combitimetables object from a
3940
Pandas DataFrame with a DatetimeIndex. DataFrames with non monotonically increasing
@@ -45,18 +46,15 @@ def df_to_combitimetable(df, filename):
4546
"""
4647
if not isinstance(df, pd.DataFrame):
4748
raise ValueError(f"df must be an instance of pandas DataFrame. Got {type(df)}")
48-
if not isinstance(df.index, pd.DatetimeIndex):
49-
raise ValueError(
50-
f"DataFrame index must be an instance of DatetimeIndex. " f"Got {type(df)}"
51-
)
49+
5250
if not df.index.is_monotonic_increasing:
5351
raise ValueError(
5452
"df DateTimeIndex is not monotonically increasing, this will"
5553
"cause Modelica to crash."
5654
)
5755

5856
df = df.copy()
59-
with open(filename, "w") as file:
57+
with open(file_path, "w") as file:
6058
file.write("#1 \n")
6159
line = ""
6260
line += f"double table1({df.shape[0]}, {df.shape[1] + 1})\n"
@@ -65,6 +63,7 @@ def df_to_combitimetable(df, filename):
6563
line += f"\t({i + 1}){col}"
6664
file.write(f"{line} \n")
6765

68-
df.index = datetime_to_seconds(df.index)
66+
if isinstance(df.index, pd.DatetimeIndex):
67+
df.index = datetime_to_seconds(df.index)
6968

7069
file.write(df.to_csv(header=False, sep="\t", lineterminator="\n"))

modelitool/corrai_connector.py

Lines changed: 0 additions & 137 deletions
This file was deleted.

0 commit comments

Comments
 (0)