Skip to content

Commit

Permalink
updates for Python 3.12 compability (#276)
Browse files Browse the repository at this point in the history
* update dependencies: numpy < 2.0 and updated fa2

* coerce 1e6 to int (instead of float)

* update bokeh compatibility

* fix small issues in unit test infrastructure

* update README to mention the possible need to escape brackets
  • Loading branch information
murrayrm authored Jun 20, 2024
1 parent 737e87f commit dee6155
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 9 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ Install with all optional dependencies::

$ pip install biocrnpyler[all]

(Note that on some operating systems you made need to use "\[all\]" to avoid shell errors.)

Further details about the installation process can be found in the [BioCRNPyler wiki](https://github.com/BuildACell/BioCRNPyler/wiki#installation).

# Bugs
Expand Down
2 changes: 1 addition & 1 deletion Tests/Combinatorial/test_jupyter_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
nb_not_installed = False
try:
import nbformat
from nbconvert.preprocessors import ExecutePreprocessor
from nbconvert.preprocessors import ExecutePreprocessor, CellExecutionError
except ModuleNotFoundError:
nb_not_installed = True
from os import listdir, getcwd, pardir
Expand Down
5 changes: 3 additions & 2 deletions Tests/Unit/test_simulation_packages_import.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2020, Build-A-Cell. All rights reserved.
# See LICENSE file in the project root directory for details.

import warnings
import pytest


Expand All @@ -11,7 +12,7 @@ def test_bioscrape_import_simulate():

X = Species("X")
CRN = ChemicalReactionNetwork(species=[X],reactions=[])
with pytest.warns(None) as record:
with pytest.warns() as record:
sim_result = CRN.simulate_with_bioscrape(timepoints=np.linspace(0, 10, 100), initial_condition_dict = {str(X):1})


Expand All @@ -33,7 +34,7 @@ def test_bioscrape_import_simulate_via_sbml():

X = Species("X")
CRN = ChemicalReactionNetwork(species=[X],reactions=[])
with pytest.warns(None) as record:
with warnings.catch_warnings(record=True) as record:
sim_result, bioscrape_model = CRN.simulate_with_bioscrape_via_sbml(timepoints=np.linspace(0, 10, 100), initial_condition_dict={str(X):1}, return_model=True)


Expand Down
5 changes: 3 additions & 2 deletions biocrnpyler/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@
import networkx as nx
from bokeh.models import (BoxSelectTool, Circle, EdgesAndLinkedNodes,
HoverTool, MultiLine, NodesAndLinkedEdges,
PanTool, Plot, Range1d, Square, TapTool,
PanTool, Plot, Range1d, TapTool,
WheelZoomTool)
from bokeh.models.markers import Square
from bokeh.plotting import from_networkx
from bokeh.palettes import Spectral4
from bokeh.io import export_svgs, output_notebook
Expand Down Expand Up @@ -922,7 +923,7 @@ def render_mixture(mixture,crn,color_dictionary=None,output = None,compiled_comp
def render_network_bokeh(CRN,layout="force", layoutfunc = None, plot_reactions = True, plot_species = True, plot_edges = True, plot_arrows = True,
iterations=2000,rseed=30,posscale=1,export=False,species_glyph_size = 12, reaction_glyph_size = 8, export_name = None, **keywords):
DG, DGspec, DGrxn = generate_networkx_graph(CRN,**keywords) #this creates the networkx objects
plot = Plot(plot_width=500, plot_height=500, x_range=Range1d(-500, 500), y_range=Range1d(-500, 500)) #this generates a
plot = Plot(width=500, height=500, x_range=Range1d(-500, 500), y_range=Range1d(-500, 500)) #this generates a
show_im = False
images = None
if("imagedict" in keywords and keywords["imagedict"] is not None):
Expand Down
2 changes: 1 addition & 1 deletion biocrnpyler/sbmlutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def create_sbml_model(compartment_id="default", time_units='second', extent_unit
document = libsbml.SBMLDocument(3, 2)
model = document.createModel()
if model_id is None:
model_id = 'biocrnpyler_'+str(randint(1, 1e6))
model_id = 'biocrnpyler_'+str(randint(1, int(1e6)))
model.setId(model_id)
model.setName(model_id)
# Define units for area (not used, but keeps COPASI from complaining)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@
"#below is CRN plotting code. set plotCRN to False to disable\n",
"if(plotCRN):\n",
" DG, DGspec, DGrxn = generate_networkx_graph(CRN_extract_1)\n",
" plot = Plot(plot_width=500, plot_height=500, x_range=Range1d(-500, 500), y_range=Range1d(-500, 500))\n",
" plot = Plot(width=500, height=500, x_range=Range1d(-500, 500), y_range=Range1d(-500, 500))\n",
" graphPlot(DG,DGspec,DGrxn,plot)\n",
" bokeh.io.show(plot)\n",
"\n",
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
],
extras_require = {
"all": [
"numpy",
"numpy<2.0",
"matplotlib",
"networkx",
"bokeh>=1.4.0",
"fa2",
"fa2_modified",
"jupyter",
"pytest",
"pytest-cov",
Expand Down

0 comments on commit dee6155

Please sign in to comment.