Skip to content

Commit

Permalink
Merge pull request #264 from Dekken/python3.7
Browse files Browse the repository at this point in the history
testing docker and python 3.7 on travis
  • Loading branch information
PhilipDeegan authored Jul 19, 2018
2 parents 72767c1 + 1c5b7d3 commit b769855
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 43 deletions.
14 changes: 6 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
language: generic

cache: ccache

branches:
only:
- master
Expand All @@ -17,24 +15,24 @@ matrix:
- os: linux
services: docker
env:
- DOCKER_IMAGE=xdatainitiative/tick_ubuntu:1.4
- PYVER=3.5.3
- DOCKER_IMAGE=xdatainitiative/tick_ubuntu:1.4.2
- PYVER=3.6.1
- os: linux
services: docker
env:
- DOCKER_IMAGE=xdatainitiative/tick_ubuntu:1.4
- PYVER=3.6.1
- DOCKER_IMAGE=xdatainitiative/tick_ubuntu:1.4.2
- PYVER=3.7.0
- os: osx
language: generic
sudo: required
env:
- PYVER=3.5.3
- PYVER=3.6.1
osx_image: xcode9.1
- os: osx
language: generic
sudo: required
env:
- PYVER=3.6.1
- PYVER=3.7.0
osx_image: xcode9.1

before_install:
Expand Down
65 changes: 37 additions & 28 deletions examples/plot_hawkes_cumulants_matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,49 @@
.. _In International Conference on Machine Learning (pp. 1-10): http://proceedings.mlr.press/v70/achab17a.html
"""

import numpy as np
skip = True
try:
import tensorflow
skip = False
except ImportError:
print("tensorflow not found, skipping HawkesCumulantMatching")

from tick.hawkes import (HawkesCumulantMatching, SimuHawkesExpKernels,
SimuHawkesMulti)
from tick.plot import plot_hawkes_kernel_norms
if not skip:

np.random.seed(7168)
import numpy as np

n_nodes = 3
baselines = 0.3 * np.ones(n_nodes)
decays = 0.5 + np.random.rand(n_nodes, n_nodes)
adjacency = np.array([
[1, 1, -0.5],
[0, 1, 0],
[0, 0, 2],
], dtype=float)
from tick.hawkes import (HawkesCumulantMatching, SimuHawkesExpKernels,
SimuHawkesMulti)
from tick.plot import plot_hawkes_kernel_norms

adjacency /= 4
np.random.seed(7168)

end_time = 1e5
integration_support = 5
n_realizations = 5
n_nodes = 3
baselines = 0.3 * np.ones(n_nodes)
decays = 0.5 + np.random.rand(n_nodes, n_nodes)
adjacency = np.array([
[1, 1, -0.5],
[0, 1, 0],
[0, 0, 2],
], dtype=float)

simu_hawkes = SimuHawkesExpKernels(baseline=baselines, adjacency=adjacency,
decays=decays, end_time=end_time,
verbose=False, seed=7168)
simu_hawkes.threshold_negative_intensity(True)
adjacency /= 4

multi = SimuHawkesMulti(simu_hawkes, n_simulations=n_realizations,
n_threads=-1)
multi.simulate()
end_time = 1e5
integration_support = 5
n_realizations = 5

nphc = HawkesCumulantMatching(integration_support, cs_ratio=.15, tol=1e-10,
step=0.3)
simu_hawkes = SimuHawkesExpKernels(baseline=baselines, adjacency=adjacency,
decays=decays, end_time=end_time,
verbose=False, seed=7168)
simu_hawkes.threshold_negative_intensity(True)

nphc.fit(multi.timestamps)
plot_hawkes_kernel_norms(nphc)
multi = SimuHawkesMulti(simu_hawkes, n_simulations=n_realizations,
n_threads=-1)
multi.simulate()

nphc = HawkesCumulantMatching(integration_support, cs_ratio=.15, tol=1e-10,
step=0.3)

nphc.fit(multi.timestamps)
plot_hawkes_kernel_norms(nphc)
7 changes: 6 additions & 1 deletion tools/travis/docker_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ python -m yapf --style tools/code_style/yapf.conf -i tick examples --recursive

python -m pip install -r requirements.txt

python setup.py cpplint build_ext --inplace cpptest pytest
python setup.py cpplint
set +e
python setup.py build_ext -j 2 --inplace
rm -rf build/lib # force relinking of libraries in case of failure
set -e
python setup.py build_ext --inplace cpptest pytest

export PYTHONPATH=${PYTHONPATH}:`pwd` && (cd doc && make doctest)
9 changes: 4 additions & 5 deletions tools/travis/osx_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ set -e -x
shell_session_update() { :; }

brew update
brew upgrade pyenv
brew install swig
brew install ccache
#brew upgrade pyenv

if [ ! -d googletest ] || [ ! -f googletest/CMakeLists.txt ]; then
git clone https://github.com/google/googletest
Expand All @@ -19,8 +18,8 @@ fi

export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
export CC="ccache clang"
export CXX="ccache clang++"
export CC="clang"
export CXX="clang++"

eval "$(pyenv init -)"

Expand All @@ -33,6 +32,6 @@ python -m pip install --quiet numpy pandas
python -m pip install -r requirements.txt
python -m pip install sphinx pillow
python -m pip install cpplint
python -m pip install tensorflow
[[ "${PYVER}" != "3.7.0" ]] && python -m pip install tensorflow # does not yet exist on python 3.7
pyenv rehash

8 changes: 7 additions & 1 deletion tools/travis/osx_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ pyenv global ${PYVER}
## export PYTHONPATH=${PYTHONPATH}:`pwd` && cd doc && make doctest
###

python setup.py cpplint build_ext --inplace cpptest pytest
python setup.py cpplint
set +e
python setup.py build_ext -j 2 --inplace # mac builds are slow but -j can fail so run twice
rm -rf build/lib # force relinking of libraries in case of failure
set -e
python setup.py build_ext --inplace cpptest pytest

export PYTHONPATH=${PYTHONPATH}:`pwd`
for f in $(find examples -maxdepth 1 -type f -name "*.py"); do
FILE=$(basename $f)
Expand Down

0 comments on commit b769855

Please sign in to comment.