Skip to content

Commit 6854c59

Browse files
committed
0.53.0 release; finallize new ID magic feature
1 parent 5bbacf2 commit 6854c59

File tree

11 files changed

+23
-19
lines changed

11 files changed

+23
-19
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
name='thermosteam',
1212
packages=['thermosteam'],
1313
license='MIT',
14-
version='0.52.19',
14+
version='0.53.0',
1515
description="BioSTEAM's Premier Thermodynamic Engine",
1616
long_description=open('README.rst', encoding='utf-8').read(),
1717
author='Yoel Cortes-Pena',

thermosteam/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
# update_module(chemicals, numba)
3232
# use_numba_chemicals()
3333
# del use_numba_chemicals
34-
__version__ = "0.52.19"
34+
__version__ = "0.53.0"
3535

3636
from . import thermo
3737
del thermo

thermosteam/_multi_stream.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def __init__(self,
250250
self._sink = self._source = None
251251
self.reset_cache()
252252

253-
if tmo.preferences.ID_inference and ID == '': ID = tmo.utils.infer_variable_assignment(self.__class__)
253+
if tmo.settings.ID_magic and ID == '': ID = tmo.utils.infer_variable_assignment(self.__class__)
254254

255255
self._register(ID)
256256
if vlle: self.vlle(T=T, P=P)

thermosteam/_preferences.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class DisplayPreferences:
4242
tooltips_full_results: False
4343
graphviz_html_height: {'big-system': ('600px', '900px'), 'huge-system': ('800px', '1200px'), 'system': ('400px', '600px'), 'unit': ('225px', '400px')}
4444
show_all_streams: True
45-
ID_inference: False
4645
flow: 'kmol/hr:.3g'
4746
T: 'K:.5g'
4847
P: 'Pa:.6g'
@@ -56,7 +55,7 @@ class DisplayPreferences:
5655
'label_color', 'label_color', 'depth_colors', 'stream_width',
5756
'unit_color', 'unit_label_color', 'unit_periphery_color',
5857
'fill_cluster', 'graphviz_format', 'tooltips_full_results',
59-
'graphviz_html_height', 'show_all_streams', 'ID_inference')
58+
'graphviz_html_height', 'show_all_streams')
6059

6160
def __init__(self):
6261
#: Whether to label the ID of streams with sources and sinks in process
@@ -124,9 +123,6 @@ def __init__(self):
124123
#: Whether to show all streams, including empty feeds and products.
125124
self.show_all_streams = True
126125

127-
#: Whether to infer ID of unit operations, streams, and systems by variable name.
128-
self.ID_inference = True
129-
130126
def temporary(self):
131127
"""Return a TemporaryPreferences object that will revert back to original
132128
preferences after context management."""

thermosteam/_settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class ProcessSettings:
101101
__slots__ = (
102102
'_thermo',
103103
'_flashpkg',
104+
'ID_magic',
104105
)
105106

106107
def __new__(cls):
@@ -281,3 +282,6 @@ def set_flashpkg(self, flashpkg):
281282

282283
#:
283284
settings: ProcessSettings = object.__new__(ProcessSettings)
285+
286+
#: Whether to infer ID of unit operations, streams, and systems by variable assignment.
287+
settings.ID_magic = True

thermosteam/_stream.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ def __init__(self, ID: Optional[str] = '',
401401
self._sink = self._source = None
402402
self.reset_cache()
403403

404-
if tmo.preferences.ID_inference and ID == '': ID = tmo.utils.infer_variable_assignment(self.__class__)
404+
if tmo.settings.ID_magic and ID == '': ID = tmo.utils.infer_variable_assignment(self.__class__)
405405
self._register(ID)
406406
if vlle:
407407
self.vlle(T=T, P=P)

thermosteam/equilibrium/lle.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def pseudo_equilibrium(K, phi, z, T, n, f_gamma, gamma_args, inner_loop_options,
121121
# Light weight
122122
def solve_lle_mol(gamma, z, T, P, sample=None, phi=1):
123123
n = z.size
124+
if sample is not None: sample = (sample,)
124125
stability = lle_tangential_plane_analysis(gamma, z, T, P, samples=sample)
125126
if stability.unstable:
126127
y = stability.candidate

thermosteam/network.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2514,10 +2514,8 @@ def from_feedstock(cls, feedstock, feeds=(), ends=None, units=None, final=True,
25142514
recycle_ends.update(disjunction_streams)
25152515
recycle_ends.update(network.get_all_recycles())
25162516
recycle_ends.update(tmo.utils.products_from_units(network.units))
2517-
# network.sort_without_recycle(recycle_ends)
25182517
if recycles: network.reduce_recycles()
25192518
network.sort(recycle_ends)
2520-
# network._add_interaction_units({}, [])
25212519
if interaction: network.add_interaction_units(old_connections, ends)
25222520
return network
25232521

@@ -2607,7 +2605,7 @@ def _add_interaction_units(self, excluded, next_units, ends):
26072605
try:
26082606
unext = next_units[0]
26092607
except:
2610-
continue
2608+
unext = None
26112609
else:
26122610
unext = path[inext]
26132611
if isa(unext, Network): unext = unext.get_first_unit()

thermosteam/utils/decorators/registered.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@ def _register(self, ID):
6868
registry.register(ID, self)
6969
elif hasattr(ID, '__iter__'):
7070
ID, *aliases = ID
71-
self._register(ID)
72-
for i in aliases: self.register_alias(i)
71+
if isinstance(ID, str):
72+
self._register(ID)
73+
for i in aliases: self.register_alias(i)
74+
else:
75+
raise ValueError(f'ID must be a string, not a {type(ID)} object')
7376
else:
7477
raise ValueError('invalid ID {ID!r}; ID must be a string, integer, or an interable of these')
7578

thermosteam/utils/registry.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,12 @@ def register_safely(self, ID, obj):
9191
num = int(num)
9292
except:
9393
other.ID = ID + '_1'
94-
else:
95-
other.ID = base + '_' + str(num + 1)
96-
base, num = other.ID.rsplit('_', 1)
97-
ID = base + '_' + str(int(num) + 1)
94+
base = ID
95+
num = 1
96+
ID = base + '_' + str(num + 1)
97+
while ID in data:
98+
num += 1
99+
ID = base + '_' + str(num)
98100
elif ID_old:
99101
warning = RuntimeWarning(
100102
f"upon renaming, {obj!r} replaced {other!r} "

0 commit comments

Comments
 (0)