Skip to content

Commit

Permalink
Dropped support for Python 3.8.
Browse files Browse the repository at this point in the history
This drops support for Python 3.8.  In addition,
* Updates pre-commit actions
* Updates Python style for 3.9/3.10 now that 3.8 is not supported.
  • Loading branch information
tturocy committed Jul 19, 2024
1 parent 6784a8e commit b0eaf78
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
strategy:
matrix:
python-version: ['3.8', '3.12']
python-version: ['3.9', '3.12']

steps:
- uses: actions/checkout@v4
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.13
rev: v0.5.3
hooks:
- id: ruff
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
rev: 7.1.0
hooks:
- id: flake8
- repo: https://github.com/MarcoGorelli/cython-lint
rev: v0.16.0
rev: v0.16.2
hooks:
- id: cython-lint
- id: double-quote-cython-strings
Expand Down
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## [16.3.0] - unreleased

### General
- Dropped support for Python 3.8.

### Added
- Implemented maximum-likelihood estimation for agent logit QRE, to parallel existing support
for strategic logit QRE. Strategic logit QRE function names have been modified to provide
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ requires = ["setuptools", "wheel", "Cython"]
[tool.ruff]
line-length = 99
indent-width = 4
target-version = "py38"
target-version = "py39"
include = ["setup.py", "src/pygambit/**/*.py", "tests/**/*.py"]
exclude = ["contrib/**.py"]

Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,13 @@ def readme():

setuptools.setup(
name="pygambit",
version="16.2.0",
version="16.3.0",
description="The package for computation in game theory",
long_description=readme(),
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -136,7 +135,7 @@ def readme():
"Source": "https://github.com/gambitproject/gambit",
"Tracker": "https://github.com/gambitproject/gambit/issues",
},
python_requires=">=3.8",
python_requires=">=3.9",
install_requires=[
"lxml", # used for reading/writing GTE files
"numpy",
Expand Down
26 changes: 13 additions & 13 deletions src/pygambit/nash.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
A set of utilities for computing Nash equilibria
"""

from __future__ import annotations

import dataclasses
import typing

import pygambit.gambit as libgbt

MixedStrategyEquilibriumSet = typing.List[libgbt.MixedStrategyProfile]
MixedBehaviorEquilibriumSet = typing.List[libgbt.MixedBehaviorProfile]
MixedStrategyEquilibriumSet = list[libgbt.MixedStrategyProfile]
MixedBehaviorEquilibriumSet = list[libgbt.MixedBehaviorProfile]


@dataclasses.dataclass(frozen=True)
Expand Down Expand Up @@ -57,7 +58,7 @@ class NashComputationResult:
method: str
rational: bool
use_strategic: bool
equilibria: typing.Union[MixedStrategyEquilibriumSet, MixedBehaviorEquilibriumSet]
equilibria: MixedStrategyEquilibriumSet | MixedBehaviorEquilibriumSet
parameters: dict = dataclasses.field(default_factory=dict)


Expand Down Expand Up @@ -143,8 +144,8 @@ def lcp_solve(
game: libgbt.Game,
rational: bool = True,
use_strategic: bool = False,
stop_after: typing.Optional[int] = None,
max_depth: typing.Optional[int] = None
stop_after: int | None = None,
max_depth: int | None = None
) -> NashComputationResult:
"""Compute Nash equilibria of a two-player game using :ref:`linear
complementarity programming <gambit-lcp>`.
Expand Down Expand Up @@ -247,8 +248,7 @@ def lp_solve(


def liap_solve(
start: typing.Union[libgbt.MixedStrategyProfileDouble,
libgbt.MixedBehaviorProfileDouble],
start: libgbt.MixedStrategyProfileDouble | libgbt.MixedBehaviorProfileDouble,
maxregret: float = 1.0e-4,
maxiter: int = 1000
) -> NashComputationResult:
Expand Down Expand Up @@ -310,9 +310,9 @@ def liap_solve(

def simpdiv_solve(
start: libgbt.MixedStrategyProfileRational,
maxregret: libgbt.Rational = None,
maxregret: libgbt.Rational | None = None,
refine: int = 2,
leash: typing.Optional[int] = None
leash: int | None = None
) -> NashComputationResult:
"""Compute Nash equilibria of a game using :ref:`simplicial
subdivision <gambit-simpdiv>`.
Expand Down Expand Up @@ -371,7 +371,7 @@ def simpdiv_solve(


def ipa_solve(
perturbation: typing.Union[libgbt.Game, libgbt.MixedStrategyProfileDouble]
perturbation: libgbt.Game | libgbt.MixedStrategyProfileDouble,
) -> NashComputationResult:
"""Compute Nash equilibria of a game using :ref:`iterated polymatrix
approximation <gambit-ipa>`.
Expand Down Expand Up @@ -423,7 +423,7 @@ def ipa_solve(


def gnm_solve(
perturbation: typing.Union[libgbt.Game, libgbt.MixedStrategyProfileDouble],
perturbation: libgbt.Game | libgbt.MixedStrategyProfileDouble,
end_lambda: float = -10.0,
steps: int = 100,
local_newton_interval: int = 3,
Expand Down Expand Up @@ -527,7 +527,7 @@ def gnm_solve(
raise


def possible_nash_supports(game: libgbt.Game) -> typing.List[libgbt.StrategySupportProfile]:
def possible_nash_supports(game: libgbt.Game) -> list[libgbt.StrategySupportProfile]:
"""Compute the set of support profiles which could possibly form the support
of a totally-mixed Nash equilibrium.
Expand Down
10 changes: 5 additions & 5 deletions src/pygambit/qre.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
"""
A set of utilities for computing and analyzing quantal response equilbria
"""
from __future__ import annotations

import math
import typing

import scipy.optimize

Expand All @@ -47,7 +48,7 @@ def logit_solve_branch(

def logit_solve_lambda(
game: libgbt.Game,
lam: typing.Union[float, typing.List[float]],
lam: float | list[float],
use_strategic: bool = False,
first_step: float = .03,
max_accel: float = 1.1,
Expand Down Expand Up @@ -238,13 +239,12 @@ def _estimate_behavior_empirical(


def logit_estimate(
data: typing.Union[libgbt.MixedStrategyProfile,
libgbt.MixedBehaviorProfile],
data: libgbt.MixedStrategyProfile | libgbt.MixedBehaviorProfile,
use_empirical: bool = False,
local_max: bool = False,
first_step: float = .03,
max_accel: float = 1.1,
) -> typing.Union[LogitQREMixedStrategyFitResult, LogitQREMixedBehaviorFitResult]:
) -> LogitQREMixedStrategyFitResult | LogitQREMixedBehaviorFitResult:
"""Use maximum likelihood estimation to find the logit quantal
response equilibrium which best fits empirical frequencies of play.
Expand Down

0 comments on commit b0eaf78

Please sign in to comment.