On Mon, Dec 10, 2018 at 9:26 AM Stephan Hoyer <sho...@gmail.com> wrote:

> On Mon, Dec 10, 2018 at 8:26 AM Alan Isaac <alan.is...@gmail.com> wrote:
>
>> On 12/10/2018 11:20 AM, Ralf Gommers wrote:
>> > there is nothing wrong with the current API
>>
>> Just to be clear: you completely reject the past
>> cautions on this list against creating APIs
>> with flag parameters.  Is that correct?
>>
>> Or is "nothing wrong" just a narrow approval in
>> this particular case?
>
>
> I agree with you that numpy.random.sample is redundant, that APIs based on
> flags are generally poorly design
>

That argument is for things like 3 boolean variables that together create 8
states. It then becomes hard to spot bugs like 1 of the 8 cases not being
handled or not being well-defined. In this case, the meaning is clear and
imho the API is better like this then if we'd create two almost identical
functions.

and that all things being equal it would be desirable for NumPy and
> Python's standard library to be aligned.
>
> That said, "replacing a function/parameter with something totally
> different by the same name" is a really painful/slow deprecation process
> that is best avoided if at all possible in mature projects.
>

+1


> Personally, I would be +1 for issuing a deprecation warning for
> np.random.sample, and removing it after a good amount of notice (maybe
> several years). This is a similar deprecation cycle to what you see in
> Python itself (e.g., for ABCs in collections vs collections.abc). If you
> look at NumPy's docs for "Simple random data" [1] we have four different
> names for this same function ("random_sample", "random", "ranf" and
> "sample"), which is frankly absurd. Some cleanup is long overdue.
>

These aliases have always been there, since before 2005:
https://github.com/numpy/numpy/commit/9338dea9. Deprecating some of those
seems fine to me, `ranf` is a really bad name, and `random` is too. I don't
see a good reason to remove `sample` and `random_sample`; they're sane
names, the function is not buggy, and it just seems like bothering our
users for no good reason.

Cheers,
Ralf



> But we should be extremely hesitant to actually reuse these names for
> something else. People depend on NumPy for stability, and there is plenty
> of code written against NumPy from five years ago that still runs just fine
> today. It's one thing to break code noisily by removing a function, but if
> there's any chance of introducing silent errors that would be inexcusable.
>
> Best,
> Stephan
>
> [1]
> https://docs.scipy.org/doc/numpy-1.15.0/reference/routines.random.html#simple-random-data
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

Reply via email to