Skip to content

Commit f7b692c

Browse files
kratsgmatthewfeickert
authored andcommitted
Simplify Travis CI with use of Xenial distribution and update package dependencies (#491)
* Simplify .travis.yml by switching to using xenial for everything * Don't run the full test suit on docs/ branches - Only build and test the docs * Update existing backend signatures to use min_value/max_value instead of min/max for codefactor * Simplify dependencies in setup.py as latest versions of various packages we pinned are behaving with each other appropriately
1 parent 0b6104c commit f7b692c

File tree

7 files changed

+30
-41
lines changed

7 files changed

+30
-41
lines changed

.travis.yml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,29 @@ dist: xenial
33
language: python
44
cache: pip
55
python:
6+
- '2.7'
67
- '3.6'
78
- '3.7'
89
before_install:
910
- sudo apt-get install libtcmalloc-minimal4
1011
- export LD_PRELOAD="/usr/lib/libtcmalloc_minimal.so.4"
1112
- pip install --upgrade pip setuptools wheel
1213
install:
13-
- if [[ $TRAVIS_DIST == 'trusty' ]]; then
14-
pip install --ignore-installed -U -q --no-cache-dir -e .[complete];
15-
else
16-
pip install --ignore-installed -U -q -e .[complete];
17-
fi
14+
- pip install --ignore-installed -U -q -e .[complete];
1815
- pip freeze
1916
script:
2017
- pyflakes pyhf
2118
- check-manifest || travis_terminate 1
2219
- python -m pytest -r sx --ignore tests/benchmarks/ --ignore tests/test_notebooks.py
2320
- if [[ $TRAVIS_PYTHON_VERSION == '3.7' ]]; then black --check --diff --verbose .; fi
2421
after_success: if [[ $TRAVIS_PYTHON_VERSION == '3.7' ]]; then coveralls; fi
25-
# Include to force matrix expansion but use trusty for Python 3.6 instead
26-
matrix:
27-
exclude:
28-
- python: '3.6'
2922

3023
# always test (on both 'push' and 'pr' builds in Travis)
3124
# test docs on 'pr' builds and 'push' builds on master
3225
# benchmark and deploy to PyPI only when merged into master (those mereges are 'push' builds)
3326
stages:
34-
- test
27+
- name: test
28+
if: NOT (branch =~ /^docs\//)
3529
- name: benchmark
3630
if: (branch = master) AND (NOT (type IN (pull_request)))
3731
- name: docs
@@ -46,19 +40,13 @@ env:
4640

4741
jobs:
4842
include:
49-
- dist: trusty
50-
python: '2.7'
51-
- dist: trusty
52-
python: '3.6'
5343
- name: "Python 2.7 Notebook Tests"
5444
python: '2.7'
55-
dist: trusty
5645
script:
5746
- python -m pytest tests/test_notebooks.py
5847
after_success: skip
5948
- name: "Python 3.6 Notebook Tests"
6049
python: '3.6'
61-
dist: trusty
6250
script:
6351
- python -m pytest tests/test_notebooks.py
6452
after_success: skip

pyhf/tensor/mxnet_backend.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class mxnet_backend(object):
1414
def __init__(self, **kwargs):
1515
self.name = 'mxnet'
1616

17-
def clip(self, tensor_in, min, max):
17+
def clip(self, tensor_in, min_value, max_value):
1818
"""
1919
Clips (limits) the tensor values to be within a specified min and max.
2020
@@ -30,14 +30,14 @@ def clip(self, tensor_in, min, max):
3030
3131
Args:
3232
tensor_in (`tensor`): The input tensor object
33-
min (`scalar` or `tensor` or `None`): The minimum value to be cliped to
34-
max (`scalar` or `tensor` or `None`): The maximum value to be cliped to
33+
min_value (`scalar` or `tensor` or `None`): The minimum value to be cliped to
34+
max_value (`scalar` or `tensor` or `None`): The maximum value to be cliped to
3535
3636
Returns:
3737
MXNet NDArray: A clipped `tensor`
3838
"""
3939
tensor_in = self.astensor(tensor_in)
40-
return nd.clip(tensor_in, min, max)
40+
return nd.clip(tensor_in, min_value, max_value)
4141

4242
def tolist(self, tensor_in):
4343
"""

pyhf/tensor/numpy_backend.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class numpy_backend(object):
1212
def __init__(self, **kwargs):
1313
self.name = 'numpy'
1414

15-
def clip(self, tensor_in, min, max):
15+
def clip(self, tensor_in, min_value, max_value):
1616
"""
1717
Clips (limits) the tensor values to be within a specified min and max.
1818
@@ -26,13 +26,13 @@ def clip(self, tensor_in, min, max):
2626
2727
Args:
2828
tensor_in (`tensor`): The input tensor object
29-
min (`scalar` or `tensor` or `None`): The minimum value to be cliped to
30-
max (`scalar` or `tensor` or `None`): The maximum value to be cliped to
29+
min_value (`scalar` or `tensor` or `None`): The minimum value to be cliped to
30+
max_value (`scalar` or `tensor` or `None`): The maximum value to be cliped to
3131
3232
Returns:
3333
NumPy ndarray: A clipped `tensor`
3434
"""
35-
return np.clip(tensor_in, min, max)
35+
return np.clip(tensor_in, min_value, max_value)
3636

3737
def tolist(self, tensor_in):
3838
try:

pyhf/tensor/pytorch_backend.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class pytorch_backend(object):
1111
def __init__(self, **kwargs):
1212
self.name = 'pytorch'
1313

14-
def clip(self, tensor_in, min, max):
14+
def clip(self, tensor_in, min_value, max_value):
1515
"""
1616
Clips (limits) the tensor values to be within a specified min and max.
1717
@@ -25,14 +25,14 @@ def clip(self, tensor_in, min, max):
2525
2626
Args:
2727
tensor_in (`tensor`): The input tensor object
28-
min (`scalar` or `tensor` or `None`): The minimum value to be cliped to
29-
max (`scalar` or `tensor` or `None`): The maximum value to be cliped to
28+
min_value (`scalar` or `tensor` or `None`): The minimum value to be cliped to
29+
max_value (`scalar` or `tensor` or `None`): The maximum value to be cliped to
3030
3131
Returns:
3232
PyTorch tensor: A clipped `tensor`
3333
"""
3434
tensor_in = self.astensor(tensor_in)
35-
return torch.clamp(tensor_in, min, max)
35+
return torch.clamp(tensor_in, min_value, max_value)
3636

3737
def tolist(self, tensor_in):
3838
try:

pyhf/tensor/tensorflow_backend.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(self, **kwargs):
1212
self.session = kwargs.get('session')
1313
self.name = 'tensorflow'
1414

15-
def clip(self, tensor_in, min, max):
15+
def clip(self, tensor_in, min_value, max_value):
1616
"""
1717
Clips (limits) the tensor values to be within a specified min and max.
1818
@@ -31,18 +31,18 @@ def clip(self, tensor_in, min, max):
3131
3232
Args:
3333
tensor_in (`tensor`): The input tensor object
34-
min (`scalar` or `tensor` or `None`): The minimum value to be cliped to
35-
max (`scalar` or `tensor` or `None`): The maximum value to be cliped to
34+
min_value (`scalar` or `tensor` or `None`): The minimum value to be cliped to
35+
max_value (`scalar` or `tensor` or `None`): The maximum value to be cliped to
3636
3737
Returns:
3838
TensorFlow Tensor: A clipped `tensor`
3939
"""
4040
tensor_in = self.astensor(tensor_in)
41-
if min is None:
42-
min = tf.reduce_min(tensor_in)
43-
if max is None:
44-
max = tf.reduce_max(tensor_in)
45-
return tf.clip_by_value(tensor_in, min, max)
41+
if min_value is None:
42+
min_value = tf.reduce_min(tensor_in)
43+
if max_value is None:
44+
max_value = tf.reduce_max(tensor_in)
45+
return tf.clip_by_value(tensor_in, min_value, max_value)
4646

4747
def tolist(self, tensor_in):
4848
try:

pyhf/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,13 @@ def hypotest(
279279
asimov_mu = 0.0
280280
asimov_data = generate_asimov_data(asimov_mu, data, pdf, init_pars, par_bounds)
281281

282-
qmu_v = tensorlib.clip(qmu(poi_test, data, pdf, init_pars, par_bounds), 0, max=None)
282+
qmu_v = tensorlib.clip(
283+
qmu(poi_test, data, pdf, init_pars, par_bounds), 0, max_value=None
284+
)
283285
sqrtqmu_v = tensorlib.sqrt(qmu_v)
284286

285287
qmuA_v = tensorlib.clip(
286-
qmu(poi_test, asimov_data, pdf, init_pars, par_bounds), 0, max=None
288+
qmu(poi_test, asimov_data, pdf, init_pars, par_bounds), 0, max_value=None
287289
)
288290
sqrtqmuA_v = tensorlib.sqrt(qmuA_v)
289291

setup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
'tensorflow~=1.14',
1616
'tensorflow-probability~=0.5',
1717
'numpy<=1.14.5,>=1.14.0', # Lower of 1.14.0 instead of 1.13.3 to ensure doctest pass
18-
'setuptools<=39.1.0',
1918
],
2019
'torch': ['torch~=1.0'],
21-
'mxnet': ['mxnet~=1.0', 'requests~=2.18.4', 'numpy<1.15.0,>=1.8.2'],
20+
'mxnet': ['mxnet~=1.0', 'numpy<1.15.0,>=1.8.2', 'graphviz<0.9.0,>=0.8.1'],
2221
# 'dask': [
2322
# 'dask[array]'
2423
# ],
@@ -49,7 +48,7 @@
4948
'sphinx-issues',
5049
'm2r',
5150
'jsonpatch',
52-
'ipython<7', # jupyter_console and ipython clash in dependency requirement -- downgrade ipython for now
51+
'ipython',
5352
'pre-commit',
5453
'black;python_version>="3.6"', # Black is Python3 only
5554
'twine',

0 commit comments

Comments
 (0)