semvec/pypi-packages huggingface dataset:
nashypy 0.0.2
Game Theory Library

# NashyPy

`nashypy` is a Python package designed for the analysis of Nash equilibria in game theory. It offers tools to read game data, visualize best response polyhedra and polytopes, and find Nash equilibria.

Note: this package is in development and currently can only run 2x2 games, 3x2 games are WIP.

## Development Status

**Note:** `nashypy` is currently under development. At this time, it supports 2x2 bimatrix games only. Support for larger games is in progress and will be available in a future update.

## Installation

To install `nashypy`, you can use pip:

```bash
pip install nashypy
```


## Features

- **Read Game**: Load game data from a file or use a predefined example.
- **Plot Best Response Polyhedra**: Visualize the best response strategies in a two-dimensional plot.
- **Plot Best Response Polytope**: Plot feasible regions based on game strategies.
- **Find Nash Equilibria**: Compute and list all Nash equilibria of a given game.

Reading Game Data
You can load games either by specifying the path to a game file or using one of the included examples:

```bash
import nashypy

# Load a game using an included example
game = nashypy.read_game(example="2x2_staghunt")

# Alternatively, load a game from a custom file path
game = nashypy.read_game(file_path="path/to/game.txt")
```

## Visualizing Game Strategies
Once you have a game object, you can visualize the best responses:

```bash
# Plot best response polyhedra
nashypy.plot_best_response_polyhedra(game, savefig=True)

# Plot best response polytope
nashypy.plot_best_response_polytope(game, savefig=True)
```

## Finding Nash Equilibria
To find and list all Nash equilibria of the loaded game:

```bash
equilibria, num_vertices = find_nash_equilibria(game)
```
rustfrecord 0.1.7
Rust implementation to read TFRecord files into PyTorch tensors
Requires Python: >=3.8

# rustfrecord

The [TFRecord format](https://www.tensorflow.org/tutorials/load_data/tfrecord) is a simple format for storing a sequence of binary records.

This package implements a high-performance reader for  `Example` records stored in TFRecord files.

Examples are loaded into native PyTorch `Tensor`s.

## Installation

The wheel can be installed on any Linux system with Python 3.8 or higher:

    pip3 install rustfrecord

## Getting Started

The `Reader` class reads TFRecord files and yields `Dict[str, Tensor]` objects.

```python
import torch
from torch import Tensor
from rustfrecord import Reader

filename = "data/002scattered.training_examples.tfrecord.gz"
r = Reader(filename, compressed=True)

for i, features in enumerate(r):
    print(features.keys())
    # ['variant_type', 'image/encoded', 'image/shape',
    #  'variant/encoded', 'label', 'alt_allele_indices/encoded',
    #  'locus', 'sequencing_type']

    label: Tensor = features['label']
    shape = torch.Size(tuple(features['image/shape']))
    image: Tensor = features['image/encoded'][0].reshape(shape)

    print(i, label, image.shape)
```

## Development

To develop this package (not just use it), you need to install the Rust compiler and the Python development headers.

    pip install uv
    uv venv
    source .venv/bin/activate

    uv pip compile pyproject.toml -o requirements.txt
    uv pip install -r requirements.txt

    export LIBTORCH_USE_PYTORCH=1
    CARGO_TARGET_DIR=target_maturin maturin develop

    python main.py