Re: [Numpy-discussion] Generalized rectangle intersection. (Was: Array blitting)

2017-07-10 Thread Mikhail V
On 10 July 2017 at 10:34, Jerome Kieffer wrote: > On Sun, 9 Jul 2017 23:35:58 +0200 > Mikhail V wrote: > >> disclaimer: I am not a past contributor to numpy and I don't know >> much about github, and what pull request means. So I just put the >> examples here.

[Numpy-discussion] Generalized rectangle intersection. (Was: Array blitting)

2017-07-09 Thread Mikhail V
e often the rectangle objects are defined as (coordinate, size) tuple and in many cases the destination box is itself the origin (i.e. it's coordinate is 0,0,..) But of course there can be various variants for the output format and order. Regards, Mikhail V _

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

2017-06-30 Thread Mikhail V
;ll need some time to think out more examples and use cases. Mikhail > > On Jun 29, 2017 20:17, "Mikhail V" wrote: >> >> Hello all >> >> I often need to copy one array into another array, given an offset. >> This is how the "blit" function

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

2017-06-29 Thread Mikhail V
Hello all I often need to copy one array into another array, given an offset. This is how the "blit" function can be understood, i.e. in every graphical lib there is such a function. The common definition is like: blit ( dest, src, offset ): where dest is destination array, src is source array and

Re: [Numpy-discussion] Array and string interoperability

2017-06-06 Thread Mikhail V
On 7 June 2017 at 00:05, Chris Barker wrote: > On Mon, Jun 5, 2017 at 3:59 PM, Mikhail V wrote: >> s= "012 abc" >> B = bytes(s.encode()) # convert to bytes >> k = len(s) >> arr = np.zeros(k,"u1") # init empty array length k >> arr[0:2] =

Re: [Numpy-discussion] Array and string interoperability

2017-06-05 Thread Mikhail V
On 5 June 2017 at 19:40, Chris Barker wrote: > > >> > Python3 assumes 4-byte strings but in reality most of the time >> > we deal with 1-byte strings, so there is huge waste of resources >> > when dealing with 4-bytes. For many serious projects it is just not >> > needed. >> >> That's quite enough

Re: [Numpy-discussion] Array and string interoperability

2017-06-05 Thread Mikhail V
On 4 June 2017 at 23:59, Thomas Jollans wrote: > > > For what it's worth, in Python 3 (which you probably should want to be > using), everything behaves as you'd expect: > import numpy as np s = b'012 abc' a = np.fromstring(s, 'u1') a > array([48, 49, 50, 32, 97, 98, 99], dtype

[Numpy-discussion] Array and string interoperability

2017-06-04 Thread Mikhail V
Array and string interoperability Just sharing my thoughts and few ideas about simplification of casting strings to arrays. In examples assume Numpy is in the namespace (from numpy import *) Initialize array from a string currently looks like: s= "012 abc" A= fromstring(s,"u1") print A -> [48 49