heaton-life 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. heaton_life-1.2.0/.gitignore +31 -0
  2. heaton_life-1.2.0/DEVELOPMENT.md +396 -0
  3. heaton_life-1.2.0/LICENSE +202 -0
  4. heaton_life-1.2.0/PKG-INFO +183 -0
  5. heaton_life-1.2.0/README.md +139 -0
  6. heaton_life-1.2.0/bandit-report.txt +891 -0
  7. heaton_life-1.2.0/black-report.txt +7 -0
  8. heaton_life-1.2.0/coverage.xml +16146 -0
  9. heaton_life-1.2.0/examples/heaton_life_intro.ipynb +243 -0
  10. heaton_life-1.2.0/examples/life_in_life/README.md +71 -0
  11. heaton_life-1.2.0/examples/life_in_life/board.py +88 -0
  12. heaton_life-1.2.0/examples/life_in_life/pick_glider.py +96 -0
  13. heaton_life-1.2.0/examples/life_in_life/render.py +384 -0
  14. heaton_life-1.2.0/examples/life_in_life/tiles.py +316 -0
  15. heaton_life-1.2.0/examples/life_in_life/verify.py +86 -0
  16. heaton_life-1.2.0/flake8-report.txt +142 -0
  17. heaton_life-1.2.0/isort-report.txt +0 -0
  18. heaton_life-1.2.0/mypy-report.txt +79 -0
  19. heaton_life-1.2.0/pyproject.toml +70 -0
  20. heaton_life-1.2.0/ruff-format-report.txt +312 -0
  21. heaton_life-1.2.0/ruff-report.txt +1 -0
  22. heaton_life-1.2.0/src/heaton_life/__init__.py +31 -0
  23. heaton_life-1.2.0/src/heaton_life/_self_check_data.py +1923 -0
  24. heaton_life-1.2.0/src/heaton_life/boids/__init__.py +5 -0
  25. heaton_life-1.2.0/src/heaton_life/boids/reynolds.py +349 -0
  26. heaton_life-1.2.0/src/heaton_life/ca/__init__.py +66 -0
  27. heaton_life-1.2.0/src/heaton_life/ca/_advance.py +88 -0
  28. heaton_life-1.2.0/src/heaton_life/ca/cyclic.py +173 -0
  29. heaton_life-1.2.0/src/heaton_life/ca/elementary.py +180 -0
  30. heaton_life-1.2.0/src/heaton_life/ca/generations.py +329 -0
  31. heaton_life-1.2.0/src/heaton_life/ca/hashlife/__init__.py +92 -0
  32. heaton_life-1.2.0/src/heaton_life/ca/hashlife/files.py +163 -0
  33. heaton_life-1.2.0/src/heaton_life/ca/hashlife/leaves.py +208 -0
  34. heaton_life-1.2.0/src/heaton_life/ca/hashlife/macrocell.py +581 -0
  35. heaton_life-1.2.0/src/heaton_life/ca/hashlife/multistate/__init__.py +38 -0
  36. heaton_life-1.2.0/src/heaton_life/ca/hashlife/multistate/convert.py +172 -0
  37. heaton_life-1.2.0/src/heaton_life/ca/hashlife/multistate/files.py +206 -0
  38. heaton_life-1.2.0/src/heaton_life/ca/hashlife/multistate/macrocell.py +572 -0
  39. heaton_life-1.2.0/src/heaton_life/ca/hashlife/multistate/render.py +164 -0
  40. heaton_life-1.2.0/src/heaton_life/ca/hashlife/multistate/rle.py +220 -0
  41. heaton_life-1.2.0/src/heaton_life/ca/hashlife/multistate/store.py +325 -0
  42. heaton_life-1.2.0/src/heaton_life/ca/hashlife/multistate/universe.py +1371 -0
  43. heaton_life-1.2.0/src/heaton_life/ca/hashlife/render.py +152 -0
  44. heaton_life-1.2.0/src/heaton_life/ca/hashlife/rle.py +161 -0
  45. heaton_life-1.2.0/src/heaton_life/ca/hashlife/store.py +355 -0
  46. heaton_life-1.2.0/src/heaton_life/ca/hashlife/universe.py +1292 -0
  47. heaton_life-1.2.0/src/heaton_life/ca/hashlife/view.py +143 -0
  48. heaton_life-1.2.0/src/heaton_life/ca/history.py +159 -0
  49. heaton_life-1.2.0/src/heaton_life/ca/lifelike.py +217 -0
  50. heaton_life-1.2.0/src/heaton_life/ca/ltl.py +459 -0
  51. heaton_life-1.2.0/src/heaton_life/ca/mergelife.py +315 -0
  52. heaton_life-1.2.0/src/heaton_life/ca/mergelife_gallery.py +113 -0
  53. heaton_life-1.2.0/src/heaton_life/ca/rulefile.py +1096 -0
  54. heaton_life-1.2.0/src/heaton_life/ca/rules/Ant-LLRR.rle +4 -0
  55. heaton_life-1.2.0/src/heaton_life/ca/rules/Ant-LLRR.rule +141 -0
  56. heaton_life-1.2.0/src/heaton_life/ca/rules/Ant-RLR.rle +4 -0
  57. heaton_life-1.2.0/src/heaton_life/ca/rules/Ant-RLR.rule +103 -0
  58. heaton_life-1.2.0/src/heaton_life/ca/rules/Byl-Loop.rle +5 -0
  59. heaton_life-1.2.0/src/heaton_life/ca/rules/Byl-Loop.rule +107 -0
  60. heaton_life-1.2.0/src/heaton_life/ca/rules/Evoloop.rle +6 -0
  61. heaton_life-1.2.0/src/heaton_life/ca/rules/Evoloop.rule +324 -0
  62. heaton_life-1.2.0/src/heaton_life/ca/rules/Langtons-Ant.rle +4 -0
  63. heaton_life-1.2.0/src/heaton_life/ca/rules/Langtons-Ant.rule +75 -0
  64. heaton_life-1.2.0/src/heaton_life/ca/rules/Langtons-Loops.rle +5 -0
  65. heaton_life-1.2.0/src/heaton_life/ca/rules/Langtons-Loops.rule +252 -0
  66. heaton_life-1.2.0/src/heaton_life/ca/rulestring.py +535 -0
  67. heaton_life-1.2.0/src/heaton_life/ca/ruletable.py +357 -0
  68. heaton_life-1.2.0/src/heaton_life/ca/state_rules.py +196 -0
  69. heaton_life-1.2.0/src/heaton_life/ca/super_rules.py +294 -0
  70. heaton_life-1.2.0/src/heaton_life/ca/wireworld.py +235 -0
  71. heaton_life-1.2.0/src/heaton_life/conformance.py +354 -0
  72. heaton_life-1.2.0/src/heaton_life/core/__init__.py +42 -0
  73. heaton_life-1.2.0/src/heaton_life/core/bignum.py +404 -0
  74. heaton_life-1.2.0/src/heaton_life/core/decimal_text.py +211 -0
  75. heaton_life-1.2.0/src/heaton_life/core/fftconv.py +24 -0
  76. heaton_life-1.2.0/src/heaton_life/core/floatexp.py +252 -0
  77. heaton_life-1.2.0/src/heaton_life/core/neighbors.py +50 -0
  78. heaton_life-1.2.0/src/heaton_life/core/params.py +53 -0
  79. heaton_life-1.2.0/src/heaton_life/core/pow10.py +102 -0
  80. heaton_life-1.2.0/src/heaton_life/core/protocols.py +41 -0
  81. heaton_life-1.2.0/src/heaton_life/core/rng.py +39 -0
  82. heaton_life-1.2.0/src/heaton_life/core/stencil.py +27 -0
  83. heaton_life-1.2.0/src/heaton_life/core/topology.py +406 -0
  84. heaton_life-1.2.0/src/heaton_life/core/turns.py +63 -0
  85. heaton_life-1.2.0/src/heaton_life/core/viewport.py +119 -0
  86. heaton_life-1.2.0/src/heaton_life/evolve/__init__.py +26 -0
  87. heaton_life-1.2.0/src/heaton_life/evolve/ga.py +199 -0
  88. heaton_life-1.2.0/src/heaton_life/evolve/objective.py +246 -0
  89. heaton_life-1.2.0/src/heaton_life/fractal/__init__.py +92 -0
  90. heaton_life-1.2.0/src/heaton_life/fractal/animate.py +40 -0
  91. heaton_life-1.2.0/src/heaton_life/fractal/bla.py +572 -0
  92. heaton_life-1.2.0/src/heaton_life/fractal/coloring.py +246 -0
  93. heaton_life-1.2.0/src/heaton_life/fractal/engine.py +392 -0
  94. heaton_life-1.2.0/src/heaton_life/fractal/escape_fields.py +461 -0
  95. heaton_life-1.2.0/src/heaton_life/fractal/locations.py +532 -0
  96. heaton_life-1.2.0/src/heaton_life/fractal/movie.py +763 -0
  97. heaton_life-1.2.0/src/heaton_life/fractal/navigation.py +185 -0
  98. heaton_life-1.2.0/src/heaton_life/fractal/newton.py +108 -0
  99. heaton_life-1.2.0/src/heaton_life/fractal/nucleus.py +509 -0
  100. heaton_life-1.2.0/src/heaton_life/fractal/perturbation.py +217 -0
  101. heaton_life-1.2.0/src/heaton_life/fractal/perturbation_t2.py +584 -0
  102. heaton_life-1.2.0/src/heaton_life/fractal/policy.py +107 -0
  103. heaton_life-1.2.0/src/heaton_life/init/__init__.py +85 -0
  104. heaton_life-1.2.0/src/heaton_life/init/builtins.py +81 -0
  105. heaton_life-1.2.0/src/heaton_life/init/formats.py +597 -0
  106. heaton_life-1.2.0/src/heaton_life/init/images.py +273 -0
  107. heaton_life-1.2.0/src/heaton_life/init/mcell.py +395 -0
  108. heaton_life-1.2.0/src/heaton_life/init/metadata.py +137 -0
  109. heaton_life-1.2.0/src/heaton_life/init/patterns.py +220 -0
  110. heaton_life-1.2.0/src/heaton_life/init/png_io.py +48 -0
  111. heaton_life-1.2.0/src/heaton_life/init/rle.py +490 -0
  112. heaton_life-1.2.0/src/heaton_life/init/seeding.py +51 -0
  113. heaton_life-1.2.0/src/heaton_life/lenia/__init__.py +16 -0
  114. heaton_life-1.2.0/src/heaton_life/lenia/asymptotic.py +63 -0
  115. heaton_life-1.2.0/src/heaton_life/lenia/base.py +160 -0
  116. heaton_life-1.2.0/src/heaton_life/lenia/classic.py +59 -0
  117. heaton_life-1.2.0/src/heaton_life/lenia/flow.py +131 -0
  118. heaton_life-1.2.0/src/heaton_life/lenia/kernels.py +37 -0
  119. heaton_life-1.2.0/src/heaton_life/playground/__init__.py +20 -0
  120. heaton_life-1.2.0/src/heaton_life/playground/__main__.py +4 -0
  121. heaton_life-1.2.0/src/heaton_life/playground/app.py +484 -0
  122. heaton_life-1.2.0/src/heaton_life/playground/canvas.py +379 -0
  123. heaton_life-1.2.0/src/heaton_life/playground/engine.py +424 -0
  124. heaton_life-1.2.0/src/heaton_life/playground/fractal_sim.py +240 -0
  125. heaton_life-1.2.0/src/heaton_life/playground/hashlife_sim.py +324 -0
  126. heaton_life-1.2.0/src/heaton_life/playground/lifelike_sim.py +378 -0
  127. heaton_life-1.2.0/src/heaton_life/playground/model.py +76 -0
  128. heaton_life-1.2.0/src/heaton_life/playground/navigator.py +90 -0
  129. heaton_life-1.2.0/src/heaton_life/playground/param_form.py +324 -0
  130. heaton_life-1.2.0/src/heaton_life/playground/registry.py +873 -0
  131. heaton_life-1.2.0/src/heaton_life/playground/transport.py +133 -0
  132. heaton_life-1.2.0/src/heaton_life/py.typed +0 -0
  133. heaton_life-1.2.0/src/heaton_life/rd/__init__.py +5 -0
  134. heaton_life-1.2.0/src/heaton_life/rd/gray_scott.py +203 -0
  135. heaton_life-1.2.0/src/heaton_life/render/__init__.py +62 -0
  136. heaton_life-1.2.0/src/heaton_life/render/_palette_tables.py +114 -0
  137. heaton_life-1.2.0/src/heaton_life/render/animate.py +204 -0
  138. heaton_life-1.2.0/src/heaton_life/render/colormap.py +173 -0
  139. heaton_life-1.2.0/src/heaton_life/render/dither.py +80 -0
  140. heaton_life-1.2.0/src/heaton_life/render/image.py +22 -0
  141. heaton_life-1.2.0/src/heaton_life/render/palette.py +334 -0
  142. heaton_life-1.2.0/src/heaton_life/render/window.py +128 -0
  143. heaton_life-1.2.0/src/heaton_life/self_check.py +591 -0
  144. heaton_life-1.2.0/src/heaton_life/version.py +5 -0
  145. heaton_life-1.2.0/tests/test_advance_cancel.py +158 -0
  146. heaton_life-1.2.0/tests/test_bla.py +406 -0
  147. heaton_life-1.2.0/tests/test_boids.py +262 -0
  148. heaton_life-1.2.0/tests/test_builtin_patterns.py +124 -0
  149. heaton_life-1.2.0/tests/test_clear_rect.py +99 -0
  150. heaton_life-1.2.0/tests/test_coloring.py +277 -0
  151. heaton_life-1.2.0/tests/test_cyclic.py +71 -0
  152. heaton_life-1.2.0/tests/test_decimal_text.py +111 -0
  153. heaton_life-1.2.0/tests/test_deep_oracle.py +220 -0
  154. heaton_life-1.2.0/tests/test_distance.py +197 -0
  155. heaton_life-1.2.0/tests/test_editing.py +648 -0
  156. heaton_life-1.2.0/tests/test_elementary.py +62 -0
  157. heaton_life-1.2.0/tests/test_evolve.py +145 -0
  158. heaton_life-1.2.0/tests/test_evolve_vectors.py +111 -0
  159. heaton_life-1.2.0/tests/test_floatexp_vectors.py +109 -0
  160. heaton_life-1.2.0/tests/test_format_vectors.py +291 -0
  161. heaton_life-1.2.0/tests/test_formats.py +448 -0
  162. heaton_life-1.2.0/tests/test_fractal.py +399 -0
  163. heaton_life-1.2.0/tests/test_fractal_sim.py +70 -0
  164. heaton_life-1.2.0/tests/test_fractal_vectors.py +314 -0
  165. heaton_life-1.2.0/tests/test_generations.py +257 -0
  166. heaton_life-1.2.0/tests/test_generations_rules_vectors.py +52 -0
  167. heaton_life-1.2.0/tests/test_grayscott.py +65 -0
  168. heaton_life-1.2.0/tests/test_hashlife.py +600 -0
  169. heaton_life-1.2.0/tests/test_hashlife_b0.py +305 -0
  170. heaton_life-1.2.0/tests/test_hashlife_giants.py +147 -0
  171. heaton_life-1.2.0/tests/test_hashlife_multistate.py +1093 -0
  172. heaton_life-1.2.0/tests/test_hashlife_multistate_vectors.py +404 -0
  173. heaton_life-1.2.0/tests/test_hashlife_sim.py +298 -0
  174. heaton_life-1.2.0/tests/test_hashlife_snapshots.py +184 -0
  175. heaton_life-1.2.0/tests/test_hashlife_vectors.py +246 -0
  176. heaton_life-1.2.0/tests/test_history.py +300 -0
  177. heaton_life-1.2.0/tests/test_interior_shortcuts.py +143 -0
  178. heaton_life-1.2.0/tests/test_lenia.py +94 -0
  179. heaton_life-1.2.0/tests/test_lifelike.py +164 -0
  180. heaton_life-1.2.0/tests/test_location_vectors.py +75 -0
  181. heaton_life-1.2.0/tests/test_locations.py +75 -0
  182. heaton_life-1.2.0/tests/test_ltl.py +334 -0
  183. heaton_life-1.2.0/tests/test_ltl_rule_vectors.py +69 -0
  184. heaton_life-1.2.0/tests/test_mcell.py +310 -0
  185. heaton_life-1.2.0/tests/test_mergelife.py +158 -0
  186. heaton_life-1.2.0/tests/test_mergelife_gallery.py +70 -0
  187. heaton_life-1.2.0/tests/test_movie.py +557 -0
  188. heaton_life-1.2.0/tests/test_navigation.py +203 -0
  189. heaton_life-1.2.0/tests/test_navigation_vectors.py +77 -0
  190. heaton_life-1.2.0/tests/test_nucleus.py +218 -0
  191. heaton_life-1.2.0/tests/test_nucleus_vectors.py +126 -0
  192. heaton_life-1.2.0/tests/test_off_center_reference.py +406 -0
  193. heaton_life-1.2.0/tests/test_palettes.py +284 -0
  194. heaton_life-1.2.0/tests/test_params.py +26 -0
  195. heaton_life-1.2.0/tests/test_pattern_vectors.py +198 -0
  196. heaton_life-1.2.0/tests/test_patterns.py +112 -0
  197. heaton_life-1.2.0/tests/test_playground_lifelike.py +309 -0
  198. heaton_life-1.2.0/tests/test_playground_model.py +65 -0
  199. heaton_life-1.2.0/tests/test_playground_navigator.py +105 -0
  200. heaton_life-1.2.0/tests/test_playground_smoke.py +1097 -0
  201. heaton_life-1.2.0/tests/test_png_io.py +32 -0
  202. heaton_life-1.2.0/tests/test_png_io_vectors.py +30 -0
  203. heaton_life-1.2.0/tests/test_policy_vectors.py +27 -0
  204. heaton_life-1.2.0/tests/test_pow10.py +58 -0
  205. heaton_life-1.2.0/tests/test_release_version.py +41 -0
  206. heaton_life-1.2.0/tests/test_render.py +69 -0
  207. heaton_life-1.2.0/tests/test_render_vectors.py +420 -0
  208. heaton_life-1.2.0/tests/test_rle.py +170 -0
  209. heaton_life-1.2.0/tests/test_rng.py +39 -0
  210. heaton_life-1.2.0/tests/test_rule_consumers.py +204 -0
  211. heaton_life-1.2.0/tests/test_rule_vectors.py +68 -0
  212. heaton_life-1.2.0/tests/test_rulefile.py +266 -0
  213. heaton_life-1.2.0/tests/test_rulestring.py +269 -0
  214. heaton_life-1.2.0/tests/test_ruletable.py +478 -0
  215. heaton_life-1.2.0/tests/test_ruletable_files_vectors.py +90 -0
  216. heaton_life-1.2.0/tests/test_self_check.py +159 -0
  217. heaton_life-1.2.0/tests/test_set_state.py +120 -0
  218. heaton_life-1.2.0/tests/test_super.py +372 -0
  219. heaton_life-1.2.0/tests/test_t2_step_vectors.py +199 -0
  220. heaton_life-1.2.0/tests/test_topology.py +515 -0
  221. heaton_life-1.2.0/tests/test_topology_vectors.py +111 -0
  222. heaton_life-1.2.0/tests/test_turns_vectors.py +49 -0
  223. heaton_life-1.2.0/tests/test_vectors.py +57 -0
  224. heaton_life-1.2.0/tests/test_viewport.py +59 -0
  225. heaton_life-1.2.0/tests/test_window.py +185 -0
  226. heaton_life-1.2.0/tests/test_wireworld.py +61 -0
  227. heaton_life-1.2.0/tests/test_zoom_vectors.py +199 -0
  228. heaton_life-1.2.0/tools/bench_hashlife.py +111 -0
  229. heaton_life-1.2.0/tools/fetch_patterns.py +142 -0
  230. heaton_life-1.2.0/tools/gen_gallery.py +113 -0
  231. heaton_life-1.2.0/tools/gen_palettes.py +240 -0
  232. heaton_life-1.2.0/tools/gen_rule_tables.py +153 -0
  233. heaton_life-1.2.0/tools/gen_self_check.py +1063 -0
  234. heaton_life-1.2.0/tools/gen_vectors.py +13154 -0
  235. heaton_life-1.2.0/tools/score_rules.py +86 -0
  236. heaton_life-1.2.0/unit_test_results.xml +1 -0
@@ -0,0 +1,31 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .eggs/
6
+ dist/
7
+ build/
8
+ .venv/
9
+ venv/
10
+ .pytest_cache/
11
+ .ruff_cache/
12
+ .mypy_cache/
13
+ .coverage
14
+ htmlcov/
15
+ # Giant test patterns (python/tools/fetch_patterns.py): no stated license, never committed
16
+ python/.patterns/
17
+ # Life in Life example: everything derived from the OTCA metapixel (no stated license)
18
+ python/examples/life_in_life/out/
19
+
20
+ # .NET
21
+ bin/
22
+ obj/
23
+ *.user
24
+ *.suo
25
+ .vs/
26
+
27
+ # OS / editors
28
+ .DS_Store
29
+ Thumbs.db
30
+ .idea/
31
+ .vscode/
@@ -0,0 +1,396 @@
1
+ # Developing heaton-life (Python)
2
+
3
+ This guide is for working on the library itself. If you only want to use it, the
4
+ [README](README.md) covers installation and the API.
5
+
6
+ The Python package is one part of a larger repository. The algorithm
7
+ specifications (`../spec/`), the golden conformance vectors (`../vectors/`), and
8
+ the .NET implementation (`../dotnet/`) sit beside it, and the tests here read the
9
+ vectors directly, so work from a full clone rather than from an installed wheel.
10
+
11
+ ## Prerequisites
12
+
13
+ - Python 3.11 or newer.
14
+ - A clone of the repository:
15
+
16
+ ```
17
+ git clone https://github.com/jeffheaton/heaton-life.git
18
+ cd heaton-life/python
19
+ ```
20
+
21
+ - Optional, for MP4 export: `ffmpeg` is pulled in by the `video` extra
22
+ (`imageio-ffmpeg`), nothing to install by hand.
23
+ - Optional, for fast deep zooms: the `precision` extra installs `gmpy2`; binary
24
+ wheels exist for the common platforms. Without it the orbit runs on plain Python
25
+ integers, about half as fast and bit-for-bit the same.
26
+
27
+ ## Setting up
28
+
29
+ The project convention is a virtual environment at `python/.venv`:
30
+
31
+ ```
32
+ python -m venv .venv
33
+ source .venv/bin/activate # Windows: .venv\Scripts\activate
34
+ pip install -e ".[dev,playground,video]"
35
+ ```
36
+
37
+ | Extra | What it adds |
38
+ |---|---|
39
+ | `dev` | pytest, pytest-cov, ruff, mypy, gmpy2 (the test suite exercises the fast deep-zoom path), mpmath (an independent oracle in `test_pow10.py`) |
40
+ | `playground` | PyQt6, for the interactive app and its offscreen tests |
41
+ | `precision` | gmpy2 for faster deep-zoom reference orbits (plain Python ints otherwise; identical results) |
42
+ | `video` | imageio-ffmpeg for `.mp4` output from `Animation.save`, `render_zoom_movie` / `MovieWriter` and `encode_frames` |
43
+
44
+ ## Layout
45
+
46
+ ```
47
+ python/
48
+ ├── pyproject.toml # packaging, ruff, pytest, and mypy configuration
49
+ ├── src/heaton_life/ # the package (src layout; installed editable above)
50
+ │ ├── core/ # protocols, Viewport, params, PCG32, buffers, kernels, integrators
51
+ │ ├── ca/ # lifelike, elementary, cyclic, wireworld, mergelife (+ the rule gallery),
52
+ │ │ # hashlife/ (the unbounded universe, Macrocell, views, frames)
53
+ │ ├── lenia/ # kernels, classic, asymptotic, flow
54
+ │ ├── fractal/ # escape-time engine, perturbation engine, mandelbrot, julia, burning_ship, newton
55
+ │ ├── boids/ # reynolds (O(N²) neighbors, capped at 2k boids; a spatial hash is future work)
56
+ │ ├── rd/ # gray_scott + presets
57
+ │ ├── evolve/ # the MergeLife genetic algorithm and objective
58
+ │ ├── init/ # soup, blob, single, RLE import, built-in patterns, PNG I/O
59
+ │ ├── render/ # colormaps, image, animate (GIF/MP4 with inline notebook display)
60
+ │ ├── playground/ # PyQt6 app (optional extra)
61
+ │ └── version.py # build stamp (see Releasing)
62
+ ├── tests/ # pytest suite; replays ../vectors and drives the playground offscreen
63
+ ├── tools/ # gen_vectors.py, gen_gallery.py, gen_palettes.py, score_rules.py,
64
+ │ # bench_hashlife.py, fetch_patterns.py
65
+ └── examples/ # the intro notebook (runs in Colab)
66
+ ```
67
+
68
+ ## The checks
69
+
70
+ These four commands are what the Build Library workflow runs. `ruff check`, `mypy`,
71
+ and `pytest` must be green before committing; `ruff format --check` is advisory (see
72
+ below).
73
+
74
+ ```
75
+ ruff check src tests tools
76
+ ruff format --check src tests tools
77
+ mypy
78
+ QT_QPA_PLATFORM=offscreen pytest -q
79
+ ```
80
+
81
+ - **ruff**: line length 100, configured in `pyproject.toml`. `ruff format --check` is
82
+ advisory in CI and the tree is not currently format-clean (about 40 files would
83
+ change), so format only the files you touch (`ruff format <file>`) rather than
84
+ reformatting the tree in an unrelated commit.
85
+ - **mypy** runs in strict mode over `heaton_life` (`gmpy2` has no stubs and is
86
+ ignored for missing imports).
87
+ - **pytest** takes a few seconds. `pytest -m "not slow"` skips the long evolver
88
+ runs and the deep-zoom oracle (`tests/test_deep_oracle.py`, the only tests that
89
+ check T1 against direct arbitrary-precision iteration), so run the full suite
90
+ before touching the fractal code. Coverage: `pytest --cov=heaton_life --cov-report=term`.
91
+ - The playground tests run Qt offscreen, which is what `QT_QPA_PLATFORM=offscreen`
92
+ is for. On a headless Linux machine install `libegl1 libgl1 libxkbcommon0` first.
93
+
94
+ ## How the library is built: the spec decides
95
+
96
+ heaton-life is spec first and multi-language, and that shapes every change.
97
+
98
+ - **The specification wins.** Each family has a page under `../spec/` describing
99
+ its math (gather, respond, integrate), its parameters, and its random draws.
100
+ When an implementation and the spec disagree, the implementation is wrong, or
101
+ the spec gets fixed deliberately and every implementation follows.
102
+ - **The vectors decide disputes.** `../vectors/` holds golden outputs
103
+ (`params.json` plus expected states) shared by every implementation. Families
104
+ in the bit-exact tier (the discrete automata, fractal iteration counts, colormaps
105
+ and frame indexing, fractal color and the phase lookup, patterns and RLE, PNG grid
106
+ I/O, the evolver) must match byte for byte; the epsilon tier (Lenia, boids,
107
+ Gray-Scott, and the `fractal-render-*` cases under `render/`) must match within the
108
+ tolerance recorded in each `params.json`, and the fractal `distance` output within
109
+ its own `relative_epsilon`.
110
+ - **All randomness flows through PCG32** (`heaton_life.core.rng.Pcg32`). Never use
111
+ NumPy's random module or Python's `random`; seeding and draw order are part of
112
+ each family's spec, and the .NET port reproduces them exactly.
113
+ - **Never regenerate existing vectors casually.** They are the cross-language
114
+ contract. Regenerate only when a deliberate spec change justifies it, and add
115
+ new families or cases additively by appending their `write_case(...)` calls to
116
+ `tools/gen_vectors.py`. The script has no section selector and regenerates every
117
+ family when run except `png-io` (its `write_png_io_cases()` is not called from
118
+ `main()` because PNG bytes are encoder-specific; invoke it by hand when adding a
119
+ png-io case); afterward check `git status ../vectors/` and confirm only the
120
+ new case directories changed (existing vectors must come back byte-identical)
121
+ before committing. `../vectors/mergelife-upstream/` tracks the upstream MergeLife
122
+ project and is never regenerated here.
123
+ - **Changes travel in order**: spec page, then the Python implementation (plus
124
+ additive vectors if there is new surface), then the .NET port, with both test
125
+ suites green. The C# port is expression for expression where a bit-exact tier
126
+ applies, so keep Python expressions in the shape the spec gives them.
127
+
128
+ Some floating-point rules are not obvious and are easy to "clean up" by mistake:
129
+
130
+ - Powers of ten in the fractal pixel scale go through `heaton_life.core.pow10`
131
+ (the integer algorithm in `../spec/pow10.md`), never `10 ** x`, `math.pow`, or
132
+ `log10`. Platform math libraries differ in the last bit at fractional zooms, and
133
+ that flips escape counts in a bit-exact vector.
134
+ - NumPy (2.0.2 and later, hence the floor) fuses complex multiplies into FMAs; the C# port mirrors that at the
135
+ same sites. Do not restructure the complex arithmetic in the fractal engine.
136
+ - Rounding is half-even (`np.round`), and operation order is specified where it
137
+ matters (for example the Gray-Scott Laplacian `((N + S) + W) + E - 4C`).
138
+
139
+ ## Adding or changing a family
140
+
141
+ 1. Write or update the spec page first, including parameters, seeding, and the
142
+ conformance cases you intend to pin.
143
+ 2. Implement it under the matching package, following the `Simulation` protocol
144
+ in `core/protocols.py`: `step(n)`, `reset(seed)`, `state`, and `frame()`.
145
+ Frames are always renderable: 2-D `uint8`, 2-D float in `[0, 1]`, or `HxWx3`
146
+ `uint8` RGB. Fractals implement the `Field` protocol instead
147
+ (`render(size, viewport)`).
148
+ 3. Give it a frozen `Params` dataclass with UI metadata on each field (`label`,
149
+ `min`, `max`, `step`, `choices`, `role`; see `ca/lifelike.py` for the pattern). The playground builds its forms from this,
150
+ so a new family gets a UI for free.
151
+ 4. Curated content (presets, galleries, built-in patterns) is part of the
152
+ cross-implementation contract: it is listed in the spec and pinned by tests in
153
+ both ports rather than by vectors.
154
+ 5. Wire it into the conformance machinery: a codec and tier for the family in
155
+ `src/heaton_life/conformance.py` (`CODECS`, `TIERS`; the codec defines the vector
156
+ file encoding, which the spec page's vector section must match) and a section in
157
+ `tools/gen_vectors.py` (read the regeneration policy above first). Then add tests:
158
+ unit tests for the implementation and a conformance test that replays the
159
+ family's vectors.
160
+ 6. Port it to .NET (`../dotnet/`), then update the docs: the README sample if it
161
+ belongs there, and the gallery image via `tools/gen_gallery.py`.
162
+
163
+ ## Tools
164
+
165
+ - `tools/gen_gallery.py` renders one tile per system into `../docs/gallery.png`,
166
+ the image at the top of both READMEs.
167
+ - `tools/gen_vectors.py` generates conformance vectors. Read the regeneration
168
+ policy above before running any of it.
169
+ - `tools/gen_palettes.py` records how the cyclic palettes (`../spec/render.md`,
170
+ "Cyclic palettes") were baked into `src/heaton_life/render/_palette_tables.py` and
171
+ `../dotnet/src/HeatonLife.Core/PaletteTables.cs`. Those bytes are normative data,
172
+ pinned by `../vectors/render/lut-<name>/`; the script is not re-run casually, and if
173
+ it is, both table files and the LUT vectors must come back unchanged.
174
+ - `tools/bench_hashlife.py` measures HashLife throughput (`../spec/hashlife.md`): load
175
+ time, then generations per second at fixed step sizes 2^e, with nodes, store memory
176
+ (and its peak), collections, and the process's peak RSS, for the built-in set or any
177
+ `.rle`/`.mc`/`.mc.gz` files given. See "HashLife giants" below.
178
+ - `tools/fetch_patterns.py` downloads the giant HashLife patterns (the Caterpillar and
179
+ Annelid) into the git-ignored `.patterns/` and checks each against its pinned size and
180
+ SHA-256. See "HashLife giants" below.
181
+ - `tools/score_rules.py` scores MergeLife rule strings with the paper objective
182
+ (`../spec/evolve.md`).
183
+
184
+ ## HashLife giants
185
+
186
+ Two engineered spaceships are the HashLife engine's stress tests: **the Caterpillar**
187
+ (Nivasch, Summers and Bell, 2004; 17c/45, 11,967,399 cells, an 8 MB Macrocell file) and
188
+ **Annelid** (Brithos, 2026; (28,3)c/84, 168,807,151 cells, 5.5 MB of gzip Macrocell).
189
+ Neither file states a license, so neither is committed. `tools/fetch_patterns.py` fetches
190
+ pinned Wayback Machine copies (conwaylife.com refuses scripts) into the git-ignored
191
+ `.patterns/`, checking each file's size and SHA-256:
192
+
193
+ ```
194
+ .venv/bin/python tools/fetch_patterns.py
195
+ export HEATON_LIFE_PATTERNS="$PWD/.patterns"
196
+ .venv/bin/pytest -q tests/test_hashlife_giants.py
197
+ .venv/bin/python tools/bench_hashlife.py .patterns/caterpillar.mc \
198
+ --budget 4000 --exponents 0,4,8 --seconds 30 --min-steps 2
199
+ ```
200
+
201
+ `tests/test_hashlife_giants.py` skips unless `HEATON_LIFE_PATTERNS` names the cache
202
+ (and is marked `slow`). It checks the Macrocell placement (the Caterpillar's top-left cell
203
+ lands on (0, 0); Annelid's box) and one period of each ship:
204
+
205
+ - The Caterpillar after 270 generations equals generation 0 moved 102 cells up, compared
206
+ row for row with `get_rect` in strips, once under an 8 GB budget and once under 1.5 GB,
207
+ where the 2^8 sub-step overflows the store and takes the abandon, collect, and halve
208
+ path ("Memory" in `../spec/hashlife.md`).
209
+ - Annelid after 252 generations has moved (−9, −84) with the same population, the same
210
+ 128 × 128 grid of `population_in` regions relative to its box, and identical 512 × 512
211
+ windows around a live cell of each occupied region on the grid's diagonals. The whole
212
+ state is too big to compare cell by cell.
213
+
214
+ It takes about five minutes and 4 to 6 GB of memory.
215
+
216
+ **Measurements** (2026-11-02, Apple silicon, CPython 3.12; one process per budget, five
217
+ at a time; `--exponents 0,4,8 --seconds 30 --min-steps 2`, so each size runs at least 30 s
218
+ and two steps, starting where the previous size stopped). Peak store is the budget's own
219
+ estimate, sampled between steps; RSS is the process's peak; collections are cumulative.
220
+
221
+ The Caterpillar loads in 0.7 s (336,720 nodes, 41 MiB of store):
222
+
223
+ | Budget (MiB) | 2^0 gen/s | 2^4 gen/s | 2^8 gen/s (512 gens) | Peak store (MiB) | Collections | Peak RSS (MiB) |
224
+ |---:|---:|---:|---:|---:|---:|---:|
225
+ | 500 | 0.20 | 1.5 | 0.95 (537 s) | 477 | 49 | 1,314 |
226
+ | 1,000 | 0.22 | 2.7 | 1.1 (471 s) | 880 | 19 | 2,262 |
227
+ | 2,000 | 0.27 | 3.0 | 5.7 (89 s) | 1,970 | 2 | 4,405 |
228
+ | 4,000 | 0.27 | 3.6 | 6.0 (85 s) | 3,096 | 1 | 5,397 |
229
+ | 8,000 | 0.26 | 3.6 | 8.2 (62 s) | 3,836 | 0 | 6,444 |
230
+
231
+ Annelid loads in 1.6 s (778,484 nodes, 101 MiB of store). One generation rebuilds about
232
+ 2.8 million nodes, so single generations cost 19 s; at 2^8 a generation costs 0.13 s:
233
+
234
+ | Budget (MiB) | 2^0 gen/s | 2^4 gen/s | 2^8 gen/s (512 gens) | Peak store (MiB) | Collections | Peak RSS (MiB) |
235
+ |---:|---:|---:|---:|---:|---:|---:|
236
+ | 1,000 | 0.05 | 0.41 | 0.59 (862 s) | 994 | 21 | 2,328 |
237
+ | 2,000 | 0.05 | 0.64 | 4.6 (112 s) | 1,855 | 2 | 3,060 |
238
+ | 4,000 | 0.05 | 0.64 | 7.4 (69 s) | 3,645 | 0 | 5,915 |
239
+ | 8,000 | 0.05 | 0.64 | 7.5 (69 s) | 3,645 | 0 | 5,908 |
240
+
241
+ At 500 MiB the first generation raises `HashLifeMemoryError`: one generation's new nodes
242
+ don't fit beside the pattern.
243
+
244
+ **The speed gate.** Neither giant stalls at the budgets Python needs for it, 2 to 8 GB:
245
+ from 2 GB up a 2^8 step costs 31 to 45 s on the Caterpillar and 34 to 56 s on Annelid,
246
+ with at most a couple of collections. Below that the budget, not the algorithm, sets the
247
+ pace. A sub-step whose new nodes overflow the store is abandoned, collected, and split in
248
+ half ("Memory" in `../spec/hashlife.md`), so at 500 MiB to 1 GB the Caterpillar's 2^8
249
+ steps run about 8 times slower (Annelid's 13 times, at 1 GB), and at the default 500 MiB
250
+ Annelid can't take a single generation (`step` says so and asks for a bigger budget).
251
+ Results are identical at every budget: the tight-budget Caterpillar test above, and
252
+ `tests/test_hashlife.py` at 10 and 500 MiB.
253
+
254
+ So `store.py` is unchanged. In-flight collection (a saved-node stack, so a step
255
+ collects midway instead of starting over) would cut the waste below 2 GB, but every
256
+ recursion would pay for the stack, and a 2^8 Caterpillar step still makes about 8 million
257
+ new nodes, a gigabyte of store, so a 500 MiB budget would collect over and over. A denser
258
+ store has little room in pure Python: a node is a dict entry, a tuple, and an int, about
259
+ 130 bytes. The C# port's arena has both. Run the giants in Python at 2 to 8 GB; the
260
+ playground's giant presets ask for 4 GB (the Caterpillar) and 8 GB (Annelid), and the
261
+ giant tests run at 8 GB (the Caterpillar's period once more at 1.5 GB).
262
+
263
+ The budget is the store's own estimate (about 130 bytes a node plus 45 to 100 per cached
264
+ result, fitted with `tracemalloc`). The process's peak RSS runs 1.6 to 2.8 times the store's
265
+ peak (the interpreter's own 100 MB or so, and memory freed by collections stays with the
266
+ allocator), so leave headroom.
267
+
268
+ ## Multi-state HashLife speed
269
+
270
+ `MultiStateHashLife` (`../spec/hashlife-multistate.md`) runs the two-state engine's
271
+ algorithm on 2 × 2 leaves of states, its base case (a 4 × 4 square's center one
272
+ generation on) computed from the rule's cell function and memoized per node. Measured on
273
+ this Mac (2026-11-21) on Wireworld soups from PCG32 (about half conductor, one cell in
274
+ twenty a head and one a tail), the same cells in both ports:
275
+
276
+ | Workload | Python | .NET |
277
+ |---|---|---|
278
+ | 256 × 256 soup: 1, 8, 64 generations | 41, 154, 288 ms (0.7–1.1 M new nodes/s) | 6, 18, 45 ms (4.7–8 M/s) |
279
+ | 1024 × 1024 soup: 1, then 64 generations | 0.70 s, then 8.0 s (0.65–0.9 M/s) | 35 ms, then 0.74 s (7–14 M/s) |
280
+ | the same soup, settled: 2^30 generations | 72 ms | 2 ms |
281
+ | a chaotic 3-state rule, 256 × 256: 256 generations | 0.57 s (0.54 M/s) | 35 ms (8.9 M/s) |
282
+ | a 1280 × 800 frame of the 1024 soup, at 4, 1, ½ and ⅛ px per cell | 1.1, 11, 4.0, 0.3 ms (tiles cached) | 2.9, 10, 11, 0.1 ms |
283
+
284
+ A node in the Python store takes about 145 bytes (`NODE_BYTES`); in the .NET store, 40.
285
+ Per node the .NET port is 7 to 20 times faster than Python here, against about 50 for the
286
+ two-state engine, whose 8 × 8 bit leaves need no hashing below them; a level-3 shortcut
287
+ straight from the leaves' states is the obvious next step if the app needs more.
288
+
289
+ ## Playground
290
+
291
+ ```
292
+ heaton-life # or: python -m heaton_life.playground
293
+ ```
294
+
295
+ Space plays and pauses, N single-steps, R resets, Ctrl+S saves a PNG. The
296
+ playground consumes only the public API; if it seems to need a hack, the API is
297
+ what needs changing.
298
+
299
+ The **HashLife** family (Cellular Automata) is the unbounded universe:
300
+
301
+ - **Pattern** is a built-in name (the presets list them) or a `.rle`, `.mc`, or `.mc.gz`
302
+ file (Browse…). Loading adopts the file's rule and fits the view to the pattern.
303
+ With `HEATON_LIFE_PATTERNS` set, the presets include the two giants, with budgets
304
+ they run well at.
305
+ - **Step (2^k gens)**: each step advances 2^k generations; the speed slider sets steps
306
+ per second. **Max memory (MB)** is the hash budget: it changes speed,
307
+ never results.
308
+ - The view is the spec's three integers: **View x/y** (the frame's top-left pixel in the
309
+ pixel plane) and **Mag** (2^mag pixels per cell; negative zooms out, one quadtree node
310
+ per pixel). The wheel (2× a notch; a trackpad swipe's coasting is ignored) and a
311
+ trackpad pinch zoom about the pointer; a drag pans while zoomed out past one cell per
312
+ pixel, with Option/Alt held at any zoom, or with the middle button; Ctrl/Cmd+click
313
+ recenters. At one cell per pixel or closer, left-click draws and right-click erases,
314
+ inside the ±10⁹ editing box (outside it the status bar says why nothing changed).
315
+ - Navigation answers at once, even while a giant plays: the canvas keeps the view
316
+ (`playground/navigator.py`) and draws the last frame where it lands in the new one. Each
317
+ gesture (a zoom, a pan, an edit) cuts a running step short; the engine renders the new
318
+ view once per burst of gestures, then the step picks up where it stopped (HashLife keeps
319
+ the work cached until memory nears the budget). A Caterpillar generation takes about 5 s
320
+ in Python; a zoom waiting for it would show only the old frame, stretched.
321
+ - The frame fills the canvas: **Frame width/height** (read-only) follow the window, at
322
+ one frame pixel per canvas pixel or the **Cell** setting's square of them, and a resize
323
+ keeps the view's center in place. Loading a pattern fits it to the canvas.
324
+ - Every field but the pattern changes the universe in place, and Reset returns to the
325
+ starting snapshot (edits made at the start belong to it) without reloading the file.
326
+ Pause and Reset cut a long step short at a completed sub-step.
327
+ - **Save pattern…** (Ctrl+Shift+S) writes RLE while the pattern lies inside the editing
328
+ box and Macrocell otherwise; the dialog also offers the other formats. The status bar
329
+ shows generation, population, step size, the center cell, nodes, and store memory.
330
+
331
+ **Life-like** starts from a pattern too: set **Init** to `pattern`, or just choose a
332
+ **Pattern** (a built-in name, or a `.rle`, `.mc`, or `.mc.gz` file with Browse…), which
333
+ sets it. The live cells are centered on the grid, the grid grows to twice their size
334
+ (2,048 a side at most), and the pattern's rule is adopted. **Save pattern…** writes the
335
+ live cells' bounding box as RLE.
336
+
337
+ A grid holds every one of its cells, and a pattern file can describe far more than memory
338
+ holds, so a file is measured before any grid is made of it (`playground/lifelike_sim.py`):
339
+
340
+ - wider or taller than the largest grid (the Caterpillar would take 1.4 GB for its cells
341
+ alone): it can only go to HashLife. The dialog offers **Load in HashLife** or
342
+ **Don't Load**;
343
+ - within the largest grid but more than half its width or height, or a Macrocell file
344
+ (whose place on the plane and generation a grid drops): HashLife is the better place,
345
+ and the dialog adds **Load in Life-like**. That answer is remembered for the file;
346
+ - anything else loads without a question.
347
+
348
+ HashLife opens the handed-over file at its own defaults: a giant still needs **Max
349
+ memory (MB)** raised there.
350
+
351
+ ## Versioning
352
+
353
+ The version lives in six places that move together, three of them here: `version` in
354
+ `pyproject.toml`, `__version__` in `src/heaton_life/__init__.py`, and the `VERSION`
355
+ baseline in `src/heaton_life/version.py`; and three in the .NET library: `<Version>` in
356
+ `../dotnet/src/HeatonLife.Core/HeatonLife.Core.csproj`, the `Version` constant in its
357
+ `Version.cs` baseline, and the `heaton-life-dotnet-<version>.zip` link in
358
+ `../dotnet/README.md`. `tests/test_release_version.py` fails unless all six agree, and
359
+ the Build Library workflow also refuses a `pyproject.toml` that disagrees with
360
+ `__version__`.
361
+
362
+ `src/heaton_life/version.py` is the build stamp that ships inside the wheel
363
+ (`VERSION`, `BUILD_DATE`, `BUILD`). The tracked file is a baseline with `BUILD = 0`,
364
+ meaning a local build (local and editable installs report its `VERSION`, and so does
365
+ the self-check's report header); the Build Library workflow regenerates it with the
366
+ run number and date before packaging.
367
+
368
+ ## Releasing
369
+
370
+ [`../RELEASING.md`](../RELEASING.md) is the whole sequence, for both packages: the
371
+ release convention's two manual steps, **Build Library**
372
+ (`.github/workflows/build-lib.yml`), which tests, stamps `version.py`, builds the wheel
373
+ and sdist and stages them with a build record on `s3://data.heatonresearch.com/library/`,
374
+ then **Deploy Library to PyPI** (`.github/workflows/deploy-lib.yml`), which uploads
375
+ what was staged by Trusted Publishing and tags `v<version>` at the built commit.
376
+ **Test Library** (`test-lib.yml`) runs the suite on Linux, macOS and Windows with
377
+ Python 3.11 to 3.14 on every push that touches `python/`, `vectors/` or `spec/`.
378
+
379
+ The staged wheel is public at
380
+ `https://data.heatonresearch.com/library/heaton_life-<version>-py3-none-any.whl`, so a
381
+ build can be tried before it is deployed: point the intro notebook's install cell
382
+ there for a trial, and revert it before committing. The notebook
383
+ (`examples/heaton_life_intro.ipynb`) installs the latest release with an unpinned
384
+ `!pip install --upgrade heaton-life` and is committed with its outputs cleared; after a
385
+ release, run it end to end against the new version, and if the API changed, update the
386
+ cells and clear the outputs. `README.md` is frozen into the wheel as the PyPI project
387
+ page, so finish README edits first.
388
+
389
+ ## Code style
390
+
391
+ - ruff clean at line length 100; mypy strict; no `Any` where a real type exists.
392
+ - Params are frozen dataclasses with UI metadata; every family follows the
393
+ `Simulation` or `Field` protocol.
394
+ - Docstrings cite the spec page a module implements, so readers can find the
395
+ contract a function is honoring.
396
+ - Nothing merges without its spec page and vectors.
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+