fix docs, don't wrap varargs in python

This commit is contained in:
John Cupitt 2008-07-29 11:30:48 +00:00
parent d9e9153300
commit f250ebdded
5 changed files with 45 additions and 6 deletions

4
TODO
View File

@ -1,3 +1,7 @@
- note new VMask constructor in docs
test new VMask constructor from python
- wrap meta() stuff in C++, we need it in py as well
need fred.get_int ("poop"); I think

View File

@ -9,25 +9,41 @@ represent matricies of integers and doubles respectively.
\subsection{Constructors}
There are three constructors for \verb+VIMask+ and \verb+VDMask+:
There are four constructors for \verb+VIMask+ and \verb+VDMask+:
\begin{verbatim}
VIMask( int xsize, int ysize );
VIMask( int xsize, int ysize,
int scale, int offset, ... );
VIMask( int xsize, int ysize,
int scale, int offset,
std::vector<int> coeff );
VIMask( const char *name );
VIMask();
VDMask( int xsize, int ysize );
VDMask( int xsize, int ysize,
double scale, double offset, ... );
VDMask( int xsize, int ysize,
double scale, double offset,
std::vector<double> coeff );
VDMask( const char *name );
VDMask();
\end{verbatim}
The first form creates an empty matrix, with the specified dimensions;
the second form initialises a matrix from a varargs list; the third form
reads the matrix from the named file. The final form makes a mask object
with no contents yet.
sets the matrix from a vector of coefficients; the fourth from the named file.
The final form makes a mask object with no contents yet.
The varargs constructors are not wrapped in Python --- use the vector
constructor instead. For example:
\begin{verbatim}
m = VMask.VIMask (3, 3, 1, 0,
[-1, -1, -1,
-1, 8, -1,
-1, -1, -1])
\end{verbatim}
\subsection{Projection functions}

View File

@ -233,6 +233,9 @@ public:
ref->pmask = new _private_detail::VPIMask( xsize, ysize );
}
/* Don't wrap the varargs constructor. We want Python to use the vector one.
*/
#ifndef SWIG
VIMask( int xsize, int ysize, int scale, int offset, ... )
{
va_list ap;
@ -247,6 +250,7 @@ public:
ref->pmask = new _private_detail::VPIMask( xsize, ysize,
scale, offset, coeff );
}
#endif /*!SWIG*/
VIMask( int xsize, int ysize, int scale, int offset,
std::vector<int> coeff )
@ -318,6 +322,9 @@ public:
ref->pmask = new _private_detail::VPDMask( xsize, ysize );
}
/* Don't wrap the varargs constructor. We want Python to use the vector one.
*/
#ifndef SWIG
VDMask( int xsize, int ysize, double scale, double offset, ... )
{
va_list ap;
@ -332,6 +339,7 @@ public:
ref->pmask = new _private_detail::VPDMask( xsize, ysize,
scale, offset, coeff );
}
#endif /*!SWIG*/
VDMask( int xsize, int ysize, double scale, double offset,
std::vector<double> coeff )

View File

@ -169,13 +169,15 @@ _private_detail::VPIMask::VPIMask( int xsize, int ysize,
int scale, int offset, std::vector<int> coeff )
throw( VError )
{
int i;
if( !(data.iptr = im_create_imask( "VPIMask::VPIMask", xsize, ysize )) )
verror();
type = _private_detail::VPMask::INT;
data.iptr->scale = scale;
data.iptr->offset = offset;
for( int i = 0; i < xsize * ysize; i++ )
for( i = 0; i < xsize * ysize; i++ )
data.iptr->coeff[i] = coeff[i];
}
@ -314,13 +316,15 @@ _private_detail::VPDMask::VPDMask( int xsize, int ysize ) throw( VError )
_private_detail::VPDMask::VPDMask( int xsize, int ysize,
double scale, double offset, std::vector<double> coeff ) throw( VError )
{
int i;
if( !(data.dptr = im_create_dmask( "VPDMask::VPDMask", xsize, ysize )) )
verror();
type = _private_detail::VPMask::DOUBLE;
data.dptr->scale = scale;
data.dptr->offset = offset;
for( int i = 0; i < xsize * ysize; i++ )
for( i = 0; i < xsize * ysize; i++ )
data.dptr->coeff[i] = coeff[i];
}

View File

@ -16,7 +16,12 @@ try:
a = VImage.VImage (sys.argv[1])
b = a.invert ()
c = b.lin ([1,2,3],[4,5,6])
c.write (sys.argv[2])
m = VMask.VIMask (3, 3, 1, 0,
[-1, -1, -1,
-1, 8, -1,
-1, -1, -1])
d = a.conv (m)
d.write (sys.argv[2])
except VError.VError, e:
e.perror (sys.argv[0])
@ -27,6 +32,8 @@ print 'starting shutdown ...'
del b
del a
del c
del d
del m
# sometimes have to do several GCs to get them all, not sure why
for i in range(10):
gc.collect ()