SourceForge logo
SourceForge logo
Menu

matplotlib-checkins — Commit notification. DO NOT POST to this list, just subscribe to it.

You can subscribe to this list here.

2007 Jan
Feb
Mar
Apr
May
Jun
Jul
(115)
Aug
(120)
Sep
(137)
Oct
(170)
Nov
(461)
Dec
(263)
2008 Jan
(120)
Feb
(74)
Mar
(35)
Apr
(74)
May
(245)
Jun
(356)
Jul
(240)
Aug
(115)
Sep
(78)
Oct
(225)
Nov
(98)
Dec
(271)
2009 Jan
(132)
Feb
(84)
Mar
(74)
Apr
(56)
May
(90)
Jun
(79)
Jul
(83)
Aug
(296)
Sep
(214)
Oct
(76)
Nov
(82)
Dec
(66)
2010 Jan
(46)
Feb
(58)
Mar
(51)
Apr
(77)
May
(58)
Jun
(126)
Jul
(128)
Aug
(64)
Sep
(50)
Oct
(44)
Nov
(48)
Dec
(54)
2011 Jan
(68)
Feb
(52)
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
(1)
2018 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S


1
(3)
2
(2)
3
(5)
4
(1)
5
6
7
(6)
8
(3)
9
(7)
10
(6)
11
(14)
12
(6)
13
(10)
14
(6)
15
16
17
(15)
18
(6)
19
(1)
20
(4)
21
(8)
22
(9)
23
(12)
24
(35)
25
(21)
26
(14)
27
(11)
28
(9)
29
(11)
30
(6)
31
(9)


Showing 1 results of 1

From: <fer...@us...> - 2008年07月19日 07:05:46
Revision: 5792
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5792&view=rev
Author: fer_perez
Date: 2008年07月19日 07:05:43 +0000 (2008年7月19日)
Log Message:
-----------
Add a new f2py example that uses F90 (it's still very simple).
Added Paths:
-----------
 trunk/py4science/examples/numpy_wrap/f2py/example4/
 trunk/py4science/examples/numpy_wrap/f2py/example4/Makefile
 trunk/py4science/examples/numpy_wrap/f2py/example4/README.txt
 trunk/py4science/examples/numpy_wrap/f2py/example4/setup.cfg
 trunk/py4science/examples/numpy_wrap/f2py/example4/setup.py
 trunk/py4science/examples/numpy_wrap/f2py/example4/simple.f90
 trunk/py4science/examples/numpy_wrap/f2py/example4/simple.pyf
 trunk/py4science/examples/numpy_wrap/f2py/example4/test_simple.py
Added: trunk/py4science/examples/numpy_wrap/f2py/example4/Makefile
===================================================================
--- trunk/py4science/examples/numpy_wrap/f2py/example4/Makefile	 (rev 0)
+++ trunk/py4science/examples/numpy_wrap/f2py/example4/Makefile	2008年07月19日 07:05:43 UTC (rev 5792)
@@ -0,0 +1,39 @@
+# Python wrappers for a simple Fortran 90 library
+
+# Build the actual library using a standard Python setup.py script
+build: simple.so
+
+simple.so: simple.f90 simple.pyf setup.py
+	./setup.py config_fc build_ext --inplace
+
+# Build the library in place via a direct call to f2py, using the manually
+# modified simple.pyf file.
+libpyf: simple.f90 simple.pyf
+	f2py -c --fcompiler=gnu95 simple.pyf simple.f90
+
+# Build the 'raw' library by hand, without any tweaks to the python interface
+# of any function. Note that this will NOT pass the tests, since the tests
+# expect the modified interface.
+libraw: simple.f90
+	f2py -c --fcompiler=gnu95 -m simple simple.f90
+
+# Run a very simple test.
+test: build
+	python test_simple.py
+
+# If you have nose installed, the test above can be run as a proper unittest.
+nose: build
+	nosetests test_simple.py
+
+# Build the .pyf file. Note that the supplied file simple.pyf has been
+# manually modified from the auto-generated one. It's a good idea to
+# auto-generate one with a different name if you intend to manually edit yours
+# later, to help prevent an accidental clobbering.
+pyf: simple.f90
+	f2py -h simple_auto.pyf -m simple simple.f90
+
+clean:
+	rm -rf *~ *module.c *.pyc *-f2pywrappers*.f90 build
+
+cleanall: clean
+	rm -rf *.so
Added: trunk/py4science/examples/numpy_wrap/f2py/example4/README.txt
===================================================================
--- trunk/py4science/examples/numpy_wrap/f2py/example4/README.txt	 (rev 0)
+++ trunk/py4science/examples/numpy_wrap/f2py/example4/README.txt	2008年07月19日 07:05:43 UTC (rev 5792)
@@ -0,0 +1,24 @@
+==================================================
+ Very simple Fortran 90 wrapping example via f2py
+==================================================
+
+This small, self-contained directory shows how to build an extension for Python
+based on Fortran 90 code. You can do it both by directly calling f2py and via
+a small setup.py file.
+
+See the accompanying makefile for the actual targets provided, but if you are
+impatient and have gfortran installed, simply type::
+
+ make test
+
+which should run the build and a simple test. If no errors are printed at the
+end, you're fine. If you have nose installed (highly recommended and needed to
+test numpy and scipy, see
+http://www.somethingaboutorange.com/mrl/projects/nose/) you can try instead::
+
+ make nose
+
+This will run the same test files but as proper tests, indicating number of
+tests, errors/failures, etc. There is currently only one test provided, but
+using this in your projects will get you going with proper testing practices
+from the start.
Added: trunk/py4science/examples/numpy_wrap/f2py/example4/setup.cfg
===================================================================
--- trunk/py4science/examples/numpy_wrap/f2py/example4/setup.cfg	 (rev 0)
+++ trunk/py4science/examples/numpy_wrap/f2py/example4/setup.cfg	2008年07月19日 07:05:43 UTC (rev 5792)
@@ -0,0 +1,2 @@
+[config_fc]
+fcompiler = gnu95
Added: trunk/py4science/examples/numpy_wrap/f2py/example4/setup.py
===================================================================
--- trunk/py4science/examples/numpy_wrap/f2py/example4/setup.py	 (rev 0)
+++ trunk/py4science/examples/numpy_wrap/f2py/example4/setup.py	2008年07月19日 07:05:43 UTC (rev 5792)
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+"""Setup script for f2py-wrapped library.
+"""
+
+# Third-party modules
+from numpy.distutils.core import setup
+from numpy.distutils.extension import Extension
+
+# Build the extension module object
+extmod = Extension( name = 'simple',
+ # List here the interface (.pyf) file, plus any sources
+ # that need to be explicitly compiled into the wrapped
+ # module (i.e., not already part of one of the fortran
+ # libraries listed below):
+ sources = ['simple.pyf',
+ 'simple.f90'
+ ],
+
+ # Additional libraries required by our extension modules
+ libraries = [],
+
+ # Add '--debug-capi' for verbose debugging of low-level
+ # calls
+ #f2py_options = ['--debug-capi'],
+ )
+
+# Make the actual distutils setup call
+setup(name = 'simple', # name of the generated extension (.so)
+ description = 'Segmentation library',
+ author = 'Felipe Arrate',
+ ext_modules = [extmod],
+ )
Property changes on: trunk/py4science/examples/numpy_wrap/f2py/example4/setup.py
___________________________________________________________________
Added: svn:executable
 + *
Added: trunk/py4science/examples/numpy_wrap/f2py/example4/simple.f90
===================================================================
--- trunk/py4science/examples/numpy_wrap/f2py/example4/simple.f90	 (rev 0)
+++ trunk/py4science/examples/numpy_wrap/f2py/example4/simple.f90	2008年07月19日 07:05:43 UTC (rev 5792)
@@ -0,0 +1,29 @@
+
+! Matlab-like linspace()
+Subroutine linspace(x,y,lin,n)
+Integer n,i
+Real(8) lin(n)
+Real x,y
+
+!write(6,*) "x",x,"y",y,"n",n ! dbg
+
+Do i=1,n-1
+ lin(i)=x+(i-1)*(y-x)/(n-1)
+End Do
+lin(n)=y;
+END Subroutine linspace
+
+! An identical copy of the above, simply to demo in the python wrapping a
+! different way to expose the API for instructional purposes.
+Subroutine linspace2(x,y,lin,n)
+Integer n,i
+Real(8) lin(n)
+Real x,y
+
+!write(6,*) "x",x,"y",y,"n",n ! dbg
+
+Do i=1,n-1
+ lin(i)=x+(i-1)*(y-x)/(n-1)
+End Do
+lin(n)=y;
+END Subroutine linspace2
Added: trunk/py4science/examples/numpy_wrap/f2py/example4/simple.pyf
===================================================================
--- trunk/py4science/examples/numpy_wrap/f2py/example4/simple.pyf	 (rev 0)
+++ trunk/py4science/examples/numpy_wrap/f2py/example4/simple.pyf	2008年07月19日 07:05:43 UTC (rev 5792)
@@ -0,0 +1,30 @@
+! -*- f90 -*-
+! Note: the context of this file is case sensitive.
+
+! NOTE: This file HAS BEEN MODIFIED! An auto-generated f2py interface was used
+! as a starting point and then modified. If you overwrite it, you'll lose all
+! changes.
+
+python module simple ! in 
+ interface ! in :simple
+
+ ! Default interface produced by 'f2py -h simple.pyf simple.f90'
+ subroutine linspace(x,y,lin,n) ! in :simple:simple.f90
+ real :: x
+ real :: y
+ real(kind=8) dimension(n) :: lin
+ integer optional,check(len(lin)>=n),depend(lin) :: n=len(lin)
+ end subroutine linspace
+
+ ! Modified interface: linspace2 is identical to linspace in Fortran, but
+ ! here we change its interface to a simpler that doesn't require the
+ ! external allocation of the output array.
+ subroutine linspace2(x,y,lin,n) ! in :simple:simple.f90
+ real :: x
+ real :: y
+ integer :: n
+ real(kind=8) dimension(n),intent(out),depend(n) :: lin
+ end subroutine linspace2
+
+ end interface 
+end python module simple
Added: trunk/py4science/examples/numpy_wrap/f2py/example4/test_simple.py
===================================================================
--- trunk/py4science/examples/numpy_wrap/f2py/example4/test_simple.py	 (rev 0)
+++ trunk/py4science/examples/numpy_wrap/f2py/example4/test_simple.py	2008年07月19日 07:05:43 UTC (rev 5792)
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+
+import numpy as np
+
+import simple
+
+def test_linspace():
+ """Test both versions of linspace for consistency."""
+ n,x,y = 5, 0, 2.0
+ a = np.empty(n)
+
+ simple.linspace(x,y,a)
+ print a
+
+ b = simple.linspace2(x,y,n)
+ print b
+
+ np.testing.assert_almost_equal(a,b,15)
+
+if __name__ == '__main__':
+ test_linspace()
Property changes on: trunk/py4science/examples/numpy_wrap/f2py/example4/test_simple.py
___________________________________________________________________
Added: svn:executable
 + *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing 1 results of 1

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /