[Numpy-discussion] Set #threads from within python code

2017-03-24 Thread Neal Becker
I don't want my python code to run multi-thread. So I can do: MKL_NUM_THREAD=1 NUMEXPR_NUM_THREADS=1 OMP_NUM_THREADS=1 my_program... But I don't seem to be able to achieve this effect without setting env variables on the command line; within my_program. Using os.environ doesn't work. I don't u

Re: [Numpy-discussion] Set #threads from within python code

2017-03-24 Thread Neal Becker
Ah, that probably explains it! On Fri, Mar 24, 2017 at 7:37 AM Daπid wrote: > On 24 March 2017 at 12:30, Neal Becker wrote: > > Using os.environ doesn't > > work. I don't understand why. > > It should, I do that for other variables. Are you setting the >

Re: [Numpy-discussion] speed of random number generator compared to Julia

2017-04-03 Thread Neal Becker
Take a look here: https://bashtage.github.io/ng-numpy-randomstate/doc/index.html On Mon, Apr 3, 2017 at 9:45 AM Jaime Fernández del Río wrote: > On Mon, Apr 3, 2017 at 3:20 PM, Pierre Haessig > wrote: > > Hello, > Le 30/03/2017 à 13:31, Pierre Haessig a écrit : > > [] > > But how come Julia

Re: [Numpy-discussion] speed of random number generator compared to Julia

2017-04-03 Thread Neal Becker
I think the intention is that this is the next gen of numpy randomstate, and will eventually be merged in. On Mon, Apr 3, 2017 at 11:47 AM Pierre Haessig wrote: > > Le 03/04/2017 à 15:52, Neal Becker a écrit : > > Take a look here: > > https://bashtage.github.io/ng-num

Re: [Numpy-discussion] proposal: smaller representation of string arrays

2017-04-20 Thread Neal Becker
I'm no unicode expert, but can't we truncate unicode strings so that only valid characters are included? On Thu, Apr 20, 2017 at 1:32 PM Chris Barker wrote: > On Thu, Apr 20, 2017 at 9:47 AM, Anne Archibald > wrote: > >> Is there any reason not to support all Unicode encodings that python >> do

Re: [Numpy-discussion] proposal: smaller representation of string arrays

2017-04-27 Thread Neal Becker
So while compression+ucs-4 might be OK for out-of-core representation, what about in-core? blosc+ucs-4? I don't think that works for mmap, does it? On Thu, Apr 27, 2017 at 7:11 AM Francesc Alted wrote: > 2017-04-27 3:34 GMT+02:00 Stephan Hoyer : > >> On Wed, Apr 26, 2017 at 4:49 PM, Nathaniel

[Numpy-discussion] Interface numpy arrays to Matlab?

2017-08-28 Thread Neal Becker
I've searched but haven't found any decent answer. I need to call Matlab from python. Matlab has a python module for this purpose, but it doesn't understand numpy AFAICT. What solutions are there for efficiently interfacing numpy arrays to Matlab? Thanks, Neal __

Re: [Numpy-discussion] Interface numpy arrays to Matlab?

2017-08-29 Thread Neal Becker
it a try myself, but it looks promising. >> >> On Mon, Aug 28, 2017 at 4:21 PM, Stephan Hoyer wrote: >> >>> If you can use Octave instead of Matlab, I've had a very good experience >>> with Oct2Py: >>> https://github.com/blink1073/oct2py >>> &g

Re: [Numpy-discussion] Moving NumPy's PRNG Forward

2018-01-20 Thread Neal Becker
On Fri, Jan 19, 2018 at 6:13 PM Nathaniel Smith wrote: > ... > I agree that relaxing our policy would be better than the status quo. > Before making any decisions, though, I'd like to make sure we > understand the alternatives and their trade-offs. Specifically, I > think the main alternative

Re: [Numpy-discussion] Prototype CorePRNG implementation feedback

2018-02-22 Thread Neal Becker
What is the syntax to construct an initialized generator? RandomGenerator(Xoroshiro128(my_seed))? On Thu, Feb 22, 2018 at 6:06 AM Kevin Sheppard wrote: > I have implemented a working prototype of a pluggable RandomState. The > repo is located at https://github.com/bashtage/core-prng. > > The ma

[Numpy-discussion] update to numpy-1.5.0 gives new warnings from scipy

2018-07-25 Thread Neal Becker
After update to numpy-1.5.0, I'm getting warnings from scipy. These probably come from my code using convolve. Does scipy need updating? /home/nbecker/.local/lib/python3.6/site-packages/scipy/fftpack/basic.py:160: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecat

Re: [Numpy-discussion] Add pybind11 to docs about writing binding code

2018-08-17 Thread Neal Becker
The only way I've seen xtensor used is *with* pybind11 On Fri, Aug 17, 2018 at 5:45 PM Robert Kern wrote: > On Fri, Aug 17, 2018 at 2:00 AM Hans Dembinski > wrote: > >> Hi Sylvain, >> >> On 16. Aug 2018, at 13:29, Sylvain Corlay >> wrote: >> >> Actually, xtensor-python does a lot more in terms

Re: [Numpy-discussion] Add pybind11 to docs about writing binding code

2018-08-20 Thread Neal Becker
I'm confused, do you have a link or example showing how to use xtensor-python without pybind11? Thanks, Neal On Mon, Aug 20, 2018 at 5:50 PM Hans Dembinski wrote: > Dear Robert, > > > On 17. Aug 2018, at 23:44, Robert Kern wrote: > > > > Even if you don't use the numpy-mimicking parts of the xt

Re: [Numpy-discussion] Ia `-fno-strict-aliasing` still required?

2019-01-04 Thread Neal Becker
Define "doing fine", does it pass all tests? On Fri, Jan 4, 2019 at 12:36 PM Charles R Harris wrote: > Hi All, > > Just asking if the `-fno-strict-aliasing` flag is still required for gcc. > Supposedly `-fstrict-aliasing` is enabled by default with optimization > levels >= `-O2` and that used to

Re: [Numpy-discussion] Add guaranteed no-copy to array creation and reshape?

2019-01-10 Thread Neal Becker
constants are easier to support for autocompletion than strings. My current env (emacs) will (usually) autocomplete the former, but not the latter. On Thu, Jan 10, 2019 at 2:21 PM Feng Yu wrote: > Hi Todd, > > I agree a flag is more suitable than classes. > > I would add another bonus of a flag

Re: [Numpy-discussion] overhauling numpy.random and randomgen Message-ID:

2019-04-19 Thread Neal Becker
The boost_random c++ library uses the terms 'generators' and 'distributions'. Distributions are applied to generators. On Fri, Apr 19, 2019 at 7:54 AM Kevin Sheppard wrote: > > > Rather than "base RNG", what about calling these classes a "random source" > or "random stream"? In particular, I wo

Re: [Numpy-discussion] Moving forward with value based casting

2019-06-07 Thread Neal Becker
On Wed, Jun 5, 2019 at 4:42 PM Sebastian Berg wrote: I think the best approach is that if the user gave unambiguous types as inputs to operators then the output should be the same dtype, or type corresponding to the common promotion type of the inputs. If the input type is not specified, I agree

[Numpy-discussion] float16 but no complex32?

2019-07-11 Thread Neal Becker
I see a float16 dtype but not complex32. Is this an oversight? Thanks, Neal -- Those who don't understand recursion are doomed to repeat it ___ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-di

Re: [Numpy-discussion] Low-level API for Random

2019-09-20 Thread Neal Becker
I have used C-api in the past, and would like to see a convenient and stable way to do this. Currently I'm using randomgen, but calling (from c++) to the python api. The inefficiency is amortized by generating and caching batches of results. I thought randomgen was supposed to be the future of n

Re: [Numpy-discussion] Low-level API for Random

2019-09-20 Thread Neal Becker
Matti Picus wrote: > > On 20/9/19 2:18 pm, Neal Becker wrote: > > I have used C-api in the past, and would like to see a convenient and > > stable way to do this. Currently I'm using randomgen, but calling > > (from c++) > > to the python api. The inefficiency is

Re: [Numpy-discussion] argmax() indexes to value

2019-10-30 Thread Neal Becker
max(axis=1)? On Wed, Oct 30, 2019, 7:33 PM Daniele Nicolodi wrote: > Hello, > > this is a very basic question, but I cannot find a satisfying answer. > Assume a is a 2D array and that I get the index of the maximum value > along the second dimension: > > i = a.argmax(axis=1) > > Is there a bette

Re: [Numpy-discussion] manylinux upgrade for numpy wheels

2020-02-06 Thread Neal Becker
Slightly off topic perhaps, it is recommended to perform custom compilation for best performance, yet is there an easy way to do this? I don't think a simple pip will do. On Wed, Feb 5, 2020 at 4:07 AM Matthew Brett wrote: > Hi, > > On Tue, Feb 4, 2020 at 10:38 PM Nathaniel Smith wrote: > > >

Re: [Numpy-discussion] Tensor Developer Summit

2020-02-19 Thread Neal Becker
Stefan van der Walt wrote: > Hi all, > > This has been mentioned on the community calls, but not on the mailing > list, so a reminder about the Tensor Developer Summit happening at March > in Berkeley: > > https://xd-con.org/tensor-2020/ > > We would love to have developers and advanced users o

[Numpy-discussion] reseed random generator (1.19)

2020-06-24 Thread Neal Becker
Consider the following: from numpy.random import default_rng rs = default_rng() Now how do I re-seed the generator? I thought perhaps rs.bit_generator.seed(), but there is no such attribute. Thanks, Neal -- *Those who don't understand recursion are doomed to repeat it*

Re: [Numpy-discussion] Numpy FFT normalization options issue (addition of new option)

2020-06-28 Thread Neal Becker
Honestly, I don't find "forward" very informative. There isn't any real convention on whether FFT of IFFT have any normalization. To the best of my experience, either forward or inverse could be normalized by 1/N, or each normalized by 1/sqrt(N), or neither could be normalized. I will say my expe

Re: [Numpy-discussion] reseed random generator (1.19)

2020-06-29 Thread Neal Becker
I was using this to reset the generator, in order to repeat the same sequence again for testing purposes. On Wed, Jun 24, 2020 at 6:40 PM Robert Kern wrote: > On Wed, Jun 24, 2020 at 3:31 PM Neal Becker wrote: > >> Consider the following: >> >> from numpy.random

Re: [Numpy-discussion] reseed random generator (1.19)

2020-07-04 Thread Neal Becker
On Sat, Jul 4, 2020 at 1:56 PM Robert Kern wrote: > > 3. Is there a way of telling the number of draws a generator did? >> >> The use case is to checkpoint the number of draws and `.advance` the >> bit generator when resuming from the checkpoint. (The runs are longer >> then the batch queue

[Numpy-discussion] C-coded dot 1000x faster than numpy?

2021-02-23 Thread Neal Becker
I have code that performs dot product of a 2D matrix of size (on the order of) [1000,16] with a vector of size [1000]. The matrix is float64 and the vector is complex128. I was using numpy.dot but it turned out to be a bottleneck. So I coded dot2x1 in c++ (using xtensor-python just for the inter

Re: [Numpy-discussion] C-coded dot 1000x faster than numpy?

2021-02-23 Thread Neal Becker
ou install numpy from conda-forge you should be able to > switch between OpenBLAS, MKL and BLIS: > https://conda-forge.org/docs/maintainer/knowledge_base.html#switching-blas-implementation > > Roman > > On 23/02/2021 19:32, Andrea Gavana wrote: > > Hi, > > > > On

Re: [Numpy-discussion] C-coded dot 1000x faster than numpy?

2021-02-23 Thread Neal Becker
las. On Tue, Feb 23, 2021 at 1:51 PM Neal Becker wrote: > > One suspect is that it seems the numpy version was multi-threading. > This isn't useful here, because I'm running parallel monte-carlo > simulations using all cores. Perhaps this is perversely slowing > things d

Re: [Numpy-discussion] C-coded dot 1000x faster than numpy?

2021-02-24 Thread Neal Becker
>> >> >> >> On Tue, Feb 23, 2021 at 11:10 AM Neal Becker wrote: >>> >>> I have code that performs dot product of a 2D matrix of size (on the >>> order of) [1000,16] with a vector of size [1000]. The matrix is >>> float64 and the ve

Re: [Numpy-discussion] C-coded dot 1000x faster than numpy?

2021-02-24 Thread Neal Becker
Supposedly can control through env variables but I didn't see any effect On Wed, Feb 24, 2021, 10:12 AM Charles R Harris wrote: > > > On Wed, Feb 24, 2021 at 8:02 AM Charles R Harris < > charlesr.har...@gmail.com> wrote: > >> >> >> On Wed, Feb 24, 20

[Numpy-discussion] Pi day easter egg

2021-03-14 Thread Neal Becker
There's a little pi day easter egg for all math fans. Google for pi to find it. ___ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion

[Numpy-discussion] Indexing question

2021-05-20 Thread Neal Becker
This seems like something that can be done with indexing, but I haven't found the solution. out is a 2D array is initialized to zeros. x is a 1D array whose values correspond to the columns of out. For each row in out, set out[row,x[row]] = 1. Here is working code: def orthogonal_mod (x, nbits)

Re: [Numpy-discussion] Indexing question

2021-05-20 Thread Neal Becker
Thanks! On Thu, May 20, 2021 at 9:53 AM Robert Kern wrote: > > On Thu, May 20, 2021 at 9:47 AM Neal Becker wrote: >> >> This seems like something that can be done with indexing, but I >> haven't found the solution. >> >> out is a 2D array is ini

Re: [Numpy-discussion] EHN: Discusions about 'add numpy.topk'

2021-05-30 Thread Neal Becker
Topk is a bad choice imo. I initially parsed it as to_pk, and had no idea what that was, although sounded a lot like a scipy signal function. Nlargest would be very obvious. On Sun, May 30, 2021, 7:50 AM Alan G. Isaac wrote: > Mathematica and Julia both seem relevant here. > Mma has TakeLargest

[Numpy-discussion] Add count (and dtype) to packbits

2021-07-21 Thread Neal Becker
In my application I need to pack bits of a specified group size into integral values. Currently np.packbits only packs into full bytes. For example, I might have a string of bits encoded as a np.uint8 vector with each uint8 item specifying a single bit 1/0. I want to encode them 4 bits at a time i

Re: [Numpy-discussion] Add count (and dtype) to packbits

2021-07-21 Thread Neal Becker
Well that's just the point, I wanted to consider group size > 8. On Wed, Jul 21, 2021 at 8:53 AM Andras Deak wrote: > > On Wed, Jul 21, 2021 at 2:40 PM Neal Becker wrote: >> >> In my application I need to pack bits of a specified group size into >> integral value

[Numpy-discussion] Re: A bite of C++

2021-09-29 Thread Neal Becker
A couple of questions from a quick casual reading 1. radixsort (void *start...) Do we really need void*? We don't know the type of start at compile time? 2. reinterpret_cast start (related to #1). 3. reinterpret_cast(malloc(num * sizeof(T))); A C-ism. Would it work to use new T[num]? On Tue,

[Numpy-discussion] Re: Code formatters

2021-11-14 Thread Neal Becker
I've also used uncrustify for c/c++. Of course this plays hell with revision control. On Sun, Nov 14, 2021 at 6:29 PM Juan Nunez-Iglesias wrote: > > > > On 15 Nov 2021, at 8:23 am, Stefan van der Walt wrote: > > On Sun, Nov 14, 2021, at 09:13, Charles R Harris wrote: > > The black formatter is

[Numpy-discussion] Re: Exporting numpy arrays to binary JSON (BJData) for better portability

2022-08-25 Thread Neal Becker
> > > the loading time (from an nvme drive, Ubuntu 18.04, python 3.6.9, numpy > 1.19.5) for each file is listed below: > > 0.179s eye1e4.npy (mmap_mode=None) > 0.001s eye1e4.npy (mmap_mode=r) > 0.718s eye1e4_bjd_raw_ndsyntax.jdb > 1.474s eye1e4_bjd_zlib.jdb > 0.635s eye1e4_bjd_lzma.jdb > > > c

[Numpy-discussion] broadcasting question

2023-03-22 Thread Neal Becker
I have a function F def F(a, b): c = a * b Initially, a is a scalar, b[240,3000]. No problem. Later I want to use F, where a[240] is a vector. I want to allow both the scalar and vector cases. So I write: def F(a,b): a = np.atleast_1d(a) c = a[:,None] * b This now works for scalar a o

[Numpy-discussion] Re: broadcasting question

2023-03-23 Thread Neal Becker
On Thu, Mar 23, 2023 at 5:21 AM Sebastian Berg wrote: > On Wed, 2023-03-22 at 12:00 -0400, Robert Kern wrote: > > On Wed, Mar 22, 2023 at 9:34 AM Neal Becker > > wrote: > > > > > I have a function F > > > def F(a, b): > > > c = a * b > &

[Numpy-discussion] Re: mean_std function returning both mean and std

2023-07-06 Thread Neal Becker
On a somewhat related note, I usually find I need to compute stats incrementally. To do this, a stat object is created so batches of samples can be fed to it sequentially. I used to use an implementation based on boost::accumulator for this. More recently I'm using my own c++ code based on xtens

[Numpy-discussion] Re: Function that searches arrays for the first element that satisfies a condition

2023-11-01 Thread Neal Becker
Thanks Juan, this is really great! I plan to make use of this right away. On Wed, Nov 1, 2023 at 8:13 AM Juan Nunez-Iglesias wrote: > Have you tried timing things? Thankfully this is easy to test because the > Python source of numba-jitted functions is available at jitted_func.py_func. > > In [

[Numpy-discussion] Re: Change definition of complex sign (and use it in copysign)

2023-12-22 Thread Neal Becker
In my opinion, with the caveat that anyone that asks for the sign of a complex number gets what they deserve, this seems about as useful a definition as any. On Fri, Dec 22, 2023 at 8:23 AM wrote: > Hi All, > > A long-standing, small wart in numpy has been that the definition of sign > for compl

[Numpy-discussion] argmin of empty masked sequence not correctly handled (returns 0)

2024-01-05 Thread Neal Becker
argmin of an empty sequence throws an exception, which I think is a good thing: np.argmin([]) --- ValueError But not for a masked array: n [24]: u = np.arange (10) In [25]: v = np.ma.array (u, mask=np.ones(10)) In [26]: v

[Numpy-discussion] Re: Original seed of a BitGenerator

2024-08-02 Thread Neal Becker
On Fri, Aug 2, 2024 at 9:37 AM Robert Kern wrote: > On Fri, Aug 2, 2024 at 1:28 AM Andrew Nelson wrote: > >> When using the new `Generator`s for stochastic optimisation I sometimes >> find myself possessing a great solution, but am wondering what path the >> random number generation took to get