Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ generate_svg(g)

> Note: Without setting the `save_to` parameter, the saved file will be based on the title field of the pygambit game object.

## Developer docs: Testing
## Developer docs

### Testing

The project includes a comprehensive test suite using pytest. To run the tests:

Expand All @@ -156,3 +158,16 @@ Run tests with coverage:
```bash
pytest tests/ --cov=draw_tree --cov-report=html
```

### Releases

To release a new version of `draw_tree`, update the version number in `pyproject.toml` and in `src/draw_tree/__init__.py`.

After the change is pushed to the main branch, push a tag:

```
git tag vX.X.X
git push origin tag vX.X.X
```

Then make the release on GitHub based on that tag.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "draw_tree"
version = "0.4.2"
version = "0.4.3"
description = "Game tree drawing tool for extensive form games"
readme = "README.md"
requires-python = ">=3.7"
Expand Down
2 changes: 1 addition & 1 deletion src/draw_tree/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from extensive form (.ef) files, with support for Jupyter notebooks.
"""

__version__ = "0.4.2"
__version__ = "0.4.3"

from .core import (
draw_tree,
Expand Down
8 changes: 6 additions & 2 deletions src/draw_tree/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,12 +883,13 @@ def arrow(words: List[str]) -> tuple[float, str, int]:
return arrowpos, arrowcolor, advance


def payoffs(words: List[str]) -> List[str]:
def payoffs(words: List[str], color_scheme: str = "default") -> List[str]:
"""
Parse 'payoffs' command to generate TikZ payoff display code.

Args:
words: List of command words starting with 'payoffs'.
color_scheme: Color scheme to use for coloring payoffs.

Returns:
List of TikZ node commands for displaying payoffs.
Expand All @@ -903,6 +904,9 @@ def payoffs(words: List[str]) -> List[str]:
# tikz code
t = " node[below,yshift="
t += fformat(payup - (i - 1)) + paydown
if color_scheme != "default":
player_color = get_player_color(i, color_scheme)
t += f",color={player_color}"
t += "] {$" + words[i]
if words[i][0] == "-": # negative payoff
t += "{\\phantom-}"
Expand Down Expand Up @@ -1193,7 +1197,7 @@ def level(
arrowcolorlist.append(arrowcolor)
count += advance
elif words[count] == "payoffs": # automatically last
pay = payoffs(words[count:])
pay = payoffs(words[count:], color_scheme=color_scheme)
break
else: # unknown keyword
error("unknown keyword " + words[count])
Expand Down
Loading