flixopt 3.1.0__py3-none-any.whl → 3.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of flixopt might be problematic. Click here for more details.
- flixopt/aggregation.py +13 -4
- flixopt/calculation.py +2 -3
- flixopt/color_processing.py +261 -0
- flixopt/components.py +12 -10
- flixopt/config.py +59 -4
- flixopt/effects.py +11 -13
- flixopt/flow_system.py +5 -3
- flixopt/interface.py +2 -1
- flixopt/io.py +239 -22
- flixopt/plotting.py +583 -789
- flixopt/results.py +475 -70
- flixopt/structure.py +4 -9
- {flixopt-3.1.0.dist-info → flixopt-3.2.0.dist-info}/METADATA +2 -2
- flixopt-3.2.0.dist-info/RECORD +26 -0
- flixopt/utils.py +0 -86
- flixopt-3.1.0.dist-info/RECORD +0 -26
- {flixopt-3.1.0.dist-info → flixopt-3.2.0.dist-info}/WHEEL +0 -0
- {flixopt-3.1.0.dist-info → flixopt-3.2.0.dist-info}/licenses/LICENSE +0 -0
- {flixopt-3.1.0.dist-info → flixopt-3.2.0.dist-info}/top_level.txt +0 -0
flixopt/structure.py
CHANGED
|
@@ -6,7 +6,6 @@ These classes are not directly used by the end user, but are used by other modul
|
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
8
|
import inspect
|
|
9
|
-
import json
|
|
10
9
|
import logging
|
|
11
10
|
from dataclasses import dataclass
|
|
12
11
|
from io import StringIO
|
|
@@ -788,8 +787,7 @@ class Interface:
|
|
|
788
787
|
try:
|
|
789
788
|
# Use the stats mode for JSON export (cleaner output)
|
|
790
789
|
data = self.get_structure(clean=True, stats=True)
|
|
791
|
-
|
|
792
|
-
json.dump(data, f, indent=4, ensure_ascii=False)
|
|
790
|
+
fx_io.save_json(data, path)
|
|
793
791
|
except Exception as e:
|
|
794
792
|
raise OSError(f'Failed to save {self.__class__.__name__} to JSON file {path}: {e}') from e
|
|
795
793
|
|
|
@@ -880,13 +878,10 @@ class Element(Interface):
|
|
|
880
878
|
|
|
881
879
|
@staticmethod
|
|
882
880
|
def _valid_label(label: str) -> str:
|
|
883
|
-
"""
|
|
884
|
-
Checks if the label is valid. If not, it is replaced by the default label
|
|
881
|
+
"""Checks if the label is valid. If not, it is replaced by the default label.
|
|
885
882
|
|
|
886
|
-
Raises
|
|
887
|
-
|
|
888
|
-
ValueError
|
|
889
|
-
If the label is not valid
|
|
883
|
+
Raises:
|
|
884
|
+
ValueError: If the label is not valid.
|
|
890
885
|
"""
|
|
891
886
|
not_allowed = ['(', ')', '|', '->', '\\', '-slash-'] # \\ is needed to check for \
|
|
892
887
|
if any([sign in label for sign in not_allowed]):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flixopt
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.2.0
|
|
4
4
|
Summary: Vector based energy and material flow optimization framework in Python.
|
|
5
5
|
Author-email: "Chair of Building Energy Systems and Heat Supply, TU Dresden" <peter.stange@tu-dresden.de>, Felix Bumann <felixbumann387@gmail.com>, Felix Panitz <baumbude@googlemail.com>, Peter Stange <peter.stange@tu-dresden.de>
|
|
6
6
|
Maintainer-email: Felix Bumann <felixbumann387@gmail.com>, Peter Stange <peter.stange@tu-dresden.de>
|
|
@@ -24,7 +24,7 @@ Requires-Dist: numpy<3,>=1.21.5
|
|
|
24
24
|
Requires-Dist: pandas<3,>=2.0.0
|
|
25
25
|
Requires-Dist: xarray<2026.0,>=2024.2.0
|
|
26
26
|
Requires-Dist: linopy<0.6,>=0.5.1
|
|
27
|
-
Requires-Dist:
|
|
27
|
+
Requires-Dist: netcdf4<2,>=1.6.1
|
|
28
28
|
Requires-Dist: pyyaml<7,>=6.0.0
|
|
29
29
|
Requires-Dist: rich<15,>=13.0.0
|
|
30
30
|
Requires-Dist: tomli<3,>=2.0.1; python_version < "3.11"
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
flixopt/__init__.py,sha256=_5d7Buc1ugaip5QbDGc9ebMO8LK0WWAjYHQMX2Th8P0,2217
|
|
2
|
+
flixopt/aggregation.py,sha256=ZE0LcUAZ8xNet13YjxvvMw8BAL7Qo4TcJBwBCE2sHqE,16562
|
|
3
|
+
flixopt/calculation.py,sha256=YkVzpWJ4lYxCReP7H-lBYrkNGrza_SggjqGMU3xVf7o,29605
|
|
4
|
+
flixopt/color_processing.py,sha256=bSq6iAnreiEBFz4Xf0AIUMyENJsWbJ-5xpiqM7_teUc,9027
|
|
5
|
+
flixopt/commons.py,sha256=ZNlUN1z-h9OGHPo-s-n5OLlJaoPZKVGcAdRyGKpMk4M,1256
|
|
6
|
+
flixopt/components.py,sha256=0EKnzoehrx4Wk-5b6NokHvmT1i7t1msi0JAMM5BA0WU,57711
|
|
7
|
+
flixopt/config.py,sha256=ScqPyYn_URJmOo_aQDViQ-TktF3TZPrcCSoBCQXVpXc,24591
|
|
8
|
+
flixopt/core.py,sha256=OG789eUaS5Lu0CjJiMIdtaixqnV5ZtMiKfERjCPRTv8,26366
|
|
9
|
+
flixopt/effects.py,sha256=1UZaqmjHEjMahbKBcmgXP3JojIRDhUZKjPgLgOAJvO0,34056
|
|
10
|
+
flixopt/elements.py,sha256=92SQ3ax57I9VLjhe0-4L6u3jaYDylrKcmuSFGuzneqI,36371
|
|
11
|
+
flixopt/features.py,sha256=kd-fMvADv8GXoKkrXObYjRJLN8toBG-5bOHTuh-59kk,25073
|
|
12
|
+
flixopt/flow_system.py,sha256=HI4nOGRFjleumBcusjCU1Momw0DN7Q2oCgy0gU0dCug,40339
|
|
13
|
+
flixopt/interface.py,sha256=ACWFIwdbjVN0x52QukKetpJgM0YGsWpvlBAtFnHgHa4,57925
|
|
14
|
+
flixopt/io.py,sha256=1vjwFTyAr2ohkiwqE4qVX9juAG0l1wgxltcWcEPaFcQ,18895
|
|
15
|
+
flixopt/linear_converters.py,sha256=tcz5c1SI36hRFbCX-4NXced12ss9VETg5BE7zOdyeo4,22699
|
|
16
|
+
flixopt/modeling.py,sha256=s0zipbblq-LJrSe7angKT3Imxgr3kIbprG98HUvmkzI,31322
|
|
17
|
+
flixopt/network_app.py,sha256=LnVAlAgzL1BgMYLsJ20a62j6nQUmNccF1zo4ACUXzL4,29433
|
|
18
|
+
flixopt/plotting.py,sha256=C_VyBVQIUP1HYt8roXk__Gz9m17cSSPikXZL4jidIpg,65024
|
|
19
|
+
flixopt/results.py,sha256=gZAj-BQpb7CHp0CcYy99ZF4_IEZvJnQfTeOEZe2TdCU,118942
|
|
20
|
+
flixopt/solvers.py,sha256=m38Smc22MJfHYMiqfNf1MA3OmvbTRm5OWS9nECkDdQk,2355
|
|
21
|
+
flixopt/structure.py,sha256=CrMqp1rzo45S-XJTVmJW4kQWh-a_ukz38uBp18LnBLU,47585
|
|
22
|
+
flixopt-3.2.0.dist-info/licenses/LICENSE,sha256=HKsZnbrM_3Rvnr_u9cWSG90cBsj5_slaqI_z_qcxnGI,1118
|
|
23
|
+
flixopt-3.2.0.dist-info/METADATA,sha256=uBnKopA20TTqYiHXdbxW1X3szcF4s4HS2JqBUXQ8cao,12855
|
|
24
|
+
flixopt-3.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
25
|
+
flixopt-3.2.0.dist-info/top_level.txt,sha256=fanTzb9NylIXfv6Ic7spU97fVmRgGDPKvI_91tw4S3E,8
|
|
26
|
+
flixopt-3.2.0.dist-info/RECORD,,
|
flixopt/utils.py
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
This module contains several utility functions used throughout the flixopt framework.
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from __future__ import annotations
|
|
6
|
-
|
|
7
|
-
import logging
|
|
8
|
-
from typing import Any, Literal
|
|
9
|
-
|
|
10
|
-
import numpy as np
|
|
11
|
-
import xarray as xr
|
|
12
|
-
|
|
13
|
-
logger = logging.getLogger('flixopt')
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def round_nested_floats(obj: dict | list | float | int | Any, decimals: int = 2) -> dict | list | float | int | Any:
|
|
17
|
-
"""Recursively round floating point numbers in nested data structures.
|
|
18
|
-
|
|
19
|
-
This function traverses nested data structures (dictionaries, lists) and rounds
|
|
20
|
-
any floating point numbers to the specified number of decimal places. It handles
|
|
21
|
-
various data types including NumPy arrays and xarray DataArrays by converting
|
|
22
|
-
them to lists with rounded values.
|
|
23
|
-
|
|
24
|
-
Args:
|
|
25
|
-
obj: The object to process. Can be a dict, list, float, int, numpy.ndarray,
|
|
26
|
-
xarray.DataArray, or any other type.
|
|
27
|
-
decimals (int, optional): Number of decimal places to round to. Defaults to 2.
|
|
28
|
-
|
|
29
|
-
Returns:
|
|
30
|
-
The processed object with the same structure as the input, but with all floating point numbers rounded to the specified precision. NumPy arrays and xarray DataArrays are converted to lists.
|
|
31
|
-
|
|
32
|
-
Examples:
|
|
33
|
-
>>> data = {'a': 3.14159, 'b': [1.234, 2.678]}
|
|
34
|
-
>>> round_nested_floats(data, decimals=2)
|
|
35
|
-
{'a': 3.14, 'b': [1.23, 2.68]}
|
|
36
|
-
|
|
37
|
-
>>> import numpy as np
|
|
38
|
-
>>> arr = np.array([1.234, 5.678])
|
|
39
|
-
>>> round_nested_floats(arr, decimals=1)
|
|
40
|
-
[1.2, 5.7]
|
|
41
|
-
"""
|
|
42
|
-
if isinstance(obj, dict):
|
|
43
|
-
return {k: round_nested_floats(v, decimals) for k, v in obj.items()}
|
|
44
|
-
elif isinstance(obj, list):
|
|
45
|
-
return [round_nested_floats(v, decimals) for v in obj]
|
|
46
|
-
elif isinstance(obj, float):
|
|
47
|
-
return round(obj, decimals)
|
|
48
|
-
elif isinstance(obj, int):
|
|
49
|
-
return obj
|
|
50
|
-
elif isinstance(obj, np.ndarray):
|
|
51
|
-
return np.round(obj, decimals).tolist()
|
|
52
|
-
elif isinstance(obj, xr.DataArray):
|
|
53
|
-
return obj.round(decimals).values.tolist()
|
|
54
|
-
return obj
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
def convert_dataarray(
|
|
58
|
-
data: xr.DataArray, mode: Literal['py', 'numpy', 'xarray', 'structure']
|
|
59
|
-
) -> list | np.ndarray | xr.DataArray | str:
|
|
60
|
-
"""
|
|
61
|
-
Convert a DataArray to a different format.
|
|
62
|
-
|
|
63
|
-
Args:
|
|
64
|
-
data: The DataArray to convert.
|
|
65
|
-
mode: The mode to convert to.
|
|
66
|
-
- 'py': Convert to python native types (for json)
|
|
67
|
-
- 'numpy': Convert to numpy array
|
|
68
|
-
- 'xarray': Convert to xarray.DataArray
|
|
69
|
-
- 'structure': Convert to strings (for structure, storing variable names)
|
|
70
|
-
|
|
71
|
-
Returns:
|
|
72
|
-
The converted data.
|
|
73
|
-
|
|
74
|
-
Raises:
|
|
75
|
-
ValueError: If the mode is unknown.
|
|
76
|
-
"""
|
|
77
|
-
if mode == 'numpy':
|
|
78
|
-
return data.values
|
|
79
|
-
elif mode == 'py':
|
|
80
|
-
return data.values.tolist()
|
|
81
|
-
elif mode == 'xarray':
|
|
82
|
-
return data
|
|
83
|
-
elif mode == 'structure':
|
|
84
|
-
return f':::{data.name}'
|
|
85
|
-
else:
|
|
86
|
-
raise ValueError(f'Unknown mode {mode}')
|
flixopt-3.1.0.dist-info/RECORD
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
flixopt/__init__.py,sha256=_5d7Buc1ugaip5QbDGc9ebMO8LK0WWAjYHQMX2Th8P0,2217
|
|
2
|
-
flixopt/aggregation.py,sha256=P374vIJc1ZcPxxG8dfCPgUKNLRNP2kf8Y-sc1JOA45U,16191
|
|
3
|
-
flixopt/calculation.py,sha256=jeJzTazlG-KJh4M5VMlEqF-_nwIdtVYN3Z94CfKG8yI,29661
|
|
4
|
-
flixopt/commons.py,sha256=ZNlUN1z-h9OGHPo-s-n5OLlJaoPZKVGcAdRyGKpMk4M,1256
|
|
5
|
-
flixopt/components.py,sha256=bm76uCaXkeLuDBfsJ1kjfaHOl8zmow2JTaNPCK4Jknc,57757
|
|
6
|
-
flixopt/config.py,sha256=kB-KyPKtmHoK1zwGp1HV8iJShVsjmi2d5SrGmL_uHxA,22000
|
|
7
|
-
flixopt/core.py,sha256=OG789eUaS5Lu0CjJiMIdtaixqnV5ZtMiKfERjCPRTv8,26366
|
|
8
|
-
flixopt/effects.py,sha256=iLVC4VdFTtZaF6B8BJiILRwe9ahj93og8JQSaAE_ocI,34063
|
|
9
|
-
flixopt/elements.py,sha256=92SQ3ax57I9VLjhe0-4L6u3jaYDylrKcmuSFGuzneqI,36371
|
|
10
|
-
flixopt/features.py,sha256=kd-fMvADv8GXoKkrXObYjRJLN8toBG-5bOHTuh-59kk,25073
|
|
11
|
-
flixopt/flow_system.py,sha256=D84MIkX5oA_4H55p9mOC7tstV96V5RN2qPeJ2exX1ks,40242
|
|
12
|
-
flixopt/interface.py,sha256=jatkXaYpugm1BsSAIbehfLCY8EgIuSmrUTPCNwidYLY,57798
|
|
13
|
-
flixopt/io.py,sha256=2ZnpoU4gVnKfv-FiwoYEA11wlqbdUU8PXJiofRSKl5M,11795
|
|
14
|
-
flixopt/linear_converters.py,sha256=tcz5c1SI36hRFbCX-4NXced12ss9VETg5BE7zOdyeo4,22699
|
|
15
|
-
flixopt/modeling.py,sha256=s0zipbblq-LJrSe7angKT3Imxgr3kIbprG98HUvmkzI,31322
|
|
16
|
-
flixopt/network_app.py,sha256=LnVAlAgzL1BgMYLsJ20a62j6nQUmNccF1zo4ACUXzL4,29433
|
|
17
|
-
flixopt/plotting.py,sha256=kGN9iD_LQlwESYG7eb6s15YaWRHL1-dLSW-eb0436nM,74553
|
|
18
|
-
flixopt/results.py,sha256=1Mizhn4YZeaA1u1G26tQe-jl4hFFE_HCNqIyzNII_nI,101596
|
|
19
|
-
flixopt/solvers.py,sha256=m38Smc22MJfHYMiqfNf1MA3OmvbTRm5OWS9nECkDdQk,2355
|
|
20
|
-
flixopt/structure.py,sha256=ntLoj--zTnaZwNYKw-WkJTNxY0ef4zDp4S0iiSxyyxE,47707
|
|
21
|
-
flixopt/utils.py,sha256=CtCMBjvq31upz7i-_1nbPnSe-1CoRoOWlPkucwiSo5Q,2930
|
|
22
|
-
flixopt-3.1.0.dist-info/licenses/LICENSE,sha256=HKsZnbrM_3Rvnr_u9cWSG90cBsj5_slaqI_z_qcxnGI,1118
|
|
23
|
-
flixopt-3.1.0.dist-info/METADATA,sha256=xErTi6739EVXchaAdkU9axCI06kuIGjGnH8PHdA6aZ0,12856
|
|
24
|
-
flixopt-3.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
25
|
-
flixopt-3.1.0.dist-info/top_level.txt,sha256=fanTzb9NylIXfv6Ic7spU97fVmRgGDPKvI_91tw4S3E,8
|
|
26
|
-
flixopt-3.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|