> +    # Clone the input lists to prevent side effects to the parameter lists:
> +    condlist = list(condlist)
> +    choicelist = list(choicelist)

This is close to free and generally a good idea in case the
implementation changes later and someone is careless. It is unrelated
to the deprecated code. I don't understand your comment.

> +
> +    # Check that the inputs are acceptable.
> +
> +    # Check the size of condlist and choicelist are the same, or abort.
> +    if len(condlist) != len(choicelist):
> +        raise ValueError('list of cases must be same length as list of conditions')

Similarly,

1. This is a quick test.

2. The select function doesn't make sense when the choice/condition
lists are different lengths, it's important to check this.

3. It's also very useful in practice to help people avoid programming
mistakes when the input lists are of slightly different sizes, an
error that might not be detected visually and might have subtle
consequences.

My own view is that it's also a cheap and valuable safety net that has
nothing to do with handling the to-be-deprecated quirks of
np.select(); again I don't understand your comment.


Cheap sanity/safety checks on function entry are a good thing imho.





On Tue, Oct 1, 2013 at 11:14 PM, Graeme Bell <graeme.b.bell@gmail.com>wrote:

> > +    # If condlist/choicelist are empty, return the default value immediately.
> > +    if len(condlist)==0:
> > +        return np.array([])
> > +
>
>
> This catches a case that was mis-handled by the old implementation; it returned a shape/value that was not specified in choicelist or default, breaking from the spec.
>
>
>
> On Tue, Oct 1, 2013 at 11:09 PM, seberg <notifications@github.com> wrote:
>
>> In numpy/lib/function_base.py:
>>
>> > +
>> > +    # Clone the input lists to prevent side effects to the parameter lists:
>> > +    condlist = list(condlist)
>> > +    choicelist = list(choicelist)
>> > +
>> > +    # Check that the inputs are acceptable.
>> > +
>> > +    # Check the size of condlist and choicelist are the same, or abort.
>> > +    if len(condlist) != len(choicelist):
>> > +        raise ValueError('list of cases must be same length as list of conditions')
>> > +
>> > +    # If condlist/choicelist are empty, return the default value immediately.
>> > +    if len(condlist)==0:
>> > +        return np.array([])
>> > +
>> > +    # If cond array is not an ndarray in boolean format or scalar bool, abort.
>>
>> OK, maybe note that the whole code block can be removed after deprecation.
>>
>> —
>> Reply to this email directly or view it on GitHub<https://github.com/numpy/numpy/pull/3537/files#r6699732>
>> .
>>
>
>