{"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,"search_vec":"'1d':13 '2.4.0':30 '2d':15 '3.6':33 '30':22 'activ':37 'analysi':46 'automata':11,16,48 'cellpylib':1,2 'cellular':10,47 'complex':55 'conway':23,50 'current':28 'e.g':20 'focus':41 'game':25,52 'librari':6,35 'life':27,54 'maintain':38 'python':5,32 'requir':31 'rule':19,21 'simul':43,49 'support':12 'system':56 'various':18 'version':29 'visual':44 'work':8","created_at":"2026-05-09T05:51:17.735626+00:00","updated_at":"2026-05-09T05:51:17.735626+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"http://github.com/lantunes/cellpylib","docs":null,"changelog":null,"pypi":"https://pypi.org/project/cellpylib/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}