<commit_before>#! /usr/env/python
r"""
Landlab's Continuous-Time Stochastic (CTS) cellular automata modeling package.

Overview
--------

A CellLab CTS model implements a particular type of cellular
automaton (CA): a continuous-time stochastic CA. The approach is based on that
of Narteau et al. (2002, 2009) and Rozier and Narteau (2014). Like a normal
CA, the domain consists of a lattice of cells, each of which has a discrete
state. Unlike a conventional CA, the updating process is stochastic, and takes
place in continuous rather than discrete time. Any given pair (or "doublet")
of adjacent cell states has a certain specified probability of transition to a
different pair of states. The transition probability is given in the form of an
average *transition rate*, :math:\lambda (with dimensions of 1/T); the actual
time of transition is a random variable drawn from an exponential probability
distribution with mean :math:1/\lambda

Subclasses
----------

Landlab provides for several different lattice and connection types:
    - RasterCTS: regular raster grid with transitions between horizontal and
        vertical cell pairs
    - OrientedRasterCTS: like a RasterLCA, but different transition rates can
        be assigned to vertical and horizontal pairs. This property of
        orientation can be used, for example, to implement rules representing
        gravitational attraction, or flow of a fluid with a particular
        direction.
    - RasterD8CTS: like a RasterLCA, but includes diagonal as well as vertical
        and horizontal cell pairs.
    - OrientedRasterD8CTS: as above but orientation also matters.
    - HexCTS: hexagonal grid
    - OrientedHexCTS: hexagonal grid, with transition rates allowed to vary
        according to orientation.

Encoding of "states"
--------------------
As in any traditional cellular automaton model, a LandlabCellularAutomaton
contains a grid of cells ("nodes" in Landlab parlance), each of which is has a
discrete state. States are represented by integers (0, 1, ... N).

In addition, every active link has an *orientation code* and a *link state
code*. The orientation code represents the orientation of the link in space: is
it "vertical" (aligned with the y axis), "horizontal" (aligned with x), or in
some other orientation? The number of possible orientations depends on the
subclass. The base class has only one orientation code (0) (meaning
"orientation doesn't matter), but this is overridden in some of the subclasses.
For example, the OrientedRasterLCA has two orientation codes (0 and 1, for<commit_msg>Changed docstring to raw for math backslashes.<commit_after>#! /usr/env/python
r"""
Landlab's Continuous-Time Stochastic (CTS) cellular automata modeling package.

Overview
--------

A CellLab CTS model implements a particular type of cellular
automaton (CA): a continuous-time stochastic CA. The approach is based on that
of Narteau et al. (2002, 2009) and Rozier and Narteau (2014). Like a normal
CA, the domain consists of a lattice of cells, each of which has a discrete
state. Unlike a conventional CA, the updating process is stochastic, and takes
place in continuous rather than discrete time. Any given pair (or "doublet")
of adjacent cell states has a certain specified probability of transition to a
different pair of states. The transition probability is given in the form of an
average *transition rate*, :math:`\lambda` (with dimensions of 1/T); the actual
time of transition is a random variable drawn from an exponential probability
distribution with mean :math:`1/\lambda`.

Subclasses
----------

Landlab provides for several different lattice and connection types:
- RasterCTS: regular raster grid with transitions between horizontal and
  vertical cell pairs
- OrientedRasterCTS: like a RasterLCA, but different transition rates can
  be assigned to vertical and horizontal pairs. This property of
  orientation can be used, for example, to implement rules representing
  gravitational attraction, or flow of a fluid with a particular
  direction.
- RasterD8CTS: like a RasterLCA, but includes diagonal as well as vertical
  and horizontal cell pairs.
- OrientedRasterD8CTS: as above but orientation also matters.
- HexCTS: hexagonal grid
- OrientedHexCTS: hexagonal grid, with transition rates allowed to vary
  according to orientation.

Encoding of "states"
--------------------
As in any traditional cellular automaton model, a LandlabCellularAutomaton
contains a grid of cells ("nodes" in Landlab parlance), each of which is has a
discrete state. States are represented by integers (0, 1, ... N).

In addition, every active link has an *orientation code* and a *link state
code*. The orientation code represents the orientation of the link in space: is
it "vertical" (aligned with the y axis), "horizontal" (aligned with x), or in
some other orientation? The number of possible orientations depends on the
subclass. The base class has only one orientation code (0) (meaning
"orientation doesn't matter), but this is overridden in some of the subclasses.
For example, the OrientedRasterLCA has two orientation codes (0 and 1, for
{'fraction_non_alphanumeric': 0.06430241621200312, 'fraction_numerical': 0.00818394388152767, 'mean_word_length': 4.127872127872128, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7358893', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1220, 'n_words': 727}