summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/getlimits.py11
-rw-r--r--numpy/core/tests/test_getlimits.py9
-rw-r--r--numpy/distutils/command/build_clib.py30
-rw-r--r--numpy/distutils/command/build_ext.py3
-rw-r--r--numpy/distutils/extension.py6
-rw-r--r--numpy/distutils/fcompiler/__init__.py15
-rw-r--r--numpy/distutils/misc_util.py6
7 files changed, 66 insertions, 14 deletions
diff --git a/numpy/core/getlimits.py b/numpy/core/getlimits.py
index 0cb1fd7f4..4754975e2 100644
--- a/numpy/core/getlimits.py
+++ b/numpy/core/getlimits.py
@@ -180,6 +180,14 @@ nexp =%(nexp)6s min= -max
---------------------------------------------------------------------
''' % self.__dict__
+ def __repr__(self):
+ c = self.__class__.__name__
+ d = self.__dict__.copy()
+ d['klass'] = c
+ return ("%(klass)s(resolution=%(resolution)s, min=-%(_str_max)s," \
+ + " max=%(_str_max)s, dtype=%(dtype)s)") \
+ % d
+
class iinfo(object):
"""
@@ -280,6 +288,9 @@ max = %(max)s
---------------------------------------------------------------------
''' % {'dtype': self.dtype, 'min': self.min, 'max': self.max}
+ def __repr__(self):
+ return "%s(min=%s, max=%s, dtype=%s)" % (self.__class__.__name__,
+ self.min, self.max, self.dtype)
if __name__ == '__main__':
f = finfo(ntypes.single)
diff --git a/numpy/core/tests/test_getlimits.py b/numpy/core/tests/test_getlimits.py
index 569dc0cc6..3570fd718 100644
--- a/numpy/core/tests/test_getlimits.py
+++ b/numpy/core/tests/test_getlimits.py
@@ -55,6 +55,15 @@ class TestIinfo(TestCase):
for T in types:
assert_equal(iinfo(T).max, T(-1))
+class TestRepr(TestCase):
+ def test_iinfo_repr(self):
+ expected = "iinfo(min=-32768, max=32767, dtype=int16)"
+ assert_equal(repr(np.iinfo(np.int16)), expected)
+
+ def test_finfo_repr(self):
+ expected = "finfo(resolution=1e-06, min=-3.4028235e+38," + \
+ " max=3.4028235e+38, dtype=float32)"
+ assert_equal(repr(np.finfo(np.float32)), expected)
def test_instances():
iinfo(10)
diff --git a/numpy/distutils/command/build_clib.py b/numpy/distutils/command/build_clib.py
index 71ca1e096..d9cfca73e 100644
--- a/numpy/distutils/command/build_clib.py
+++ b/numpy/distutils/command/build_clib.py
@@ -81,21 +81,23 @@ class build_clib(old_build_clib):
if self.have_f_sources():
from numpy.distutils.fcompiler import new_fcompiler
- self.fcompiler = new_fcompiler(compiler=self.fcompiler,
- verbose=self.verbose,
- dry_run=self.dry_run,
- force=self.force,
- requiref90='f90' in languages,
- c_compiler=self.compiler)
- if self.fcompiler is not None:
- self.fcompiler.customize(self.distribution)
+ self._f_compiler = new_fcompiler(compiler=self.fcompiler,
+ verbose=self.verbose,
+ dry_run=self.dry_run,
+ force=self.force,
+ requiref90='f90' in languages,
+ c_compiler=self.compiler)
+ if self._f_compiler is not None:
+ self._f_compiler.customize(self.distribution)
libraries = self.libraries
self.libraries = None
- self.fcompiler.customize_cmd(self)
+ self._f_compiler.customize_cmd(self)
self.libraries = libraries
- self.fcompiler.show_customization()
+ self._f_compiler.show_customization()
+ else:
+ self._f_compiler = None
self.build_libraries(self.libraries)
@@ -121,7 +123,7 @@ class build_clib(old_build_clib):
def build_a_library(self, build_info, lib_name, libraries):
# default compilers
compiler = self.compiler
- fcompiler = self.fcompiler
+ fcompiler = self._f_compiler
sources = build_info.get('sources')
if sources is None or not is_sequence(sources):
@@ -175,6 +177,10 @@ class build_clib(old_build_clib):
raise DistutilsError("library %s has Fortran sources"\
" but no Fortran compiler found" % (lib_name))
+ if fcompiler is not None:
+ fcompiler.extra_f77_compile_args = build_info.get('extra_f77_compile_args') or []
+ fcompiler.extra_f90_compile_args = build_info.get('extra_f90_compile_args') or []
+
macros = build_info.get('macros')
include_dirs = build_info.get('include_dirs')
if include_dirs is None:
@@ -233,7 +239,7 @@ class build_clib(old_build_clib):
debug=self.debug,
extra_postargs=extra_postargs)
- if requiref90 and self.fcompiler.module_dir_switch is None:
+ if requiref90 and self._f_compiler.module_dir_switch is None:
# move new compiled F90 module files to module_build_dir
for f in glob('*.mod'):
if f in existing_modules:
diff --git a/numpy/distutils/command/build_ext.py b/numpy/distutils/command/build_ext.py
index 840d43716..f63d5249c 100644
--- a/numpy/distutils/command/build_ext.py
+++ b/numpy/distutils/command/build_ext.py
@@ -299,6 +299,9 @@ class build_ext (old_build_ext):
fcompiler = self._f77_compiler
else: # in case ext.language is c++, for instance
fcompiler = self._f90_compiler or self._f77_compiler
+ if fcompiler is not None:
+ fcompiler.extra_f77_compile_args = ext.extra_f77_compile_args or []
+ fcompiler.extra_f90_compile_args = ext.extra_f90_compile_args or []
cxx_compiler = self._cxx_compiler
# check for the availability of required compilers
diff --git a/numpy/distutils/extension.py b/numpy/distutils/extension.py
index 9f28263d8..2fc29f6d5 100644
--- a/numpy/distutils/extension.py
+++ b/numpy/distutils/extension.py
@@ -31,6 +31,8 @@ class Extension(old_Extension):
language=None,
f2py_options=None,
module_dirs=None,
+ extra_f77_compile_args=None,
+ extra_f90_compile_args=None,
):
old_Extension.__init__(self,name, [],
include_dirs,
@@ -63,7 +65,9 @@ class Extension(old_Extension):
# numpy_distutils features
self.f2py_options = f2py_options or []
self.module_dirs = module_dirs or []
-
+ self.extra_f77_compile_args = extra_f77_compile_args or []
+ self.extra_f90_compile_args = extra_f90_compile_args or []
+
return
def has_cxx_sources(self):
diff --git a/numpy/distutils/fcompiler/__init__.py b/numpy/distutils/fcompiler/__init__.py
index 69d9d68d3..38fca575a 100644
--- a/numpy/distutils/fcompiler/__init__.py
+++ b/numpy/distutils/fcompiler/__init__.py
@@ -213,6 +213,10 @@ class FCompiler(CCompiler):
# command/{build_ext.py, build_clib.py, config.py} files.
c_compiler = None
+ # extra_{f77,f90}_compile_args are set by build_ext.build_extension method
+ extra_f77_compiler_args = []
+ extra_f90_compiler_args = []
+
def __init__(self, *args, **kw):
CCompiler.__init__(self, *args, **kw)
self.distutils_vars = self.distutils_vars.clone(self._environment_hook)
@@ -560,18 +564,21 @@ class FCompiler(CCompiler):
flavor = ':f77'
compiler = self.compiler_f77
src_flags = get_f77flags(src)
+ extra_compile_args = self.extra_f77_compile_args or []
elif is_free_format(src):
flavor = ':f90'
compiler = self.compiler_f90
if compiler is None:
raise DistutilsExecError('f90 not supported by %s needed for %s'\
% (self.__class__.__name__,src))
+ extra_compile_args = self.extra_f90_compile_args or []
else:
flavor = ':fix'
compiler = self.compiler_fix
if compiler is None:
raise DistutilsExecError('f90 (fixed) not supported by %s needed for %s'\
% (self.__class__.__name__,src))
+ extra_compile_args = self.extra_f90_compile_args or []
if self.object_switch[-1]==' ':
o_args = [self.object_switch.strip(),obj]
else:
@@ -580,13 +587,17 @@ class FCompiler(CCompiler):
assert self.compile_switch.strip()
s_args = [self.compile_switch, src]
+ if extra_compile_args:
+ log.info('extra %s options: %r' \
+ % (flavor[1:], ' '.join(extra_compile_args)))
+
extra_flags = src_flags.get(self.compiler_type,[])
if extra_flags:
log.info('using compile options from source: %r' \
% ' '.join(extra_flags))
command = compiler + cc_args + extra_flags + s_args + o_args \
- + extra_postargs
+ + extra_postargs + extra_compile_args
display = '%s: %s' % (os.path.basename(compiler[0]) + flavor,
src)
@@ -961,5 +972,7 @@ def get_f77flags(src):
f.close()
return flags
+# TODO: implement get_f90flags and use it in _compile similarly to get_f77flags
+
if __name__ == '__main__':
show_fcompilers()
diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py
index 53ef87373..2e4ed27f3 100644
--- a/numpy/distutils/misc_util.py
+++ b/numpy/distutils/misc_util.py
@@ -1403,6 +1403,8 @@ class Configuration(object):
extra_objects:
extra_compile_args:
extra_link_args:
+ extra_f77_compile_args:
+ extra_f90_compile_args:
export_symbols:
swig_opts:
depends:
@@ -1497,6 +1499,8 @@ class Configuration(object):
* macros
* include_dirs
* extra_compiler_args
+ * extra_f77_compiler_args
+ * extra_f90_compiler_args
* f2py_options
* language
@@ -1548,6 +1552,8 @@ class Configuration(object):
* macros
* include_dirs
* extra_compiler_args
+ * extra_f77_compiler_args
+ * extra_f90_compiler_args
* f2py_options
* language