Skip to content

Commit

Permalink
minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Aug 12, 2024
1 parent 77296dc commit 3aa6170
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
26 changes: 18 additions & 8 deletions docs/life_pt1.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
<hr>

> ⚠️ __Note:__ This section is completely optional, and is provided for a bit of nerdy fun. It is by no means essential, feel free to skip it if it doesn't interest you!
!!!note
This section is completely optional, and is provided for a bit
of nerdy fun. It is by no means essential, feel free to skip
it if it doesn't interest you!

Well, someone can, probably. But doom in a dataframe would be kinda hard to play, so let's try something simpler.
[Conway's Game of Life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life) is a notorious Cellular Automaton that we could perhaps implement with a plugin.
Expand All @@ -16,7 +19,11 @@ For science, of course.
Jokes aside, life allows us to show how a plugin can access elements in both neighbouring rows and columns for each element.
With a little bit of extra Python, we can display things in an almost pretty manner.

> __Note:__ For this tutorial, we'll assume you created a new plugin from the cookiecutter template and named it `game_of_life` (these steps aren't shown here, since they were already covered at the very beginning of this series).
!!!note
For this tutorial, we'll assume you created a new plugin from the
cookiecutter template and named it `game_of_life`
(these steps aren't shown here, since they were already covered at the
very beginning of this series).

In this section we'll cover the developer side of the plugin (both Python and Rust).
In the next section we'll show how a user can import and use what we developed here.
Expand Down Expand Up @@ -62,11 +69,13 @@ Starting with the function to parse a board from a file or stdin:

```python
def parse_board(
ifile: str
| bytes
| PathLike[str]
| PathLike[bytes]
| Iterable[str | bytes | PathLike[str] | PathLike[bytes]],
ifile: (
str
| bytes
| PathLike[str]
| PathLike[bytes]
| Iterable[str | bytes | PathLike[str] | PathLike[bytes]]
),
) -> list[list[int]]:
"""
Converts a board in a file containing only 0s and 1s, e.g.::
Expand Down Expand Up @@ -141,7 +150,8 @@ def board_to_df(board: list[list[int]]) -> pl.DataFrame:

Let's skip `_nwise_wrapping` and `step` for now and jump straight to the last function - we'll return to the two we skipped soon:

> Don't forget to read the comments!
!!!note
Don't forget to read the comments!

```python
def life_step(left: IntoExpr, mid: IntoExpr, right: IntoExpr) -> pl.Expr:
Expand Down
10 changes: 5 additions & 5 deletions docs/life_pt2.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ class Application:
# ...

def start(
self,
n: int | None = None,
delay: float | None = None,
print_df: bool = True,
self,
n: int | None = None,
delay: float | None = None,
print_df: bool = True,
):
if n is None:
n = self.steps
Expand Down Expand Up @@ -163,4 +163,4 @@ __Victory!__

## Reference

The entire code for this plugin, including the user's side can be found on [GitHub](https://github.com/condekind/life_polars_plugin).
The entire code for this plugin, including the user's side, can be found on [GitHub](https://github.com/condekind/life_polars_plugin).

0 comments on commit 3aa6170

Please sign in to comment.