Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

r3493@803638d: kern | 2005-09-27 19:52:10 -0700

 get_scipy_include() docs and fix; f2py updated to use get_scipy_include(); mtrand integration
  • Loading branch information...
commit 2199334cfa7e3934bf81076510a84a73054ca868 1 parent 861df81
@rkern rkern authored
View
6 MANIFEST.in
@@ -1,4 +1,4 @@
-recursive-include *.txt
+recursive-include . *.txt
include MANIFEST.in
include scipy/f2py2e/f2py.1
recursive-include scipy/f2py2e *.cfg
@@ -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
View
12 scipy/base/numeric.py
@@ -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')
View
966 scipy/corelib/mtrand/mtrand.c
520 additions, 446 deletions not shown
View
7 scipy/corelib/mtrand/mtrand.pyx
@@ -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:
View
16 scipy/corelib/mtrand/protos.h
@@ -24,14 +24,14 @@ 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 );
@@ -39,7 +39,7 @@ 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 );
View
1  scipy/f2py2e/f2py2e.py
@@ -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:
View
19 scipy/stats/__init__.py
@@ -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, ...])
@@ -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])
@@ -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

0 comments on commit 2199334

Please sign in to comment.
Something went wrong with that request. Please try again.