Skip to content

Commit 0ed0cf8

Browse files
committed
Merge branch 'master' into dev_minpay
2 parents 1cf0920 + 3489b98 commit 0ed0cf8

12 files changed

Lines changed: 80 additions & 83 deletions

File tree

.github/ISSUE_TEMPLATE/tutorial_request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ body:
3232
description: Add links to any research papers or other resources the author will need to write this tutorial.
3333
value: "`[Markdown link text](url)`"
3434
validations:
35-
required: false
35+
required: false

.github/workflows/lint.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,7 @@ name: Linters and coding standards checks
22

33
on:
44
push:
5-
paths-ignore:
6-
- 'doc/**'
7-
- '.github/ISSUE_TEMPLATE/**'
8-
- 'README.md'
95
pull_request:
10-
paths-ignore:
11-
- 'doc/**'
12-
- '.github/ISSUE_TEMPLATE/**'
13-
- 'README.md'
146

157
jobs:
168
clang-format:

.github/workflows/osxbinary.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ name: MacOS static GUI binary
22

33
on:
44
push:
5-
paths-ignore:
6-
- 'doc/**'
7-
- '.github/ISSUE_TEMPLATE/**'
8-
- 'README.md'
95
tags:
106
- 'v*'
117
schedule:

.github/workflows/python.yml

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,7 @@ name: pygambit Python extension
22

33
on:
44
push:
5-
paths-ignore:
6-
- 'doc/**'
7-
- '.github/ISSUE_TEMPLATE/**'
8-
- 'README.md'
95
pull_request:
10-
paths-ignore:
11-
- 'doc/**'
12-
- '.github/ISSUE_TEMPLATE/**'
13-
- 'README.md'
146

157
jobs:
168
linux:
@@ -29,7 +21,9 @@ jobs:
2921
- name: Set up dependencies
3022
run: |
3123
python -m pip install --upgrade pip
32-
pip install setuptools build cython pytest pytest-skip-slow wheel lxml numpy scipy nbformat nbclient ipykernel
24+
pip install setuptools build cython wheel
25+
pip install -r tests/requirements.txt
26+
pip install -r doc/requirements.txt
3327
- name: Build source distribution
3428
run:
3529
python -m build
@@ -38,13 +32,7 @@ jobs:
3832
cd dist
3933
pip install -v pygambit*.tar.gz
4034
- name: Run tests
41-
run: |
42-
if [ "${{ matrix.python-version }}" = "3.9" ]; then
43-
# Python 3.9 on linux skips the notebook execution test (notebooks may require newer kernels/deps)
44-
pytest -q -k 'not test_execute_notebook'
45-
else
46-
pytest
47-
fi
35+
run: pytest
4836

4937
macos-13:
5038
runs-on: macos-13
@@ -62,7 +50,9 @@ jobs:
6250
- name: Set up dependencies
6351
run: |
6452
python -m pip install --upgrade pip
65-
pip install cython pytest pytest-skip-slow wheel lxml numpy scipy nbformat nbclient ipykernel
53+
pip install setuptools build cython wheel
54+
pip install -r tests/requirements.txt
55+
pip install -r doc/requirements.txt
6656
- name: Build extension
6757
run: |
6858
python -m pip install -v .
@@ -85,7 +75,9 @@ jobs:
8575
- name: Set up dependencies
8676
run: |
8777
python -m pip install --upgrade pip
88-
pip install cython pytest pytest-skip-slow wheel lxml numpy scipy nbformat nbclient ipykernel
78+
pip install setuptools build cython wheel
79+
pip install -r tests/requirements.txt
80+
pip install -r doc/requirements.txt
8981
- name: Build extension
9082
run: |
9183
python -m pip install -v .
@@ -108,7 +100,9 @@ jobs:
108100
- name: Set up dependencies
109101
run: |
110102
python -m pip install --upgrade pip
111-
pip install cython pytest pytest-skip-slow wheel lxml numpy scipy nbformat nbclient ipykernel
103+
pip install setuptools build cython wheel
104+
pip install -r tests/requirements.txt
105+
pip install nbformat nbclient ipykernel jupyter matplotlib
112106
- name: Build extension
113107
run: |
114108
python -m pip install -v .

.github/workflows/tools.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,7 @@ name: Build executables
22

33
on:
44
push:
5-
paths-ignore:
6-
- 'doc/**'
7-
- '.github/ISSUE_TEMPLATE/**'
8-
- 'README.md'
95
pull_request:
10-
paths-ignore:
11-
- 'doc/**'
12-
- '.github/ISSUE_TEMPLATE/**'
13-
- 'README.md'
146

157
jobs:
168
linux:

.github/workflows/wheels.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ name: pygambit wheels
33

44
on:
55
push:
6-
paths-ignore:
7-
- 'doc/**'
8-
- '.github/ISSUE_TEMPLATE/**'
9-
- 'README.md'
106
tags:
117
- 'v*'
128
schedule:

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ Gambit.app/*
4444
doc/tutorials/games/*.nfg
4545
doc/tutorials/games/*.efg
4646
*.dmg
47-
Gambit.app/*
47+
Gambit.app/*

doc/requirements.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
Cython==3.1.2
2-
numpy==2.3.2
3-
scipy==1.16.1
4-
pydata-sphinx-theme==0.16.1
5-
sphinx_design==0.6.1
6-
sphinx-autobuild==2024.10.3
7-
nbsphinx==0.9.7
8-
ipython==9.4.0
9-
matplotlib==3.10.5
10-
pickleshare==0.7.5
11-
jupyter==1.1.1
12-
open_spiel==1.6.9
1+
Cython
2+
numpy
3+
scipy
4+
pydata-sphinx-theme
5+
sphinx_design
6+
sphinx-autobuild
7+
nbsphinx
8+
ipython
9+
matplotlib
10+
pickleshare
11+
jupyter
12+
open_spiel

doc/tutorials/running_locally.rst

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,34 @@
33
How to run PyGambit tutorials on your computer
44
==============================================
55

6-
The PyGambit tutorials are available as Jupyter notebooks and can be run interactively using any program that supports Jupyter notebooks, such as JupyterLab or VSCode.
7-
You will need a working installation of Python 3.9+ on your machine to run PyGambit (however the tutorials contain some syntax that may not be compatible with earlier versions of Python than 3.13).
6+
Running the PyGambit tutorials on your machine requires some familiarity with the basics of Python and how to use Git & GitHub.
7+
The tutorials are available as Jupyter notebooks and can be run interactively using any program that supports Jupyter notebooks, such as JupyterLab or VSCode.
8+
9+
.. tip:: Create a virtual environment with Python 3.13 or higher
810

911
1. To download the tutorials, open your OS's command prompt and clone the Gambit repository from GitHub, then navigate to the tutorials directory: ::
1012

1113
git clone https://github.com/gambitproject/gambit.git
12-
cd gambit/doc
1314

14-
2. Install `pygambit` and other requirements (including `JupyterLab` and other packages used by the tutorials). We recommend creating a new virtual environment and installing both the requirements there. e.g. ::
15+
2. Install `pygambit`:
16+
17+
* To install the latest release from PyPI::
18+
19+
pip install pygambit
20+
21+
* Alternatively, to install the latest development version::
1522

16-
python -m venv pygambit-env
17-
source pygambit-env/bin/activate
18-
pip install pygambit
23+
pip install .
24+
25+
3. Install other requirements (including `JupyterLab`) used by the tutorials ::
26+
27+
cd gambit/doc
1928
pip install -r requirements.txt
2029

21-
3. Open `JupyterLab` and click on any of the tutorial notebooks (files ending in `.ipynb`) ::
30+
.. warning::
31+
Windows users will encounter an error when installing the requirements, which include the OpenSpiel library. Users wishing to run the OpenSpiel tutorial will need to install this manually; see the `OpenSpiel installation instructions <https://openspiel.readthedocs.io/en/latest/windows.html>`_ for details.
32+
33+
4. Open `JupyterLab` and click on any of the tutorial notebooks (files ending in `.ipynb`) ::
2234

2335
cd tutorials
2436
jupyter lab

src/games/ndarray.h

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// This file is part of Gambit
33
// Copyright (c) 1994-2024, The Gambit Project (http://www.gambit-project.org)
44
//
5-
// FILE: src/solvers/enumpoly/ndarray.h
5+
// FILE: src/games/ndarray.h
66
// A simple N-dimensional array class
77
//
88
// This program is free software; you can redistribute it and/or modify
@@ -20,8 +20,8 @@
2020
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2121
//
2222

23-
#ifndef NDARRAY_H
24-
#define NDARRAY_H
23+
#ifndef GAMBIT_GAMES_NDARRAY_H
24+
#define GAMBIT_GAMES_NDARRAY_H
2525

2626
#include <numeric>
2727

@@ -42,11 +42,14 @@ namespace Gambit {
4242
///
4343
/// @tparam T The data type of elements of the array
4444
template <class T> class NDArray {
45+
using reference = typename std::vector<T>::reference;
46+
using const_reference = typename std::vector<T>::const_reference;
47+
4548
protected:
4649
Array<int> m_index_dim;
47-
int m_vector_dim;
50+
int m_vector_dim{0};
4851
Array<int> m_offsets;
49-
int m_offsets_sum;
52+
int m_offsets_sum{0};
5053
std::vector<T> m_storage;
5154

5255
int ComputeOffset(const Array<int> &p_array_index, int p_vector_index) const
@@ -59,10 +62,9 @@ template <class T> class NDArray {
5962
}
6063

6164
public:
62-
NDArray() : m_vector_dim(0), m_offsets_sum(0) {}
63-
explicit NDArray(const Array<int> &p_index_dim, int p_vector_dim)
65+
NDArray() = default;
66+
explicit NDArray(const Array<int> &p_index_dim, const int p_vector_dim)
6467
: m_index_dim(p_index_dim), m_vector_dim(p_vector_dim), m_offsets(p_index_dim.size() + 1),
65-
m_offsets_sum(0),
6668
m_storage(std::accumulate(m_index_dim.begin(), m_index_dim.end(), 1, std::multiplies<>()) *
6769
m_vector_dim)
6870
{
@@ -74,21 +76,24 @@ template <class T> class NDArray {
7476
// NOLINTEND(cppcoreguidelines-prefer-member-initializer)
7577
}
7678

77-
NDArray(const NDArray<T> &) = default;
79+
NDArray(const NDArray &) = default;
7880
~NDArray() = default;
7981

80-
NDArray<T> &operator=(const NDArray<T> &) = default;
82+
NDArray &operator=(const NDArray &) = default;
8183

82-
const T &at(const Array<int> &v, int index) const
84+
const_reference at(const Array<int> &v, const int index) const
85+
{
86+
return m_storage.at(ComputeOffset(v, index));
87+
}
88+
reference at(const Array<int> &v, const int index)
8389
{
8490
return m_storage.at(ComputeOffset(v, index));
8591
}
86-
T &at(const Array<int> &v, int index) { return m_storage.at(ComputeOffset(v, index)); }
8792

8893
const Array<int> &GetIndexDimension() const { return m_index_dim; }
89-
int GetVectorDimension() { return m_vector_dim; }
94+
int GetVectorDimension() const { return m_vector_dim; }
9095
};
9196

9297
} // end namespace Gambit
9398

94-
#endif // NDARRAY_H
99+
#endif // GAMBIT_GAMES_NDARRAY_H

0 commit comments

Comments
 (0)