Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Tests

on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
name: Running Tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install -e .
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with pytest
run: |
pytest
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/Github-Training-Repository.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

112 changes: 112 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: git-training
channels:
- conda-forge
- defaults
dependencies:
- ca-certificates=2022.12.7=h5b45459_0
- libsqlite=3.40.0=hcfcfb64_0
- openssl=1.1.1s=hcfcfb64_1
- pip=22.3.1=pyhd8ed1ab_0
- python=3.8.0=hc9e8b01_5
- setuptools=65.5.1=pyhd8ed1ab_0
- sqlite=3.40.0=hcfcfb64_0
- ucrt=10.0.22621.0=h57928b3_0
- vc=14.3=h3d8a991_9
- vs2015_runtime=14.32.31332=h1d6e394_9
- wheel=0.38.4=pyhd8ed1ab_0
- pip:
- anyio==3.6.2
- argon2-cffi==21.3.0
- argon2-cffi-bindings==21.2.0
- arrow==1.2.3
- asttokens==2.2.1
- attrs==22.1.0
- backcall==0.2.0
- beautifulsoup4==4.11.1
- bleach==5.0.1
- cffi==1.15.1
- colorama==0.4.6
- comm==0.1.2
- debugpy==1.6.4
- decorator==5.1.1
- defusedxml==0.7.1
- entrypoints==0.4
- exceptiongroup==1.0.4
- executing==1.2.0
- fastjsonschema==2.16.2
- fqdn==1.5.1
- idna==3.4
- importlib-metadata==5.1.0
- importlib-resources==5.10.1
- iniconfig==1.1.1
- ipykernel==6.19.2
- ipython==8.7.0
- ipython-genutils==0.2.0
- ipywidgets==8.0.3
- isoduration==20.11.0
- jedi==0.18.2
- jinja2==3.1.2
- jsonpointer==2.3
- jsonschema==4.17.3
- jupyter==1.0.0
- jupyter-client==7.4.8
- jupyter-console==6.4.4
- jupyter-core==5.1.0
- jupyter-events==0.5.0
- jupyter-server==2.0.1
- jupyter-server-terminals==0.4.2
- jupyterlab-pygments==0.2.2
- jupyterlab-widgets==3.0.4
- markupsafe==2.1.1
- matplotlib-inline==0.1.6
- mistune==2.0.4
- nbclassic==0.4.8
- nbclient==0.7.2
- nbconvert==7.2.6
- nbformat==5.7.0
- nest-asyncio==1.5.6
- notebook==6.5.2
- notebook-shim==0.2.2
- packaging==22.0
- pandocfilters==1.5.0
- parso==0.8.3
- pickleshare==0.7.5
- pkgutil-resolve-name==1.3.10
- platformdirs==2.6.0
- pluggy==1.0.0
- prometheus-client==0.15.0
- prompt-toolkit==3.0.36
- psutil==5.9.4
- pure-eval==0.2.2
- pycparser==2.21
- pygments==2.13.0
- pyrsistent==0.19.2
- pytest==7.2.0
- python-dateutil==2.8.2
- python-json-logger==2.0.4
- pywin32==305
- pywinpty==2.0.9
- pyyaml==6.0
- pyzmq==24.0.1
- qtconsole==5.4.0
- qtpy==2.3.0
- rfc3339-validator==0.1.4
- rfc3986-validator==0.1.1
- send2trash==1.8.0
- six==1.16.0
- sniffio==1.3.0
- soupsieve==2.3.2.post1
- stack-data==0.6.2
- terminado==0.17.1
- tinycss2==1.2.1
- tomli==2.0.1
- tornado==6.2
- traitlets==5.7.0
- uri-template==1.2.0
- wcwidth==0.2.5
- webcolors==1.12
- webencodings==0.5.1
- websocket-client==1.4.2
- widgetsnbextension==4.0.4
- zipp==3.11.0
prefix: C:\Users\zl\miniconda3\envs\git-training
53 changes: 53 additions & 0 deletions scripts/Import_numerical.py.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"id": "84e76ec0",
"metadata": {},
"outputs": [],
"source": [
"from src.numerical import add_numbers"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "48dfa364",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Sum: 13.5\n"
]
}
],
"source": [
"add_numbers(3.5, 10)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "git-training",
"language": "python",
"name": "git-training"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
6 changes: 6 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from setuptools import find_packages, setup

setup(
name='src',
packages=find_packages(),
)
Empty file added src/__initial__.py
Empty file.
18 changes: 18 additions & 0 deletions src/numerical.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
def add_numbers(a = 7, b = 8):
"""
add the numbers together

Arguments:
a: one number
b: the other number

Returns:
float: the addition of the two numbers
"""
if isinstance(a, str) or isinstance(b, str):
raise NotImplementedError('This function only takes numerical values')
def add_numbers_inner(a, b):
sum = float(a) + float(b)
return sum
return add_numbers_inner(a, b)

25 changes: 25 additions & 0 deletions src/plotting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import matplotlib.pyplot as plt
import numpy as np

def plot_scatter(X, Y):
"""
plot a scatterplot for inputs X and Y

Arguments:
X: an array or a list of numbers
Y: an array or a list of numbers

Returns:
plot: scatter plot with X being x-axis and Y being Y-axis
"""
# use the ALLFED plot style
plt.style.use("https://raw.githubusercontent.com/allfed/ALLFED-matplotlib-style-sheet/main/ALLFED.mplstyle")
plt.scatter(x, y)
plt.show()


np.random.seed(123)
N = 30
x = np.random.rand(N)
y = np.random.rand(N)
plot_scatter(x, y)
23 changes: 23 additions & 0 deletions tests/test1_numerical_py.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
def add_numbers(a = 7, b = 8):
"""
add the numbers together

Arguments:
a: one number
b: the other number

Returns:
float: the addition of the two numbers
"""
if isinstance(a, str) or isinstance(b, str):
raise NotImplementedError('This function only takes numerical values')
def add_numbers_inner(a, b):
sum = float(a) + float(b)
return sum
return add_numbers_inner(a, b)

if __name__ == '__main__':
assert add_numbers(4, 8) == 12
assert add_numbers(4.3, 9.2) == 13.5
assert add_numbers(-2, -3) == -5
print("Tests passed")
14 changes: 14 additions & 0 deletions tests/test2_numerical_py.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from src.numerical import add_numbers
import pytest

def test_typical():
assert add_numbers(4, 8) == 12
assert add_numbers(4.3, 9.2) == 13.5
assert add_numbers(-2, -3) == -5

def test_raises():
with pytest.raises(NotImplementedError):
add_numbers("23", 3)

with pytest.raises(NotImplementedError):
add_numbers(23, "5.1")