pythermodb-settings 0.1.7__tar.gz → 0.1.9__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 (23) hide show
  1. {pythermodb_settings-0.1.7/pythermodb_settings.egg-info → pythermodb_settings-0.1.9}/PKG-INFO +1 -1
  2. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9}/pyproject.toml +1 -1
  3. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9}/pythermodb_settings/configs/about.py +1 -1
  4. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9}/pythermodb_settings/utils/component_utils.py +72 -12
  5. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9/pythermodb_settings.egg-info}/PKG-INFO +1 -1
  6. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9}/LICENSE +0 -0
  7. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9}/README.md +0 -0
  8. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9}/pythermodb_settings/__init__.py +0 -0
  9. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9}/pythermodb_settings/app.py +0 -0
  10. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9}/pythermodb_settings/configs/__init__.py +0 -0
  11. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9}/pythermodb_settings/models/__init__.py +0 -0
  12. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9}/pythermodb_settings/models/components.py +0 -0
  13. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9}/pythermodb_settings/models/conditions.py +0 -0
  14. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9}/pythermodb_settings/models/configs.py +0 -0
  15. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9}/pythermodb_settings/models/references.py +0 -0
  16. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9}/pythermodb_settings/models/rules.py +0 -0
  17. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9}/pythermodb_settings/models/source.py +0 -0
  18. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9}/pythermodb_settings/utils/__init__.py +0 -0
  19. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9}/pythermodb_settings.egg-info/SOURCES.txt +0 -0
  20. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9}/pythermodb_settings.egg-info/dependency_links.txt +0 -0
  21. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9}/pythermodb_settings.egg-info/requires.txt +0 -0
  22. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9}/pythermodb_settings.egg-info/top_level.txt +0 -0
  23. {pythermodb_settings-0.1.7 → pythermodb_settings-0.1.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythermodb-settings
3
- Version: 0.1.7
3
+ Version: 0.1.9
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.7"
7
+ version = "0.1.9"
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.7"
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"
@@ -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', 'Formula-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
- # set component id
104
+ # init component id
105
+ component_id: str = ""
106
+
107
+ # NOTE: set component id
93
108
  if component_key == "Name-State":
94
- return component_idx.name_state
109
+ component_id = component_idx.name_state.strip()
95
110
  elif component_key == "Formula-State":
96
- return component_idx.formula_state
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 "
@@ -192,9 +231,15 @@ def create_binary_mixture_id(
192
231
  def create_mixture_id(
193
232
  components: list[Component],
194
233
  mixture_key: Literal[
195
- 'Name', 'Formula', 'Name-State', 'Formula-State',
234
+ 'Name',
235
+ 'Formula',
236
+ 'Name-State',
237
+ 'Formula-State',
238
+ 'Name-Formula-State',
239
+ 'Formula-Name-State'
196
240
  ] = 'Name',
197
- delimiter: str = "|"
241
+ delimiter: str = "|",
242
+ case: Literal['lower', 'upper', None] = None
198
243
  ) -> str:
199
244
  """Create a unique mixture ID based on a list of components (sorted alphabetically).
200
245
 
@@ -202,10 +247,12 @@ def create_mixture_id(
202
247
  ----------
203
248
  components : list[Component]
204
249
  List of components in the mixture.
205
- component_key : Literal['Name', 'Formula'], optional
250
+ component_key : Literal['Name', 'Formula', 'Name-State', 'Formula-State', 'Name-Formula-State', 'Formula-Name-State'], optional
206
251
  The key to use for identifying the components, by default 'Name'.
207
252
  delimiter : str, optional
208
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'.
209
256
 
210
257
  Returns
211
258
  -------
@@ -248,25 +295,38 @@ def create_mixture_id(
248
295
  component_ids = []
249
296
  for comp in components:
250
297
  if mixture_key == 'Name':
251
- comp_id = comp.name.strip().lower()
298
+ comp_id = comp.name.strip()
252
299
  elif mixture_key == 'Formula':
253
- comp_id = comp.formula.strip().lower()
300
+ comp_id = comp.formula.strip()
254
301
  elif mixture_key == 'Name-State':
255
- comp_id = f"{comp.name.strip().lower()}-{comp.state.strip().lower()}"
302
+ comp_id = f"{comp.name.strip()}-{comp.state.strip()}"
256
303
  elif mixture_key == 'Formula-State':
257
- comp_id = f"{comp.formula.strip().lower()}-{comp.state.strip().lower()}"
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()}"
258
309
  else:
259
310
  raise ValueError(
260
- "component_key must be either 'Name' or 'Formula'"
311
+ "component_key must be one of the following: Name, Formula, Name-State, Formula-State, Name-Formula-State, Formula-Name-State"
261
312
  )
262
313
  component_ids.append(comp_id)
263
314
 
264
315
  # SECTION: create unique mixture ID (sorted to ensure uniqueness)
316
+ # ! sorted alphabetically
265
317
  mixture_id = delimiter.join(sorted(component_ids))
266
318
 
267
319
  # strip
268
320
  mixture_id = mixture_id.strip()
269
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
+
270
330
  # return
271
331
  return mixture_id
272
332
  except Exception as e:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythermodb-settings
3
- Version: 0.1.7
3
+ Version: 0.1.9
4
4
  Summary: Add your description here
5
5
  Author-email: Sina Gilassi <sina.gilassi@gmail.com>
6
6
  License-Expression: MIT