pythermodb-settings 0.1.8__py3-none-any.whl → 0.1.9__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.
- pythermodb_settings/configs/about.py +1 -1
- pythermodb_settings/utils/component_utils.py +29 -8
- {pythermodb_settings-0.1.8.dist-info → pythermodb_settings-0.1.9.dist-info}/METADATA +1 -1
- {pythermodb_settings-0.1.8.dist-info → pythermodb_settings-0.1.9.dist-info}/RECORD +7 -7
- {pythermodb_settings-0.1.8.dist-info → pythermodb_settings-0.1.9.dist-info}/WHEEL +0 -0
- {pythermodb_settings-0.1.8.dist-info → pythermodb_settings-0.1.9.dist-info}/licenses/LICENSE +0 -0
- {pythermodb_settings-0.1.8.dist-info → pythermodb_settings-0.1.9.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
# NOTE: app info
|
2
|
-
__version__ = "0.1.
|
2
|
+
__version__ = "0.1.9"
|
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"
|
@@ -231,9 +231,15 @@ def create_binary_mixture_id(
|
|
231
231
|
def create_mixture_id(
|
232
232
|
components: list[Component],
|
233
233
|
mixture_key: Literal[
|
234
|
-
'Name',
|
234
|
+
'Name',
|
235
|
+
'Formula',
|
236
|
+
'Name-State',
|
237
|
+
'Formula-State',
|
238
|
+
'Name-Formula-State',
|
239
|
+
'Formula-Name-State'
|
235
240
|
] = 'Name',
|
236
|
-
delimiter: str = "|"
|
241
|
+
delimiter: str = "|",
|
242
|
+
case: Literal['lower', 'upper', None] = None
|
237
243
|
) -> str:
|
238
244
|
"""Create a unique mixture ID based on a list of components (sorted alphabetically).
|
239
245
|
|
@@ -241,10 +247,12 @@ def create_mixture_id(
|
|
241
247
|
----------
|
242
248
|
components : list[Component]
|
243
249
|
List of components in the mixture.
|
244
|
-
component_key : Literal['Name', 'Formula', 'Name-State', 'Formula-State'], optional
|
250
|
+
component_key : Literal['Name', 'Formula', 'Name-State', 'Formula-State', 'Name-Formula-State', 'Formula-Name-State'], optional
|
245
251
|
The key to use for identifying the components, by default 'Name'.
|
246
252
|
delimiter : str, optional
|
247
253
|
Delimiter to separate the components in the ID, by default "|".
|
254
|
+
case : Literal['lower', 'upper', None], optional
|
255
|
+
Convert the identifier to lower or upper case, by default 'lower'.
|
248
256
|
|
249
257
|
Returns
|
250
258
|
-------
|
@@ -287,25 +295,38 @@ def create_mixture_id(
|
|
287
295
|
component_ids = []
|
288
296
|
for comp in components:
|
289
297
|
if mixture_key == 'Name':
|
290
|
-
comp_id = comp.name.strip()
|
298
|
+
comp_id = comp.name.strip()
|
291
299
|
elif mixture_key == 'Formula':
|
292
|
-
comp_id = comp.formula.strip()
|
300
|
+
comp_id = comp.formula.strip()
|
293
301
|
elif mixture_key == 'Name-State':
|
294
|
-
comp_id = f"{comp.name.strip()
|
302
|
+
comp_id = f"{comp.name.strip()}-{comp.state.strip()}"
|
295
303
|
elif mixture_key == 'Formula-State':
|
296
|
-
comp_id = f"{comp.formula.strip()
|
304
|
+
comp_id = f"{comp.formula.strip()}-{comp.state.strip()}"
|
305
|
+
elif mixture_key == 'Name-Formula-State':
|
306
|
+
comp_id = f"{comp.name.strip()}-{comp.formula.strip()}-{comp.state.strip()}"
|
307
|
+
elif mixture_key == 'Formula-Name-State':
|
308
|
+
comp_id = f"{comp.formula.strip()}-{comp.name.strip()}-{comp.state.strip()}"
|
297
309
|
else:
|
298
310
|
raise ValueError(
|
299
|
-
"component_key must be
|
311
|
+
"component_key must be one of the following: Name, Formula, Name-State, Formula-State, Name-Formula-State, Formula-Name-State"
|
300
312
|
)
|
301
313
|
component_ids.append(comp_id)
|
302
314
|
|
303
315
|
# SECTION: create unique mixture ID (sorted to ensure uniqueness)
|
316
|
+
# ! sorted alphabetically
|
304
317
|
mixture_id = delimiter.join(sorted(component_ids))
|
305
318
|
|
306
319
|
# strip
|
307
320
|
mixture_id = mixture_id.strip()
|
308
321
|
|
322
|
+
# NOTE: apply conversion
|
323
|
+
if case == 'lower':
|
324
|
+
mixture_id = mixture_id.lower()
|
325
|
+
elif case == 'upper':
|
326
|
+
mixture_id = mixture_id.upper()
|
327
|
+
elif case is None:
|
328
|
+
pass
|
329
|
+
|
309
330
|
# return
|
310
331
|
return mixture_id
|
311
332
|
except Exception as e:
|
@@ -1,7 +1,7 @@
|
|
1
1
|
pythermodb_settings/__init__.py,sha256=VzJSYgJJNw_j5NmnIbq0pJhBd_9Kp-bbfOsRLepplSw,229
|
2
2
|
pythermodb_settings/app.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
pythermodb_settings/configs/__init__.py,sha256=QR38PBCzgoFwYqcViR9bFT2YIR5m9s7q8C7cV4fZjz4,211
|
4
|
-
pythermodb_settings/configs/about.py,sha256=
|
4
|
+
pythermodb_settings/configs/about.py,sha256=4ztRhYUuPC_hC5TgOIXZ2Rbr05AQrg69VbHRG25jT5s,379
|
5
5
|
pythermodb_settings/models/__init__.py,sha256=4qi2Gut42auzeEpK4Gw0UkbALYlQ-kLnes0blSu_UFs,766
|
6
6
|
pythermodb_settings/models/components.py,sha256=4CwZcGpbm1PiEBQUpEmo6T6mP4y3S3LIiHCM0y9C7XU,1674
|
7
7
|
pythermodb_settings/models/conditions.py,sha256=Zm5JcM2kyMlS6b8hPbs6awa_6ps3xFoCVA4zwNPc5eg,1083
|
@@ -10,9 +10,9 @@ pythermodb_settings/models/references.py,sha256=A27Y-7L8X-g2m-pxuDk0ateFScPE1MME
|
|
10
10
|
pythermodb_settings/models/rules.py,sha256=1a9CyTHwpQkZQXFJWDMrEcKQAOTOwquepoOQPGznTlc,74
|
11
11
|
pythermodb_settings/models/source.py,sha256=0yU21YpYSqnew8rjTrlRuoWAuSAlUvMOebC5X0Sr8X4,1325
|
12
12
|
pythermodb_settings/utils/__init__.py,sha256=j3MYKYv7nx5u356J82cacKBzC-CBUJ8GPI4J3c5ss_U,277
|
13
|
-
pythermodb_settings/utils/component_utils.py,sha256=
|
14
|
-
pythermodb_settings-0.1.
|
15
|
-
pythermodb_settings-0.1.
|
16
|
-
pythermodb_settings-0.1.
|
17
|
-
pythermodb_settings-0.1.
|
18
|
-
pythermodb_settings-0.1.
|
13
|
+
pythermodb_settings/utils/component_utils.py,sha256=T8xKuYRiqHEWfHNAcEXPI-l6nTCYkX0pU_FehRVOYcA,11268
|
14
|
+
pythermodb_settings-0.1.9.dist-info/licenses/LICENSE,sha256=pHRAx3wjVKpt2ec3NyhntY6_bGgJqV2SyE8xNUJ7MYE,1090
|
15
|
+
pythermodb_settings-0.1.9.dist-info/METADATA,sha256=AudDdrfkg66Q9FDZ160J4Bc-ETgsIZY6Ea1-M-53hN8,4894
|
16
|
+
pythermodb_settings-0.1.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
17
|
+
pythermodb_settings-0.1.9.dist-info/top_level.txt,sha256=6IdVIbW__wHFsKQYx7DDnXArm10qiJVIyaoSEFQylK4,20
|
18
|
+
pythermodb_settings-0.1.9.dist-info/RECORD,,
|
File without changes
|
{pythermodb_settings-0.1.8.dist-info → pythermodb_settings-0.1.9.dist-info}/licenses/LICENSE
RENAMED
File without changes
|
File without changes
|