Skip to content

Commit

Permalink
Merge pull request #357 from GillesPy2/develop
Browse files Browse the repository at this point in the history
Release 1.4.1 - MERGE BADGES FIRST
  • Loading branch information
seanebum authored May 29, 2020
2 parents a1d330a + 2cc04a4 commit b4bf213
Show file tree
Hide file tree
Showing 14 changed files with 315 additions and 10,743 deletions.
Binary file removed .graphics/coverage.png
Binary file not shown.
21 changes: 0 additions & 21 deletions .graphics/coverage.svg

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ New developments happen primarily in the [`develop`](https://github.com/GillesPy

<p align="center">

| Master Branch | Develop Branch | Coverage | Maintainability |
| Master Branch | Develop Branch | Test Coverage | Maintainability |
|:---------------:|:--------------:|:--------:|:---------------:|
| [![Build Status](https://travis-ci.org/GillesPy2/GillesPy2.svg?branch=master)](https://travis-ci.org/GillesPy2/GillesPy2) | [![Build Status](https://travis-ci.org/GillesPy2/GillesPy2.svg?branch=develop)](https://travis-ci.org/GillesPy2/GillesPy2) | ![Coverage](https://raw.githubusercontent.com/GillesPy2/GillesPy2/develop/.graphics/coverage.svg?sanitize=true) | [![Maintainability](https://api.codeclimate.com/v1/badges/990ac9d778d681d32eea/maintainability)](https://codeclimate.com/github/GillesPy2/GillesPy2/maintainability) |
| [![Build Status](https://travis-ci.org/GillesPy2/GillesPy2.svg?branch=master)](https://travis-ci.org/GillesPy2/GillesPy2) | [![Build Status](https://travis-ci.org/GillesPy2/GillesPy2.svg?branch=develop)](https://travis-ci.org/GillesPy2/GillesPy2) | [![Test Coverage](https://api.codeclimate.com/v1/badges/990ac9d778d681d32eea/test_coverage)](https://codeclimate.com/github/GillesPy2/GillesPy2/test_coverage) | [![Maintainability](https://api.codeclimate.com/v1/badges/990ac9d778d681d32eea/maintainability)](https://codeclimate.com/github/GillesPy2/GillesPy2/maintainability) |

License
-------
Expand Down
10,674 changes: 44 additions & 10,630 deletions examples/DataVisualization/DataVisualization.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gillespy2/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# @website https://github.com/GillesPy2/GillesPy2
# =============================================================================

__version__ = '1.4.0'
__version__ = '1.4.1'
__title__ = 'GillesPy2'
__description__ = 'Python interface for Gillespie-style biochemical simulations'
__url__ = 'https://github.com/GillesPy2/GillesPy2'
Expand Down
29 changes: 29 additions & 0 deletions gillespy2/core/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,34 @@ class Event:
TODO: MORE INFO
use_values_from_trigger_time: boolean
"""
def __eq__(self, other):
return str(self)==str(other)

def __ne__(self, other):
return not self.__eq__(other)

def __gt__(self, other):
return not self.__le__(other)

def __ge__(self, other):
return not self.__lt__(other)

def __lt__(self, other):
return str(self) < str(other)

def __le__(self, other):
return str(self) <= str(other)

def __hash__(self):
if hasattr(self, '_hash'):
return self._hash
if hasattr(self, 'id'):
self._hash = hash(self.id)
elif hasattr(self, 'name'):
self._hash = hash(self.name)
else:
self._hash = hash(self)
return self._hash

def __init__(self, name="", delay = None, assignments = [], priority="0",
trigger = None, use_values_from_trigger_time = False):
Expand Down Expand Up @@ -171,6 +199,7 @@ def __init__(self, name="", delay = None, assignments = [], priority="0",
else:
raise EventError(
'use_values_from_trigger_time requires bool')

def __str__(self):
print_string = self.name
print_string += '\n\tTrigger: ' + str(self.trigger)
Expand Down
72 changes: 40 additions & 32 deletions gillespy2/core/gillespy2.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,13 @@ def __ge__(self, other):
return not self.__lt__(other)

def __lt__(self, other):
if hasattr(self, 'id') and hasattr(other, 'id'):
return self.id.lower() < other.id.lower()
elif hasattr(self, 'name') and hasattr(other, 'name'):
return self.name.lower() < other.name.lower()
else:
return repr(self) < repr(other)
return str(self) < str(other)

def __le__(self, other):
if hasattr(self, 'id') and hasattr(other, 'id'):
return self.id.lower() <= other.id.lower()
elif hasattr(self, 'name') and hasattr(other, 'name'):
return self.name.lower() <= other.name.lower()
else:
return repr(self) <= repr(other)
return str(self) <= str(other)

def __cmp__(self, other):
if hasattr(self, 'id') and hasattr(other, 'id'):
return cmp(self.id.lower(), other.id.lower())
elif hasattr(self, 'name') and hasattr(other, 'name'):
return cmp(self.name.lower(), other.name.lower())
else:
return cmp(repr(self), repr(other))
return cmp(str(self), str(other))

def __hash__(self):
if hasattr(self, '_hash'):
Expand Down Expand Up @@ -276,7 +261,6 @@ def add_species(self, obj):
obj : Species, or list of Species
The species or list of species to be added to the model object.
"""

if isinstance(obj, list):
for S in sorted(obj):
self.add_species(S)
Expand Down Expand Up @@ -790,38 +774,48 @@ def run(self, solver=None, timeout=0, **solver_args):

if solver is not None:
try:
solver_results, rc = solver.run(model=self, t=self.tspan[-1],
increment=self.tspan[-1] - self.tspan[-2], timeout=timeout, **solver_args)
solver_results, rc = solver.run(model=self, t=self.tspan[-1], increment=self.tspan[-1] - self.tspan[-2],
timeout=timeout, **solver_args)
except Exception as e:
raise SimulationError(
"argument 'solver={}' to run() failed. Reason Given: {}".format(solver, e))
else:
from gillespy2.solvers.auto import SSASolver
solver = SSASolver
solver_results, rc = SSASolver.run(model=self, t=self.tspan[-1],
increment=self.tspan[-1] -
self.tspan[-2], timeout=timeout, **solver_args)
if len(self.get_all_assignment_rules()) > 0 or len(self.get_all_rate_rules()) > 0 \
or len(self.get_all_function_definitions()) > 0 or len(self.get_all_events()) > 0:
from gillespy2.solvers.numpy import can_use_numpy
if can_use_numpy:
from gillespy2.solvers.numpy.basic_tau_hybrid_solver import BasicTauHybridSolver
solver = BasicTauHybridSolver
else:
raise ModelError('BasicTauHybridSolver is the only solver currently that supports '
'AssignmentRules, RateRules, FunctionDefinitions, or Events. '
'Please install Numpy.')
else:
from gillespy2.solvers.auto import SSASolver
solver = SSASolver

solver_results, rc = solver.run(model=self, t=self.tspan[-1], increment=self.tspan[-1] - self.tspan[-2],
timeout=timeout, **solver_args)

if rc == 33:
from gillespy2.core import log
log.warning('GillesPy2 simulation exceeded timeout.')

if hasattr(solver_results[0], 'shape'):
return solver_results

if len(solver_results) is 1:
results_list = []
results_list.append(Trajectory(data=solver_results[0], model=self,
solver_name=solver.name, rc=rc))
results_list = [Trajectory(data=solver_results[0], model=self,
solver_name=solver.name, rc=rc)]
return Results(results_list)

if len(solver_results) > 1:
results_list = []
for i in range(0,solver_args.get('number_of_trajectories')):
results_list.append(Trajectory(data=solver_results[i],model=self,solver_name=solver.name,
rc=rc))
results_list.append(Trajectory(data=solver_results[i], model=self, solver_name=solver.name,
rc = rc))
return Results(results_list)


else:
raise ValueError("number_of_trajectories must be non-negative and non-zero")

Expand Down Expand Up @@ -907,6 +901,20 @@ def __str__(self):
'''
return print_string

def set_initial_value(self,num):
"""
Setter method for initial_value of a population
:param num: Integer to set initial species population
:raises SpeciesError: If num is non-negative or a decimal number
"""
print(num)
print(self.mode)
if isinstance(num,float) and (self.mode != 'dynamic' or self.mode != 'continuous'):
raise SpeciesError("Mode set to discrete, species must be an integer number.")
if num < 0 and self.allow_negative_populations == False:
raise SpeciesError("Species population must be non-negative, or allow_negative_populations "
"must be set to True")
self.initial_value = num

class Parameter(SortableObject):
"""
Expand Down
Loading

0 comments on commit b4bf213

Please sign in to comment.