Skip to content

Commit

Permalink
Fixed tox issue
Browse files Browse the repository at this point in the history
  • Loading branch information
michelbierlaire committed Mar 27, 2024
1 parent ad6a883 commit 073bec9
Show file tree
Hide file tree
Showing 22 changed files with 278 additions and 146 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build wheels on multiple OS

on:
workflow_dispatch:
release:
types: [created]

jobs:
build_sdist:
name: Build Source Distribution
runs-on: ubuntu-latest # Source distribution is independent of OS and Python version
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install build dependencies
run: python -m pip install --upgrade pip build
- name: Build source distribution
run: python -m build --sdist --outdir dist/
- name: Upload Source Distribution Artifact
uses: actions/upload-artifact@v3
with:
name: sdist
path: dist/*.tar.gz

build:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install build dependencies
run: python -m pip install --upgrade pip wheel
- name: Build wheels
run: pip wheel . -w dist
- name: Check directory
run: ls dist
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist/biogeme*.whl

pypi-publish:
name: upload release to PyPI
needs: [build_sdist, build]
runs-on: ubuntu-latest
# Specifying a GitHub environment is optional, but strongly encouraged
environment: release
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- name: Download Wheel Artifacts
uses: actions/download-artifact@v3
with:
name: wheels
path: dist

- name: Download sdist Artifacts
uses: actions/download-artifact@v3
with:
name: sdist
path: dist

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
10 changes: 7 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
name: Run tox on multiple OS

on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop

jobs:
test:
Expand All @@ -13,12 +17,12 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ['3.12', '3.11', '3.10', '3.9']
python-version: ['3.12', '3.11', '3.10']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{matrix.python-version }}
- name: Install dependencies
Expand Down
16 changes: 12 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,15 @@ reports/specAssistance_v2/pareto.png
reports/mdcev/mdcev.ps
clean_all.py
docs/examples/assisted/b07everything_assisted.pareto
docs/examples/latent/b01one_latent_regression.tex
docs/examples/latent/b02one_latent_ordered.tex
docs/examples/latent/b04latent_choice_seq_mc.tex
docs/examples/latent/b07problem.tex
docs/examples/latent/*.tex
docs/examples/montecarlo/*.html
docs/examples/programmers/*.html
docs/examples/programmers/test*.dat
docs/examples/sampling/cnl_10_63.dat
docs/examples/sampling/*.html
docs/examples/sampling/logit_asian_10_alt.dat
docs/examples/sampling/nested_downtown_20.dat
docs/examples/swissmetro/*.html
docs/examples/swissmetro/*.tex

docs/examples/swissmetro/*.pareto
10 changes: 5 additions & 5 deletions docs/examples/programmers/plot_biogeme.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,20 @@

# %%
# Now the unscaled version.
f, g, h, bhhh = my_biogeme.calculateLikelihoodAndDerivatives(
the_output: BiogemeFunctionOutput = my_biogeme.calculate_likelihood_and_derivatives(
xplus, scaled=False, hessian=True, bhhh=True
)
# %%
print(f'f = {f}')
print(f'f = {the_output.function}')

# %%
print(f'g = {g}')
print(f'g = {the_output.gradient}')

# %%
pd.DataFrame(h)
pd.DataFrame(the_output.hessian)

# %%
pd.DataFrame(bhhh)
pd.DataFrame(the_output.bhhh)


# %%
Expand Down
9 changes: 6 additions & 3 deletions docs/examples/programmers/plot_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@
# %%
# We build an expression that involves the three random variables
x = random_draws1 + random_draws2 + random_draws3
types = x.dict_of_elementary_expression(TypeOfElementaryExpression.DRAWS)
dict_of_draws = x.dict_of_elementary_expression(TypeOfElementaryExpression.DRAWS)
types = {name: expression.drawType for name, expression in dict_of_draws.items()}
print(types)

# %%
Expand Down Expand Up @@ -285,8 +286,9 @@ def exponential_draws(sample_size: int, number_of_draws: int) -> np.ndarray:
random_draws2 = bioDraws('random_draws2', 'EXP')
x = random_draws1 + random_draws2
the_draws = x.dict_of_elementary_expression(TypeOfElementaryExpression.DRAWS)
the_types = {name: expression.drawType for name, expression in the_draws.items()}
the_draws_table = my_data.generate_draws(
draws=the_draws, names=['random_draws1', 'random_draws2'], number_of_draws=10
draw_types=the_types, names=['random_draws1', 'random_draws2'], number_of_draws=10
)
print(the_draws_table)

Expand Down Expand Up @@ -328,7 +330,8 @@ def exponential_draws(sample_size: int, number_of_draws: int) -> np.ndarray:
# %%
# We build an expression that involves the two random variables
x = random_draws1 + random_draws2
types = x.dict_of_elementary_expression(TypeOfElementaryExpression.DRAWS)
the_draws = x.dict_of_elementary_expression(TypeOfElementaryExpression.DRAWS)
types = {name: expression.drawType for name, expression in the_draws.items()}
the_draws_table = my_panel_data.generate_draws(
types, ['random_draws1', 'random_draws2'], 10
)
Expand Down
Loading

0 comments on commit 073bec9

Please sign in to comment.