1 Dec 01:01
1 Dec 13:29
Re: fminbound vs. brent
Neil Muller <drnlmuller+scipy <at> gmail.com>
2008-12-01 12:29:11 GMT
2008-12-01 12:29:11 GMT
On Mon, Dec 1, 2008 at 2:01 AM, Gideon Simpson <simpson <at> math.toronto.edu> wrote: > Based on the documentation, I'm a bit unclear on how fminbound and > brent, as optimization algorithms, differ. Could someone clarify this > for me? brent doesn't do constrained optimisation, while fminbound does. Consider: In [1]: import scipy.optimize as opt In [2]: f = lambda x: x*x In [3]: opt.brent(f, brack=(3, 4)) Out[3]: 0.0 In [4]: opt.fminbound(f, x1=3, x2=4) Out[4]: 3.00000596086 Hope that helps. -- -- Neil Muller drnlmuller <at> gmail.com
1 Dec 14:34
1 Dec 18:58
Re: Is it possible to pass Fortran derived data types to Python via C and SWIG?
David Huard <david.huard <at> gmail.com>
2008-12-01 17:58:59 GMT
2008-12-01 17:58:59 GMT
John,
this is something I've wanted to look at. Here is what I had planned to do, so there is no guarantee that it will actually work...
The ISO_C_BINDING module is part of the 2003 standard and allows interoperability between C and Fortran (it is included in the latest gfortran compiler). It allows interoperability of Fortran derived types with C structures (with certain restrictions). For example,
use iso_c_binding
type, bind(c) :: mytype
real(c_float) :: data
integer(c_int) :: n
end type
is interoperable with
typedef struct {
float data;
int n;
} mytype
Now, I am just guessing, but if such a module was built into a shared library, maybe it could be accessed from python using ctypes STRUCTURES.
Regards,
David
On Sun, Nov 30, 2008 at 4:38 PM, Berthold Höllmann <berthold <at> xn--hllmanns-n4a.de> wrote:
Matthieu Brucher <matthieu.brucher <at> gmail.com> writes:
>
> 2008/11/30 David Cournapeau <david <at> ar.media.kyoto-u.ac.jp>:> > John Salvatier wrote:A feasible way to achieve this would be to write a Fortran wrapper
> >> I have a Fortran 90 algorithm which uses a derived data type to return
> >> data, and I would like to make a python wrapper for this algorithm. I
> >> understand that f2py cannot wrap derived data types; is it possible to
> >> do so with a C interface for the Fortran algorithm and SWIG? I would
> >> have to pass the derived data type into a C struct and then to Python.
> >
> > It is possible as long as you can pass the structure from fortran to C.
> > I don't know anything about Fortran derived data types, but if it is a
> > non trivial object (more than a set of fundamental types), I am afraid
> > it will be difficult. Does F90 supports POD data ? Otherwise, you will
> > need a scheme for marshalling your data from Fortran to C (to match
> > exactly how the structure would look like in C at the binary level).
> >
> > David
>
> I've read an article (I don't remember where though, possibly CiSE)
> that stated that it's really not an easy task, as each Fortran
> compiler can do as it pleases it. So depending on the compiler and the
> Fortran standard, it can be possible, or not. So as there are no
> guaranties, you should write a function that transforms the Fortran
> structure in several pieces that are then passed to the C function.
>
> Matthieu
around your routine(x) that decomposes your derived data type to
standard types and exposes these in the interface. Than you can compose
the derived data type again in the wrapper and pass it to the original
routine. ::
module geom
type Point
real :: x, y
end type Point
type Circle
type (Point) :: Center
real :: Radius
end type Circle
end module geom
subroutine test(c)
use geom
type (Circle) :: c
print*, c%Radius
print*, c%Center%X
print*, c%Center%Y
end subroutine test
subroutine w_test(x, y, r)
use geom
real :: x, y, z
type (Circle) :: C
c%Radius = r
c%Center%X = x
c%Center%Y = y
call test(c)
end subroutine w_test
Wrapping w_test should be trivial using f2py
Regards
Berthold
_______________________________________________
SciPy-user mailing list
SciPy-user <at> scipy.org
http://projects.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-user mailing list SciPy-user <at> scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
1 Dec 19:44
Re: scikits.timeseries
Robert Ferrell <ferrell <at> diablotech.com>
2008-12-01 18:44:52 GMT
2008-12-01 18:44:52 GMT
On Nov 28, 2008, at 12:03 PM, Pierre GM wrote:
> Robert:
> It's always easier to manipulate series withoutmissing data. The trick
> I gave you earlier about computing a moving average after having
> removed the missing dates was that, just a trick. However, I'm
> confident it should work.
It does work quite well. When I plot I have a few holes in the data
(at holidays), but that's about the only issue I haven't resolved.
>
>
> Unfortunately, there's no easy way to define new frequencies, and it's
> not on or todo list either. Frequencies are defined in the C part of
> the code...
How do you (or other users) use the Business frequency?
Also, I get this error when I use tsplot:
---------------------------------------------------------------------------
<type 'exceptions.AttributeError'> Traceback (most recent call
last)
/Users/Shared/Develop/Financial/≤ipython console> in <module>()
/Library/Frameworks/Python.framework/Versions/2.5.2001/lib/python2.5/
site-packages/scikits/timeseries/lib/plotlib.py in tsplot(self, *args,
**kwargs)
1021 # when adding a right axis (using add_yaxis), for
some reason the
1022 # x axis limits don't get properly set. This gets
around the problem
-> 1023 if self.get_xlim().tolist() == [0., 1.]:
1024 # if xlim still at default values, autoscale the
axis
1025 self.autoscale_view()
<type 'exceptions.AttributeError'>: 'tuple' object has no attribute
'tolist'
That comes up no matter what kind of data or frequency I'm using
(full, valid, etc...). Is that possibly why the cursor won't give me
x axis position when I mouse around?
thanks again,
-robert
1 Dec 19:54
Re: scikits.timeseries
Pierre GM <pgmdevlist <at> gmail.com>
2008-12-01 18:54:29 GMT
2008-12-01 18:54:29 GMT
On Dec 1, 2008, at 1:44 PM, Robert Ferrell wrote: >> Unfortunately, there's no easy way to define new frequencies, and >> it's >> not on or todo list either. Frequencies are defined in the C part of >> the code... > > How do you (or other users) use the Business frequency? I'll let other users answer that. I never used that frequency myself. > > Also, I get this error when I use tsplot: Looks familiar... What version of matplotlib and scikits.timeseries are you using? > > That comes up no matter what kind of data or frequency I'm using > (full, valid, etc...). Is that possibly why the cursor won't give me > x axis position when I mouse around? No. I never took the time to find out what I can't get the x axis position under the cursor either, but the two issues are unrelated: the error you see comes from an update of matplotlib that hasn't been ported yet to scikits.timeseries.
1 Dec 21:09
HDF5 for Python 1.0
Andrew Collette <h5py <at> alfven.org>
2008-12-01 20:09:56 GMT
2008-12-01 20:09:56 GMT
Thought this might be of interest to the scipy crowd... Like PyTables it
lets you store array data in a hierarchical format, and perform slicing
and partial I/O, but it has a simpler, NumPy-oriented interface and also
provides access to the majority of the HDF5 C API. However, it doesn't
have the database-style indexing and query support of tables.
=====================================
Announcing HDF5 for Python (h5py) 1.0
=====================================
What is h5py?
-------------
HDF5 for Python (h5py) is a general-purpose Python interface to the
Hierarchical Data Format library, version 5. HDF5 is a versatile,
mature scientific software library designed for the fast, flexible
storage of enormous amounts of data.
>From a Python programmer's perspective, HDF5 provides a robust way to
store data, organized by name in a tree-like fashion. You can create
datasets (arrays on disk) hundreds of gigabytes in size, and perform
random-access I/O on desired sections. Datasets are organized in a
filesystem-like hierarchy using containers called "groups", and
accesed using the tradional POSIX /path/to/resource syntax.
This is the fourth major release of h5py, and represents the end
of the "unstable" (0.X.X) design phase.
Why should I use it?
--------------------
H5py provides a simple, robust read/write interface to HDF5 data
from Python. Existing Python and NumPy concepts are used for the
interface; for example, datasets on disk are represented by a proxy
class that supports slicing, and has dtype and shape attributes.
HDF5 groups are are presented using a dictionary metaphor, indexed
by name.
A major design goal of h5py is interoperability; you can read your
existing data in HDF5 format, and create new files that any HDF5-
aware program can understand. No Python-specific extensions are
used; you're free to implement whatever file structure your application
desires.
Almost all HDF5 features are available from Python, including things
like compound datatypes (as used with NumPy recarray types), HDF5
attributes, hyperslab and point-based I/O, and more recent features
in HDF 1.8 like resizable datasets and recursive iteration over entire
files.
The foundation of h5py is a near-complete wrapping of the HDF5 C API.
HDF5 identifiers are first-class objects which participate in Python
reference counting, and expose the C API via methods. This low-level
interface is also made available to Python programmers, and is
exhaustively documented.
See the Quick-Start Guide for a longer introduction with code examples:
http://h5py.alfven.org/docs/guide/quick.html
Where to get it
---------------
* Main website, documentation: http://h5py.alfven.org
* Downloads, bug tracker: http://h5py.googlecode.com
* The HDF group website also contains a good introduction:
http://www.hdfgroup.org/HDF5/doc/H5.intro.html
Requires
--------
* UNIX-like platform (Linux or Mac OS-X); Windows version is in
progress.
* Python 2.5 or 2.6
* NumPy 1.0.3 or later (1.1.0 or later recommended)
* HDF5 1.6.5 or later, including 1.8. Some features only available
when compiled against HDF5 1.8.
* Optionally, Cython (see cython.org) if you want to use custom install
options. You'll need version 0.9.8.1.1 or later.
About this version
------------------
Version 1.0 follows version 0.3.1 as the latest public release. The
major design phase (which began in May of 2008) is now over; the design
of the high-level API will be supported as-is for the rest of the 1.X
series, with minor enhancements.
This is the first version to support Python 2.6, and the first to use
Cython for the low-level interface. The license remains 3-clause BSD.
** This project is NOT affiliated with The HDF Group. **
Thanks
------
Thanks to D. Dale, E. Lawrence and other for their continued support
and comments. Also thanks to the PyTables project, for inspiration
and generously providing their code to the community, and to everyone
at the HDF Group for creating such a useful piece of software.
1 Dec 21:21
Re: scikits.timeseries
Robert Ferrell <ferrell <at> diablotech.com>
2008-12-01 20:21:52 GMT
2008-12-01 20:21:52 GMT
On Dec 1, 2008, at 11:54 AM, Pierre GM wrote: > > On Dec 1, 2008, at 1:44 PM, Robert Ferrell wrote: >>> Unfortunately, there's no easy way to define new frequencies, and >>> it's >>> not on or todo list either. Frequencies are defined in the C part of >>> the code... >> >> How do you (or other users) use the Business frequency? > > I'll let other users answer that. I never used that frequency myself. > > >> >> Also, I get this error when I use tsplot: > > Looks familiar... What version of matplotlib and scikits.timeseries > are you using? In [741]: matplotlib.__version__ Out[741]: '0.98.3' In [742]: ts.__version__ Out[742]: '0.67.0.dev-r1570' > > >> >> That comes up no matter what kind of data or frequency I'm using >> (full, valid, etc...). Is that possibly why the cursor won't give me >> x axis position when I mouse around? > > No. I never took the time to find out what I can't get the x axis > position under the cursor either, but the two issues are unrelated: > the error you see comes from an update of matplotlib that hasn't been > ported yet to scikits.timeseries. The error seems benign enough that I can ignore it. -robert
1 Dec 23:57
Re: scikits.timeseries
Pierre GM <pgmdevlist <at> gmail.com>
2008-12-01 22:57:19 GMT
2008-12-01 22:57:19 GMT
Robert, Thx a lot for reporting, I'll take a better look ASAP. On Dec 1, 2008, at 3:21 PM, Robert Ferrell wrote: > > On Dec 1, 2008, at 11:54 AM, Pierre GM wrote: > >> >> On Dec 1, 2008, at 1:44 PM, Robert Ferrell wrote: >>>> Unfortunately, there's no easy way to define new frequencies, and >>>> it's >>>> not on or todo list either. Frequencies are defined in the C part >>>> of >>>> the code... >>> >>> How do you (or other users) use the Business frequency? >> >> I'll let other users answer that. I never used that frequency myself. >> >> >>> >>> Also, I get this error when I use tsplot: >> >> Looks familiar... What version of matplotlib and scikits.timeseries >> are you using? > > In [741]: matplotlib.__version__ > Out[741]: '0.98.3' > > In [742]: ts.__version__ > Out[742]: '0.67.0.dev-r1570' > > >> >> >>> >>> That comes up no matter what kind of data or frequency I'm using >>> (full, valid, etc...). Is that possibly why the cursor won't give >>> me >>> x axis position when I mouse around? >> >> No. I never took the time to find out what I can't get the x axis >> position under the cursor either, but the two issues are unrelated: >> the error you see comes from an update of matplotlib that hasn't been >> ported yet to scikits.timeseries. > > The error seems benign enough that I can ignore it. > > -robert > > _______________________________________________ > SciPy-user mailing list > SciPy-user <at> scipy.org > http://projects.scipy.org/mailman/listinfo/scipy-user
2 Dec 00:53
Re: weave problems, weave_imp.o no such file or directory
Daniel Wheeler <daniel.wheeler2 <at> gmail.com>
2008-12-01 23:53:36 GMT
2008-12-01 23:53:36 GMT
I have a similar issue when using pythonxy (2.1.4) (python version
2.5.2) and windows. The following
import scipy
print 'scipy.__version__',scipy.__version__
print 'scipy.__path__',scipy.__path__
from scipy import weave
weave.inline('printf("hello world");', verbose=2)
returns
scipy.__version__ 0.6.0
scipy.__path__ ['C:\\Program
Files\\pythonxy\\python\\lib\\site-packages\\scipy']
<weave: compiling>
kw {'extra_link_args': [], 'define_macros': [], 'libraries': [],
'sources': ['C:\\Program
Files\\pythonxy\\python\\lib\\site-packages\\scipy\\weave\\scxx\\weave_imp.cpp'],
'extra_compile_args': [], 'library_dirs': [], 'include_dirs':
['C:\\Program Files\\pythonxy\\python\\lib\\site-packages\\scipy\\weave',
'C:\\Program Files\\pythonxy\\python\\lib\\site-packages\\scipy\\weave\\scxx']}
running build_ext
running build_src
building extension "sc_5c84b188757e017720cf8a0a3b0555304" sources
customize Mingw32CCompiler
customize Mingw32CCompiler using build_ext
customize Mingw32CCompiler
customize Mingw32CCompiler using build_ext
building 'sc_5c84b188757e017720cf8a0a3b0555304' extension
compiling C++ sources
C compiler: g++ -mno-cygwin -O2 -Wall
compile options: '-I"C:\Program
Files\pythonxy\python\lib\site-packages\scipy\weave" -I"C:\Program
Files\pythonxy\python\lib\site-packages\scipy\weave\scxx"
-I"C:\Program Files\pythonxy\python\lib\site-packages\numpy\core\include"
-I"C:\Program Files\pythonxy\python\include" -I"C:\Program
Files\pythonxy\python\PC" -c'
g++ -mno-cygwin -O2 -Wall -I"C:\Program
Files\pythonxy\python\lib\site-packages\scipy\weave" - I"C:\Program
Files\pythonxy\python\lib\site-packages\scipy\weave\scxx"
-I"C:\Program Files\pythonxy\python\lib\site-packages\numpy\core\include"
-I"C:\Program Files\pythonxy\python\include" -I"C:\Program
Files\pythonxy\python\PC" -c
c:\docume~1\wd15\locals~1\temp\wd15\python25_compiled\sc_5c84b188757e017720cf8a0a3b0555304.cpp
-o c:\docume~1\wd15\locals~1\temp\wd15\python25_intermediate\compiler_08edc7e348e1c33f63a33ab500aef08e\Release\docume~1\wd15\locals~1\temp\wd15\python25_compiled\sc_5c84b188757e017720cf8a0a3b0555304.o
Found executable C:\MinGW\bin\g++.exe
g++ -mno-cygwin -shared
c:\docume~1\wd15\locals~1\temp\wd15\python25_intermediate\compiler_08edc7e348e1c33f63a33ab500aef08e\Release\docume~1\wd15\locals~1\temp\wd15\python25_compiled\sc_5c84b188757e017720cf8a0a3b0555304.o
c:\docume~1\wd15\locals~1\temp\wd15\python25_intermediate\compiler_08edc7e348e1c33f63a33ab500aef08e\Release\program
files\pythonxy\python\lib\site-packages\scipy\weave\scxx\weave_imp.o
-L"C:\Program Files\pythonxy\python\libs" -L"C:\Program
Files\pythonxy\python\PCBuild" -lpython25 -lmsvcr71 -o
c:\docume~1\wd15\locals~1\temp\wd15\python25_compiled\sc_5c84b188757e017720cf8a0a3b0555304.pyd
g++.exe: files\pythonxy\python\lib\site-packages\scipy\weave\scxx\weave_imp.o:
No such file or directory
On Mon, Jul 7, 2008 at 2:31 PM, Søren Nielsen
<soren.skou.nielsen <at> gmail.com> wrote:
> I have a space in my path too... So thats why it works on some computers and
> not on others...
--
--
Daniel Wheeler
RSS Feed