Skip to content

Commit

Permalink
r3493@803638d6: kern | 2005-09-27 19:52:10 -0700
Browse files Browse the repository at this point in the history
 get_scipy_include() docs and fix; f2py updated to use get_scipy_include(); mtrand integration
  • Loading branch information
rkern committed Sep 28, 2005
1 parent 861df81 commit 2199334
Show file tree
Hide file tree
Showing 7 changed files with 566 additions and 461 deletions.
6 changes: 4 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
recursive-include *.txt
recursive-include . *.txt
include MANIFEST.in
include scipy/f2py2e/f2py.1
recursive-include scipy/f2py2e *.cfg
Expand All @@ -8,4 +8,6 @@ recursive-include scipy/f2py2e/tests *.py
recursive-include scipy/f2py2e/tests/mixed *.f *.f90
#recursive-include scipy/f2py2e/doc *.py *.txt *.tex *.html Makefile
recursive-include scipy/f2py2e/docs *.txt *.html *.dat *.f *.f90 *.pyf setup_example.py f2py_style.css

recursive-include scipy/corelib/mtrand *.c *.h *.pyx *.pxi
prune scipy/base/include/scipy
recursive-include scipy/base/include/scipy *object.h
12 changes: 11 additions & 1 deletion scipy/base/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,17 @@ def getbufsize(size):
from oldnumeric import *

def get_scipy_include():
"""Return the directory in the package that contains the scipy/*.h header
files.
Extension modules that need to compile against scipy.base should use this
function to locate the appropriate include directory. Using distutils:
import scipy
Extension('extension_name', ...
include_dirs=[scipy.get_scipy_include()])
"""
import os
dir, fn = os.path.split(__file__)
return os.path.join(dir, 'include', 'scipy')
return os.path.join(dir, 'include')

966 changes: 520 additions & 446 deletions scipy/corelib/mtrand/mtrand.c

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion scipy/corelib/mtrand/mtrand.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -617,12 +617,17 @@ cdef class RandomState:
return multin

def permutation(self, object x):
"""Modify the sequence in-place by shuffling its contents.
"""If given a sequence, modify it in-place by shuffling its contents;
if given an integer, return a shuffled sequence of integers >= 0 and
< x.
permutation(x)
"""
cdef long i, j

if type(x) is int:
return self.permutation(scipy.arange(x))

# adaptation of random.shuffle()
i = len(x) - 1
while i > 0:
Expand Down
16 changes: 8 additions & 8 deletions scipy/corelib/mtrand/protos.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ extern double chdtrc ( double df, double x );
extern double chdtr ( double df, double x );
extern double chdtri ( double df, double y );
extern void clog ( cmplx *z, cmplx *w );
extern void cexp ( cmplx *z, cmplx *w );
extern void csin ( cmplx *z, cmplx *w );
extern void ccos ( cmplx *z, cmplx *w );
extern void ctan ( cmplx *z, cmplx *w );
/* extern void cexp ( cmplx *z, cmplx *w ); */
/* extern void csin ( cmplx *z, cmplx *w ); */
/* extern void ccos ( cmplx *z, cmplx *w ); */
/* extern void ctan ( cmplx *z, cmplx *w ); */
extern void ccot ( cmplx *z, cmplx *w );
extern void casin ( cmplx *z, cmplx *w );
extern void cacos ( cmplx *z, cmplx *w );
extern void catan ( cmplx *z, cmplx *w );
/* extern void casin ( cmplx *z, cmplx *w ); */
/* extern void cacos ( cmplx *z, cmplx *w ); */
/* extern void catan ( cmplx *z, cmplx *w ); */
extern void cadd ( cmplx *a, cmplx *b, cmplx *c );
extern void csub ( cmplx *a, cmplx *b, cmplx *c );
extern void cmul ( cmplx *a, cmplx *b, cmplx *c );
extern void cdiv ( cmplx *a, cmplx *b, cmplx *c );
extern void cmov ( void *a, void *b );
extern void cneg ( cmplx *a );
/*extern double cabs ( cmplx *z );*/
extern void csqrt ( cmplx *z, cmplx *w );
/* extern void csqrt ( cmplx *z, cmplx *w ); */
extern double hypot ( double x, double y );
extern double cosh ( double x );
extern double dawsn ( double xx );
Expand Down
1 change: 1 addition & 0 deletions scipy/f2py2e/f2py2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ def run_compile():
import scipy
n = 'scipy'
p = get_prefix(scipy)
include_dirs.append(scipy.get_scipy_include())
num_info = get_info('scipy')
else:
try:
Expand Down
19 changes: 16 additions & 3 deletions scipy/stats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,20 @@

# some aliases
ranf = random_sample
randn = standard_normal
random = random_sample

def rand(*args):
"""rand(d1,...,dn) returns a matrix of the given dimensions
which is initialized to random numbers from a uniform distribution
in the range [0,1).
"""
return random_sample(size=args)

def randn(*args):
"""u = randn(d0,d1,...,dn) returns zero-mean, unit-variance Gaussian
random numbers in an array of size (d0,d1,...,dn).
"""
return standard_normal(args)

def multivariate_normal(mean, cov, shape=[]):
"""multivariate_normal(mean, cov) or multivariate_normal(mean, cov, [m, n, ...])
Expand All @@ -42,7 +55,7 @@ def multivariate_normal(mean, cov, shape=[]):
if mean.shape[0] != cov.shape[0]:
raise ArgumentError, "mean and cov must have same length."
# Compute shape of output
if isinstance(shape, IntType):
if isinstance(shape, int):
shape = [shape]
final_shape = list(shape[:])
final_shape.append(mean.shape[0])
Expand All @@ -63,7 +76,7 @@ def multivariate_normal(mean, cov, shape=[]):
# The rows of x now have the correct covariance but mean 0. Add
# mean to each row. Then each row will have mean mean.
Numeric.add(mean,x,x)
x.shape = final_shape
x.shape = tuple(final_shape)
return x

# XXX: should we also bring over mean_var_test() from random_lite.py? It seems
Expand Down

0 comments on commit 2199334

Please sign in to comment.