[Numpy-discussion] Re: feature request: N-D Gaussian function (not random distribution)

2024-07-21 Thread Joseph Fox-Rabinovitz
There's also an implementation in scikit-guess, which I mostly maintain. On Sun, Jul 21, 2024, 00:38 Dom Grigonis wrote: > For statistics functions there is `scipy` package. > > If you are referring to pdf of n-dimensional gaussian distribution, > `scipy.stats.multivariate_normal.pdf` should do

[Numpy-discussion] Re: ndarray shape permutation

2022-05-17 Thread Joseph Fox-Rabinovitz
You could easily write an extension to ndarray that maps axis names to indices and vice versa. Joe On Tue, May 17, 2022, 21:32 Paul Korir wrote: > Thanks for your replies. > > In retrospect, I realise that using the shape will not be helpful for a > cubic array i.e. the permutations of (10, 10,

[Numpy-discussion] Re: Feature query: fetch top/bottom k from array

2022-02-22 Thread Joseph Fox-Rabinovitz
Joe, Could you show an example that you find inelegant and elaborate on how you intend to improve it? It's hard to discuss without more specific information. - Joe On Tue, Feb 22, 2022, 07:23 Joseph Bolton wrote: > Morning, > > My apologies if this deviates from the vision of numpy: > > I find

[Numpy-discussion] Re: Proposal for new function to determine if a float contains an integer

2022-01-02 Thread Joseph Fox-Rabinovitz
number, or -1 if it has a fractional part? Then you could just test something like ``(k := integer_bits(a)) < 64 & k > 0``. - Joe On Sat, Jan 1, 2022 at 5:55 AM Joseph Fox-Rabinovitz < jfoxrabinov...@gmail.com> wrote: > Stefano, > > That is an excellent point. Just to make

[Numpy-discussion] Proposal to add method for string slicing to np.char

2022-01-01 Thread Joseph Fox-Rabinovitz
I made a PR for another new method `np.char.slice_` here: https://github.com/numpy/numpy/pull/20694 Here is an excerpt of the PR message: There are numerous examples of string slicing being a fairly requested feature: - https://stackoverflow.com/q/70547027/2988730 - https://stackoverflow.com/q/3

[Numpy-discussion] Re: Proposal for new function to determine if a float contains an integer

2022-01-01 Thread Joseph Fox-Rabinovitz
Stefano, That is an excellent point. Just to make sure I understand, would an interface like `is_integer(a, int_dtype=None)` be satisfactory? That way, there are no bounds by default (call it python integer bounds), but the user can specify a limited type at will. An alternative would be something

[Numpy-discussion] Re: Proposal for new function to determine if a float contains an integer

2021-12-31 Thread Joseph Fox-Rabinovitz
On Fri, Dec 31, 2021 at 5:46 AM Andras Deak wrote: > On Fri, Dec 31, 2021 at 1:36 AM Joseph Fox-Rabinovitz < > jfoxrabinov...@gmail.com> wrote: > >> Hi, >> >> I wrote a reference implementation for a C ufunc, `isint`, which returns >> True for integers

[Numpy-discussion] Re: Proposal for new function to determine if a float contains an integer

2021-12-30 Thread Joseph Fox-Rabinovitz
t also "np.iinfo(dtype).min <= x > <= np.info(dtype).max" for some particular dtype. i.e. "Can I losslessly > set these values into the array I already have?" > > > > On Thu, Dec 30, 2021 at 4:34 PM Joseph Fox-Rabinovitz < > jfoxrabinov...@gmail.com> wro

[Numpy-discussion] Proposal for new function to determine if a float contains an integer

2021-12-30 Thread Joseph Fox-Rabinovitz
Hi, I wrote a reference implementation for a C ufunc, `isint`, which returns True for integers and False for non-integers, found here: https://github.com/madphysicist/isint_ufunc. The idea came from a Stack Overflow question of mine, which has gotten a fair number of views and even some upvotes: h

[Numpy-discussion] Re: Proposal: Automatic estimation of number of histogram bins for weighted data

2021-12-24 Thread Joseph Fox-Rabinovitz
priate to talk here, let me know. > > On Thu, Dec 23, 2021 at 2:29 PM Joseph Fox-Rabinovitz < > jfoxrabinov...@gmail.com> wrote: > >> For what it's worth, I've looked into this a long time ago. The missing >> ingredient has always been weighted quantiles. If

[Numpy-discussion] Re: Proposal: Automatic estimation of number of histogram bins for weighted data

2021-12-23 Thread Joseph Fox-Rabinovitz
For what it's worth, I've looked into this a long time ago. The missing ingredient has always been weighted quantiles. If I'm not mistaken, the interface already exists, but raises an error. I've had it on my back burner to provide an O(n) C implementation of weighted introselect, but never quite g

[Numpy-discussion] Re: What happened to the numpy.random documentation?

2021-10-14 Thread Joseph Fox-Rabinovitz
I second that reinstating such a list would be extremely useful. My issue has been with the polynomial package, but the end result is the same. - Joe On Thu, Oct 14, 2021, 12:45 Melissa Mendonça wrote: > Hi Paul, > > Do you think having a page with the flat list of routines back, in > addition

Re: [Numpy-discussion] Expanding the scope of numpy.unpackbits and numpy.packbits to include more than uint8 type

2021-03-29 Thread Joseph Fox-Rabinovitz
You can view any array as uint8 On Mon, Mar 29, 2021, 14:27 Rashiq Azhan wrote: > I would like this feature to be added since I think it can very useful > when there is a need to process data that cannot be included in uint8. > One of my personal requirements is modifying a 10-bit, per channel,

Re: [Numpy-discussion] ENH: Proposal to add atleast_nd function

2021-02-16 Thread Joseph Fox-Rabinovitz
I'm getting a generally lukewarm not negative response. Should we put it to a vote? - Joe On Fri, Feb 12, 2021, 16:06 Robert Kern wrote: > On Fri, Feb 12, 2021 at 3:42 PM Ralf Gommers > wrote: > >> >> On Fri, Feb 12, 2021 at 9:21 PM Robert Kern >> wrote: >> >>> On Fri, Feb 12, 2021 at 1:47 PM

Re: [Numpy-discussion] ENH: Proposal to add atleast_nd function

2021-02-12 Thread Joseph Fox-Rabinovitz
On Fri, Feb 12, 2021, 09:32 Robert Kern wrote: > On Fri, Feb 12, 2021 at 5:15 AM Eric Wieser > wrote: > >> > There might be some linear algebraic reason why those axis positions >> make sense, but I’m not aware of it... >> >> My guess is that the historical motivation was to allow grayscale `(H,

Re: [Numpy-discussion] ENH: Proposal to add atleast_nd function

2021-02-11 Thread Joseph Fox-Rabinovitz
-cases for this new function? >> Have any libraries building on top of NumPy implemented a version of this? >> >> >>> Juan. >>> >>> On 11 Feb 2021, at 9:48 am, Sebastian Berg >>> wrote: >>> >>> On Wed, 2021-02-10 at 17:31 -0500, Jose

[Numpy-discussion] ENH: Proposal to add atleast_nd function

2021-02-10 Thread Joseph Fox-Rabinovitz
I've created PR#18386 to add a function called atleast_nd to numpy and numpy.ma. This would generalize the existing atleast_1d, atleast_2d, and atleast_3d functions. I proposed a similar idea about four and a half years ago: https://mail.python.org/pipermail/numpy-discussion/2016-July/075722.html,

Re: [Numpy-discussion] How to speed up array generating

2021-01-09 Thread Joseph Fox-Rabinovitz
What other ways have you tried? On Sat, Jan 9, 2021 at 2:15 PM wrote: > Hello. There is a random 1D array m_0 with size 3000, for example: > > m_0 = np.array([0, 1, 2]) > > I need to generate two 1D arrays: > > m_1 = np.array([0, 1, 2, 0, 1, 2, 0, 1, 2]) > m_2 = np.array([0, 0, 0, 1, 1, 1, 2, 2,

Re: [Numpy-discussion] Optimized np.digitize for equidistant bins

2020-12-18 Thread Joseph Fox-Rabinovitz
There is: np.floor_divide. On Fri, Dec 18, 2020, 14:38 Martín Chalela wrote: > Right! I just thought there would/should be a "digitize" function that did > this. > > El vie, 18 dic 2020 a las 14:16, Joseph Fox-Rabinovitz (< > jfoxrabinov...@gmail.com>) escribi

Re: [Numpy-discussion] Optimized np.digitize for equidistant bins

2020-12-18 Thread Joseph Fox-Rabinovitz
Bin index is just value floor divided by the bin size. On Fri, Dec 18, 2020, 09:59 Martín Chalela wrote: > Hi all! I was wondering if there is a way around to using np.digitize when > dealing with equidistant bins. For example: > bins = np.linspace(0, 1, 20) > > The main problem I encountered is

Re: [Numpy-discussion] introducing autoreg and autoregnn

2020-06-05 Thread Joseph Fox-Rabinovitz
Rondall, Are you familiar with the lmfit project? I am not an expert, but it seems like your algorithms may be useful there. I recommend checking with Matt Newville via the mailing list. Regards, Joe On Fri, Jun 5, 2020, 17:00 Ralf Gommers wrote: > > > On Fri, Jun 5, 2020 at 9:48 PM rondall

[Numpy-discussion] PR 14966: Adding a new argument to np.asfarray

2019-11-22 Thread Joseph Fox-Rabinovitz
Hi, I've submitted PR #14966, which makes a couple of small, backward compatible, changes to the API of `asfarray`: 1. Added `copy` parameter that defaults to `False` 2. Added `None` option to the `dtype` parameter Item #1 is inspired by situations like the one in Stack Overflow question https:/

[Numpy-discussion] ENH: Added option to suppress stout/err capture in tests PR #12829

2019-01-22 Thread Joseph Fox-Rabinovitz
Hi, I recently had some issues setting up gdb to fix some self-inflicted segfaults, so instead I ended up adding an option to suppress stdout/stderr capture by pytest in PR#12829. I think this is a useful feature to have in general, so I made this PR. The only problem with it is that there are no

[Numpy-discussion] DOC: Updates to nditer usage instructions PR#12828

2019-01-22 Thread Joseph Fox-Rabinovitz
Hi, I have just added PR #12828, based off issue #12764 to clarify some of the documentation of `nditer`. While it contains most of the necessary material, it's still a bit of a rough draft, and I'd be happy to have some comments/advice on it. In particular, I didn't know how much to emphasize th

Re: [Numpy-discussion] Depreciating asfortranarray and ascontiguousarray

2018-10-25 Thread Joseph Fox-Rabinovitz
In that vein, would it be advisable to re-implement them as aliases for the correctly behaving functions instead? - Joe On Thu, Oct 25, 2018 at 5:01 PM Joe Kington wrote: > For what it's worth, these are fairly widely used functions. From a user > standpoint, I'd gently argue against deprecati

Re: [Numpy-discussion] PR Cleanup

2018-09-25 Thread Joseph Fox-Rabinovitz
I think that PRs 7804 and 10855 can be merged (or closed; closure either way). 7804: ENH: Added atleast_nd This has been ready to go for a while. It was deemed superfluous at one point, but then experienced a revival, which ended up stagnating. 10855: ENH: Adding a count parameter to np.unpack

Re: [Numpy-discussion] Short-circuiting equivalent of np.any or np.all?

2018-04-26 Thread Joseph Fox-Rabinovitz
Would it be useful to have a short-circuited version of the function that is not a ufunc? - Joe On Thu, Apr 26, 2018 at 12:51 PM, Hameer Abbasi wrote: > Hi Nathan, > > np.any and np.all call np.or.reduce and np.and.reduce respectively, and > unfortunately the underlying function (ufunc.reduce)

Re: [Numpy-discussion] Adding a return value to np.random.shuffle

2018-04-12 Thread Joseph Fox-Rabinovitz
Agreed. I closed the PR. - Joe On Thu, Apr 12, 2018 at 4:24 PM, Alan Isaac wrote: > Some people consider that not to be Pythonic: > https://mail.python.org/pipermail/python-dev/2003-October/038855.html > > Alan Isaac > > On 4/12/2018 1:36 PM, Joseph Fox-Rabinovitz wrote: &

Re: [Numpy-discussion] Adding a return value to np.random.shuffle

2018-04-12 Thread Joseph Fox-Rabinovitz
Sounds good. I will close the PR. - Joe On Thu, Apr 12, 2018 at 1:54 PM, Sebastian Berg wrote: > On Thu, 2018-04-12 at 13:36 -0400, Joseph Fox-Rabinovitz wrote: > > Would it break backwards compatibility to add the input as a return > > value to np.random.shuffle? I doubt anyo

[Numpy-discussion] Adding a return value to np.random.shuffle

2018-04-12 Thread Joseph Fox-Rabinovitz
Would it break backwards compatibility to add the input as a return value to np.random.shuffle? I doubt anyone out there is relying on the None return value. The change is trivial, and allows shuffling a new array in one line instead of two: x = np.random.shuffle(np.array(some_junk)) I've im

[Numpy-discussion] ENH: Adding a count parameter to np.unpackbits

2018-04-07 Thread Joseph Fox-Rabinovitz
Hi, I have added PR #10855 to allow unpackbits to unpack less than the entire set of bits. This is not a very big change, and 100% backwards compatible. It serves two purposes: 1. To make packbits and unpackbits completely invertible (and prevent things like this from being necessary: https://sta

[Numpy-discussion] Possible bug in np.array type calculation

2018-04-03 Thread Joseph Fox-Rabinovitz
I recently asked a question on Stack Overflow about whether `np.array` could raise an error if not passed a dtype parameter: https://stackoverflow.com/q/49639414/2988730. Turns out it can: np.array([1, [2]]) raises `ValueError: setting an array element with a sequence.` Surprisingly though,

[Numpy-discussion] PR adding support for object arrays to np.isinf, np.isnan, np.isfinite

2018-03-28 Thread Joseph Fox-Rabinovitz
I have opened PR #10820 to add support for `dtype=object` to `np.isinf`, `np.isnan`, `np.isfinite`. The PR is a fairly minor change, but I would like to make sure that I understand at least the basics of ufuncs before I start adding support for datetimes and timedeltas to `np.isfinite` and eventual

Re: [Numpy-discussion] best way of speeding up a filtering-like algorithm

2018-03-28 Thread Joseph Fox-Rabinovitz
It looks like you are creating a coastline mask (or a coastline mask + some other mask), and computing the ratio of two quantities in a particular window around each point. If your coastline covers a sufficiently large portion of the image, you may get quite a bit of mileage using an efficient conv

Re: [Numpy-discussion] Sorting of an array row-by-row?

2017-10-20 Thread Joseph Fox-Rabinovitz
dea to keep > then right-to-left? How does this relate to lexicographic order? > > 2017-10-20 17:11 GMT+03:00 Joseph Fox-Rabinovitz : >> >> There are two mistakes in your PS. The immediate error comes from the >> fact that lexsort accepts an iterable of 1D arrays, so w

Re: [Numpy-discussion] Sorting of an array row-by-row?

2017-10-20 Thread Joseph Fox-Rabinovitz
There are two mistakes in your PS. The immediate error comes from the fact that lexsort accepts an iterable of 1D arrays, so when you pass in arr as the argument, it is treated as an iterable over the rows, each of which is 1D. 1D arrays do not have an axis=1. You actually want to iterate over the

Re: [Numpy-discussion] Sustainability

2017-10-04 Thread Joseph Fox-Rabinovitz
Could you elaborate on the purpose of the meeting, or perhaps point to a link with a description if there is one? Sustainability is a very broad topic. What do you plan on discussing? -Joe On Tue, Oct 3, 2017 at 7:04 PM, Charles R Harris wrote: > Hi All, > > I and a number of others represen

[Numpy-discussion] ENH: Proposal to add np.neighborwise in PR#9514

2017-08-04 Thread Joseph Fox-Rabinovitz
I would like to propose the addition of a new function, `np.neighborwise` in PR#9514. It is based on the discussion relating to my proposal for `np.ratio` (PR#9481) and Eric Wieser's `np.neighborwise` in PR#9428. This function accepts an array `a`, a vectorized function of two arguments `func`, and

Re: [Numpy-discussion] quantile() or percentile()

2017-08-04 Thread Joseph Fox-Rabinovitz
On Thu, Aug 3, 2017 at 11:10 AM, Joseph Fox-Rabinovitz > wrote: >> >> Not that I know of. The algorithm is very simple, requiring a >> relatively small addition to the current introselect algorithm used >> for `np.partition`. My biggest hurdle is figuring out how the c

Re: [Numpy-discussion] quantile() or percentile()

2017-08-03 Thread Joseph Fox-Rabinovitz
p.argsort because it was familiar to >> me. Didn't know about the C code. >> >> On Fri, Jul 21, 2017 at 3:43 PM, Joseph Fox-Rabinovitz >> wrote: >>> >>> While #9211 is a good start, it is pretty inefficient in terms of the >>> fact that it perf

Re: [Numpy-discussion] ENH: ratio function to mimic diff

2017-07-29 Thread Joseph Fox-Rabinovitz
ld have to take in some domain filter, like many of the translated masked functions do. A ufunc could provide that transparently. -n On Jul 28, 2017 3:25 PM, "Joseph Fox-Rabinovitz" wrote: > I have created PR#9481 to introduce a `ratio` function that behaves very > similarly to

Re: [Numpy-discussion] ENH: ratio function to mimic diff

2017-07-29 Thread Joseph Fox-Rabinovitz
easy, and I added an argument to flag actual zeros. On Fri, Jul 28, 2017 at 3:25 PM Joseph Fox-Rabinovitz < jfoxrabinov...@gmail.com> wrote: > I have created PR#9481 to introduce a `ratio` function that behaves very > similarly to `diff`, except that it divides successive elements inste

[Numpy-discussion] ENH: ratio function to mimic diff

2017-07-28 Thread Joseph Fox-Rabinovitz
I have created PR#9481 to introduce a `ratio` function that behaves very similarly to `diff`, except that it divides successive elements instead of subtracting them. It has some handling built in for zero division, as well as the ability to select between `/` and `//` operators. There is currently

Re: [Numpy-discussion] quantile() or percentile()

2017-07-21 Thread Joseph Fox-Rabinovitz
Fri, Jul 21, 2017 at 5:34 PM, Chun-Wei Yuan wrote: > Just to provide some context, 9213 actually spawned off of this guy: > > https://github.com/numpy/numpy/pull/9211 > > which might address the weighted inputs issue Joe brought up. > > C > > On Fri, Jul 21, 2017 at 2:2

Re: [Numpy-discussion] quantile() or percentile()

2017-07-21 Thread Joseph Fox-Rabinovitz
I think that there would be a very good reason to have a separate function if we were to introduce weights to the inputs, similarly to the way that we have mean and average. This would have some (positive) repercussions like making weighted histograms with the Freedman-Diaconis binwidth estimator a

Re: [Numpy-discussion] Array blitting (pasting one array into another)

2017-06-30 Thread Joseph Fox-Rabinovitz
PM, Mikhail V wrote: > On 30 June 2017 at 03:34, Joseph Fox-Rabinovitz > wrote: > > This is a useful idea certainly. I would recommended extending it to an > > arbitrary number of axes. You could either raise an error if the ndim of > the > > two arrays are unequal

Re: [Numpy-discussion] Array blitting (pasting one array into another)

2017-06-29 Thread Joseph Fox-Rabinovitz
This is a useful idea certainly. I would recommended extending it to an arbitrary number of axes. You could either raise an error if the ndim of the two arrays are unequal, or allow a broadcast of a lesser ndimmed src array. - Joe On Jun 29, 2017 20:17, "Mikhail V" wrote: > Hello all > > I ofte