pythermodb-settings 0.1.2__tar.gz → 0.1.3__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.
Files changed (24) hide show
  1. {pythermodb_settings-0.1.2/pythermodb_settings.egg-info → pythermodb_settings-0.1.3}/PKG-INFO +1 -1
  2. {pythermodb_settings-0.1.2 → pythermodb_settings-0.1.3}/pyproject.toml +1 -1
  3. {pythermodb_settings-0.1.2 → pythermodb_settings-0.1.3}/pythermodb_settings/configs/about.py +1 -1
  4. pythermodb_settings-0.1.3/pythermodb_settings/utils/__init__.py +12 -0
  5. {pythermodb_settings-0.1.2 → pythermodb_settings-0.1.3}/pythermodb_settings/utils/component_utils.py +82 -0
  6. {pythermodb_settings-0.1.2 → pythermodb_settings-0.1.3/pythermodb_settings.egg-info}/PKG-INFO +1 -1
  7. pythermodb_settings-0.1.2/pythermodb_settings/utils/__init__.py +0 -7
  8. {pythermodb_settings-0.1.2 → pythermodb_settings-0.1.3}/LICENSE +0 -0
  9. {pythermodb_settings-0.1.2 → pythermodb_settings-0.1.3}/README.md +0 -0
  10. {pythermodb_settings-0.1.2 → pythermodb_settings-0.1.3}/pythermodb_settings/__init__.py +0 -0
  11. {pythermodb_settings-0.1.2 → pythermodb_settings-0.1.3}/pythermodb_settings/app.py +0 -0
  12. {pythermodb_settings-0.1.2 → pythermodb_settings-0.1.3}/pythermodb_settings/configs/__init__.py +0 -0
  13. {pythermodb_settings-0.1.2 → pythermodb_settings-0.1.3}/pythermodb_settings/models/__init__.py +0 -0
  14. {pythermodb_settings-0.1.2 → pythermodb_settings-0.1.3}/pythermodb_settings/models/components.py +0 -0
  15. {pythermodb_settings-0.1.2 → pythermodb_settings-0.1.3}/pythermodb_settings/models/conditions.py +0 -0
  16. {pythermodb_settings-0.1.2 → pythermodb_settings-0.1.3}/pythermodb_settings/models/configs.py +0 -0
  17. {pythermodb_settings-0.1.2 → pythermodb_settings-0.1.3}/pythermodb_settings/models/references.py +0 -0
  18. {pythermodb_settings-0.1.2 → pythermodb_settings-0.1.3}/pythermodb_settings/models/rules.py +0 -0
  19. {pythermodb_settings-0.1.2 → pythermodb_settings-0.1.3}/pythermodb_settings/models/source.py +0 -0
  20. {pythermodb_settings-0.1.2 → pythermodb_settings-0.1.3}/pythermodb_settings.egg-info/SOURCES.txt +0 -0
  21. {pythermodb_settings-0.1.2 → pythermodb_settings-0.1.3}/pythermodb_settings.egg-info/dependency_links.txt +0 -0
  22. {pythermodb_settings-0.1.2 → pythermodb_settings-0.1.3}/pythermodb_settings.egg-info/requires.txt +0 -0
  23. {pythermodb_settings-0.1.2 → pythermodb_settings-0.1.3}/pythermodb_settings.egg-info/top_level.txt +0 -0
  24. {pythermodb_settings-0.1.2 → pythermodb_settings-0.1.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythermodb-settings
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: Add your description here
5
5
  Author-email: Sina Gilassi <sina.gilassi@gmail.com>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pythermodb-settings"
7
- version = "0.1.2"
7
+ version = "0.1.3"
8
8
  description = "Add your description here"
9
9
  authors = [
10
10
  { name = "Sina Gilassi", email = "sina.gilassi@gmail.com" }
@@ -1,5 +1,5 @@
1
1
  # NOTE: app info
2
- __version__ = "0.1.2"
2
+ __version__ = "0.1.3"
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"
@@ -0,0 +1,12 @@
1
+ # export
2
+ from .component_utils import (
3
+ create_component_id,
4
+ set_component_id,
5
+ create_binary_mixture_id
6
+ )
7
+
8
+ __all__ = [
9
+ "create_component_id",
10
+ "set_component_id",
11
+ "create_binary_mixture_id",
12
+ ]
@@ -105,3 +105,85 @@ def set_component_id(
105
105
  f"'{component}': {e}"
106
106
  )
107
107
  raise e
108
+
109
+
110
+ def create_binary_mixture_id(
111
+ component_1: Component,
112
+ component_2: Component,
113
+ mixture_key: Literal[
114
+ 'Name', 'Formula'
115
+ ] = 'Name',
116
+ delimiter: str = "|"
117
+ ) -> str:
118
+ """Create a unique binary mixture ID based on two components.
119
+
120
+ Parameters
121
+ ----------
122
+ component1 : Component
123
+ The first component in the mixture.
124
+ component2 : Component
125
+ The second component in the mixture.
126
+ component_key : Literal['Name', 'Formula'], optional
127
+ The key to use for identifying the components, by default 'Name'.
128
+ delimiter : str, optional
129
+ Delimiter to separate the two components in the ID, by default "|".
130
+
131
+ Returns
132
+ -------
133
+ str
134
+ A unique binary mixture ID.
135
+
136
+ Raises
137
+ ------
138
+ ValueError
139
+ If the component_key is not recognized.
140
+
141
+ Examples
142
+ --------
143
+ The following example creates a binary mixture ID for water and ethanol
144
+ using their names:
145
+
146
+ >>> comp1 = Component(name="Water", formula="H2O", state="l")
147
+ >>> comp2 = Component(name="Ethanol", formula="C2H5OH", state="l")
148
+ >>> create_binary_mixture_id(comp1, comp2, mixture_key='Name')
149
+ 'Ethanol|Water'
150
+ """
151
+ try:
152
+ # SECTION: validate inputs
153
+ # NOTE: component
154
+ if (
155
+ not isinstance(component_1, Component) or
156
+ not isinstance(component_2, Component)
157
+ ):
158
+ raise TypeError(
159
+ "Both component1 and component2 must be instances of Component"
160
+ )
161
+
162
+ # NOTE: delimiter
163
+ if not isinstance(delimiter, str):
164
+ raise TypeError("delimiter must be a string")
165
+ # strip delimiter
166
+ delimiter = delimiter.strip()
167
+
168
+ # SECTION: get component IDs
169
+ if mixture_key == 'Name':
170
+ comp1_id = component_1.name.strip()
171
+ comp2_id = component_2.name.strip()
172
+ elif mixture_key == 'Formula':
173
+ comp1_id = component_1.formula.strip()
174
+ comp2_id = component_2.formula.strip()
175
+ else:
176
+ raise ValueError(
177
+ "component_key must be either 'Name' or 'Formula'"
178
+ )
179
+
180
+ # SECTION: create unique mixture ID (sorted to ensure uniqueness)
181
+ mixture_id = delimiter.join(sorted([comp1_id, comp2_id]))
182
+ # strip
183
+ mixture_id = mixture_id.strip()
184
+
185
+ # return
186
+ return mixture_id
187
+ except Exception as e:
188
+ logging.error(f"Error in create_binary_mixture_id: {e}")
189
+ raise
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythermodb-settings
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: Add your description here
5
5
  Author-email: Sina Gilassi <sina.gilassi@gmail.com>
6
6
  License-Expression: MIT
@@ -1,7 +0,0 @@
1
- # export
2
- from .component_utils import create_component_id, set_component_id
3
-
4
- __all__ = [
5
- "create_component_id",
6
- "set_component_id"
7
- ]