Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/coverage #19

Merged
merged 14 commits into from
May 18, 2022
Merged
7 changes: 7 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[run]
branch = True
[report]
include =
*.ipynb
*.py
python/*.py
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ install:

- conda env create -n test-environment python=$TRAVIS_PYTHON_VERSION -f binder/environment.yml
- source activate test-environment
#Packages for testing only -- don't need in user environment.
- pip3 install codecov pytest-cov pytest_notebook nbval papermill
- ipython kernel install --user --name=galactic-spin

before_script: cd binder
script:
- travis_wait 60 py.test
- pytest --cov=./ --cov-report=xml --nbval --current-env --cov-config=../.coveragerc
- papermill --prepare-only -p galaxy NGC5533 07_Bonus_Bulge_Rotation_Curve.ipynb 07_Bonus_Bulge_Rotation_Curve_NGC5533.ipynb
- papermill --prepare-only -p galaxy NGC7814 07_Bonus_Bulge_Rotation_Curve.ipynb 07_Bonus_Bulge_Rotation_Curve_NGC7814.ipynb
- pytest --cov=./ --cov-report=xml --nbval-lax 07_Bonus_Bulge_Rotation_Curve_NGC????.ipynb --cov-append --current-env --cov-config=../.coveragerc
after_script:
- codecov
2 changes: 2 additions & 0 deletions binder/01_DM_Rotation_Curve_Intro.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@
}
],
"source": [
"#NBVAL_IGNORE_OUTPUT\n",
"#Because the calculation time naturally varies.\n",
"# Calculation time\n",
"executionTime3 = (time.time() - startTime)\n",
"ttt3=executionTime3/60\n",
Expand Down
4 changes: 3 additions & 1 deletion binder/02_Widget_NGC5533_DMonly.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,8 @@
}
],
"source": [
"#NBVAL_IGNORE_OUTPUT\n",
"#Because the figure doesn't save to the repository correctly.\n",
"# Widget\n",
"VBox([button,out,interactive_plot(f)])"
]
Expand Down Expand Up @@ -603,7 +605,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.9.7"
}
},
"nbformat": 4,
Expand Down
4 changes: 3 additions & 1 deletion binder/03_Measured_Data_Plotting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@
}
],
"source": [
"#NBVAL_IGNORE_OUTPUT\n",
"#Because the timing won't be exactly the same each time.\n",
"# Time\n",
"executionTime = (time.time() - startTime)\n",
"ttt=executionTime/60\n",
Expand Down Expand Up @@ -295,7 +297,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.9.7"
}
},
"nbformat": 4,
Expand Down
2 changes: 2 additions & 0 deletions binder/04_Plotting_Rotation_Curves.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,8 @@
}
],
"source": [
"#NBVAL_IGNORE_OUTPUT\n",
"#Because the timing won't be exactly the same each time.\n",
"# Time\n",
"executionTime = (time.time() - startTime)\n",
"ttt = executionTime/60\n",
Expand Down
4 changes: 3 additions & 1 deletion binder/05_Widget_NGC5533_All_Components.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@
}
],
"source": [
"#NBVAL_IGNORE_OUTPUT\n",
"#Because the figure doesn't save to the repository correctly.\n",
"# Widget\n",
"VBox([button,out,interactive_plot(f)])"
]
Expand Down Expand Up @@ -446,7 +448,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.9.7"
}
},
"nbformat": 4,
Expand Down
30 changes: 17 additions & 13 deletions binder/06_Plotting_SPARC_data.ipynb

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions binder/07_Bonus_Bulge_Rotation_Curve.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"metadata": {
"tags": [
"parameters"
]
},
"outputs": [],
"source": [
"galaxy = \"NGC891\" # Change this value to select a galaxy out of the 3 choices: NGC5533, NGC891, NGC7814"
Expand Down Expand Up @@ -105,6 +109,8 @@
}
],
"source": [
"#NBVAL_IGNORE_OUTPUT\n",
"#Because the filepath won't be the same across devices\n",
"import importlib\n",
"importlib.reload(b) # Reload library so the changes take effect"
]
Expand Down Expand Up @@ -635,6 +641,8 @@
}
],
"source": [
"#NBVAL_IGNORE_OUTPUT\n",
"#Because the timing won't be exactly the same each time.\n",
"executionTime = (time.time() - startTime)\n",
"print(f'Execution time: {executionTime:.2f} seconds')"
]
Expand Down Expand Up @@ -682,9 +690,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "galactic-spin",
"language": "python",
"name": "python3"
"name": "galactic-spin"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -696,7 +704,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.9.7"
}
},
"nbformat": 4,
Expand Down
4 changes: 4 additions & 0 deletions binder/08_Interactive_Fitting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@
}
],
"source": [
"#NBVAL_IGNORE_OUTPUT\n",
"#Because there is some randomness to the fit itself\n",
"f_fit = f_mod.fit(m_velocities, f_params, r = m_radii, weights = weighdata)\n",
"\n",
"# Show fit statistics\n",
Expand Down Expand Up @@ -454,6 +456,8 @@
}
],
"source": [
"#NBVAL_IGNORE_OUTPUT\n",
"#Because the timing won't be exactly the same each time.\n",
"# Time\n",
"executionTime = (time.time() - startTime)\n",
"ttt=executionTime/60\n",
Expand Down
8 changes: 8 additions & 0 deletions binder/09_Widget_SPARC_Galaxies.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@
}
],
"source": [
"#NBVAL_IGNORE_OUTPUT\n",
"#Because the button doesn't save to the repository correctly.\n",
"print(\"Would you like to download and unzip SPARC data files to your computer?\")\n",
"dsd.displaybuttons"
]
Expand Down Expand Up @@ -198,6 +200,8 @@
}
],
"source": [
"#NBVAL_IGNORE_OUTPUT\n",
"#Because the dropdown doesn't save to the repository correctly.\n",
"galaxylist = ['NGC5005'] # default list of galaxies \n",
"def on_change(change): # add selected galaxynames to the list\n",
" if change['type'] == 'change' and change['name'] == 'value':\n",
Expand Down Expand Up @@ -285,6 +289,8 @@
}
],
"source": [
"#NBVAL_IGNORE_OUTPUT\n",
"#Because the figure doesn't save to the repository correctly.\n",
"# Widget Output\n",
"widget.VBox([widget.button,widget.out,widget.interactive_plot(widget.widgetfunction)])"
]
Expand Down Expand Up @@ -323,6 +329,8 @@
}
],
"source": [
"#NBVAL_IGNORE_OUTPUT\n",
"#Because there is some randomness in the fit itself\n",
"# Show fit statistics\n",
"widget.fit"
]
Expand Down
6 changes: 5 additions & 1 deletion binder/10_Bonus_Black_Holes_as_DM.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
}
],
"source": [
"#NBVAL_IGNORE_OUTPUT\n",
"#Because the figure doesn't save to the repository correctly.\n",
"# Widget Output\n",
"widget.VBox([widget.button_5533,widget.out_5533,widget.interactive_plot_5533(widget.f5533)])"
]
Expand Down Expand Up @@ -135,6 +137,8 @@
}
],
"source": [
"#NBVAL_IGNORE_OUTPUT\n",
"#Because the figure doesn't save to the repository correctly.\n",
"%matplotlib inline\n",
"widget.VBox([widget.button_7814,widget.out_7814,widget.interactive_plot_7814(widget.f7814)])"
]
Expand Down Expand Up @@ -209,7 +213,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.9.7"
}
},
"nbformat": 4,
Expand Down
1 change: 1 addition & 0 deletions binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies:
- ipywidgets==7.6.5
- ffmpeg
- pip
- ipykernel
- pip:
- lmfit
- astroquery
Expand Down
25 changes: 0 additions & 25 deletions binder/test_local.py

This file was deleted.