Registry / data / cellpylib

cellpylib

JSON →
library2.4.0pypypi✓ verified 88d ago

CellPyLib is a Python library for working with Cellular Automata, supporting 1D and 2D automata with various rules (e.g., Rule 30, Conway's Game of Life). Current version 2.4.0 requires Python >3.6. The library is actively maintained with a focus on simulation, visualization, and analysis.

pip install cellpylib
INSTALL
IMPORT
SIG · CELLPYLIB
C
cellpylib
datapythonv2.4.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cellular_automaton
✓ import cellpylib as cpl
✗ from cellpylib import cellular_automaton
The correct usage is to import the module and access functions via cpl (e.g., cpl.cellular_automaton())
init_simple
✓ from cellpylib import init_simple
Direct import is also possible for individual functions.
evolve
✓ from cellpylib import evolve
evolve is a core function used to iterate cellular automaton steps.

Initialize a 1D cellular automaton with Rule 30 and evolve it for 100 steps.

import cellpylib as cpl import matplotlib.pyplot as plt # Initialize a 1D cellular automaton (Rule 30, size 100) cellular_automaton = cpl.init_simple(100) # Evolve for 100 time steps cellular_automaton = cpl.evolve(cellular_automaton, timesteps=100, apply_rule=lambda n, c, g: cpl.nks_rule(n, 30)) # Plot the result plt.imshow(cellular_automaton, cmap='binary') plt.show()
Debug
Known issues
breakingIn v2.x, the 'evolve' function signature changed. The 'apply_rule' parameter now expects a function with three arguments (n, c, g) instead of two (n, c). Update your custom rules accordingly.
fix
Change rule function signature from lambda n, c: ... to lambda n, c, g: ...
affects: 2.0.0+
gotchainit_simple() expects a tuple (rows, cols) for 2D, but many users mistakenly pass a single integer for 1D. For 1D, pass the size as an integer, for 2D pass a tuple.
fix
For 1D: init_simple(100). For 2D: init_simple((50,50)).
affects: all
gotchaPlotting requires Matplotlib to be installed separately. It is not a dependency of cellpylib.
fix
Install matplotlib: pip install matplotlib
affects: all
Errors
Common errors & fixes
TypeError: evolve() got an unexpected keyword argument 'apply_rule'
Using old v1.x API where evolve accepted 'rule' parameter instead of 'apply_rule'.
fix
Upgrade to v2.x and change 'rule' to 'apply_rule': cpl.evolve(ca, timesteps=100, apply_rule=...) or for v1.x use evolve(ca, timesteps=100, rule=...)
AttributeError: module 'cellpylib' has no attribute 'cellular_automaton'
Attempting to import 'cellular_automaton' as a function; it is not a top-level function but a class or incorrect import pattern.
fix
Use import cellpylib as cpl and then cpl.init_simple(), cpl.evolve() etc.
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Trying to use a rule function that returns a vector instead of a single value, common in custom rules.
fix
Ensure the rule function returns a single integer (0 or 1) per cell.
Upgrade
Version history
2.4.0latest on PyPI · released Feb 15, 2023
Audit
Dependencies

No dependency data recorded yet.

Agent activity
18 hits · last 30 days
node
14
Amazon
1
OpenAI (training)
1
Resources
cellpylib — pip install cellpylib · libregistry