summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/distutils/system_info.py30
-rw-r--r--numpy/lib/shape_base.py10
-rw-r--r--numpy/random/mtrand/mtrand.pyx3
3 files changed, 41 insertions, 2 deletions
diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py
index a0c6f44f7..7ea8b8c62 100644
--- a/numpy/distutils/system_info.py
+++ b/numpy/distutils/system_info.py
@@ -1678,9 +1678,37 @@ class blas_info(system_info):
info = self.check_libs(lib_dirs, blas_libs, [])
if info is None:
return
- info['language'] = 'f77' # XXX: is it generally true?
+ if platform.system() != 'Windows' and self.has_cblas():
+ # The check for windows is needed because has_cblas uses the
+ # same compiler that was used to compile Python and msvc is
+ # often not installed when mingw is being used. This rough
+ # treatment is not desirable, but windows is tricky.
+ info['language'] = 'c'
+ info['define_macros'] = [('HAVE_CBLAS', None)]
+ else:
+ info['language'] = 'f77' # XXX: is it generally true?
self.set_info(**info)
+ def has_cblas(self):
+ # primitive cblas check by looking for the header
+ res = False
+ c = distutils.ccompiler.new_compiler()
+ tmpdir = tempfile.mkdtemp()
+ s = """#include <cblas.h>"""
+ src = os.path.join(tmpdir, 'source.c')
+ try:
+ with open(src, 'wt') as f:
+ f.write(s)
+ try:
+ c.compile([src], output_dir=tmpdir,
+ include_dirs=self.get_include_dirs())
+ res = True
+ except distutils.ccompiler.CompileError:
+ res = False
+ finally:
+ shutil.rmtree(tmpdir)
+ return res
+
class openblas_info(blas_info):
section = 'openblas'
diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py
index 615cf88f4..ffbe56721 100644
--- a/numpy/lib/shape_base.py
+++ b/numpy/lib/shape_base.py
@@ -799,6 +799,9 @@ def tile(A, reps):
Thus for an `A` of shape (2, 3, 4, 5), a `reps` of (2, 2) is treated as
(1, 1, 2, 2).
+ Note : Although tile may be used for broadcasting, it is strongly
+ recommended to use numpy's broadcasting operations and functions.
+
Parameters
----------
A : array_like
@@ -814,6 +817,7 @@ def tile(A, reps):
See Also
--------
repeat : Repeat elements of an array.
+ broadcast_to : Broadcast an array to a new shape
Examples
--------
@@ -837,6 +841,12 @@ def tile(A, reps):
[1, 2],
[3, 4]])
+ >>> c = np.array([1,2,3,4])
+ >>> np.tile(c,(4,1))
+ array([[1, 2, 3, 4],
+ [1, 2, 3, 4],
+ [1, 2, 3, 4],
+ [1, 2, 3, 4]])
"""
try:
tup = tuple(reps)
diff --git a/numpy/random/mtrand/mtrand.pyx b/numpy/random/mtrand/mtrand.pyx
index f8ae8d71b..080591e5e 100644
--- a/numpy/random/mtrand/mtrand.pyx
+++ b/numpy/random/mtrand/mtrand.pyx
@@ -127,6 +127,7 @@ cdef extern from "initarray.h":
# Initialize numpy
import_array()
+cimport cython
import numpy as np
import operator
import warnings
@@ -4484,7 +4485,7 @@ cdef class RandomState:
mnarr = <ndarray>multin
mnix = <long*>PyArray_DATA(mnarr)
sz = PyArray_SIZE(mnarr)
- with self.lock, nogil:
+ with self.lock, nogil, cython.cdivision(True):
i = 0
while i < sz:
Sum = 1.0