On Tue, Jan 19, 2016 at 9:27 AM, Charles R Harris <charlesr.har...@gmail.com > wrote:
> On Tue, Jan 19, 2016 at 9:23 AM, Chris Barker - NOAA Federal < > chris.bar...@noaa.gov> wrote: > >> What does the standard lib do for rand range? I see that randint Is >> closed on both ends, so order doesn't matter, though if it raises for b<a, >> then that's a precedent we could follow. >> > > randint is not closed on the high end. The now deprecated random_integers > is the function that does that. > I was referring to the stdlib randint: In [*7*]: [random.randint(2,5) for i in range(10)] Out[*7*]: [5, 5, 2, 4, 5, 5, 3, 5, 2, 2] thinking that compatibility with that would be good -- but that ship has sailed. randrange is open on the high end, as range is, (duh!) [random.randrange(2,5) for i in range(10)] Out[*9*]: [3, 3, 4, 3, 3, 2, 4, 2, 3, 3] but you get an exception is low >=high: In [*10*]: random.randrange(5,2) ValueError: empty range for randrange() (5,2, -3) I like the exception idea best -- but backward compatibility and all that. -CHB -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion