pythermodb-settings 0.1.5__tar.gz → 0.1.7__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.5/pythermodb_settings.egg-info → pythermodb_settings-0.1.7}/PKG-INFO +1 -1
- {pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pyproject.toml +36 -36
- {pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings/configs/about.py +1 -1
- {pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings/models/__init__.py +3 -2
- pythermodb_settings-0.1.7/pythermodb_settings/models/source.py +59 -0
- {pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings/utils/__init__.py +3 -1
- {pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings/utils/component_utils.py +85 -0
- {pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7/pythermodb_settings.egg-info}/PKG-INFO +1 -1
- pythermodb_settings-0.1.5/pythermodb_settings/models/source.py +0 -28
- {pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/LICENSE +0 -0
- {pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/README.md +0 -0
- {pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings/__init__.py +0 -0
- {pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings/app.py +0 -0
- {pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings/configs/__init__.py +0 -0
- {pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings/models/components.py +0 -0
- {pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings/models/conditions.py +0 -0
- {pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings/models/configs.py +0 -0
- {pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings/models/references.py +0 -0
- {pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings/models/rules.py +0 -0
- {pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings.egg-info/SOURCES.txt +0 -0
- {pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings.egg-info/dependency_links.txt +0 -0
- {pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings.egg-info/requires.txt +0 -0
- {pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings.egg-info/top_level.txt +0 -0
- {pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/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.7"
|
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.5 → pythermodb_settings-0.1.7}/pythermodb_settings/configs/about.py
RENAMED
@@ -1,5 +1,5 @@
|
|
1
1
|
# NOTE: app info
|
2
|
-
__version__ = "0.1.
|
2
|
+
__version__ = "0.1.7"
|
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.5 → pythermodb_settings-0.1.7}/pythermodb_settings/models/__init__.py
RENAMED
@@ -10,7 +10,7 @@ from .references import (
|
|
10
10
|
MixtureReferenceThermoDB
|
11
11
|
)
|
12
12
|
from .rules import ComponentRule
|
13
|
-
from .source import ComponentThermoDBSource
|
13
|
+
from .source import ComponentThermoDBSource, MixtureThermoDBSource
|
14
14
|
|
15
15
|
__all__ = [
|
16
16
|
"Component",
|
@@ -24,5 +24,6 @@ __all__ = [
|
|
24
24
|
"CustomReference",
|
25
25
|
"MixtureReferenceThermoDB",
|
26
26
|
"ComponentRule",
|
27
|
-
"ComponentThermoDBSource"
|
27
|
+
"ComponentThermoDBSource",
|
28
|
+
"MixtureThermoDBSource"
|
28
29
|
]
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# import libs
|
2
|
+
from pydantic import (
|
3
|
+
BaseModel,
|
4
|
+
Field,
|
5
|
+
ConfigDict
|
6
|
+
)
|
7
|
+
# local
|
8
|
+
from .components import Component
|
9
|
+
|
10
|
+
|
11
|
+
class ComponentThermoDBSource(BaseModel):
|
12
|
+
'''
|
13
|
+
ThermoDB source containing `component` thermodb.
|
14
|
+
|
15
|
+
Attributes
|
16
|
+
----------
|
17
|
+
component: Component
|
18
|
+
Component thermodb
|
19
|
+
source: str
|
20
|
+
Path to the thermodb file
|
21
|
+
'''
|
22
|
+
component: Component = Field(
|
23
|
+
..., description="Component object containing name, formula, and state"
|
24
|
+
)
|
25
|
+
source: str = Field(
|
26
|
+
...,
|
27
|
+
description="Path to the thermodb file"
|
28
|
+
)
|
29
|
+
|
30
|
+
model_config = ConfigDict(
|
31
|
+
arbitrary_types_allowed=True,
|
32
|
+
extra="allow"
|
33
|
+
)
|
34
|
+
|
35
|
+
|
36
|
+
class MixtureThermoDBSource(BaseModel):
|
37
|
+
'''
|
38
|
+
ThermoDB source containing `mixture` thermodb.
|
39
|
+
|
40
|
+
Attributes
|
41
|
+
----------
|
42
|
+
components: list[Component]
|
43
|
+
List of components in the mixture thermodb
|
44
|
+
source: str
|
45
|
+
Path to the thermodb file
|
46
|
+
'''
|
47
|
+
components: list[Component] = Field(
|
48
|
+
...,
|
49
|
+
description="List of components in the mixture thermodb"
|
50
|
+
)
|
51
|
+
source: str = Field(
|
52
|
+
...,
|
53
|
+
description="Path to the thermodb file"
|
54
|
+
)
|
55
|
+
|
56
|
+
model_config = ConfigDict(
|
57
|
+
arbitrary_types_allowed=True,
|
58
|
+
extra="allow"
|
59
|
+
)
|
{pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/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.5 → pythermodb_settings-0.1.7}/pythermodb_settings/utils/component_utils.py
RENAMED
@@ -187,3 +187,88 @@ def create_binary_mixture_id(
|
|
187
187
|
except Exception as e:
|
188
188
|
logging.error(f"Error in create_binary_mixture_id: {e}")
|
189
189
|
raise
|
190
|
+
|
191
|
+
|
192
|
+
def create_mixture_id(
|
193
|
+
components: list[Component],
|
194
|
+
mixture_key: Literal[
|
195
|
+
'Name', 'Formula', 'Name-State', 'Formula-State',
|
196
|
+
] = 'Name',
|
197
|
+
delimiter: str = "|"
|
198
|
+
) -> str:
|
199
|
+
"""Create a unique mixture ID based on a list of components (sorted alphabetically).
|
200
|
+
|
201
|
+
Parameters
|
202
|
+
----------
|
203
|
+
components : list[Component]
|
204
|
+
List of components in the mixture.
|
205
|
+
component_key : Literal['Name', 'Formula'], optional
|
206
|
+
The key to use for identifying the components, by default 'Name'.
|
207
|
+
delimiter : str, optional
|
208
|
+
Delimiter to separate the components in the ID, by default "|".
|
209
|
+
|
210
|
+
Returns
|
211
|
+
-------
|
212
|
+
str
|
213
|
+
A unique mixture ID.
|
214
|
+
|
215
|
+
Raises
|
216
|
+
------
|
217
|
+
ValueError
|
218
|
+
If the component_key is not recognized.
|
219
|
+
|
220
|
+
Examples
|
221
|
+
--------
|
222
|
+
The following example creates a mixture ID for water, ethanol, and methanol
|
223
|
+
using their names:
|
224
|
+
|
225
|
+
>>> comp1 = Component(name="Water", formula="H2O", state="l")
|
226
|
+
>>> comp2 = Component(name="Ethanol", formula="C2H5OH", state="l")
|
227
|
+
>>> comp3 = Component(name="Methanol", formula="CH3OH", state="l")
|
228
|
+
>>> create_mixture_id([comp1, comp2, comp3], mixture_key='Name')
|
229
|
+
'Ethanol|Methanol|Water'
|
230
|
+
"""
|
231
|
+
try:
|
232
|
+
# SECTION: validate inputs
|
233
|
+
# NOTE: components
|
234
|
+
if not all(isinstance(comp, Component) for comp in components):
|
235
|
+
raise TypeError(
|
236
|
+
"All items in components must be instances of Component"
|
237
|
+
)
|
238
|
+
if len(components) == 0:
|
239
|
+
raise ValueError("components list cannot be empty")
|
240
|
+
|
241
|
+
# NOTE: delimiter
|
242
|
+
if not isinstance(delimiter, str):
|
243
|
+
raise TypeError("delimiter must be a string")
|
244
|
+
# strip delimiter
|
245
|
+
delimiter = delimiter.strip()
|
246
|
+
|
247
|
+
# SECTION: get component IDs
|
248
|
+
component_ids = []
|
249
|
+
for comp in components:
|
250
|
+
if mixture_key == 'Name':
|
251
|
+
comp_id = comp.name.strip().lower()
|
252
|
+
elif mixture_key == 'Formula':
|
253
|
+
comp_id = comp.formula.strip().lower()
|
254
|
+
elif mixture_key == 'Name-State':
|
255
|
+
comp_id = f"{comp.name.strip().lower()}-{comp.state.strip().lower()}"
|
256
|
+
elif mixture_key == 'Formula-State':
|
257
|
+
comp_id = f"{comp.formula.strip().lower()}-{comp.state.strip().lower()}"
|
258
|
+
else:
|
259
|
+
raise ValueError(
|
260
|
+
"component_key must be either 'Name' or 'Formula'"
|
261
|
+
)
|
262
|
+
component_ids.append(comp_id)
|
263
|
+
|
264
|
+
# SECTION: create unique mixture ID (sorted to ensure uniqueness)
|
265
|
+
mixture_id = delimiter.join(sorted(component_ids))
|
266
|
+
|
267
|
+
# strip
|
268
|
+
mixture_id = mixture_id.strip()
|
269
|
+
|
270
|
+
# return
|
271
|
+
return mixture_id
|
272
|
+
except Exception as e:
|
273
|
+
logging.error(f"Error in create_mixture_id: {e}")
|
274
|
+
raise
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# import libs
|
2
|
-
from pydantic import (
|
3
|
-
BaseModel,
|
4
|
-
Field,
|
5
|
-
ConfigDict
|
6
|
-
)
|
7
|
-
# local
|
8
|
-
from .components import Component
|
9
|
-
|
10
|
-
|
11
|
-
class ComponentThermoDBSource(BaseModel):
|
12
|
-
'''
|
13
|
-
ThermoDB source containing component thermodb.
|
14
|
-
|
15
|
-
Attributes
|
16
|
-
----------
|
17
|
-
component: Component
|
18
|
-
Component thermodb
|
19
|
-
source: str
|
20
|
-
Path to the thermodb file
|
21
|
-
'''
|
22
|
-
component: Component
|
23
|
-
source: str
|
24
|
-
|
25
|
-
model_config = ConfigDict(
|
26
|
-
arbitrary_types_allowed=True,
|
27
|
-
extra="allow"
|
28
|
-
)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings/configs/__init__.py
RENAMED
File without changes
|
{pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings/models/components.py
RENAMED
File without changes
|
{pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings/models/conditions.py
RENAMED
File without changes
|
{pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings/models/configs.py
RENAMED
File without changes
|
{pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings/models/references.py
RENAMED
File without changes
|
File without changes
|
{pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings.egg-info/SOURCES.txt
RENAMED
File without changes
|
File without changes
|
{pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings.egg-info/requires.txt
RENAMED
File without changes
|
{pythermodb_settings-0.1.5 → pythermodb_settings-0.1.7}/pythermodb_settings.egg-info/top_level.txt
RENAMED
File without changes
|
File without changes
|