summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2015-12-17 15:27:07 -0700
committerCharles Harris <charlesr.harris@gmail.com>2015-12-17 15:27:07 -0700
commitdcc9b48e549efce6bdb966ea4204306e87abb73c (patch)
treea281d2debee9c5a01d9763cf871d70a62637af09
parenteaad7e8f3d9ebd0c85106e12b88f36f286941e1a (diff)
parentd8967ceefe7afca7a260df3f744699d1512f6fd6 (diff)
downloadnumpy-dcc9b48e549efce6bdb966ea4204306e87abb73c.tar.gz
Merge pull request #6852 from charris/fixup-gh-6696
Fixup #6696, updates to f2py.compile
-rw-r--r--doc/release/1.11.0-notes.rst31
-rw-r--r--numpy/f2py/__init__.py36
2 files changed, 47 insertions, 20 deletions
diff --git a/doc/release/1.11.0-notes.rst b/doc/release/1.11.0-notes.rst
index 7790ac58f..b3ddae604 100644
--- a/doc/release/1.11.0-notes.rst
+++ b/doc/release/1.11.0-notes.rst
@@ -39,6 +39,7 @@ DeprecationWarning to error
* Non-integers used as index values raise TypeError,
e.g., in reshape, take, and specifying reduce axis.
+
FutureWarning to changed behavior
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -62,21 +63,29 @@ mention it here for completeness.
New Features
============
-* `np.histogram` now provides plugin estimators for automatically estimating the optimal
-number of bins. Passing one of ['auto', 'fd', 'scott', 'rice', 'sturges']
-as the argument to 'bins' results in the corresponding estimator being used.
+* `np.histogram` now provides plugin estimators for automatically
+ estimating the optimal number of bins. Passing one of ['auto', 'fd',
+ 'scott', 'rice', 'sturges'] as the argument to 'bins' results in the
+ corresponding estimator being used.
-* A benchmark suite using `Airspeed Velocity <http://spacetelescope.github.io/asv/>`__
-has been added, converting the previous vbench-based one. You can run the suite locally
-via ``python runtests.py --bench``. For more details, see ``benchmarks/README.rst``.
+* A benchmark suite using `Airspeed Velocity
+ <http://spacetelescope.github.io/asv/>`__ has been added, converting the
+ previous vbench-based one. You can run the suite locally via ``python
+ runtests.py --bench``. For more details, see ``benchmarks/README.rst``.
* A new function ``np.shares_memory`` that can check exactly whether two
-arrays have memory overlap is added. ``np.may_share_memory`` also now
-has an option to spend more effort to reduce false positives.
+ arrays have memory overlap is added. ``np.may_share_memory`` also now has
+ an option to spend more effort to reduce false positives.
+
+* ``SkipTest`` and ``KnownFailureException`` exception classes are exposed
+ in the ``numpy.testing`` namespace. Raise them in a test function to mark
+ the test to be skipped or mark it as a known failure, respectively.
+
+* ``f2py.compile`` has a new ``extension`` keyword parameter that allows the
+ fortran extension to be specified for generated temp files. For instance,
+ the files can be specifies to be ``*.f90``. The ``verbose`` argument is
+ also activated, it was previously ignored.
-* ``SkipTest`` and ``KnownFailureException`` exception classes are exposed in the
-``numpy.testing`` namespace. Raise them in a test function to mark the test to
-be skipped or mark it as a known failure, respectively.
Improvements
============
diff --git a/numpy/f2py/__init__.py b/numpy/f2py/__init__.py
index 17a575927..ef92114ed 100644
--- a/numpy/f2py/__init__.py
+++ b/numpy/f2py/__init__.py
@@ -19,16 +19,32 @@ main = f2py2e.main
def compile(source,
modulename='untitled',
extra_args='',
- verbose=1,
- source_fn=None
+ verbose=True,
+ source_fn=None,
+ extension='.f'
):
''' Build extension module from processing source with f2py.
- Read the source of this function for more information.
+
+ Parameters
+ ----------
+ source : str
+ Fortran source of module / subroutine to compile
+ modulename : str, optional
+ the name of compiled python module
+ extra_args: str, optional
+ additional parameters passed to f2py
+ verbose: bool, optional
+ print f2py output to screen
+ extension: {'.f', '.f90'}, optional
+ filename extension influences the fortran compiler behavior
+
+ .. versionadded:: 1.11.0
+
'''
from numpy.distutils.exec_command import exec_command
import tempfile
if source_fn is None:
- f = tempfile.NamedTemporaryFile(suffix='.f')
+ f = tempfile.NamedTemporaryFile(suffix=extension)
else:
f = open(source_fn, 'w')
@@ -36,13 +52,15 @@ def compile(source,
f.write(source)
f.flush()
- args = ' -c -m %s %s %s' % (modulename, f.name, extra_args)
- c = '%s -c "import numpy.f2py as f2py2e;f2py2e.main()" %s' % \
- (sys.executable, args)
- s, o = exec_command(c)
+ args = ' -c -m {} {} {}'.format(modulename, f.name, extra_args)
+ c = '{} -c "import numpy.f2py as f2py2e;f2py2e.main()" {}'
+ c = c.format(sys.executable, args)
+ status, output = exec_command(c)
+ if verbose:
+ print(output)
finally:
f.close()
- return s
+ return status
from numpy.testing import Tester
test = Tester().test