Skip to content

Commit 511d7ba

Browse files
committed
BLD: Update build
Update travis to modernize it
1 parent 255cf82 commit 511d7ba

File tree

4 files changed

+50
-67
lines changed

4 files changed

+50
-67
lines changed

.travis.yml

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ env:
1111
global:
1212
- secure: "aupv9PPJZh7WjV2fl8fnxvztT5HHPz0j3pPkaMrxWT5fhWhbL/RYSqkkCh+GZiYFnDToXEdiNLuj2UD3CsRNu1ry9RuI9f9KcBgL9udacu2XC00c8XMl1Puiy02RjHe17DAHmAyoTEcckDoHyoKHM6rfyYCjGEDoqJuW6VfJr0KdNUE9bZSdj+kDQgQT0cilaHywzLnHg0v7K83vp2MG0BELV4vcB/OU/BmFeekjqNWaYHDHP0Ur+WG7FoOpGyG3dqO+Hlutx8tXlwjVHgTjkd6vJOU/3AHjWFfrNd9Z6Pzi2afCBZjLXHOeHm8X4Be4Gd9EJnWpARRev+6bgXVCyVZsaRscXPsdl0ylmYFROiUqIlvnqjPRDTRhq4kA72Fvtsf6RzTHX0CdDyctVMw3RoasrA9yRRg7SQYuTn1yKCpEpSGeDWjHo1/PqyBTvGdAwTse9jitBxyw3lC3dXAQDpQo5Smk5ZFwBS+9T0tm8QR1P63Nv9TeK9yjsJe/cytb5ZP495FKBJ1iBntjhOfhoahKbcFcVZjyZZYQZ5f1pVcZoKI4iTuBZup060ZmDRXjwStR2N63za9DocY6oVIyHaLcrgiej8KqvBeqWCxNvMNdiw/4O47/4T6qsvsjdceSUBkR8yPyuL3NfkZXUzzxdWwkNKHynxYYLprKZqHqfUU="
1313

14-
services:
15-
- docker
16-
17-
before_install:
18-
- docker pull ubuntu:16.04
19-
2014
matrix:
2115
fast_finish: true
2216
include:
@@ -35,31 +29,28 @@ matrix:
3529

3630
before_install:
3731
- if [ ${TRAVIS_OS_NAME} = "osx" ]; then wget https://repo.continuum.io/miniconda/Miniconda-latest-MacOSX-x86_64.sh -O miniconda.sh; fi
38-
- if [ ${TRAVIS_OS_NAME} = "linux" ]; then wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh; fi
39-
- chmod +x miniconda.sh
40-
- ./miniconda.sh -b
41-
- export PATH=$HOME/miniconda/bin:$PATH
42-
- export PATH=$HOME/miniconda2/bin:$PATH
43-
- conda config --set always_yes yes
32+
- if [ ${TRAVIS_OS_NAME} = "linux" ]; then wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda3.sh; fi
33+
- chmod +x miniconda3.sh
34+
- ./miniconda3.sh -b
35+
- export PATH=/home/travis/miniconda3/bin:$PATH
36+
- conda config --set always_yes true
4437
- conda update --all --quiet
4538
- PKGS="python=${PYTHON}"
4639
- PKGS="${PKGS} numpy"; if [ ${NUMPY} ]; then PKGS="${PKGS}=${NUMPY}"; fi
4740
- PKGS="${PKGS} Cython"; if [ ${CYTHON} ]; then PKGS="${PKGS}=${CYTHON}"; fi
4841
- PKGS="${PKGS} pandas"; if [ ${PANDAS} ]; then PKGS="${PKGS}=${PANDAS}"; fi
49-
50-
# Install packages
51-
install:
52-
- conda create -n randomstate-test ${PKGS} nose pip setuptools matplotlib pyyaml --quiet
42+
- export BUILD_DIR=$PWD
43+
- conda create -n randomstate-test ${PKGS} pytest pip setuptools matplotlib pyyaml nose --quiet
5344
- source activate randomstate-test
5445
- pip install tempita sphinx guzzle_sphinx_theme ipython -q
46+
47+
install:
48+
- python setup.py develop
5549
- python setup.py install
56-
- export BUILD_DIR=$PWD
57-
- cd $HOME
5850

5951
script:
6052
- set -e
61-
- nosetests randomstate
62-
- cd $BUILD_DIR/randomstate
53+
- pytest randomstate
6354
- |
6455
if [ ${PYTHON} = 3.5 ]; then
6556
conda install -c conda-forge doctr

randomstate/tests/test_against_numpy.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import unittest
21
import numpy as np
32
import numpy.random
43
from numpy.testing import assert_allclose, assert_array_equal, assert_equal
@@ -38,7 +37,7 @@ def compare_2_input(f1, f2, is_np=False, is_scalar=False):
3837
((np.array([a] * 10), b), {}),
3938
((a, np.array([b] * 10)), {}),
4039
((a, np.array([b] * 10)), {'size': 10}),
41-
((np.reshape(np.array([[a] * 100]), (100,1)), np.array([b] * 10)), {'size': (100, 10)}),
40+
((np.reshape(np.array([[a] * 100]), (100, 1)), np.array([b] * 10)), {'size': (100, 10)}),
4241
((np.ones((7, 31), dtype=dtype) * a, np.array([b] * 31)), {'size': (7, 31)}),
4342
((np.ones((7, 31), dtype=dtype) * a, np.array([b] * 31)), {'size': (10, 7, 31)})]
4443

@@ -50,7 +49,7 @@ def compare_2_input(f1, f2, is_np=False, is_scalar=False):
5049
v1 = f1(*i[0], **i[1])
5150
v2 = f2(*i[0], **i[1])
5251
assert_allclose(v1, v2)
53-
print('OK!'*20)
52+
print('OK!' * 20)
5453

5554

5655
def compare_3_input(f1, f2, is_np=False):
@@ -79,7 +78,7 @@ def compare_3_input(f1, f2, is_np=False):
7978
assert_allclose(v1, v2)
8079

8180

82-
class TestAgainstNumPy(unittest.TestCase):
81+
class TestAgainstNumPy(object):
8382
@classmethod
8483
def setup_class(cls):
8584
cls.np = numpy.random
@@ -107,7 +106,7 @@ def _is_state_common(self):
107106
assert (state[1] == state2['state'][0]).all()
108107
assert (state[2] == state2['state'][1])
109108
assert (state[3] == state2['gauss']['has_gauss'])
110-
assert_allclose(state[4],state2['gauss']['gauss'])
109+
assert_allclose(state[4], state2['gauss']['gauss'])
111110

112111
def test_common_seed(self):
113112
self.rs.seed(1234)
@@ -512,15 +511,13 @@ def test_array(self):
512511
def test_dir(self):
513512
nprs_d = dir(self.nprs)
514513
rs_d = dir(self.rs)
515-
assert(len(set(nprs_d).difference(rs_d)) == 0)
514+
assert (len(set(nprs_d).difference(rs_d)) == 0)
516515

517516
npmod = dir(numpy.random)
518517
mod = dir(randomstate)
519518
known_exlcuded = ['__all__', 'Tester', 'info', 'bench',
520519
'__RandomState_ctor', 'mtrand', 'test',
521-
'__warningregistry__','_numpy_tester']
520+
'__warningregistry__', '_numpy_tester']
522521
mod += known_exlcuded
523522
diff = set(npmod).difference(mod)
524523
assert_equal(len(diff), 0)
525-
526-

randomstate/tests/test_direct.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import os
22
import sys
33
from os.path import join
4-
from unittest import TestCase
5-
from nose import SkipTest
64

75
import numpy as np
86
from randomstate.prng.mlfg_1279_861 import mlfg_1279_861
@@ -210,16 +208,17 @@ def test_seed_float_array(self):
210208
def test_seed_out_of_range(self):
211209
# GH #82
212210
rs = self.RandomState(*self.data1['seed'])
213-
assert_raises(ValueError, rs.seed, 2 ** (2 * self.bits+1))
211+
assert_raises(ValueError, rs.seed, 2 ** (2 * self.bits + 1))
214212
assert_raises(ValueError, rs.seed, -1)
215213

216214
def test_seed_out_of_range_array(self):
217215
# GH #82
218216
rs = self.RandomState(*self.data1['seed'])
219-
assert_raises(ValueError, rs.seed, [2 ** (2 * self.bits+1)])
217+
assert_raises(ValueError, rs.seed, [2 ** (2 * self.bits + 1)])
220218
assert_raises(ValueError, rs.seed, [-1])
221219

222-
class TestXorshift128(Base, TestCase):
220+
221+
class TestXorshift128(Base):
223222
@classmethod
224223
def setup_class(cls):
225224
cls.RandomState = xorshift128.RandomState
@@ -231,7 +230,7 @@ def setup_class(cls):
231230
cls.seed_error_type = TypeError
232231

233232

234-
class TestXoroshiro128plus(Base, TestCase):
233+
class TestXoroshiro128plus(Base):
235234
@classmethod
236235
def setup_class(cls):
237236
cls.RandomState = xoroshiro128plus.RandomState
@@ -241,7 +240,8 @@ def setup_class(cls):
241240
cls.data2 = cls._read_csv(join(pwd, './data/xoroshiro128plus-testset-2.csv'))
242241
cls.seed_error_type = TypeError
243242

244-
class TestXorshift1024(Base, TestCase):
243+
244+
class TestXorshift1024(Base):
245245
@classmethod
246246
def setup_class(cls):
247247
cls.RandomState = xorshift1024.RandomState
@@ -251,7 +251,8 @@ def setup_class(cls):
251251
cls.data2 = cls._read_csv(join(pwd, './data/xorshift1024-testset-2.csv'))
252252
cls.seed_error_type = TypeError
253253

254-
class TestMT19937(Base, TestCase):
254+
255+
class TestMT19937(Base):
255256
@classmethod
256257
def setup_class(cls):
257258
cls.RandomState = mt19937.RandomState
@@ -266,14 +267,14 @@ def test_seed_out_of_range(self):
266267
rs = self.RandomState(*self.data1['seed'])
267268
assert_raises(ValueError, rs.seed, 2 ** (self.bits + 1))
268269
assert_raises(ValueError, rs.seed, -1)
269-
assert_raises(ValueError, rs.seed, 2 ** (2 * self.bits+1))
270+
assert_raises(ValueError, rs.seed, 2 ** (2 * self.bits + 1))
270271

271272
def test_seed_out_of_range_array(self):
272273
# GH #82
273274
rs = self.RandomState(*self.data1['seed'])
274275
assert_raises(ValueError, rs.seed, [2 ** (self.bits + 1)])
275276
assert_raises(ValueError, rs.seed, [-1])
276-
assert_raises(TypeError, rs.seed, [2 ** (2 * self.bits+1)])
277+
assert_raises(TypeError, rs.seed, [2 ** (2 * self.bits + 1)])
277278

278279
def test_seed_float(self):
279280
# GH #82
@@ -292,7 +293,7 @@ def test_seed_float_array(self):
292293
assert_raises(TypeError, rs.seed, [0, np.pi])
293294

294295

295-
class TestPCG32(Base, TestCase):
296+
class TestPCG32(Base):
296297
@classmethod
297298
def setup_class(cls):
298299
cls.RandomState = pcg32.RandomState
@@ -307,10 +308,10 @@ def test_seed_out_of_range_array(self):
307308
rs = self.RandomState(*self.data1['seed'])
308309
assert_raises(TypeError, rs.seed, [2 ** (self.bits + 1)])
309310
assert_raises(TypeError, rs.seed, [-1])
310-
assert_raises(TypeError, rs.seed, [2 ** (2 * self.bits+1)])
311+
assert_raises(TypeError, rs.seed, [2 ** (2 * self.bits + 1)])
311312

312313

313-
class TestPCG64(Base, TestCase):
314+
class TestPCG64(Base):
314315
@classmethod
315316
def setup_class(cls):
316317
cls.RandomState = pcg64.RandomState
@@ -325,10 +326,10 @@ def test_seed_out_of_range_array(self):
325326
rs = self.RandomState(*self.data1['seed'])
326327
assert_raises(TypeError, rs.seed, [2 ** (self.bits + 1)])
327328
assert_raises(TypeError, rs.seed, [-1])
328-
assert_raises(TypeError, rs.seed, [2 ** (2 * self.bits+1)])
329+
assert_raises(TypeError, rs.seed, [2 ** (2 * self.bits + 1)])
329330

330331

331-
class TestMRG32K3A(Base, TestCase):
332+
class TestMRG32K3A(Base):
332333
@classmethod
333334
def setup_class(cls):
334335
cls.RandomState = mrg32k3a.RandomState
@@ -339,7 +340,7 @@ def setup_class(cls):
339340
cls.seed_error_type = TypeError
340341

341342

342-
class TestMLFG(Base, TestCase):
343+
class TestMLFG(Base):
343344
@classmethod
344345
def setup_class(cls):
345346
cls.RandomState = mlfg_1279_861.RandomState
@@ -361,7 +362,7 @@ def test_raw(self):
361362
assert_equal(uints, mod_data)
362363

363364

364-
class TestDSFMT(Base, TestCase):
365+
class TestDSFMT(Base):
365366
@classmethod
366367
def setup_class(cls):
367368
cls.RandomState = dsfmt.RandomState

randomstate/tests/test_smoke.py

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import pickle
22
import time
3-
4-
try:
5-
import cPickle
6-
except ImportError:
7-
cPickle = pickle
3+
from unittest import SkipTest
84
import sys
95
import os
10-
import unittest
6+
117
import numpy as np
128
import randomstate.entropy as entropy
139
from randomstate.prng.mlfg_1279_861 import mlfg_1279_861
@@ -21,8 +17,6 @@
2117
from randomstate.prng.dsfmt import dsfmt
2218
from numpy.testing import assert_almost_equal, assert_equal, assert_raises, assert_, assert_array_equal
2319

24-
from nose import SkipTest
25-
2620

2721
def params_0(f):
2822
val = f()
@@ -290,9 +284,9 @@ def test_chisquare(self):
290284
vals = self.rs.chisquare(2.0, 10)
291285
assert_(len(vals) == 10)
292286
params_1(self.rs.chisquare)
293-
287+
294288
def test_complex_normal(self):
295-
vals = self.rs.complex_normal(2.0+7.0j, 10.0, 5.0-5.0j, size=10)
289+
vals = self.rs.complex_normal(2.0 + 7.0j, 10.0, 5.0 - 5.0j, size=10)
296290
assert_(len(vals) == 10)
297291

298292
def test_exponential(self):
@@ -474,8 +468,8 @@ def test_pickle(self):
474468
assert_((type(self.rs) == type(unpick)))
475469
assert_(comp_state(self.rs.get_state(), unpick.get_state()))
476470

477-
pick = cPickle.dumps(self.rs)
478-
unpick = cPickle.loads(pick)
471+
pick = pickle.dumps(self.rs)
472+
unpick = pickle.loads(pick)
479473
assert_((type(self.rs) == type(unpick)))
480474
assert_(comp_state(self.rs.get_state(), unpick.get_state()))
481475

@@ -722,7 +716,7 @@ def test_numpy_state(self):
722716
assert_((state[4] == state2['gauss']['gauss']))
723717

724718

725-
class TestPCG32(RNG, unittest.TestCase):
719+
class TestPCG32(RNG):
726720
@classmethod
727721
def setup_class(cls):
728722
cls.mod = pcg32
@@ -753,7 +747,7 @@ def test_seed_array_error(self):
753747
assert_raises(TypeError, self.rs.seed, seed)
754748

755749

756-
class TestPCG64(RNG, unittest.TestCase):
750+
class TestPCG64(RNG):
757751
@classmethod
758752
def setup_class(cls):
759753
cls.mod = pcg64
@@ -785,7 +779,7 @@ def test_seed_array_error(self):
785779
assert_raises(TypeError, self.rs.seed, seed)
786780

787781

788-
class TestXorShift128(RNG, unittest.TestCase):
782+
class TestXorShift128(RNG):
789783
@classmethod
790784
def setup_class(cls):
791785
cls.mod = xorshift128
@@ -797,7 +791,7 @@ def setup_class(cls):
797791
cls._extra_setup()
798792

799793

800-
class TestXoroShiro128Plus(RNG, unittest.TestCase):
794+
class TestXoroShiro128Plus(RNG):
801795
@classmethod
802796
def setup_class(cls):
803797
cls.mod = xoroshiro128plus
@@ -809,7 +803,7 @@ def setup_class(cls):
809803
cls._extra_setup()
810804

811805

812-
class TestXorShift1024(RNG, unittest.TestCase):
806+
class TestXorShift1024(RNG):
813807
@classmethod
814808
def setup_class(cls):
815809
cls.mod = xorshift1024
@@ -821,7 +815,7 @@ def setup_class(cls):
821815
cls._extra_setup()
822816

823817

824-
class TestMLFG(RNG, unittest.TestCase):
818+
class TestMLFG(RNG):
825819
@classmethod
826820
def setup_class(cls):
827821
cls.mod = mlfg_1279_861
@@ -833,7 +827,7 @@ def setup_class(cls):
833827
cls._extra_setup()
834828

835829

836-
class TestMRG32k3A(RNG, unittest.TestCase):
830+
class TestMRG32k3A(RNG):
837831
@classmethod
838832
def setup_class(cls):
839833
cls.mod = mrg32k3a
@@ -845,7 +839,7 @@ def setup_class(cls):
845839
cls.seed_vector_bits = 64
846840

847841

848-
class TestDSFMT(RNG, unittest.TestCase):
842+
class TestDSFMT(RNG):
849843
@classmethod
850844
def setup_class(cls):
851845
cls.mod = dsfmt
@@ -857,7 +851,7 @@ def setup_class(cls):
857851
cls.seed_vector_bits = 32
858852

859853

860-
class TestEntropy(unittest.TestCase):
854+
class TestEntropy(object):
861855
def test_entropy(self):
862856
e1 = entropy.random_entropy()
863857
e2 = entropy.random_entropy()

0 commit comments

Comments
 (0)