Skip to content

Commit

Permalink
update github actions for python3
Browse files Browse the repository at this point in the history
  • Loading branch information
kadrlica committed Jun 26, 2024
1 parent 82abffc commit e448ddb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
strategy:
max-parallel: 3
matrix:
python-version: [2.7, 3.8]
python-version: ["3.7", "3.8", "3.9"]
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@v5
with:
python-version: ${{ matrix.python-version }}
- name: Setup conda
Expand All @@ -32,7 +32,7 @@ jobs:
conda info
- name: Create conda environment
run: |
conda create -y -q -n env python=${{ matrix.python-version }} numpy scipy matplotlib astropy healpy pyyaml emcee fitsio corner -c conda-forge -c kadrlica
conda create -y -q -n env python=${{ matrix.python-version }} numpy scipy matplotlib astropy healpy pyyaml emcee fitsio corner -c conda-forge
# Add UGALIDIR to environment
conda env config vars set UGALIDIR=$HOME/.ugali -n env
- name: Install package
Expand All @@ -55,7 +55,7 @@ jobs:
# Exclude notebook tests
nosetests -v -I test_notebook.py;
- name: Test notebooks
if: ${{ matrix.python-version == '2.7' }}
if: ${{ true }}
run: |
source activate env
conda install -q jupyter nbconvert -c conda-forge
Expand Down
16 changes: 8 additions & 8 deletions notebooks/kernel_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
],
"source": [
"plummer = kernel.factory(name='EllipticalPlummer',lon=0,lat=0,r_h=0.1,ellipticity=0.5, position_angle=45)\n",
"print plummer"
"print(plummer)"
]
},
{
Expand Down Expand Up @@ -227,9 +227,9 @@
"# `extension` member, though the meaning of `extension` is \n",
"# different for each kernel type\n",
"\n",
"print plummer\n",
"print king\n",
"print exponential"
"print(plummer)\n",
"print(king)\n",
"print(exponential)"
]
},
{
Expand Down Expand Up @@ -317,7 +317,7 @@
"ker.extension = 0.2\n",
"ker.r_h = 0.2 \n",
"\n",
"print ker"
"print(ker)"
]
},
{
Expand All @@ -340,7 +340,7 @@
"try:\n",
" ker.r_h = 40\n",
"except ValueError as e:\n",
" print \"Error:\",e\n"
" print(\"Error:\",e)\n"
]
},
{
Expand Down Expand Up @@ -396,8 +396,8 @@
"plt.sca(ax[1])\n",
"bins = np.linspace(0,1,100)\n",
"centers = (bins[:-1]+bins[1:])/2.\n",
"plt.hist(angsep(ker.lon,ker.lat,lon,lat),bins=bins,histtype='step',normed=True,label='Polar Radius')\n",
"plt.hist(ker.radius(lon,lat),bins=bins,histtype='step',normed=True,label='Elliptical Radius')\n",
"plt.hist(angsep(ker.lon,ker.lat,lon,lat),bins=bins,histtype='step',density=True,label='Polar Radius')\n",
"plt.hist(ker.radius(lon,lat),bins=bins,histtype='step',density=True,label='Elliptical Radius')\n",
"plt.plot(centers,[len(bins)*ker.integrate(b1,b2) for b1,b2 in zip(bins[:-1],bins[1:])],label='Elliptical Radius')\n",
"plt.xlim(0,0.7)\n",
"plt.xlabel('Radius (deg)')\n",
Expand Down
10 changes: 6 additions & 4 deletions tests/test_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Adapted from:
https://blog.thedataincubator.com/2016/06/testing-jupyter-notebooks/
"""
import os
import os,sys
import unittest
import glob

Expand All @@ -18,11 +18,13 @@ def _notebook_run(path):
"""Execute a notebook via nbconvert and collect output.
:returns (parsed nb object, execution errors)
"""
kernel_name = "python"+str(sys.version_info.major)
with tempfile.NamedTemporaryFile(suffix=".ipynb") as fout:
args = ["jupyter", "nbconvert", "--to", "notebook", "--execute",
"--ExecutePreprocessor.timeout=60",
"--log-level=WARN",
"--output", fout.name, path]
"--ExecutePreprocessor.timeout=60",
"--ExecutePreprocessor.kernel_name=%s"%(kernel_name),
"--log-level=WARN",
"--output", fout.name, path]
subprocess.check_call(args)

fout.seek(0)
Expand Down

0 comments on commit e448ddb

Please sign in to comment.