pythermodb-settings 0.1.6__tar.gz → 0.1.8__tar.gz
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.
- {pythermodb_settings-0.1.6/pythermodb_settings.egg-info → pythermodb_settings-0.1.8}/PKG-INFO +1 -1
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pyproject.toml +36 -36
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/configs/about.py +1 -1
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/utils/__init__.py +3 -1
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/utils/component_utils.py +128 -4
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8/pythermodb_settings.egg-info}/PKG-INFO +1 -1
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/LICENSE +0 -0
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/README.md +0 -0
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/__init__.py +0 -0
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/app.py +0 -0
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/configs/__init__.py +0 -0
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/models/__init__.py +0 -0
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/models/components.py +0 -0
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/models/conditions.py +0 -0
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/models/configs.py +0 -0
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/models/references.py +0 -0
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/models/rules.py +0 -0
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/models/source.py +0 -0
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings.egg-info/SOURCES.txt +0 -0
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings.egg-info/dependency_links.txt +0 -0
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings.egg-info/requires.txt +0 -0
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings.egg-info/top_level.txt +0 -0
- {pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/setup.cfg +0 -0
@@ -1,36 +1,36 @@
|
|
1
|
-
[build-system]
|
2
|
-
requires = ["setuptools>=61.0", "wheel"]
|
3
|
-
build-backend = "setuptools.build_meta"
|
4
|
-
|
5
|
-
[project]
|
6
|
-
name = "pythermodb-settings"
|
7
|
-
version = "0.1.
|
8
|
-
description = "Add your description here"
|
9
|
-
authors = [
|
10
|
-
{ name = "Sina Gilassi", email = "sina.gilassi@gmail.com" }
|
11
|
-
]
|
12
|
-
license = "MIT"
|
13
|
-
license-files = ["LICENSE"]
|
14
|
-
readme = "README.md"
|
15
|
-
requires-python = ">=3.11"
|
16
|
-
classifiers = [
|
17
|
-
"Programming Language :: Python :: 3.11",
|
18
|
-
"Operating System :: OS Independent",
|
19
|
-
]
|
20
|
-
|
21
|
-
dependencies = [
|
22
|
-
"pydantic>=2.11.7",
|
23
|
-
"pydantic-settings>=2.10.1",
|
24
|
-
]
|
25
|
-
|
26
|
-
[project.urls]
|
27
|
-
"Homepage" = "https://github.com/sinagilassi/PyThermoDB-Settings"
|
28
|
-
"Tracker" = "https://github.com/sinagilassi/PyThermoDB-Settings/issues"
|
29
|
-
|
30
|
-
[tool.setuptools.packages.find]
|
31
|
-
where = ["."]
|
32
|
-
include = ["pythermodb_settings*"]
|
33
|
-
exclude = ["tests*", "examples*", "docs*"]
|
34
|
-
|
35
|
-
[tool.setuptools.package-data]
|
36
|
-
"pythermodb_settings" = ["data/**/*"]
|
1
|
+
[build-system]
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
3
|
+
build-backend = "setuptools.build_meta"
|
4
|
+
|
5
|
+
[project]
|
6
|
+
name = "pythermodb-settings"
|
7
|
+
version = "0.1.8"
|
8
|
+
description = "Add your description here"
|
9
|
+
authors = [
|
10
|
+
{ name = "Sina Gilassi", email = "sina.gilassi@gmail.com" }
|
11
|
+
]
|
12
|
+
license = "MIT"
|
13
|
+
license-files = ["LICENSE"]
|
14
|
+
readme = "README.md"
|
15
|
+
requires-python = ">=3.11"
|
16
|
+
classifiers = [
|
17
|
+
"Programming Language :: Python :: 3.11",
|
18
|
+
"Operating System :: OS Independent",
|
19
|
+
]
|
20
|
+
|
21
|
+
dependencies = [
|
22
|
+
"pydantic>=2.11.7",
|
23
|
+
"pydantic-settings>=2.10.1",
|
24
|
+
]
|
25
|
+
|
26
|
+
[project.urls]
|
27
|
+
"Homepage" = "https://github.com/sinagilassi/PyThermoDB-Settings"
|
28
|
+
"Tracker" = "https://github.com/sinagilassi/PyThermoDB-Settings/issues"
|
29
|
+
|
30
|
+
[tool.setuptools.packages.find]
|
31
|
+
where = ["."]
|
32
|
+
include = ["pythermodb_settings*"]
|
33
|
+
exclude = ["tests*", "examples*", "docs*"]
|
34
|
+
|
35
|
+
[tool.setuptools.package-data]
|
36
|
+
"pythermodb_settings" = ["data/**/*"]
|
{pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/configs/about.py
RENAMED
@@ -1,5 +1,5 @@
|
|
1
1
|
# NOTE: app info
|
2
|
-
__version__ = "0.1.
|
2
|
+
__version__ = "0.1.8"
|
3
3
|
__description__ = """PyThermoDB Settings is a Python package that acts as an interface between pythermdb and other applications, providing robust, Pydantic-based data models and configuration structures for managing thermodynamic database (ThermoDB) settings."""
|
4
4
|
__author__ = "Sina Gilassi"
|
5
5
|
__author_email__ = "sina.gilassi@gmail.com"
|
{pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/utils/__init__.py
RENAMED
@@ -2,11 +2,13 @@
|
|
2
2
|
from .component_utils import (
|
3
3
|
create_component_id,
|
4
4
|
set_component_id,
|
5
|
-
create_binary_mixture_id
|
5
|
+
create_binary_mixture_id,
|
6
|
+
create_mixture_id
|
6
7
|
)
|
7
8
|
|
8
9
|
__all__ = [
|
9
10
|
"create_component_id",
|
10
11
|
"set_component_id",
|
11
12
|
"create_binary_mixture_id",
|
13
|
+
"create_mixture_id"
|
12
14
|
]
|
{pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/utils/component_utils.py
RENAMED
@@ -57,9 +57,15 @@ def create_component_id(
|
|
57
57
|
def set_component_id(
|
58
58
|
component: Component,
|
59
59
|
component_key: Literal[
|
60
|
-
'Name-State',
|
60
|
+
'Name-State',
|
61
|
+
'Formula-State',
|
62
|
+
'Name',
|
63
|
+
'Formula',
|
64
|
+
'Name-Formula-State',
|
65
|
+
'Formula-Name-State'
|
61
66
|
],
|
62
67
|
separator_symbol: str = '-',
|
68
|
+
case: Literal['lower', 'upper', None] = None
|
63
69
|
) -> str:
|
64
70
|
'''
|
65
71
|
Set component identifier based on the specified key.
|
@@ -73,9 +79,15 @@ def set_component_id(
|
|
73
79
|
Options are:
|
74
80
|
- 'Name-State': Use the name-state identifier.
|
75
81
|
- 'Formula-State': Use the formula-state identifier.
|
82
|
+
- 'Name': Use the component name.
|
83
|
+
- 'Formula': Use the component formula.
|
84
|
+
- 'Name-Formula-State': Use the name, formula, and state.
|
85
|
+
- 'Formula-Name-State': Use the formula, name, and state.
|
76
86
|
separator_symbol : str, optional
|
77
87
|
The symbol to use as a separator between the name/formula and state.
|
78
88
|
Default is '-'.
|
89
|
+
case : Literal['lower', 'upper', None], optional
|
90
|
+
Convert the identifier to lower or upper case.
|
79
91
|
|
80
92
|
Returns
|
81
93
|
-------
|
@@ -89,16 +101,43 @@ def set_component_id(
|
|
89
101
|
separator_symbol=separator_symbol
|
90
102
|
)
|
91
103
|
|
92
|
-
#
|
104
|
+
# init component id
|
105
|
+
component_id: str = ""
|
106
|
+
|
107
|
+
# NOTE: set component id
|
93
108
|
if component_key == "Name-State":
|
94
|
-
|
109
|
+
component_id = component_idx.name_state.strip()
|
95
110
|
elif component_key == "Formula-State":
|
96
|
-
|
111
|
+
component_id = component_idx.formula_state.strip()
|
112
|
+
elif component_key == "Name":
|
113
|
+
component_id = component.name.strip()
|
114
|
+
elif component_key == "Formula":
|
115
|
+
component_id = component.formula.strip()
|
116
|
+
elif component_key == "Name-Formula-State":
|
117
|
+
component_id = f"{component.name.strip()}{separator_symbol}{component.formula.strip()}{separator_symbol}{component.state.strip().lower()}"
|
118
|
+
elif component_key == "Formula-Name-State":
|
119
|
+
component_id = f"{component.formula.strip()}{separator_symbol}{component.name.strip()}{separator_symbol}{component.state.strip().lower()}"
|
97
120
|
else:
|
98
121
|
raise ValueError(
|
99
122
|
f"Invalid component_key '{component_key}'. "
|
100
123
|
f"Must be 'Name-State' or 'Formula-State'."
|
101
124
|
)
|
125
|
+
|
126
|
+
# NOTE: apply conversion
|
127
|
+
if case == 'lower':
|
128
|
+
component_id = component_id.lower()
|
129
|
+
elif case == 'upper':
|
130
|
+
component_id = component_id.upper()
|
131
|
+
elif case is None:
|
132
|
+
pass
|
133
|
+
else:
|
134
|
+
raise ValueError(
|
135
|
+
f"Invalid case '{case}'. "
|
136
|
+
f"Must be 'lower', 'upper', or None."
|
137
|
+
)
|
138
|
+
|
139
|
+
# result
|
140
|
+
return component_id
|
102
141
|
except Exception as e:
|
103
142
|
logger.error(
|
104
143
|
f"Failed to set component identifier for "
|
@@ -187,3 +226,88 @@ def create_binary_mixture_id(
|
|
187
226
|
except Exception as e:
|
188
227
|
logging.error(f"Error in create_binary_mixture_id: {e}")
|
189
228
|
raise
|
229
|
+
|
230
|
+
|
231
|
+
def create_mixture_id(
|
232
|
+
components: list[Component],
|
233
|
+
mixture_key: Literal[
|
234
|
+
'Name', 'Formula', 'Name-State', 'Formula-State',
|
235
|
+
] = 'Name',
|
236
|
+
delimiter: str = "|"
|
237
|
+
) -> str:
|
238
|
+
"""Create a unique mixture ID based on a list of components (sorted alphabetically).
|
239
|
+
|
240
|
+
Parameters
|
241
|
+
----------
|
242
|
+
components : list[Component]
|
243
|
+
List of components in the mixture.
|
244
|
+
component_key : Literal['Name', 'Formula', 'Name-State', 'Formula-State'], optional
|
245
|
+
The key to use for identifying the components, by default 'Name'.
|
246
|
+
delimiter : str, optional
|
247
|
+
Delimiter to separate the components in the ID, by default "|".
|
248
|
+
|
249
|
+
Returns
|
250
|
+
-------
|
251
|
+
str
|
252
|
+
A unique mixture ID.
|
253
|
+
|
254
|
+
Raises
|
255
|
+
------
|
256
|
+
ValueError
|
257
|
+
If the component_key is not recognized.
|
258
|
+
|
259
|
+
Examples
|
260
|
+
--------
|
261
|
+
The following example creates a mixture ID for water, ethanol, and methanol
|
262
|
+
using their names:
|
263
|
+
|
264
|
+
>>> comp1 = Component(name="Water", formula="H2O", state="l")
|
265
|
+
>>> comp2 = Component(name="Ethanol", formula="C2H5OH", state="l")
|
266
|
+
>>> comp3 = Component(name="Methanol", formula="CH3OH", state="l")
|
267
|
+
>>> create_mixture_id([comp1, comp2, comp3], mixture_key='Name')
|
268
|
+
'Ethanol|Methanol|Water'
|
269
|
+
"""
|
270
|
+
try:
|
271
|
+
# SECTION: validate inputs
|
272
|
+
# NOTE: components
|
273
|
+
if not all(isinstance(comp, Component) for comp in components):
|
274
|
+
raise TypeError(
|
275
|
+
"All items in components must be instances of Component"
|
276
|
+
)
|
277
|
+
if len(components) == 0:
|
278
|
+
raise ValueError("components list cannot be empty")
|
279
|
+
|
280
|
+
# NOTE: delimiter
|
281
|
+
if not isinstance(delimiter, str):
|
282
|
+
raise TypeError("delimiter must be a string")
|
283
|
+
# strip delimiter
|
284
|
+
delimiter = delimiter.strip()
|
285
|
+
|
286
|
+
# SECTION: get component IDs
|
287
|
+
component_ids = []
|
288
|
+
for comp in components:
|
289
|
+
if mixture_key == 'Name':
|
290
|
+
comp_id = comp.name.strip().lower()
|
291
|
+
elif mixture_key == 'Formula':
|
292
|
+
comp_id = comp.formula.strip().lower()
|
293
|
+
elif mixture_key == 'Name-State':
|
294
|
+
comp_id = f"{comp.name.strip().lower()}-{comp.state.strip().lower()}"
|
295
|
+
elif mixture_key == 'Formula-State':
|
296
|
+
comp_id = f"{comp.formula.strip().lower()}-{comp.state.strip().lower()}"
|
297
|
+
else:
|
298
|
+
raise ValueError(
|
299
|
+
"component_key must be either 'Name' or 'Formula'"
|
300
|
+
)
|
301
|
+
component_ids.append(comp_id)
|
302
|
+
|
303
|
+
# SECTION: create unique mixture ID (sorted to ensure uniqueness)
|
304
|
+
mixture_id = delimiter.join(sorted(component_ids))
|
305
|
+
|
306
|
+
# strip
|
307
|
+
mixture_id = mixture_id.strip()
|
308
|
+
|
309
|
+
# return
|
310
|
+
return mixture_id
|
311
|
+
except Exception as e:
|
312
|
+
logging.error(f"Error in create_mixture_id: {e}")
|
313
|
+
raise
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/configs/__init__.py
RENAMED
File without changes
|
{pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/models/__init__.py
RENAMED
File without changes
|
{pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/models/components.py
RENAMED
File without changes
|
{pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/models/conditions.py
RENAMED
File without changes
|
{pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/models/configs.py
RENAMED
File without changes
|
{pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/models/references.py
RENAMED
File without changes
|
File without changes
|
{pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings/models/source.py
RENAMED
File without changes
|
{pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings.egg-info/SOURCES.txt
RENAMED
File without changes
|
File without changes
|
{pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings.egg-info/requires.txt
RENAMED
File without changes
|
{pythermodb_settings-0.1.6 → pythermodb_settings-0.1.8}/pythermodb_settings.egg-info/top_level.txt
RENAMED
File without changes
|
File without changes
|