diff --git a/.travis.yml b/.travis.yml index 1bdbd7a69..2fe067094 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,10 @@ matrix: env: - PINTS_UNIT=true if: type != cron + - python: "2.7.6" + env: + - PINTS_UNIT=true + if: type != cron - python: "3.4" env: - PINTS_UNIT=true @@ -50,10 +54,17 @@ matrix: - python: "3.6" if: type == cron -# command to install dependencies +# Install dependencies +# Note: Use pip (not apt-get) for Python dependencies +# Note: Only install normal dependencies for unit tests; these should be tested +# without the packages from -dev and -doc! install: + - pip install --upgrade pip - pip install . - - pip install -r requirements-dev.txt + - pip install -r requirements.txt + - if [[ $PINTS_DOCS == true ]]; then pip install -r requirements-docs.txt; fi; + - if [[ $PINTS_STYLE == true ]]; then pip install -r requirements-dev.txt; fi; + - if [[ $TRAVIS_EVENT_TYPE == 'cron' ]]; then pip install -r requirements-dev.txt; fi; - if [[ $PINTS_COVER == true ]]; then pip install coverage codecov; fi; before_script: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b4d12b204..3acfe66e4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -241,6 +241,12 @@ Note that these files must be kept in sync with The requirements files link to each other, so that calling `$ pip install -r requirements-dev.txt` will install everything listed in `requirements.txt` and `requirements-docs.txt` as well. +It's always worth using an up-to-date version of pip. On older systems especially, having an up-to-date pip will prevent all kinds of version incompatibility issues: + +``` +$ pip install --upgrade pip +``` + ### Travis CI All committed code is tested using [Travis CI](https://travis-ci.org/), tests are published on https://travis-ci.org/pints-team/pints. diff --git a/README.md b/README.md index 44fc8b42e..78a1986f0 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,13 @@ You'll need the following requirements: - Python 2.7 or Python 3.4+ - Python libraries: `cma` `numpy` `matplotlib` `scipy` -These will be installed automatically if you go to the directory you downloaded pints to, and run +These can easily be installed using `pip`. To do this, first make sure you have the latest version of pip installed: + +``` +$ pip install --upgrade pip +``` + +Then navigate to the path where you downloaded Pints to, and install both Pints and its dependencies by typing: ``` $ pip install . diff --git a/pints/noise.py b/pints/noise.py index cbef0f0c4..ed5398d73 100644 --- a/pints/noise.py +++ b/pints/noise.py @@ -29,8 +29,8 @@ def independent(sigma, shape): noisy_values = values + noise.independent(5, values.shape) """ - # Don't test sigma/shape: handled by numpy for higher-dimensions etc.! + # Don't test sigma/shape: handled by numpy for higher-dimensions etc.! return np.random.normal(0, sigma, shape) @@ -75,7 +75,11 @@ def ar1(rho, sigma, n): return np.array([]) # Generate noise - v = np.random.normal(0, sigma * np.sqrt(1 - rho**2), n) + s = sigma * np.sqrt(1 - rho**2) + if s == 0: + v = np.zeros(n) + else: + v = np.random.normal(0, s, n) v[0] = np.random.rand() for t in range(1, n): v[t] += rho * v[t - 1] diff --git a/pints/tests/test_noise.py b/pints/tests/test_noise.py index 5ac777c0c..949c01e65 100755 --- a/pints/tests/test_noise.py +++ b/pints/tests/test_noise.py @@ -41,7 +41,7 @@ def test_independent_noise(self): self.assertRaises(ValueError, pn.independent, -1, clean.shape) # Shape must be a nice shape (handled by numpy) - self.assertRaises(TypeError, pn.independent, 0, 'hello') + self.assertRaises(TypeError, pn.independent, 1, 'hello') def test_ar1(self):