Skip to content
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
20 changes: 0 additions & 20 deletions .github/workflows/coverage.yml

This file was deleted.

244 changes: 132 additions & 112 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,44 @@ on: [push,pull_request]
jobs:
# This is a job for linux python3 tests
linuxpy3:
runs-on: [ubuntu-18.04]
container:
image: 'rootproject/root:latest'
runs-on: [ubuntu-20.04]
steps:
- uses: actions/checkout@v2

# Install dependencies
- name: Install dependencies
- name: Install python dependencies
run: |
yum install -y python-pip ghostscript
python -m pip install pytest_pylint configparser astroid pyyml papermill nbconvert

curl https://bootstrap.pypa.io/get-pip.py > get-pip.py
python3 get-pip.py
python3 -m pip install pytest_pylint configparser astroid pyyml papermill nbconvert jupyter pytest pytest-cov
- name: Fixup ImageMagick
run: |
sudo sed -i '/.*PDF.*/ s/none/read | write/g' /etc/ImageMagick*/policy.xml
ls /etc/ImageMagick*/policy.xml
cat /etc/ImageMagick*/policy.xml
sudo apt update
sudo apt install ghostscript
echo "---GS---"
which gs
echo "--------"
- name: Install ROOT
run: |
wget -q https://root.cern/download/root_v6.24.00.Linux-ubuntu20-x86_64-gcc9.3.tar.gz
tar xf *tar.gz
source root/bin/thisroot.sh
# Run pytest
- name: Run pytest
run: |
python -m pip install -e .
python setup.py test
source root/bin/thisroot.sh
python3 -m pip install -e .
python3 setup.py test

# Save notebooks
- name: Save notebooks
if: ${{ always() }}
run: |
python -m jupyter nbconvert --ExecutePreprocessor.timeout=600 --ExecutePreprocessor.allow_errors=True --to html --execute examples/*.ipynb
python3 -m jupyter kernelspec list
python3 -m jupyter nbconvert --ExecutePreprocessor.timeout=600 --ExecutePreprocessor.allow_errors=True --to html --execute examples/*.ipynb

# Upload notebooks
- name: Upload notebooks
Expand All @@ -42,116 +57,121 @@ jobs:
- name: Run pylint
if: ${{ always() }}
run: |
python -m pip install -e .
python -m pylint hepdata_lib/*.py
python -m pylint tests/*.py --rcfile=tests/pylintrc

python3 -m pip install -e .
python3 -m pylint hepdata_lib/*.py
python3 -m pylint tests/*.py --rcfile=tests/pylintrc
- name: Upload coverage data to coveralls.io
run: |
python -m pip install coveralls==2.2
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# This is a job for macOS python3 tests
macospy3:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
# macospy3:
# runs-on: macos-latest
# steps:
# - uses: actions/checkout@v2

# Install dependencies
- name: Install dependencies
run: |
brew update
brew install fontconfig gd gettext libffi glib jasper netpbm gts graphviz gsl libxml2 openblas numpy tbb xrootd || true
brew install python@3.8 openssl@1.1 || true
# # Install dependencies
# - name: Install dependencies
# run: |
# brew update
# brew install fontconfig gd gettext libffi glib jasper netpbm gts graphviz gsl libxml2 openblas numpy tbb xrootd || true
# brew install python@3.8 openssl@1.1 || true

# Run pytest
- name: Run pytest
run: |
ROOT_VERSION=6.20.04_1
curl -O https://clange.web.cern.ch/clange/root-v${ROOT_VERSION}.tar.gz
tar xzf root-v${ROOT_VERSION}.tar.gz
mkdir -p /usr/local/Cellar/root
mv ${ROOT_VERSION} /usr/local/Cellar/root/
cd /usr/local/Cellar/root/${ROOT_VERSION}
export PATH=${PWD}/bin:$(brew --cellar python@3.8)/$(ls $(brew --cellar python@3.8))/bin:${PATH}
export PYTHONPATH=${PWD}/lib/root:${PYTHONPATH}
export LD_LIBRARY_PATH=${PWD}/lib/root:${LD_LIBRARY_PATH}
echo ${PYTHONPATH}
cd -
python3 -m pip install pytest ipykernel papermill jupyter_client nbconvert
python3 setup.py test
# # Run pytest
# - name: Run pytest
# run: |
# ROOT_VERSION=6.20.04_1
# curl -O https://clange.web.cern.ch/clange/root-v${ROOT_VERSION}.tar.gz
# tar xzf root-v${ROOT_VERSION}.tar.gz
# mkdir -p /usr/local/Cellar/root
# mv ${ROOT_VERSION} /usr/local/Cellar/root/
# cd /usr/local/Cellar/root/${ROOT_VERSION}
# export PATH=${PWD}/bin:$(brew --cellar python@3.8)/$(ls $(brew --cellar python@3.8))/bin:${PATH}
# export PYTHONPATH=${PWD}/lib/root:${PYTHONPATH}
# export LD_LIBRARY_PATH=${PWD}/lib/root:${LD_LIBRARY_PATH}
# echo ${PYTHONPATH}
# cd -
# python3 -m pip install pytest ipykernel papermill jupyter_client nbconvert
# python3 setup.py test

# Save notebooks
- name: Save notebooks
if: ${{ always() }}
run: |
cd /usr/local/Cellar/root/${ROOT_VERSION}
export PATH=${PWD}/bin:$(brew --cellar python@3.8)/$(ls $(brew --cellar python@3.8))/bin:${PATH}
export PYTHONPATH=${PWD}/lib/root:${PYTHONPATH}
export LD_LIBRARY_PATH=${PWD}/lib/root:${LD_LIBRARY_PATH}
echo ${PYTHONPATH}
cd -
python3 -m jupyter nbconvert --ExecutePreprocessor.timeout=600 --ExecutePreprocessor.kernel_name=python3 --ExecutePreprocessor.allow_errors=True --to html --execute examples/*.ipynb
# # Save notebooks
# - name: Save notebooks
# if: ${{ always() }}
# run: |
# cd /usr/local/Cellar/root/${ROOT_VERSION}
# export PATH=${PWD}/bin:$(brew --cellar python@3.8)/$(ls $(brew --cellar python@3.8))/bin:${PATH}
# export PYTHONPATH=${PWD}/lib/root:${PYTHONPATH}
# export LD_LIBRARY_PATH=${PWD}/lib/root:${LD_LIBRARY_PATH}
# echo ${PYTHONPATH}
# cd -
# python3 -m jupyter nbconvert --ExecutePreprocessor.timeout=600 --ExecutePreprocessor.kernel_name=python3 --ExecutePreprocessor.allow_errors=True --to html --execute examples/*.ipynb

# Upload notebooks
- name: Upload notebooks
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: notebooks macOS
path: examples/*.html
# # Upload notebooks
# - name: Upload notebooks
# if: ${{ always() }}
# uses: actions/upload-artifact@v2
# with:
# name: notebooks macOS
# path: examples/*.html

# Run Pylint
- name: Run Pylint
if: ${{ always() }}
run: |
python3 -m pip install pytest ipykernel papermill
python3 -m pip install -e .
python3 -m pylint hepdata_lib/*.py
python3 -m pylint tests/*.py --rcfile=tests/pylintrc
# # Run Pylint
# - name: Run Pylint
# if: ${{ always() }}
# run: |
# python3 -m pip install pytest ipykernel papermill
# python3 -m pip install -e .
# python3 -m pylint hepdata_lib/*.py
# python3 -m pylint tests/*.py --rcfile=tests/pylintrc

# This is a job for linux python2.7 tests
linuxpy27:
runs-on: ubuntu-16.04
steps:
- uses: actions/checkout@v2
# # This is a job for linux python2.7 tests
# linuxpy27:
# runs-on: ubuntu-16.04
# steps:
# - uses: actions/checkout@v2

# Install dependencies
- name: Install dependencies
run: |
sudo apt-get install python2.7
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
curl -O https://root.cern.ch/download/root_v6.20.00.Linux-ubuntu16-x86_64-gcc5.4.tar.gz
tar xzf root_v6.20.00.Linux-ubuntu16-x86_64-gcc5.4.tar.gz
python -m pip install numpy==1.16.5
sudo sed -i '/MVG/d' /etc/ImageMagick-6/policy.xml
sudo sed -i '/PDF/{s/none/read|write/g}' /etc/ImageMagick-6/policy.xml
sudo sed -i '/PDF/ a <policy domain="coder" rights="read|write" pattern="LABEL" />' /etc/ImageMagick-6/policy.xml
python -m pip install --upgrade enum34 pytest_pylint configparser astroid future ipykernel papermill nbconvert
sudo apt update
sudo apt install -y ghostscript
# # Install dependencies
# - name: Install dependencies
# run: |
# sudo apt-get install python2.7
# python -m pip install --upgrade pip
# python -m pip install --upgrade setuptools
# curl -O https://root.cern.ch/download/root_v6.20.00.Linux-ubuntu16-x86_64-gcc5.4.tar.gz
# tar xzf root_v6.20.00.Linux-ubuntu16-x86_64-gcc5.4.tar.gz
# python -m pip install numpy==1.16.5
# sudo sed -i '/MVG/d' /etc/ImageMagick-6/policy.xml
# sudo sed -i '/PDF/{s/none/read|write/g}' /etc/ImageMagick-6/policy.xml
# sudo sed -i '/PDF/ a <policy domain="coder" rights="read|write" pattern="LABEL" />' /etc/ImageMagick-6/policy.xml
# python -m pip install --upgrade enum34 pytest_pylint configparser astroid future ipykernel papermill nbconvert
# sudo apt update
# sudo apt install -y ghostscript

# Run pytest
- name: Run pytest
run: |
source root/bin/thisroot.sh
python setup.py test
# # Run pytest
# - name: Run pytest
# run: |
# source root/bin/thisroot.sh
# python setup.py test

# Save notebooks
- name: Save notebooks
if: ${{ always() }}
run: |
source root/bin/thisroot.sh
export PATH=$PATH:~/.local/bin
source ~/.bash_profile
jupyter nbconvert --ExecutePreprocessor.timeout=600 --ExecutePreprocessor.kernel_name=python2 --ExecutePreprocessor.allow_errors=True --to html --execute examples/*.ipynb
# Upload notebooks
- name: Upload notebooks
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: notebooks py27
path: examples/*.html
# # Save notebooks
# - name: Save notebooks
# if: ${{ always() }}
# run: |
# source root/bin/thisroot.sh
# export PATH=$PATH:~/.local/bin
# source ~/.bash_profile
# jupyter nbconvert --ExecutePreprocessor.timeout=600 --ExecutePreprocessor.kernel_name=python2 --ExecutePreprocessor.allow_errors=True --to html --execute examples/*.ipynb
# # Upload notebooks
# - name: Upload notebooks
# if: ${{ always() }}
# uses: actions/upload-artifact@v2
# with:
# name: notebooks py27
# path: examples/*.html

# Run pylint
- name: Run Pylint
if: ${{ always() }}
run: |
python -m pylint hepdata_lib/*.py
python -m pylint tests/*.py --rcfile=tests/pylintrc
# # Run pylint
# - name: Run Pylint
# if: ${{ always() }}
# run: |
# python -m pylint hepdata_lib/*.py
# python -m pylint tests/*.py --rcfile=tests/pylintrc
Binary file modified examples/example_inputs/mlfit_lm_1000.root
Binary file not shown.
13 changes: 7 additions & 6 deletions hepdata_lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import warnings
from collections import defaultdict
import yaml
from future.utils import raise_from

# try to use LibYAML bindings if possible
try:
Expand Down Expand Up @@ -77,20 +78,20 @@ def values(self, value_list):
if self.is_binned:
# Check that the input is well-formed
try:
assert all([len(x) == 2 for x in value_list])
except (AssertionError, TypeError, ValueError):
raise ValueError("For binned Variables, values should be tuples of length two: \
assert all((len(x) == 2 for x in value_list))
except (AssertionError, TypeError, ValueError) as err:
msg = "For binned Variables, values should be tuples of length two: \
(lower bin edge, upper bin edge)."
)
raise_from(ValueError(msg), err)

# All good
self._values = [(float(x[0]), float(x[1])) for x in value_list]
else:
# Check that the input is well-formed
try:
parsed_values = [x if isinstance(x, str) else float(x) for x in value_list]
except (TypeError, ValueError):
raise ValueError("Malformed input for unbinned variable: ", value_list)
except (TypeError, ValueError) as err:
raise_from(ValueError("Malformed input for unbinned variable: ", value_list),err)
self._values = parsed_values

def scale_values(self, factor):
Expand Down
22 changes: 11 additions & 11 deletions hepdata_lib/c_file_reader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
""".C file reader"""

import io
from array import array
from future.utils import raise_from
import six
from ROOT import TGraph, TGraphErrors
import hepdata_lib.root_utils as ru
Expand Down Expand Up @@ -171,8 +171,8 @@ def create_tgrapherrors(self, x_value, y_value, dx_value, dy_value):
dy_values.append(dy_value[value])
try:
t_object = TGraphErrors(length, x_values, y_values, dx_values, dy_values)
except TypeError:
raise TypeError("Invalid value in TGraphErrors constructor!")
except TypeError as err:
raise_from(TypeError("Invalid value in TGraphErrors constructor!"), err)
graph = ru.get_graph_points(t_object)

return graph
Expand All @@ -197,8 +197,8 @@ def create_tgraph(self, x_value, y_value):
y_values.append(y_value[value])
try:
t_object = TGraph(length, x_values, y_values)
except TypeError:
raise TypeError("Invalid value in TGraph constructor!")
except TypeError as err:
raise_from(TypeError("Invalid value in TGraph constructor!"), err)
graph = ru.get_graph_points(t_object)

return graph
Expand Down Expand Up @@ -287,17 +287,17 @@ def find_graphs(self):
if start == 1:
try:
tgraph_names.append(line.split('"', 1)[1].split('"')[0])
except IndexError:
except IndexError as err:
tgraph_names = 'null'
raise IndexError("index out of range")
raise_from(IndexError("index out of range"), err)
start = 0
counter = 0
if start == 2:
try:
tgrapherror_names.append(line.split('"', 1)[1].split('"')[0])
except IndexError:
except IndexError as err:
tgrapherror_names = 'null'
raise IndexError("index out of range")
raise_from(IndexError("index out of range"), err)
start = 0
counter = 0

Expand Down Expand Up @@ -401,6 +401,6 @@ def read_graph(self, graphname):
values.append(int(i))
except ValueError:
values.append(float(i))
except ValueError:
raise ValueError("Value is not a number in variable:", graphname)
except ValueError as err:
raise_from(ValueError("Value is not a number in variable:", graphname), err)
return values
Loading