Below are some of PySB’s frequently asked questions. If your question is not answered here, you can try our Gitter channel. For more general Python related questions, we recommend Stack Overflow.

## General¶

• Do you support Python 3?

Yes. The current release of PySB supports Python 3.6 and Python 2.7. Other Python 3.x releases are not explicitly tested.

In PySB version 1.5 and earlier, the <> operator was used for reversible rules. <> is pending deprecation from PySB, and does not work at all in Python 3. All new models should use | as the reversible rule operator. Previous models should be upgraded if compatibility with future PySB versions is required.

## Rule and Reaction Rate Laws¶

• Can I specify a non-mass action rate law?

Yes. PySB has a special entity for this, called Expressions. Expressions can be used in place of Parameters for rule rates. Expressions can contain mathematical expressions and can utilize other Expressions, Parameters, and Observables. Here’s a contrived example for demonstration purposes:

```Parameter('A_multiplier', 2.0)
Observable('A_total', A())
Expression('kf_A`, A_total * A_multiplier)
Rule('bindA', A(b=None) + A(b=None) >> A(b=1) % A(b=1), kf_A)
```

Like Parameters, note that Expressions are multiplied by reactant species concentrations within a rule to get the final rate.

• Can I use a discontinuous rate law, like a Heaviside function?

Yes. For simple examples like the Heaviside function, one could simply write a rate Expression like the following:

```Observable('A_total', A())
Parameter('p1', 1.0)
Expression('e1', (A_total > 100) * p1))
```

The inequality in parentheses evaluates to 1 if True and 0 if False. Thus, the Expression will be equal to p1 when A_total > 100 and 0 otherwise.

For more complex piecewise expressions, sympy’s Piecewise can be used:

```Expression('kf_A', Piecewise((0, A_total < 400.0),
(0.001, A_total < 500.0),
(0.01, True)))
```

Piecewise takes a list of (value, condition) tuples. The Expression’s value will come from the first condition which evaluates to True. Thus, for the Expression to always have a value, the last condition should default to True.

## Simulation¶

• How can I speed up my ScipyOdeSimulator simulation?

Check the weave library is installed. weave is a Python library which converts your system of ordinary differential equations (ODEs) to C code, which is faster to execute than pure Python code. You can check if weave is installed by trying to import it at the Python prompt:

```import weave
```

If no ImportError appears, weave is available. Note that weave is only available for Python 2. We are working on an alternative for Python 3 using Cython.

When running large numbers of simulations, consider using the CupSodaSimulator if you have an NVIDIA graphics card (GPU) available. It is a GPU-based simulator which can run lots of simulations in parallel. See the Simulator module documentation for details.