File: SimulationOutput.py

package info (click to toggle)
cain 1.10%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 29,856 kB
  • sloc: cpp: 49,612; python: 14,988; xml: 11,654; ansic: 3,644; makefile: 133; sh: 2
file content (25 lines) | stat: -rw-r--r-- 803 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""Implements the SimulationOutput class."""

def isSorted(x):
    """Return true if the sequence is sorted."""
    if len(x) == 0:
        return True
    for i in range(len(x) - 1):
        if x[i] > x[i + 1]:
            return False
    return True

class SimulationOutput:
    """A base class for simulation output."""
    
    def __init__(self, recordedSpecies, recordedReactions):
        # The recorded species.
        self.recordedSpecies = recordedSpecies
        # The recorded reactions.
        self.recordedReactions = recordedReactions

    def hasErrors(self):
        """Return None if valid. Otherwise return an error message."""
        if not self.recordedSpecies and not self.recordedReactions:
            return 'There are no recorded species or reactions.'
        return None