Oops, I forgot: PyQwt exports also images to numpy/numarray arrays.
See sip/qwtqimage.sip and the files in the numpy directory in PyQwt.
On Fri, 6 Feb 2004 23:50:03 +0100
Gerard Vermeulen <gvermeul at grenoble.cnrs.fr> wrote:
> PyQwt only copies data from numpy/numarray arrays to C++, not the other way
> around. I explain what I would do (look at the code in CVS --
> http://cvs.sourceforge.net/viewcvs.py/pyqwt/pyqwt/ -- or get the snapshot from
> http://pyqwt.sourceforge.net/snapshot/PyQwt-20040118.tar.gz )
>> You have to import the C-API's in the main sip file. In sip/qwtmod.sip this
> is done with:
>> %PostInitialisationCode
> #ifdef HAS_NUMARRAY
> qwt_import_libnumarray();
> #endif
> #ifdef HAS_NUMERIC
> qwt_import_array();
> #endif
> %End
>> The qwt_import_* functions are defined in separate files in the numpy directory
> for two reasons:
> 1. Name collisions in the header files that define the C-API of numpy and
> numarray (see below)
> 2. I do not like C++ code in sip files because it takes longer to rebuild
> after correct errors.
>> The file sip/qwtcurve.sip shows how to copy data from a numpy array, numarray
> array or normal Python sequence of doubles to a QwtArray:
>> void setData(SIP_PYOBJECT, SIP_PYOBJECT);
> %MethodCode
> QwtArray<double> xArray;
> if (-1 == try_PyObject_to_QwtArray(a0, xArray))
> return 0;
>> QwtArray<double> yArray;
> if (-1 == try_PyObject_to_QwtArray(a1, yArray))
> return 0;
>> Py_BEGIN_ALLOW_THREADS
> sipCpp->setData(xArray, yArray);
> Py_END_ALLOW_THREADS
> %End
>> Again, try_PyObject_to_QwtArray delegates the C-API specific stuff to functions
> in separate files. Note that at least the numpy conversion function makes it
> unsafe to allow threading during the conversion (recent versions of numarray may
> be thread safe).
>> I would try to write a getData() function like this:
>> SIP_PYOBJECT getData()
> %MethodCode
> Create a numerical Python extension array and assign it to a pointer
> Copy the data into it
> Return the pointer to the array
> %End
>> Maybe you have to replace SIP_PYOBJECT with void *.
> The Numeric or numarray docs show to implement the pseudo code.
>> Gerard
>> On Fri, 06 Feb 2004 11:19:15 -0800
> "Claus, Richard" <claus at SLAC.Stanford.EDU> wrote:
>> > Hi Ulrich & Gerard,
> >
> > Your discussion about numpy/numarray usage by pyQwt piqued my interest. Could one of you please post a snippet of code showing how one exposes an array of, say, unsigneds, in custom C++ code as a numpy and/or numarray array in python via sip, or point me to where I can learn how to do this? I tried to discover how to do this once but gave up due to time constraints.
> >
> > Thanks very much.
> >
> > Ric
> >
> >
> > > -----Original Message-----
> > > From: Gerard Vermeulen [mailto:gvermeul at grenoble.cnrs.fr]
> > > Sent: Monday, February 02, 2004 12:00 AM
> > > To: ulrich.berning at t-online.de
> > > Cc: pykde at mats.imk.fraunhofer.de
> > > Subject: Re: [PyKDE] How to add handwritten *.cpp files to a
> > > sip generated module with configure.py
> > >
> > >
> > > On Mon, 02 Feb 2004 00:15:35 +0100
> > > ulrich.berning at t-online.de (Ulrich Berning) wrote:
> > >
> > > > Gerard Vermeulen schrieb:
> > > >
> > > > >Hi Phil,
> > > > >
> > > > >Ulrich Berning kindly provided me with code to build PyQwt with
> > > > >configure.py.
> > > > >
> > > > >One of his changes was to put a few handwritten *.cpp files to
> > > > >interface the Numerical Python extension modules (numpy
> > > and numarray)
> > > > >in the qwtmod.sip file.
> > > > >
> > > > >The problem is that there are conflicts between the header
> > > files of
> > > > >numpy and numarray (numarray should become the successor
> > > of numpy, so
> > > > >there is an overlap in their API). Putting all the
> > > interface code in
> > > > >the qwtmod.sip file leads to compile errors because of the
> > > inclusion
> > > > >of the conflicting headers in the same .cpp file.
> > > > >
> > > > >Ulli did not see it, because he is only having numpy, I guess.
> > > > >
> > > > >
> > > > >
> > > > Yes, this is true. I can't see why I should have numpy AND numarray.
> > > > Because numarry will be the successor of numpy someday, but
> > > currently it
> > > > is not, I choosed to stay with numpy. The only reason to
> > > support numpy
> > > > AND numeric could be to provide a binary module that works
> > > either with
> > > > numpy or with numarray or with none of them. But then, the
> > > interface
> > > > code needs some modifactions. You have to find out in the
> > > init function
> > > > if numpy or numarray or none of both is available. Simply calling
> > > > import_array() and/or import_libnumarray() does not work.
> > > If you call
> > > > import_libnumarray() when nummarray is not installed you get a
> > > > Py_FatalError().
> > > >
> > > > And at least, if I take a look at Numeric/arrayobject.h and
> > > > numarray/arrayobject.h, I can see the following:
> > > >
> > > > in Numeric/arrayobject.h:
> > > > #ifndef Py_ARRAYOBJECT_H
> > > > #define Py_ARRAYOBJECT_H
> > > >
> > > > in numarray/arrayobject.h:
> > > > #ifdef Py_ARRAYOBJECT_H
> > > > #error "Can't use numarray Numeric compatability *and*
> > > Numeric in same
> > > > module"
> > > > #endif
> > > >
> > > > My recommendation is, either numpy is used, if it is there
> > > OR numarray
> > > > if it is there OR none of them. Using the numpy API AND the
> > > numarray API
> > > > in the same module may work, but was not intended by the Numerical
> > > > Python Group and seems to be dangerous.
> > > >
> > > PyQwt is able to import both, since version 3.7 and since
> > > version 3.8 it includes numarray/libnumarray.h. It really
> > > works in the same Python program but it requires that calls
> > > to the Numeric API and numarray API are split into different
> > > source files (importing a C API from a C/C++ extension module
> > > is nothing else than setting up a table with pointers to
> > > functions into the module).
> > >
> > > I provide the possibility to use both so that people can make
> > > the transition. It also facilitates support and testing.
> > >
> > > The purpose of my mail was to point out a facility that is
> > > lacking from Phil's new build system (but I can hack my way
> > > out). It explains also why I am sticking so long with my own
> > > tools which are lacking in other respects.
> > >
> > > Gerard
> > >
> > > _______________________________________________
> > > PyKDE mailing list PyKDE at mats.imk.fraunhofer.de
> > > http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
> > >
> >
>> _______________________________________________
> PyKDE mailing list PyKDE at mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
>
More information about the PyQt
mailing list
‘She has never mentioned her father to me. Was he—well, the sort of man whom the County Club would not have blackballed?’ "We walked by the side of our teams or behind the wagons, we slept on the ground at night, we did our own cooking, we washed our knives by sticking them into the ground rapidly a few times, and we washed our plates with sand and wisps of grass. When we stopped, we arranged our wagons in a circle, and thus formed a 'corral,' or yard, where we drove our oxen to yoke them up. And the corral was often very useful as a fort, or camp, for defending ourselves against the Indians. Do you see that little hollow down there?" he asked, pointing to a depression in the ground a short distance to the right of the train. "Well, in that hollow our wagon-train was kept three days and nights by the Indians. Three days and nights they stayed around, and made several attacks. Two of our men were killed and three were wounded by their arrows, and others had narrow escapes. One arrow hit me on the throat, but I was saved by the knot of my neckerchief, and the point only tore the skin a little. Since that time I have always had a fondness for large neckties. I don't know how many of the Indians we killed, as they carried off their dead and wounded, to save them from being scalped. Next to getting the scalps of their enemies, the most important thing with the Indians is to save their own. We had several fights during our journey, but that one was the worst. Once a little party of us were surrounded in a small 'wallow,' and had a tough time to defend ourselves successfully. Luckily for us, the Indians had no fire-arms then, and their bows and arrows were no match for our rifles. Nowadays they are well armed, but there are[Pg 41] not so many of them, and they are not inclined to trouble the railway trains. They used to do a great deal of mischief in the old times, and many a poor fellow has been killed by them." As dusk came on nearly the whole population of Maastricht, with all their temporary guests, formed an endless procession and went to invoke God's mercy by the Virgin Mary's intercession. They went to Our Lady's Church, in which stands the miraculous statue of Sancta Maria Stella Maris. The procession filled all the principal streets and squares of the town. I took my stand at the corner of the Vrijthof, where all marched past me, men, women, and children, all praying aloud, with loud voices beseeching: "Our Lady, Star of the Sea, pray for us ... pray for us ... pray for us ...!" It had not occurred to her for some hours after Mrs. Campbell had told her of Landor's death that she was free now to give herself to Cairness. She had gasped, indeed, when she did remember it, and had put the thought away, angrily and self-reproachfully. But it returned now, and she felt that she might cling to it. She had been grateful, and she had been faithful, too.[Pg 286] She remembered only that Landor had been kind to her, and forgot that for the last two years she had borne with much harsh coldness, and with a sort of contempt which she felt in her unanalyzing mind to have been entirely unmerited. Gradually she raised herself until she sat quite erect by the side of the mound, the old exultation of her half-wild girlhood shining in her face as she planned the future, which only a few minutes before had seemed so hopeless. After he had gloated over Sergeant Ramsey, Shorty got his men into the road ready to start. Si placed himself in front of the squad and deliberately loaded his musket in their sight. Shorty took his place in the rear, and gave out: The groups about each gun thinned out, as the shrieking fragments of shell mowed down man after man, but the rapidity of the fire did not slacken in the least. One of the Lieutenants turned and motioned with his saber to the riders seated on their horses in the line of limbers under the cover of the slope. One rider sprang from each team and ran up to take the place of men who had fallen. "As long as there's men and women in the world, the men 'ull be top and the women bottom." Then, in the house, the little girls were useful. Mrs. Backfield was not so energetic as she used to be. She had never been a robust woman, and though her husband's care had kept her well and strong, her frame was not equal to Reuben's demands; after fourteen years' hard labour, she suffered from rheumatism, which though seldom acute, was inclined to make her stiff and slow. It was here that Caro and Tilly came in, and Reuben began to appreciate his girls. After all, girls were needed in a house—and as for young men and marriage, their father could easily see that such follies did not spoil their usefulness or take them from him. Caro and Tilly helped their grandmother in all sorts of ways—they dusted, they watched pots, they shelled peas and peeled potatoes, they darned house-linen, they could even make a bed between them. HoME一级毛片视频免费公开
ENTER NUMBET 0018www.vip724.com.cn wpar13fz.com.cn adminshell.com.cn shjwmy.com.cn teraki.com.cn rzgu.net.cn xoea.com.cn www.smzdg.com.cn suobo.net.cn pepeixun.com.cn