{"id":27639,"library":"cellpylib","title":"CellPyLib","description":"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.","status":"active","version":"2.4.0","language":"python","source_language":"en","source_url":"https://github.com/lantunes/cellpylib","tags":["cellular automata","simulation","conway's game of life","complex systems"],"install":[{"cmd":"pip install cellpylib","lang":"bash","label":"Install via pip"}],"dependencies":[],"imports":[{"note":"The correct usage is to import the module and access functions via cpl (e.g., cpl.cellular_automaton())","wrong":"from cellpylib import cellular_automaton","symbol":"cellular_automaton","correct":"import cellpylib as cpl"},{"note":"Direct import is also possible for individual functions.","symbol":"init_simple","correct":"from cellpylib import init_simple"},{"note":"evolve is a core function used to iterate cellular automaton steps.","symbol":"evolve","correct":"from cellpylib import evolve"}],"quickstart":{"code":"import cellpylib as cpl\nimport matplotlib.pyplot as plt\n\n# Initialize a 1D cellular automaton (Rule 30, size 100)\ncellular_automaton = cpl.init_simple(100)\n# Evolve for 100 time steps\ncellular_automaton = cpl.evolve(cellular_automaton, timesteps=100, apply_rule=lambda n, c, g: cpl.nks_rule(n, 30))\n# Plot the result\nplt.imshow(cellular_automaton, cmap='binary')\nplt.show()","lang":"python","description":"Initialize a 1D cellular automaton with Rule 30 and evolve it for 100 steps."},"warnings":[{"fix":"Change rule function signature from lambda n, c: ... to lambda n, c, g: ...","message":"In 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.","severity":"breaking","affected_versions":"2.0.0+"},{"fix":"For 1D: init_simple(100). For 2D: init_simple((50,50)).","message":"init_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.","severity":"gotcha","affected_versions":"all"},{"fix":"Install matplotlib: pip install matplotlib","message":"Plotting requires Matplotlib to be installed separately. It is not a dependency of cellpylib.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"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=...)","cause":"Using old v1.x API where evolve accepted 'rule' parameter instead of 'apply_rule'.","error":"TypeError: evolve() got an unexpected keyword argument 'apply_rule'"},{"fix":"Use import cellpylib as cpl and then cpl.init_simple(), cpl.evolve() etc.","cause":"Attempting to import 'cellular_automaton' as a function; it is not a top-level function but a class or incorrect import pattern.","error":"AttributeError: module 'cellpylib' has no attribute 'cellular_automaton'"},{"fix":"Ensure the rule function returns a single integer (0 or 1) per cell.","cause":"Trying to use a rule function that returns a vector instead of a single value, common in custom rules.","error":"ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}