Skip to content

Commit e3fa086

Browse files
committed
SETUP: Prepare coe for PyPI
Initial preparations for release on PyPI
1 parent cccdc88 commit e3fa086

File tree

4 files changed

+250
-6
lines changed

4 files changed

+250
-6
lines changed

MANIFEST.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
recursive-include randomstate *.c *.h *.pxi *.pxd *.pyx
2+
recursive-include randomstate/tests *.csv
3+
include *.md
4+
exclude randomstate/entropy.c
5+
exclude randomstate/dsfmt*
6+
exclude randomstate/mt19937*
7+
exclude randomstate/mlfg_1279_861*
8+
exclude randomstate/pcg32*
9+
exclude randomstate/pcg64*
10+
exclude randomstate/xorshift128*
11+
exclude randomstate/xorshift1024*
12+

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# randomstate
2-
[![Build Status](https://travis-ci.org/bashtage/ng-numpy-randomstate.svg?branch=master)](https://travis-ci.org/bashtage/ng-numpy-randomstate)
3-
[![Build status](https://ci.appveyor.com/api/projects/status/odc5c4ukhru5xicl/branch/master?svg=true)](https://ci.appveyor.com/project/bashtage/ng-numpy-randomstate/branch/master)
2+
3+
[![Travis Build Status](https://travis-ci.org/bashtage/ng-numpy-randomstate.svg?branch=master)](https://travis-ci.org/bashtage/ng-numpy-randomstate)
4+
[![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/odc5c4ukhru5xicl/branch/master?svg=true)](https://ci.appveyor.com/project/bashtage/ng-numpy-randomstate/branch/master)
45

56
This is a library and generic interface for alternative random generators
67
in Python and Numpy.
@@ -74,6 +75,10 @@ identical sequence of random numbers for a given seed.
7475
* OSX 64-bit, Python 2.7
7576
* Windows 32/64 bit (only tested on Python 2.7 and 3.5, but should work on 3.3/3.4)
7677

78+
## Version
79+
The version matched the latest verion of NumPy where
80+
`randomstate.prng.mt19937` passes all NumPy test.
81+
7782
## Documentation
7883

7984
A occasionally updated build of the documentation is available on

README.rst

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
randomstate
2+
===========
3+
4+
|Travis Build Status| |Appveyor Build Status|
5+
6+
This is a library and generic interface for alternative random
7+
generators in Python and Numpy.
8+
9+
Features
10+
11+
- Immediate drop in replacement for Numy's RandomState
12+
13+
.. code:: python
14+
15+
# import numpy.random as rnd
16+
import randomstate as rnd
17+
x = rnd.standard_normal(100)
18+
y = rnd.random_sample(100)
19+
z = rnd.randn(10,10)
20+
21+
- Default random generator is identical to NumPy's RandomState (i.e.,
22+
same seed, same random numbers).
23+
- Support for random number generators that support independent streams
24+
and jumping ahead so that substreams can be generated
25+
- Faster ranomd number generations, especially for Normals using the
26+
Ziggurat method
27+
28+
.. code:: python
29+
30+
import randomstate as rnd
31+
w = rnd.standard_normal(10000, method='zig')
32+
33+
Included Pseudo Random Number Generators
34+
----------------------------------------
35+
36+
This modules includes a number of alternative random number generators
37+
in addition to the MT19937 that is included in NumPy. The RNGs include:
38+
39+
- `MT19937 <https://github.com/numpy/numpy/blob/master/numpy/random/mtrand/>`__,
40+
the NumPy rng
41+
- `dSFMT <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/>`__ a
42+
SSE2-aware version of the MT19937 generator that is especially fast
43+
at generating doubles
44+
- `xorshift128+ <http://xorshift.di.unimi.it/>`__ and
45+
`xorshift1024\* <http://xorshift.di.unimi.it/>`__
46+
- `PCG32 <http://www.pcg-random.org/>`__ and
47+
`PCG64 <http:w//www.pcg-random.org/>`__
48+
- `MRG32K3A <http://simul.iro.umontreal.ca/rng>`__
49+
- A multiplicative lagged fibonacci generator (LFG(31, 1279, 861, \*))
50+
51+
Differences from ``numpy.random.RandomState``
52+
---------------------------------------------
53+
54+
New Features
55+
~~~~~~~~~~~~
56+
57+
- ``stanard_normal``, ``normal``, ``randn`` and ``multivariate_normal``
58+
all support an additional ``method`` keyword argument which can be
59+
``inv`` or ``zig`` where ``inv`` corresponds to the current method
60+
and ``zig`` uses tha much faster (100%+) ziggurat method.
61+
62+
New Functions
63+
~~~~~~~~~~~~~
64+
65+
- ``random_entropy`` - Read from the system entropy provider, which is
66+
commonly used in cryptographic applications
67+
- ``random_uintegers`` - unsigned integers ``[0, 2**64-1]``
68+
- ``jump`` - Jumps RNGs that support it. ``jump`` moves the state a
69+
great distance. *Only available if supported by the RNG.*
70+
- ``advance`` - Advanced the core RNG 'as-if' a number of draws were
71+
made, without actually drawing the numbers. *Only available if
72+
supported by the RNG.*
73+
74+
Status
75+
------
76+
77+
- Complete drop-in replacement for ``numpy.random.RandomState``. The
78+
``mt19937`` generator is identical to ``numpy.random.RandomState``,
79+
and will produce an identical sequence of random numbers for a given
80+
seed.
81+
- Builds and passes all tests on:
82+
- Linux 32/64 bit, Python 2.6, 2.7, 3.3, 3.4, 3.5
83+
- PC-BSD (FreeBSD) 64-bit, Python 2.7
84+
- OSX 64-bit, Python 2.7
85+
- Windows 32/64 bit (only tested on Python 2.7 and 3.5, but should work
86+
on 3.3/3.4)
87+
88+
Version
89+
-------
90+
91+
The version matched the latest verion of NumPy where
92+
``randomstate.prng.mt19937`` passes all NumPy test.
93+
94+
Documentation
95+
-------------
96+
97+
A occasionally updated build of the documentation is available on `my
98+
github pages <http://bashtage.github.io/ng-numpy-randomstate/>`__.
99+
100+
Plans
101+
-----
102+
103+
This module is essentially complete. There are a few rough edges that
104+
need to be smoothed.
105+
106+
- Stream support for MLFG and MRG32K3A
107+
- Creation of additional streams from a RandomState where supported
108+
(i.e. a ``next_stream()`` method)
109+
110+
Requirements
111+
------------
112+
113+
Building requires:
114+
115+
- Numpy (1.9, 1.10)
116+
- Cython (0.22, 0.23)
117+
- Python (2.6, 2.7, 3.3, 3.4, 3.5)
118+
119+
**Note:** it might work with other versions but only tested with these
120+
versions.
121+
122+
All development has been on 64-bit Linux, and it is regularly tested on
123+
Travis-CI. The library is occasionally tested on Linux 32-bit, OSX
124+
10.10, PC-BSD 10.2 (should also work on Free BSD) and Windows (Python
125+
2.7/3.5, both 32 and 64-bit).
126+
127+
Basic tests are in place for all RNGs. The MT19937 is tested against
128+
NumPy's implementation for identical results. It also passes NumPy's
129+
test suite.
130+
131+
Installing
132+
----------
133+
134+
.. code:: bash
135+
136+
python setup.py install
137+
138+
Windows
139+
~~~~~~~
140+
141+
Either use a binary installer or if building from scratch using Python
142+
3.5 and the free Visual Studio 2015 Community Edition. It can also be
143+
build using Microsoft Visual C++ Compiler for Python 2.7 and Python 2.7,
144+
although some modifications are needed to distutils to find the
145+
compiler.
146+
147+
Using
148+
-----
149+
150+
The separate generators are importable from ``randomstate.prng``.
151+
152+
.. code:: python
153+
154+
import randomstate
155+
rs = randomstate.prng.xorshift128.RandomState()
156+
rs.random_sample(100)
157+
158+
rs = randomstate.prng.pcg64.RandomState()
159+
rs.random_sample(100)
160+
161+
# Identical to NumPy
162+
rs = randomstate.prng.mt19937.RandomState()
163+
rs.random_sample(100)
164+
165+
Like NumPy, ``randomstate`` also exposes a single instance of the
166+
``mt19937`` generator directly at the module level so that commands like
167+
168+
.. code:: python
169+
170+
import randomstate
171+
randomstate.standard_normal()
172+
randomstate.exponential(1.0, 1.0, size=10)
173+
174+
will work.
175+
176+
License
177+
-------
178+
179+
Standard NCSA, plus sub licenses for components.
180+
181+
Performance
182+
-----------
183+
184+
Performance is promising, and even the mt19937 seems to be faster than
185+
NumPy's mt19937.
186+
187+
::
188+
189+
Speed-up relative to NumPy (Slow Normals)
190+
************************************************************
191+
randomstate.prng-dsfmt-standard_normal 107.2%
192+
randomstate.prng-mlfg_1279_861-standard_normal 51.2%
193+
randomstate.prng-mrg32k3a-standard_normal -11.8%
194+
randomstate.prng-mt19937-standard_normal 44.0%
195+
randomstate.prng-pcg32-standard_normal 51.2%
196+
randomstate.prng-pcg64-standard_normal 51.1%
197+
randomstate.prng-xorshift1024-standard_normal 50.5%
198+
randomstate.prng-xorshift128-standard_normal 52.1%
199+
200+
Speed-up relative to NumPy (Ziggural Normals)
201+
************************************************************
202+
randomstate.prng-dsfmt-standard_normal 283.7%
203+
randomstate.prng-mlfg_1279_861-standard_normal 217.4%
204+
randomstate.prng-mrg32k3a-standard_normal 16.6%
205+
randomstate.prng-mt19937-standard_normal 201.3%
206+
randomstate.prng-pcg32-standard_normal 274.9%
207+
randomstate.prng-pcg64-standard_normal 310.8%
208+
randomstate.prng-xorshift1024-standard_normal 336.3%
209+
randomstate.prng-xorshift128-standard_normal 425.1%
210+
211+
.. |Travis Build Status| image:: https://travis-ci.org/bashtage/ng-numpy-randomstate.svg?branch=master
212+
:target: https://travis-ci.org/bashtage/ng-numpy-randomstate
213+
.. |Appveyor Build Status| image:: https://ci.appveyor.com/api/projects/status/odc5c4ukhru5xicl/branch/master?svg=true
214+
:target: https://ci.appveyor.com/project/bashtage/ng-numpy-randomstate/branch/master

setup.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
import shutil
33
import sys
44
from os.path import join
5+
import subprocess
56

67
import numpy
78
from Cython.Build import cythonize
89
from setuptools import setup, find_packages
910
from setuptools.extension import Extension
11+
from setuptools.dist import Distribution
1012

1113
FORCE_EMULATION = False
1214

@@ -138,6 +140,14 @@ def write_config(file_name, config):
138140

139141
configs.append(config)
140142

143+
class BinaryDistribution(Distribution):
144+
def is_pure(self):
145+
return False
146+
147+
try:
148+
subprocess.call(['pandoc','--from=markdown','--to=rst','--output=README.rst','README.md'])
149+
except:
150+
pass
141151
# Generate files and extensions
142152
extensions = [Extension('randomstate.entropy',
143153
sources=[join(mod_dir, 'entropy.pyx'),
@@ -172,16 +182,19 @@ def write_config(file_name, config):
172182
ext_modules = cythonize(extensions)
173183

174184
setup(name='randomstate',
175-
version='0.1',
185+
version='1.10',
176186
packages=find_packages(),
177187
package_dir={'randomstate': './randomstate'},
178-
package_data={'randomstate.tests.data': ['*.csv', '*.dat']},
179-
include_package_data=False,
188+
package_data={'': ['*.c','*.h','*.pxi','*.pyx','*.pxd'],
189+
'randomstate.tests.data': ['*.csv']},
190+
include_package_data=True,
180191
license='NSCA',
181192
author='Kevin Sheppard',
193+
author_email='[email protected]',
194+
distclass=BinaryDistribution,
182195
description='Next-gen RandomState supporting multiple PRNGs',
183196
url='https://github.com/bashtage/ng-numpy-randomstate',
184-
long_description=open('README.md').read(),
197+
long_description=open('README.rst').read(),
185198
ext_modules=ext_modules,
186199
zip_safe=False)
187200

0 commit comments

Comments
 (0)