From a7286ac4222a5440e58a0d0bfe194fd1e241082a Mon Sep 17 00:00:00 2001 From: Jesse Reeve Date: Fri, 10 Apr 2020 12:32:47 -0400 Subject: [PATCH 1/2] Changed 'is' to '==', 'is not' to '!=' when comparing to non-singletons --- gillespy2/core/gillespy2.py | 4 ++-- gillespy2/core/results.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gillespy2/core/gillespy2.py b/gillespy2/core/gillespy2.py index d806aebae..d497dc828 100644 --- a/gillespy2/core/gillespy2.py +++ b/gillespy2/core/gillespy2.py @@ -658,7 +658,7 @@ def excepthook(type, value, traceback): if isinstance(solver_results[0], (np.ndarray)): return solver_results - if len(solver_results) is 1: + if len(solver_results) == 1: return Results(data=solver_results[0], model=self, solver_name=solver.name, rc=rc) @@ -1251,7 +1251,7 @@ def to_model(self, name): root = self.document # Try to set name from document - if model.name is "": + if model.name == "": name = root.find('Name') if name.text is None: raise NameError("The Name cannot be none") diff --git a/gillespy2/core/results.py b/gillespy2/core/results.py index c050ea6f0..7359d3994 100644 --- a/gillespy2/core/results.py +++ b/gillespy2/core/results.py @@ -18,7 +18,7 @@ def _plot_iterate(self, show_labels = True, included_species_list = []): import matplotlib.pyplot as plt for i,species in enumerate(self.data): - if species is not 'time': + if species != 'time': if species not in included_species_list and included_species_list: continue @@ -43,7 +43,7 @@ def _plotplotly_iterate(result, show_labels = True, trace_list = None, line_dict import plotly.graph_objs as go for i,species in enumerate(result.data): - if species is not 'time': + if species != 'time': if species not in included_species_list and included_species_list: continue @@ -480,13 +480,13 @@ def average_ensemble(self): for i in range(0,number_of_trajectories): #Add every value of every Results Dict into one output Results results_dict = results_list[i] for species in results_dict: - if species is 'time': + if species == 'time': continue for k in range(0,len(output[species])): output[species][k] += results_dict[species][k] for species in output: #Divide for mean of every value in output Results - if species is 'time': + if species == 'time': continue for i in range(0,len(output[species])): output[species][i] /= number_of_trajectories @@ -529,14 +529,14 @@ def stddev_ensemble(self,ddof = 0): for i in range(0,number_of_trajectories): results_dict = results_list[i] for species in results_dict: - if species is 'time': + if species == 'time': continue for k in range(0,len(output[species])): output[species][k] += (results_dict[species][k] - average_list[species][k])\ *(results_dict[species][k] - average_list[species][k]) for species in output: #Divide for mean of every value in output Results - if species is 'time': + if species == 'time': continue for i in range(0,len(output[species])): output[species][i] /= (number_of_trajectories - ddof) @@ -584,7 +584,7 @@ def plotplotly_std_dev_range(self, xaxis_label = "Time (s)", yaxis_label="Specie trace_list=[] for species in average_result: - if species is not 'time': + if species != 'time': if species not in included_species_list and included_species_list: continue @@ -691,7 +691,7 @@ def plot_std_dev_range(self, xaxis_label ="Time (s)", yaxis_label ="Species Popu plt.figure(figsize=figsize) for species in average_result: - if species is 'time': + if species == 'time': continue if species not in included_species_list and included_species_list: From f332373001380039e4424318dc219ca10be852a6 Mon Sep 17 00:00:00 2001 From: Jesse Reeve Date: Fri, 10 Apr 2020 13:13:02 -0400 Subject: [PATCH 2/2] Updated with existing commits from develop --- gillespy2/core/gillespy2.py | 45 ------------------------------------- 1 file changed, 45 deletions(-) diff --git a/gillespy2/core/gillespy2.py b/gillespy2/core/gillespy2.py index 194f4b12d..48000419a 100644 --- a/gillespy2/core/gillespy2.py +++ b/gillespy2/core/gillespy2.py @@ -629,50 +629,6 @@ def run(self, solver=None, timeout=0, **solver_args): if rc == 33: from gillespy2.core import log log.warning('GillesPy2 simulation exceeded timeout.') -<<<<<<< HEAD - raise SimulationTimeoutError() - - - with time_out(timeout): - if solver is not None: - if ((isinstance(solver, type) - and issubclass(solver, GillesPySolver))) or issubclass(type(solver), GillesPySolver): - if solver.name == 'SSACSolver': - signal.signal(signal.SIGALRM, signal.SIG_IGN) - solver_args['timeout'] = timeout - solver_results, rc = solver.run(model=self, t=self.tspan[-1], increment=self.tspan[-1] - self.tspan[-2], **solver_args) - else: - raise SimulationError( - "argument 'solver' to run() must be a subclass of GillesPySolver") - else: - from gillespy2.solvers.auto import SSASolver - solver = SSASolver - if solver.name == 'SSACSolver': - signal.signal(signal.SIGALRM, signal.SIG_IGN) - solver_args['timeout'] = timeout - solver_results, rc = SSASolver.run(model=self, t=self.tspan[-1], - increment=self.tspan[-1] - self.tspan[-2], **solver_args) - - if rc == 33: - from gillespy2.core import log - log.warning('GillesPy2 simulation exceeded timeout.') - - if isinstance(solver_results[0], (np.ndarray)): - return solver_results - - if len(solver_results) == 1: - return Results(data=solver_results[0], model=self, - solver_name=solver.name, rc=rc) - - if len(solver_results) > 1: - results_list = [] - for i in range(0,solver_args.get('number_of_trajectories')): - results_list.append(Results(data=solver_results[i],model=self,solver_name=solver.name, - rc=rc)) - return EnsembleResults(results_list) - else: - raise ValueError("number_of_trajectories must be non-negative and non-zero") -======= if hasattr(solver_results[0], 'shape'): return solver_results @@ -691,7 +647,6 @@ def run(self, solver=None, timeout=0, **solver_args): else: raise ValueError("number_of_trajectories must be non-negative and non-zero") ->>>>>>> 2d0f2658cf21086297a452f37f30ac2f77568364 class Species(SortableObject):