[Numpy-discussion] [NumPy/Swig] Return NumPy array with same size as input array (no additional length argument)

2015-10-31 Thread laurentes
Hello,

Using Swig, I don't manage to (properly) create the Python Binding for the
following C-like function:

void add_array(double* input_array1, double* input_array2, double*
output_array, int length);

where the three arrays have all the same length.

This is similar to  this thread
 
, which has never been fully addressed online.

>From Python, I would like to be able to call:

add_array(input_array1, input_array2)

which would return me a newly allocated NumPy array (output_array) with the
result.

In my Swig file, I've first used the wrapper function trick described  here

 
, that is:

%apply (double* IN_ARRAY1, int DIM1) {(double* input_array1, int length1),
(double* input_array2, int length2)};
%apply (double* ARGOUT_ARRAY1, int DIM1) {(double* output_array, int
length3)};

%rename (add_array) my_add_array;
%exception my_add_array {
$action
if (PyErr_Occurred()) SWIG_fail;
}
%inline %{
void my_add_array(double* input_array1, int length1, double* input_array2,
int length2, double* output_array, int length3) {
  if (length1 != length2 || length1 != length3) {
  PyErr_Format(PyExc_ValueError,
   "Arrays of lengths (%d,%d,%d) given",
   length1, length2, length3);
  }
  else {
add_array(input_array1, input_array2, output_array, length1);
  }
}
%}

This allows me to call the function from Python using
add_array(input_array1, input_array2, length). But the third argument of
this function is useless and this function does not look 'Pythonic'.

Could someone help me to modify my Swig file, such that only the first two
arguments are required for the Python API?

Thanks a lot,
Laurent



--
View this message in context: 
http://numpy-discussion.10968.n7.nabble.com/NumPy-Swig-Return-NumPy-array-with-same-size-as-input-array-no-additional-length-argument-tp41601.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Proposal: stop supporting 'setup.py install'; start requiring 'pip install .' instead

2015-10-31 Thread Ralf Gommers
On Thu, Oct 29, 2015 at 8:11 PM, Warren Weckesser <
warren.weckes...@gmail.com> wrote:

>
>
> On Tue, Oct 27, 2015 at 12:31 AM, Nathaniel Smith  wrote:
>
>> Hi all,
>>
>> Apparently it is not well known that if you have a Python project
>> source tree (e.g., a numpy checkout), then the correct way to install
>> it is NOT to type
>>
>>   python setup.py install   # bad and broken!
>>
>> but rather to type
>>
>>   pip install .
>>
>>
>
> FWIW, I don't see any mention of this in the numpy docs, but I do see a
> lot of instructions involving `setup.py build` and `setup.py install`.
> See, for example, INSTALL.txt.  Also see
> http://docs.scipy.org/doc/numpy/user/install.html#building-from-source
> So I guess it is not surprising that it is not well known.
>

Indeed, install docs are always hopelessly outdated. And we have too many
of them. There's duplicate info in INSTALL.txt and
http://scipy.org/scipylib/building/index.html for example. We should
probably just empty out INSTALL.txt and simply put a link in it to the html
docs.

I've created an issue with a long todo list and a bunch of links:
https://github.com/numpy/numpy/issues/6599. Feel free to add stuff. Or to
go fix something:)

Ralf
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Proposal: stop supporting 'setup.py install'; start requiring 'pip install .' instead

2015-10-31 Thread Ralf Gommers
On Sun, Nov 1, 2015 at 1:54 AM, Ralf Gommers  wrote:

>
>
>
> On Thu, Oct 29, 2015 at 8:11 PM, Warren Weckesser <
> warren.weckes...@gmail.com> wrote:
>
>>
>>
>> On Tue, Oct 27, 2015 at 12:31 AM, Nathaniel Smith  wrote:
>>
>>> Hi all,
>>>
>>> Apparently it is not well known that if you have a Python project
>>> source tree (e.g., a numpy checkout), then the correct way to install
>>> it is NOT to type
>>>
>>>   python setup.py install   # bad and broken!
>>>
>>> but rather to type
>>>
>>>   pip install .
>>>
>>>
>>
>> FWIW, I don't see any mention of this in the numpy docs, but I do see a
>> lot of instructions involving `setup.py build` and `setup.py install`.
>> See, for example, INSTALL.txt.  Also see
>>
>> http://docs.scipy.org/doc/numpy/user/install.html#building-from-source
>> So I guess it is not surprising that it is not well known.
>>
>
> Indeed, install docs are always hopelessly outdated. And we have too many
> of them. There's duplicate info in INSTALL.txt and
> http://scipy.org/scipylib/building/index.html for example. We should
> probably just empty out INSTALL.txt and simply put a link in it to the html
> docs.
>
> I've created an issue with a long todo list and a bunch of links:
> https://github.com/numpy/numpy/issues/6599. Feel free to add stuff. Or to
> go fix something:)
>

Oh, and: looking at this thread there haven't been serious unanswered
concerns (at least in my perception), so without more discussion I'd
interpret the current status as "go ahead".

Ralf
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Commit rights for Jonathan J. Helmus

2015-10-31 Thread Jaime Fernández del Río
"Gruetzi!", as I just found out we say in Switzerland...
On Oct 30, 2015 8:20 AM, "Jonathan Helmus"  wrote:

> On 10/28/2015 09:43 PM, Allan Haldane wrote:
> > On 10/28/2015 05:27 PM, Nathaniel Smith wrote:
> >> Hi all,
> >>
> >> Jonathan J. Helmus (@jjhelmus) has been given commit rights -- let's all
> >> welcome him aboard.
> >>
> >> -n
> >
> > Welcome Jonathan, happy to have you on the team!
> >
> > Allan
> >
>
> Thanks you everyone for the kind welcome.  I'm looking forwarding to
> being part of them team.
>
> - Jonathan Helmus
>
> ___
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion
>
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] NumFOCUS fiscal sponsorship agreement

2015-10-31 Thread Ralf Gommers
Hi all,

On Wed, Oct 28, 2015 at 11:48 PM, Ralf Gommers 
wrote:

>
> Hi all, there wasn't much feedback on this FSA, but I want to point out
> that it's actually quite important for the project.
>
> Maybe everyone already thought about this when the governance model was
> agreed on (it does include a NumFOCUS subcommittee after all), but if not:
> read / think /ask question fast, because we're moving forward with signing
> of the agreement with the people listed at
> http://docs.scipy.org/doc/numpy-dev/dev/governance/people.html#numfocus-subcommittee.
>
>

The document is now signed. No other project with an FSA seems to have done
this (yet), but I think it would be good to publish the FSA. Either on
numpy.org, scipy.org or numfocus.org. Any objections/concerns about that?

+1's from the people that signed would be good to have before moving
forward.

Cheers,
Ralf
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] NumFOCUS fiscal sponsorship agreement

2015-10-31 Thread Thomas Caswell
+1 to posting it as part of the documentation.

I also like the idea of numfocus hosting the whole collection of them
locally so that we can just link to them.

On Sat, Oct 31, 2015, 19:01 Ralf Gommers  wrote:

> Hi all,
>
> On Wed, Oct 28, 2015 at 11:48 PM, Ralf Gommers 
> wrote:
>
>>
>> Hi all, there wasn't much feedback on this FSA, but I want to point out
>> that it's actually quite important for the project.
>>
>> Maybe everyone already thought about this when the governance model was
>> agreed on (it does include a NumFOCUS subcommittee after all), but if not:
>> read / think /ask question fast, because we're moving forward with signing
>> of the agreement with the people listed at
>> http://docs.scipy.org/doc/numpy-dev/dev/governance/people.html#numfocus-subcommittee.
>>
>>
>
> The document is now signed. No other project with an FSA seems to have
> done this (yet), but I think it would be good to publish the FSA. Either on
> numpy.org, scipy.org or numfocus.org. Any objections/concerns about that?
>
> +1's from the people that signed would be good to have before moving
> forward.
>
> Cheers,
> Ralf
>
>
>
>
> ___
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion
>
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] NumFOCUS fiscal sponsorship agreement

2015-10-31 Thread Nathaniel Smith
On Oct 31, 2015 4:01 PM, "Ralf Gommers"  wrote:
>
> Hi all,
>
> On Wed, Oct 28, 2015 at 11:48 PM, Ralf Gommers  wrote:
>>
>>
>> Hi all, there wasn't much feedback on this FSA, but I want to point out that 
>> it's actually quite important for the project.
>>
>> Maybe everyone already thought about this when the governance model was 
>> agreed on (it does include a NumFOCUS subcommittee after all), but if not: 
>> read / think /ask question fast, because we're moving forward with signing 
>> of the agreement with the people listed at 
>> http://docs.scipy.org/doc/numpy-dev/dev/governance/people.html#numfocus-subcommittee.
>
>
> The document is now signed. No other project with an FSA seems to have done 
> this (yet), but I think it would be good to publish the FSA. Either on 
> numpy.org, scipy.org or numfocus.org. Any objections/concerns about that?
>
> +1's from the people that signed would be good to have before moving forward.

+1 from me, with the proviso that most project FSAs probably contain
individual contributor's home addresses, which should be redacted just
in case.

(Correctly redacting PDFs is notoriously tricky [1], but it looks like
recent versions of e.g. Acrobat have tools that take appropriate care
[2].)

-n

[1] http://blog.foxitsoftware.com/how-to-properly-redact-pdf-files/
[2] https://helpx.adobe.com/acrobat/using/removing-sensitive-content-pdfs.html
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] NumFOCUS fiscal sponsorship agreement

2015-10-31 Thread Nathaniel Smith
On Sat, Oct 31, 2015 at 4:57 PM, Ralf Gommers  wrote:
>
> On Sun, Nov 1, 2015 at 12:53 AM, Nathaniel Smith  wrote:
>>
>> On Oct 31, 2015 4:01 PM, "Ralf Gommers"  wrote:
>> >
>> > Hi all,
>> >
>> > On Wed, Oct 28, 2015 at 11:48 PM, Ralf Gommers 
>> > wrote:
>> >>
>> >>
>> >> Hi all, there wasn't much feedback on this FSA, but I want to point out
>> >> that it's actually quite important for the project.
>> >>
>> >> Maybe everyone already thought about this when the governance model was
>> >> agreed on (it does include a NumFOCUS subcommittee after all), but if not:
>> >> read / think /ask question fast, because we're moving forward with signing
>> >> of the agreement with the people listed at
>> >> http://docs.scipy.org/doc/numpy-dev/dev/governance/people.html#numfocus-subcommittee.
>> >
>> >
>> > The document is now signed. No other project with an FSA seems to have
>> > done this (yet), but I think it would be good to publish the FSA. Either on
>> > numpy.org, scipy.org or numfocus.org. Any objections/concerns about that?
>> >
>> > +1's from the people that signed would be good to have before moving
>> > forward.
>>
>> +1 from me, with the proviso that most project FSAs probably contain
>> individual contributor's home addresses, which should be redacted just
>> in case.
>
>
> Ours doesn't contain any home addressed, and I don't think the ones for
> other projects do either (didn't check yet).

Yes it does -- one of the things to fill in on the FSA template is the
"project mailing address", and since most projects don't actually have
one of those, the advice is to pick some contributor's address and use
that.

-n

-- 
Nathaniel J. Smith -- http://vorpus.org
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] NumFOCUS fiscal sponsorship agreement

2015-10-31 Thread Ralf Gommers
On Sun, Nov 1, 2015 at 12:53 AM, Nathaniel Smith  wrote:

> On Oct 31, 2015 4:01 PM, "Ralf Gommers"  wrote:
> >
> > Hi all,
> >
> > On Wed, Oct 28, 2015 at 11:48 PM, Ralf Gommers 
> wrote:
> >>
> >>
> >> Hi all, there wasn't much feedback on this FSA, but I want to point out
> that it's actually quite important for the project.
> >>
> >> Maybe everyone already thought about this when the governance model was
> agreed on (it does include a NumFOCUS subcommittee after all), but if not:
> read / think /ask question fast, because we're moving forward with signing
> of the agreement with the people listed at
> http://docs.scipy.org/doc/numpy-dev/dev/governance/people.html#numfocus-subcommittee
> .
> >
> >
> > The document is now signed. No other project with an FSA seems to have
> done this (yet), but I think it would be good to publish the FSA. Either on
> numpy.org, scipy.org or numfocus.org. Any objections/concerns about that?
> >
> > +1's from the people that signed would be good to have before moving
> forward.
>
> +1 from me, with the proviso that most project FSAs probably contain
> individual contributor's home addresses, which should be redacted just
> in case.
>

Ours doesn't contain any home addressed, and I don't think the ones for
other projects do either (didn't check yet).

Ralf


> (Correctly redacting PDFs is notoriously tricky [1], but it looks like
> recent versions of e.g. Acrobat have tools that take appropriate care
> [2].)
>
> -n
>
> [1] http://blog.foxitsoftware.com/how-to-properly-redact-pdf-files/
> [2]
> https://helpx.adobe.com/acrobat/using/removing-sensitive-content-pdfs.html
> ___
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion
>
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] NumFOCUS fiscal sponsorship agreement

2015-10-31 Thread Ralf Gommers
On Sun, Nov 1, 2015 at 1:00 AM, Nathaniel Smith  wrote:

> On Sat, Oct 31, 2015 at 4:57 PM, Ralf Gommers 
> wrote:
> >
> > On Sun, Nov 1, 2015 at 12:53 AM, Nathaniel Smith  wrote:
> >>
> >> On Oct 31, 2015 4:01 PM, "Ralf Gommers"  wrote:
> >> >
> >> > Hi all,
> >> >
> >> > On Wed, Oct 28, 2015 at 11:48 PM, Ralf Gommers <
> ralf.gomm...@gmail.com>
> >> > wrote:
> >> >>
> >> >>
> >> >> Hi all, there wasn't much feedback on this FSA, but I want to point
> out
> >> >> that it's actually quite important for the project.
> >> >>
> >> >> Maybe everyone already thought about this when the governance model
> was
> >> >> agreed on (it does include a NumFOCUS subcommittee after all), but
> if not:
> >> >> read / think /ask question fast, because we're moving forward with
> signing
> >> >> of the agreement with the people listed at
> >> >>
> http://docs.scipy.org/doc/numpy-dev/dev/governance/people.html#numfocus-subcommittee
> .
> >> >
> >> >
> >> > The document is now signed. No other project with an FSA seems to have
> >> > done this (yet), but I think it would be good to publish the FSA.
> Either on
> >> > numpy.org, scipy.org or numfocus.org. Any objections/concerns about
> that?
> >> >
> >> > +1's from the people that signed would be good to have before moving
> >> > forward.
> >>
> >> +1 from me, with the proviso that most project FSAs probably contain
> >> individual contributor's home addresses, which should be redacted just
> >> in case.
> >
> >
> > Ours doesn't contain any home addressed, and I don't think the ones for
> > other projects do either (didn't check yet).
>
> Yes it does -- one of the things to fill in on the FSA template is the
> "project mailing address", and since most projects don't actually have
> one of those, the advice is to pick some contributor's address and use
> that.


That was pretty well hidden (I searched for "address" and "mailing") but
found it now, thanks. So good point, home addresses will need redacting.

Ralf
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion