Skip to content

Commit ae6a6e0

Browse files
committed
2.52.20 release; python 3.13 support
1 parent b70b61d commit ae6a6e0

File tree

9 files changed

+158
-158
lines changed

9 files changed

+158
-158
lines changed

biosteam/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
1414
"""
1515
from __future__ import annotations
16-
__version__ = '2.52.19'
16+
__version__ = '2.52.20'
1717

1818
#: Chemical engineering plant cost index (defaults to 567.5 at 2017).
1919
CE: float = 567.5

biosteam/_system.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,15 @@ def solve_material_flows(self, composition_sensitive=False, full_output=False):
212212
[(f(j) if callable(f:=bi[j]) else f) for j in delayed_index]
213213
for bi in b
214214
], float)
215-
values = solve(A_delayed, b_delayed.T).T
215+
values = np.array([solve(A_delayed[i], b_delayed[:, i]) for i in range(b.shape[1])]).T
216216
values[values < 0] = 0
217217
for obj, value in zip(objs, values):
218218
obj._update_material_flows(value, delayed_index)
219219
else:
220220
A, objs = dictionaries2array(A)
221221
if np.isnan(A).any(): raise RuntimeError('invalid number encountered')
222-
values = solve(A, np.array(b).T).T
222+
b = np.array(b)
223+
values = np.array([solve(A[i], b[:, i]) for i in range(b.shape[1])]).T
223224
if np.isnan(values).any(): raise RuntimeError('invalid number encountered')
224225
values[(values < 0) & (values > -1e-6)] = 0
225226
masks = values < 0

biosteam/evaluation/_model.py

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from scipy.optimize import shgo, differential_evolution
1717
import numpy as np
1818
import pandas as pd
19-
from chaospy import distributions as shape
2019
from ._indicator import Indicator
2120
from ._feature import MockFeature
2221
from ._utils import var_indices, var_columns, indices_to_multiindex
@@ -30,6 +29,12 @@
3029
from ._parameter import Parameter
3130
from .evaluation_tools import load_default_parameters
3231
import pickle
32+
try:
33+
from chaospy import distributions as shape
34+
import chaospy as cp
35+
Distribution = shape.baseclass.Distribution
36+
except:
37+
Distribution = None
3338

3439
__all__ = ('Model', 'EasyInputModel')
3540

@@ -60,35 +65,6 @@ def f(x):
6065
function = wrapper_fn(code)
6166
return function
6267

63-
# %% Fix compatibility with new chaospy version
64-
65-
import chaospy as cp
66-
version_components = cp.__version__.split('.')
67-
CP_MAJOR, CP_MINOR = int(version_components[0]), int(version_components[1])
68-
CP4 = (CP_MAJOR, CP_MINOR) >= (4, 0)
69-
if CP4:
70-
from inspect import signature
71-
def save_repr_init(f):
72-
defaults = list(signature(f).parameters.values())[1:]
73-
defaults = {i.name: i.default for i in defaults}
74-
def init(self, *args, **kwargs):
75-
if not hasattr(self, '_repr'):
76-
self._repr = params = defaults.copy()
77-
for i, j in zip(params, args): params[i] = j
78-
params.update(kwargs)
79-
f(self, *args, **kwargs)
80-
return init
81-
82-
shapes = cp.distributions
83-
Distribution = cp.distributions.Distribution
84-
baseshapes = set([i for i in cp.distributions.baseclass.__dict__.values()
85-
if isinstance(i, type) and issubclass(i, Distribution)])
86-
for i in shapes.__dict__.values():
87-
if isinstance(i, type) and issubclass(i, Distribution) and i not in baseshapes:
88-
i.__init__ = save_repr_init(i.__init__)
89-
del signature, save_repr_init, shapes, baseshapes, Distribution, i
90-
del version_components, CP_MAJOR, CP_MINOR, CP4
91-
9268
# %% Simulation of process systems
9369

9470
class Model:
@@ -324,7 +300,7 @@ def parameter(self,
324300
element: Optional[Unit]=None,
325301
coupled: Optional[bool]=None,
326302
name: Optional[str]=None,
327-
distribution: Optional[str|shape.baseclass.Distribution]=None,
303+
distribution: Optional[str|Distribution]=None,
328304
units: Optional[str]=None,
329305
baseline: Optional[float]=None,
330306
bounds: Optional[tuple[float, float]]=None,

biosteam/evaluation/_parameter.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,41 @@
1212
from ._feature import Feature
1313
from ..utils import format_title
1414
import biosteam as bst
15-
from chaospy import distributions as shape
15+
from warnings import warn
1616
from inspect import signature
1717

18+
try:
19+
from chaospy import distributions as shape
20+
except:
21+
warn('chaospy not installed; cannot use automation features for uncertainty and optimization', RuntimeWarning, stacklevel=2)
22+
else:
23+
# Fix compatibility with new chaospy version
24+
import chaospy as cp
25+
version_components = cp.__version__.split('.')
26+
CP_MAJOR, CP_MINOR = int(version_components[0]), int(version_components[1])
27+
CP4 = (CP_MAJOR, CP_MINOR) >= (4, 0)
28+
if CP4:
29+
def save_repr_init(f):
30+
defaults = list(signature(f).parameters.values())[1:]
31+
defaults = {i.name: i.default for i in defaults}
32+
def init(self, *args, **kwargs):
33+
if not hasattr(self, '_repr'):
34+
self._repr = params = defaults.copy()
35+
for i, j in zip(params, args): params[i] = j
36+
params.update(kwargs)
37+
f(self, *args, **kwargs)
38+
return init
39+
40+
shapes = cp.distributions
41+
Distribution = cp.distributions.Distribution
42+
baseshapes = set([i for i in cp.distributions.baseclass.__dict__.values()
43+
if isinstance(i, type) and issubclass(i, Distribution)])
44+
for i in shapes.__dict__.values():
45+
if isinstance(i, type) and issubclass(i, Distribution) and i not in baseshapes:
46+
i.__init__ = save_repr_init(i.__init__)
47+
del save_repr_init, shapes, baseshapes, Distribution, i
48+
del version_components, CP_MAJOR, CP_MINOR, CP4
49+
1850
class Parameter(Feature):
1951
"""
2052
Create a Parameter object that, when called, runs the setter and

biosteam/evaluation/evaluation_tools/parameter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
# for license details.
88
"""
99
"""
10-
from chaospy import distributions as shape
10+
try: from chaospy import distributions as shape
11+
except: pass
1112
import biosteam as bst
1213

1314
__all__ = ('load_default_parameters',

docs/index.rst

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,13 @@ Installation
117117
118118
$ git clone --depth 10 git://github.com/BioSTEAMDevelopmentGroup/biosteam
119119
120-
#. BioSTEAM uses `Graphviz <http://www.graphviz.org/>`__ to make flowsheet diagrams.
121-
You will need to install Graphviz separately as follows:
120+
#. BioSTEAM uses `Graphviz <http://www.graphviz.org/>`__ to make flowsheet diagrams. To properly install Graphviz in an anaconda distribution, run the following line:
121+
122+
.. code-block:: bash
123+
124+
$ conda install python-graphviz
125+
126+
#. If you **do not** have an anaconda distribution, you will need to install Graphviz separately as follows:
122127

123128
* Windows: Download the EXE installer and follow the instructions listed `in this link <https://graphviz.org/download/>`__
124129

@@ -133,19 +138,20 @@ Installation
133138
.. code-block:: bash
134139
135140
$ brew install graphviz
136-
137-
#. To properly install Graphviz in an anaconda distribution, run the following line:
138-
139-
.. code-block:: bash
140-
141-
$ conda install python-graphviz
142141
143142
Common Issues
144143
-------------
145144

145+
* **Unit and system diagrams are not displaying:**
146+
147+
Graphviz may not be properly installed or may be missing from your python path.
148+
Please follow the graphviz installation procedure outlined above.
149+
146150
* **Cannot install/update BioSTEAM:**
147151

148-
If you are having trouble installing or updating BioSTEAM, it may be due to dependency issues. You can bypass these using:
152+
If you are having trouble installing or updating BioSTEAM, it may be due to dependency issues.
153+
Some dependencies like chaospy/numpoly require Microsoft C++ Build Tools. Download and install the `C++ build tools here. <https://visualstudio.microsoft.com/visual-cpp-build-tools/>`__
154+
You can also bypass dependency issues using:
149155

150156
.. code-block:: bash
151157
@@ -157,11 +163,6 @@ Common Issues
157163
158164
$ pip install biosteam==<version>
159165
160-
* **Unit and system diagrams are not displaying:**
161-
162-
Graphviz may not be properly installed or may be missing from your python path.
163-
Please follow the graphviz installation procedure outlined above.
164-
165166
Scientific Papers
166167
-----------------
167168

setup.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111
name='biosteam',
1212
packages=['biosteam'],
1313
license='MIT',
14-
version='2.52.19',
14+
version='2.52.20',
1515
description='The Biorefinery Simulation and Techno-Economic Analysis Modules',
1616
long_description=open('README.rst', encoding='utf-8').read(),
1717
author='Yoel Cortes-Pena',
1818
install_requires=['IPython>=7.9.0',
19-
'thermosteam>=0.52.16',
19+
'thermosteam>=0.52.18',
2020
'graphviz>=0.17',
21-
'numpoly==1.2.13',
22-
'chaospy==4.3.15',
21+
'chaospy>=4.3.21',
2322
'pyyaml'],
2423
extras_require={
2524
'dev': [

0 commit comments

Comments
 (0)