Skip to content

Commit

Permalink
Merge pull request #40 from pygsl/dev/feature/ci-python-matrix
Browse files Browse the repository at this point in the history
[TASK] CI: check for different python versions
  • Loading branch information
PierreSchnizer committed Feb 7, 2024
2 parents 4459e6c + ecb77af commit dd4f57b
Show file tree
Hide file tree
Showing 10 changed files with 326 additions and 344 deletions.
41 changes: 29 additions & 12 deletions .github/workflows/pygsl-ci.yml
@@ -1,24 +1,34 @@
name: PyGSL build
on: [push, pull_request]

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
wrap_and_build:
# Re-generate SWIG wrappers, then build and test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11" , "3.12" ]

steps:
# Checkout the repository contents
- name: Checkout PyGSL code
uses: actions/checkout@v3
uses: actions/checkout@v4

# Setup Python version
- name: Setup Python 3.8
uses: actions/setup-python@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: 3.8

python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
**/setup.cfg
**/requirements*.txt
# Install dependencies
- name: Install apt dependencies
run: |
Expand All @@ -30,8 +40,9 @@ jobs:
- name: Python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest numpy scipy matplotlib wheel
python -m pip install pycodestyle
python -m pip install pytest wheel setuptools
python -m pip install pycodestyle flake8
python -m pip install numpy scipy matplotlib
- name: gsl_wrappers
run: |
Expand All @@ -45,6 +56,12 @@ jobs:
run: |
python setup.py install
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 pygsl --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 pygsl --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: test
run: |
# make sure to move out of the source directory
Expand All @@ -60,13 +77,13 @@ jobs:
steps:
# Checkout the repository contents
- name: Checkout PyGSL code
uses: actions/checkout@v3
uses: actions/checkout@v4

# Setup Python version
- name: Setup Python 3.8
uses: actions/setup-python@v4
- name: Setup Python 3.10
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: "3.10"

# Install dependencies
- name: Install apt dependencies
Expand Down
38 changes: 19 additions & 19 deletions examples/siman.py
Expand Up @@ -11,26 +11,26 @@
import pygsl.rng as rng

# how many points do we try before stepping
N_TRIES = 200
# how many iterations for each T?
ITERS_FIXED_T = 10
# max step size in random walk
STEP_SIZE = 10
N_TRIES = 200

# how many iterations for each T?
ITERS_FIXED_T = 10

# max step size in random walk
STEP_SIZE = 10

# Boltzmann constant
K = 1.0
K = 1.0

# initial temperature
T_INITIAL = 0.002
T_INITIAL = 0.002

# damping factor for temperature
MU_T = 1.005
# damping factor for temperature
MU_T = 1.005
T_MIN = 2.0e-6


class MySiman(siman.NumericEnsemble):

class MySiman(siman.NumericEnsemble):
def EFunc(self):
x = self._data
t = x-1.0
Expand All @@ -42,20 +42,20 @@ def EFunc(self):
else:
tmp = numx.exp(-t2)
return tmp*numx.sin(8*x)
def Metric(self, outer):

def Metric(self, outer):
return numx.absolute(self._data - outher.GetData())

def Step(self, rng, step_size):
old_x = self._data

u = rng.uniform();
new_x = u * 2 * step_size - step_size + old_x;
self._data = new_x


def Print(self):
print "%12g" % self._data,
print("%12g" % self._data)

m = MySiman()
m.SetData(15.5)
Expand All @@ -66,4 +66,4 @@ def Print(self):
#result = siman.solve(r, m, do_print=1, n_tries=N_TRIES, iters_fixed_T=ITERS_FIXED_T,
# step_size=STEP_SIZE, k=K, t_initial=T_INITIAL, mu_t = MU_T,
# t_min=T_MIN)
print "# Found minimum at %f" % result.GetData()
print("# Found minimum at %f" % result.GetData())
8 changes: 0 additions & 8 deletions gsl_dist/array_includes.py

This file was deleted.

0 comments on commit dd4f57b

Please sign in to comment.