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

Unit tests cleanup #245

Merged
merged 12 commits into from
Apr 6, 2022
Merged
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
17 changes: 11 additions & 6 deletions .github/workflows/get-dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#!/bin/bash

pyver=$(python --version | sed 's|Python \([0-9]*\).\([0-9]*\).[0-9]*|\1\2|')
[[ -f /etc/os-release ]] && linux_distro=$(awk -F= '/^NAME/{print $2}' /etc/os-release | cut -d ' ' -f1)

if [ "$pyver" -gt "35" ]; then
sudo apt-get install -y llvm
else
sudo apt-get install -y llvm-8
sudo ln -s /usr/bin/llvm-config-8 /usr/bin/llvm-config
if [[ "${linux_distro}" == "Ubuntu" || "${linux_distro}" == "Debian" ]]; then

pyver=$(python --version | sed 's|Python \([0-9]*\).\([0-9]*\).[0-9]*|\1\2|')

if [ "$pyver" -gt "35" ]; then
sudo apt-get install -y llvm
else
sudo apt-get install -y llvm-8
sudo ln -s /usr/bin/llvm-config-8 /usr/bin/llvm-config
fi
fi

python -m pip install --upgrade pip wheel setuptools numpy GitPython pytest
29 changes: 16 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
push:
branches:
- main
- master
- dev
- refactor
- 'releases/**'
pull_request:
Expand Down Expand Up @@ -33,19 +31,24 @@ jobs:
.github/workflows/get-dependencies.sh
python -m pip install .
- name: Run unit tests
run: pytest test
run: |
pytest tests

test-in-legend-container:
name: Test pygama in LEGEND container
runs-on: ubuntu-latest
container: docker://legendexp/legend-base:latest
# test-in-legend-container:
# name: Test pygama in LEGEND container
# runs-on: ubuntu-latest
# container: docker://legendexp/legend-base:${{ matrix.docker-tag }}
# strategy:
# fail-fast: false
# matrix:
# docker-tag: [latest, ubuntu]

steps:
- uses: actions/checkout@v2
- name: Install and run unit tests
run: |
pip install .
pytest test
# steps:
# - uses: actions/checkout@v2
# - name: Install and run unit tests
# run: |
# python -m pip install .
# pytest tests

deploy-docs:
name: Deploy documentation on legend-exp.github.io/pygama
Expand Down
1 change: 0 additions & 1 deletion pygama/dsp/test/unit_test.py

This file was deleted.

1 change: 0 additions & 1 deletion pygama/flow/test/unit_test.py

This file was deleted.

1 change: 0 additions & 1 deletion pygama/hit/test/unit_test.py

This file was deleted.

36 changes: 0 additions & 36 deletions pygama/lgdo/test/test_lgdo_utils.py

This file was deleted.

60 changes: 0 additions & 60 deletions pygama/lgdo/test/test_struct.py

This file was deleted.

2 changes: 1 addition & 1 deletion pygama/math/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def plot_hist(hist, bins, var=None, show_stats=False, stats_hloc=0.75, stats_vlo
dmean = stddev/np.sqrt(N)

mean, dmean = pgu.get_formatted_stats(mean, dmean, 2)
stats = '$\mu=%s \pm %s$\n$\sigma=%#.3g$' % (mean, dmean, stddev)
stats = r'$\mu=%s \pm %s$\n$\sigma=%#.3g$' % (mean, dmean, stddev)
stats_fontsize = rcParams['legend.fontsize']
plt.text(stats_hloc, stats_vloc, stats, transform=plt.gca().transAxes, fontsize = stats_fontsize)

Expand Down
4 changes: 2 additions & 2 deletions pygama/math/peak_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,8 @@ def gauss_tail(x, mu, sigma, tau):
x = np.asarray(x)
tmp = ((x-mu)/tau) + ((sigma**2)/(2*tau**2))
tail_f = np.where(tmp < limit,
gauss_tail_exact_pdf(x, mu, sigma, tau),
gauss_tail_approx_pdf(x, mu, sigma, tau))
gauss_tail_exact(x, mu, sigma, tau),
gauss_tail_approx(x, mu, sigma, tau))
return tail_f

@nb.njit(**kwd)
Expand Down
33 changes: 0 additions & 33 deletions pygama/math/test/test_fwhm.py

This file was deleted.

17 changes: 0 additions & 17 deletions pygama/pargen/test/ecal_test.py

This file was deleted.

3 changes: 3 additions & 0 deletions pygama/raw/fc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Subpackage documentation
"""
3 changes: 3 additions & 0 deletions pygama/raw/orca/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Subpackage documentation
"""
54 changes: 0 additions & 54 deletions pygama/raw/test/raw_buffer_test.py

This file was deleted.

1 change: 0 additions & 1 deletion pygama/vis/test/unit_test.py

This file was deleted.

7 changes: 7 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[pytest]
minversion = 6.0
addopts = -ra --showlocals --strict-markers --strict-config
xfail_strict = true
filterwarnings = error
log_cli_level = info
testpaths = tests
1 change: 0 additions & 1 deletion test/README.md

This file was deleted.

1 change: 0 additions & 1 deletion test/functional/l200_dataproc_test.py

This file was deleted.

1 change: 0 additions & 1 deletion test/functional/teststand_dataproc_test.py

This file was deleted.

1 change: 0 additions & 1 deletion test/integration/integration_test.py

This file was deleted.

6 changes: 0 additions & 6 deletions test/lh5/test_types.py

This file was deleted.

3 changes: 0 additions & 3 deletions test/pygama_test.py

This file was deleted.

1 change: 1 addition & 0 deletions tests/functional/test_l200_dataproc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions tests/functional/test_teststand_dataproc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

38 changes: 38 additions & 0 deletions tests/lgdo/test_lgdo_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import pygama.lgdo.lgdo_utils as lgdo_utils
import numpy as np


def test_get_element_type():

objs = [
('hi', 'string'),
(True, 'bool'),
(np.void(0), 'blob'),
(int(0), 'real'),
(np.uint8(0), 'real'),
(float(0), 'real'),
(1+1j, 'complex'),
(b'hi', 'string'),
(np.array(['hi']), 'string'),
]

for obj, name in objs:
get_name = lgdo_utils.get_element_type(obj)
assert get_name == name


def test_parse_datatype():

datatypes = [
('real', ('scalar', None, 'real')),
('array<1>{bool}', ('array', (1,), 'bool')),
('fixedsizearray<2>{real}', ('fixedsizearray', (2,), 'real')),
('arrayofequalsizedarrays<3,4>{complex}', ('arrayofequalsizedarrays', (3, 4), 'complex')),
('array<1>{array<1>{blob}}', ('array', (1,), 'array<1>{blob}')),
('struct{field1,field2,fieldn}', ('struct', None, ['field1', 'field2', 'fieldn'])),
('table{col1,col2,coln}', ('table', None, ['col1', 'col2', 'coln'])),
]

for string, dt_tuple in datatypes:
pd_dt_tuple = lgdo_utils.parse_datatype(string)
assert pd_dt_tuple == dt_tuple
Loading