That worked. Many thanks Eryk.
Rob
On 30/06/2022 23:45, Eryk Sun wrote:
On 6/30/22, Rob Cliffe via Python-list wrote:
AKAIK it is not possible to give ctypes a bytearray object and persuade
it to give you a pointer to the actual array data, suitable for passing
to a DLL.
You're overlooking t
Il giorno venerdì 1 luglio 2022 alle 00:46:13 UTC+2 ery...@gmail.com ha scritto:
> On 6/30/22, Rob Cliffe via Python-list wrote:
> >
> > AKAIK it is not possible to give ctypes a bytearray object and persuade
> > it to give you a pointer to the actual array data, suitable for passing
> > to a
On 6/30/22, Rob Cliffe via Python-list wrote:
>
> AKAIK it is not possible to give ctypes a bytearray object and persuade
> it to give you a pointer to the actual array data, suitable for passing
> to a DLL.
You're overlooking the from_buffer() method. For example:
>>> ba = bytearray(10)
I have an application in which I wanted a fixed-length "array of bytes"
(that's intended as an informal term) where I could read and write
individual bytes and slices, and also pass the array to a DLL (one I
wrote in C) which expects an "unsigned char *" parameter.
I am using ctypes to talk to t
v/pandas/issues
>
> On Sun, 4 Oct 2020 at 13:55, Tim Williams wrote:
>
>> On Sun, Oct 4, 2020 at 8:39 AM Tim Williams wrote:
>>
>> >
>> >
>> > On Fri, Oct 2, 2020 at 11:00 AM Shaozhong SHI
>> > wrote:
>> >
>> >>
> >> Hello,
> >>
> >> I got a json response from an API and tried to use pandas to put data
> into
> >> a dataframe.
> >>
> >> However, I kept getting this ValueError: arrays must all be same length.
> >>
> >> Can anyone he
On Sun, Oct 4, 2020 at 8:39 AM Tim Williams wrote:
>
>
> On Fri, Oct 2, 2020 at 11:00 AM Shaozhong SHI
> wrote:
>
>> Hello,
>>
>> I got a json response from an API and tried to use pandas to put data into
>> a dataframe.
>>
>> However, I ke
On Fri, Oct 2, 2020 at 11:00 AM Shaozhong SHI
wrote:
> Hello,
>
> I got a json response from an API and tried to use pandas to put data into
> a dataframe.
>
> However, I kept getting this ValueError: arrays must all be same length.
>
> Can anyone help?
>
>
Am 02.10.20 um 14:34 schrieb Shaozhong SHI:
Hello,
I got a json response from an API and tried to use pandas to put data into
a dataframe.
However, I kept getting this ValueError: arrays must all be same length.
Can anyone help?
The following is the json text.
What do you expect the
On Fri, 2 Oct 2020 13:34:46 +0100, Shaozhong SHI wrote:
> Hello,
>
> I got a json response from an API and tried to use pandas to put data into
> a dataframe.
>
> However, I kept getting this ValueError: arrays must all be same length.
>
> Can anyone help?
>
>
Hello,
I got a json response from an API and tried to use pandas to put data into
a dataframe.
However, I kept getting this ValueError: arrays must all be same length.
Can anyone help?
The following is the json text. Regards, Shao
{
"locationId": "1-1004508435"
Hi,
is it possible to append data to or remove data from numpy arrays like
Python lists? I have some code where I currently use lists and often
do things like
a.append(elem)
a += b
del a[:-n]
I am thinking of changing to numpy arrays but it seems I cannot modify
numpy arrays like
Hi,
How can I create a boolean mask for the data arrays with integer type? I want
to create a 'useSample' boolean array for masking or discarding the unwanted
data from the array.
[nr,nc] = np.shape(ftype) #
useSamples = np.full((nr,nc), True, dtype=bool)
I want to transform the
mpy.fromfile(fd, dtype=numpy.int)
What you should not do:
arr = [1, 2, 3, 4]
with open('plain.txt', 'wt') as fd:
fd.write(repr(arr))
with open('plain.txt') as fd:
arr = eval(fd.read())
If you need to store more data, you should think about a database.
On 16-4-2017 14:28, jorge.conr...@cptec.inpe.br wrote:
> Hi,
>
> I'm new on Python software. I would like to write on disk arrays in binary or
> ascii
> format. Can someone please help me?
>
> Thanks,
>
> Conrado
What kind of data is in the arrays?
Who or wha
Hi,
I'm new on Python software. I would like to write on disk arrays in
binary or ascii format. Can someone please help me?
Thanks,
Conrado
--
https://mail.python.org/mailman/listinfo/python-list
Seb wrote:
> Is there an easier way to write a numpy array with a regular structure?
> For example, an array with [0, 1] along the diagnal of one of the array
> dimensions, and zero elsewhere:
>
> zz = np.array([[[0, 1], [0, 0], [0, 0]],
>[[0, 0], [0, 1], [0, 0]],
>
Hello,
Is there an easier way to write a numpy array with a regular structure?
For example, an array with [0, 1] along the diagnal of one of the array
dimensions, and zero elsewhere:
zz = np.array([[[0, 1], [0, 0], [0, 0]],
[[0, 0], [0, 1], [0, 0]],
[[0, 0], [0, 0],
Some common ways to handle the boundary condition:
1. Generate clamped indices, test for validity and substitute invalid
entries with an "identity" element. E.g.
ijk = np.mgrid[:a,:b,:c]
i,j,k = ijk
i0,j0,k0 = np.maximum(0,ijk-1)
i1,j1,k1 = np.minimum(np.array(a,b,c).T-1,ijk+1)
n1 = (i>
Heli wrote:
> I have a 3d numpy array containing true/false values for each i,j,k. The
> size of the array is a*b*c.
>
> for each cell with indices i,j,k; I will need to check all its neighbours
> and calculate the number of neighbour cells with true values.
>
> A cell with index i,j,k has the f
there anyway I can get an array containg all n1 neighbour, a second array
containing all n2 neighbours and so on and then add n1 to n6 arrays
element-wise to get all neighbours that meet certain conditions for a cell.
Thanks in Advance for your help,
--
https://mail.python.org/mailman/listinfo/python-list
On 06/07/2016 06:17 PM, Harrison Chudleigh wrote:
> I was programming a computer game and found that while 1D arrays can be
> created using the module array, there is no module for two-dimensional
> arrays, unlike languages like C. Currently, the closest thing Python has to
> a 2
On 6/7/2016 8:17 PM, Harrison Chudleigh wrote:
I was programming a computer game and found that while 1D arrays can be
created using the module array, there is no module for two-dimensional
arrays, unlike languages like C. Currently, the closest thing Python has to
a 2D array is a dictionary
Harrison Chudleigh wrote:
> I was programming a computer game and found that while 1D arrays can be
> created using the module array, there is no module for two-dimensional
> arrays, unlike languages like C. Currently, the closest thing Python has to
> a 2D array is a dictionary cont
On Tuesday, June 7, 2016 at 8:19:33 PM UTC-4, Harrison Chudleigh wrote:
> I was programming a computer game and found that while 1D arrays can be
> created using the module array, there is no module for two-dimensional
> arrays, unlike languages like C. Currently, the closest thing Pyth
Harrison Chudleigh writes:
> Currently, the closest thing Python has to a 2D array is a dictionary
> containing lists.
Tuples work fine:
d = {}
d[2,3] = 5 # etc...
> Is this idea PEPable?
I don't think it would get any traction. If you're doing something
numerical t
I was programming a computer game and found that while 1D arrays can be
created using the module array, there is no module for two-dimensional
arrays, unlike languages like C. Currently, the closest thing Python has to
a 2D array is a dictionary containing lists.
I propose that a module , 2DArray
As you said, this did the trick.
sortedVal=np.array(val[ind]).reshape((xcoord.size,ycoord.size,zcoord.size))
Only val[ind] instead of val[ind,:] as val is 1D.
Thanks Oscar,
--
https://mail.python.org/mailman/listinfo/python-list
Thanks Oscar,
In my case this did the trick.
sortedVal=np.array(val[ind]).reshape((xcoord.size,ycoord.size,zcoord.size))
--
https://mail.python.org/mailman/listinfo/python-list
On 7 April 2016 at 15:31, Heli wrote:
>
> Thanks a lot Oscar,
>
> The lexsort you suggested was the way to go.
Glad to hear it.
> import h5py
> import numpy as np
> f=np.loadtxt(inputFile,delimiter=None)
> xcoord=np.sort(np.unique(f[:,0]))
> ycoord=np.sort(np.unique(f[:,1]))
> zcoord=np.sort(np.
Thanks a lot Oscar,
The lexsort you suggested was the way to go.
import h5py
import numpy as np
f=np.loadtxt(inputFile,delimiter=None)
xcoord=np.sort(np.unique(f[:,0]))
ycoord=np.sort(np.unique(f[:,1]))
zcoord=np.sort(np.unique(f[:,2]))
x=f[:,0]
y=f[:,1]
z=f[:,2]
val=f[:,3]
ind = np.lexsort(
On 6 April 2016 at 17:26, Heli wrote:
>
> Thanks for your replies. I have a question in regard with my previous
> question. I have a file that contains x,y,z and a value for that coordinate
> on each line. Here I am giving an example of the file using a numpy array
> called f.
>
> f=np.array([[
Thanks for your replies. I have a question in regard with my previous question.
I have a file that contains x,y,z and a value for that coordinate on each line.
Here I am giving an example of the file using a numpy array called f.
f=np.array([[1,1,1,1],
[1,1,2,2],
[1,1,3
> What you want is called *transposing* the array:
>
> http://docs.scipy.org/doc/numpy/reference/generated/numpy.transpose.html
>
> That should be a sufficiently fast operation.
Transposing itself is fast, as it just swaps the strides and dimensions
without touching the data (i.e. it returns a n
On 23 March 2016 10:06:56 GMT+00:00, Heli wrote:
>Hi,
>
>I have a 2D numpy array like this:
>
>[[1,2,3,4],
> [1,2,3,4],
> [1,2,3,4]
> [1,2,3,4]]
>
>Is there any fast way to convert this array to
>
>[[1,1,1,1],
> [2,2,2,2]
> [3,3,3,3]
> [4,4,4,4]]
Use the transpose() method:
http://docs.scipy
[3,3,3,3]
> [4,4,4,4]]
>
> In general I would need to retrieve every nth element of the interior arrays
> in to single arrays. I know I can loop over and do this, but I have really
> big arrays and I need the fastest way to do this.
>
> Thanks for your help,
Thanks a lot
On Wed, Mar 23, 2016 at 9:06 PM, Heli wrote:
> I have a 2D numpy array like this:
>
> [[1,2,3,4],
> [1,2,3,4],
> [1,2,3,4]
> [1,2,3,4]]
>
> Is there any fast way to convert this array to
>
> [[1,1,1,1],
> [2,2,2,2]
> [3,3,3,3]
> [4,4,4,4]]
What you want is called *transposing* the array:
h
;t mean just transposing your original array, as in
original_array.T, right?
> In general I would need to retrieve every nth element of the interior
> arrays in to single arrays. I know I can loop over and do this, but I
> have really big arrays and I need the fastest way to do this.
I d
On Wed, 23 Mar 2016 09:06 pm, Heli wrote:
> Hi,
>
> I have a 2D numpy array like this:
>
> [[1,2,3,4],
> [1,2,3,4],
> [1,2,3,4]
> [1,2,3,4]]
>
> Is there any fast way to convert this array to
>
> [[1,1,1,1],
> [2,2,2,2]
> [3,3,3,3]
> [4,4,4,4]]
Mathematically, this is called the "tran
Hi,
I have a 2D numpy array like this:
[[1,2,3,4],
[1,2,3,4],
[1,2,3,4]
[1,2,3,4]]
Is there any fast way to convert this array to
[[1,1,1,1],
[2,2,2,2]
[3,3,3,3]
[4,4,4,4]]
In general I would need to retrieve every nth element of the interior arrays in
to single arrays. I know I can
On 12/01/15 at 06:47pm, Peter Otten wrote:
> Extract 2D arrays:
>
> >>> a[:,2,3]
> array([[ 55, 56, 57, 58, 59],
>[115, 116, 117, 118, 119]])
> >>> a[1,:,2]
> array([[ 70, 71, 72, 73, 74],
>[ 90, 91, 92, 93, 94],
>
[ 95, 96, 97, 98, 99]],
[[100, 101, 102, 103, 104],
[105, 106, 107, 108, 109],
[110, 111, 112, 113, 114],
[115, 116, 117, 118, 119)
Extract 2D arrays:
>>> a[:,2,3]
array([[ 55, 56, 57, 58, 59],
[115, 116, 117, 118, 119]])
>>&g
Hi,
I use the IDL but now I'm change to PYTHON. I have a 4D array (time,
level,lon,lat). I would like to get a 2D array for a specific time
(time1) and level (level1). In IDL I use: 2Darray =
4Darray(time1,level1,*,*). How can I get the 2D array in Python
Conrado
--
https://mail.python.or
On Tue, 19 Aug 2014 05:54:24 -0700, Jurgens de Bruin wrote:
> I do hope somebody can help me with the following:
> I have the followings lists which represent the upper and lower value of
> a range/array.
>
> a = [1,50]
> b = [75,150]
> c = [25,42]
> d = [120,149]
> e = [35,55]
I think you're st
Hi,
I made a fast implementation (I'm sure that can be done better) but it
works (for what I understood).
Is tested in Python3.4, if you will execute in Python 2.x, or don't have
mypy or don't like it, you always can remove the function annotations :)
http://gist.github.com/rockneurotiko/017044d
Jurgens de Bruin wrote:
> Hi All,
>
> I do hope somebody can help me with the following:
> I have the followings lists which represent the upper and lower value of a
> range/array.
>
> a = [1,50]
> b = [75,150]
> c = [25,42]
> d = [120,149]
> e = [35,55]
>
> What I would like to happen is that
On Tue, 19 Aug 2014 05:54:24 -0700 (PDT), Jurgens de Bruin wrote:
>
> I do hope somebody can help me with the following:
> I have the followings lists which represent the upper and lower value
> of a range/array.
>
> a = [1,50]
> b = [75,150]
> c = [25,42]
> d = [120,149]
> e = [35,55]
>
> What I w
Hi All,
I do hope somebody can help me with the following:
I have the followings lists which represent the upper and lower value of a
range/array.
a = [1,50]
b = [75,150]
c = [25,42]
d = [120,149]
e = [35,55]
What I would like to happen is that overlapping range will "collapse" to a
single ran
; convenient to work with than lists of lists. What are the advantages and
> disadvantages of storing the symbols [A,B] and dates
> [2014-01-01,2014-01-02] as lists vs. NumPy arrays?
If you don't mind the numpy dependency I can't see any disadvantages.
You might also have a look at
nvenient to work with than lists of lists. What are the advantages and
> disadvantages of storing the symbols [A,B] and dates
> [2014-01-01,2014-01-02] as lists vs. NumPy arrays?
You could also use a dictionary of either lists or tuples or even NumPy
arrays keyed on the date.
$ python
Python
storing the symbols [A,B] and dates [2014-01-01,2014-01-02] as
lists vs. NumPy arrays?
--
https://mail.python.org/mailman/listinfo/python-list
,D,x,tinicial))
> File "D:\Yan\Documents\Aptana Studio 3 Workspace\DIF1DMEDYER\SOLUCION
NUMERICA PARA LA ECUACION DE LA DIFUSION EN 1D DYER", line 32, in Cdifuana
> Cdifuana = (M/temp)*math.exp(-x**2 /(4*D*t))
> TypeError: only length-1 arrays can be converted to Python
>
The
na
Cdifuana = (M/temp)*math.exp(-x**2 /(4*D*t))
TypeError: only length-1 arrays can be converted to Python
--
*Gracias, cordialmente, *
*
*
*
*
*ING. YANETH ESCOLAR RAMBAL*
*HAFI Engineering & Consulting GmbH*
*CEL: + 57 3166257245*
*TEL: + 57 (1) 6508308*
*TEL: ++43 5522 77924 0
On Thu, 02 May 2013 02:10:11 -0700, Ana Dionísio wrote:
> Hello! I have several numpy arrays in my script and i want to add them.
> For example:
>
> a=[1,2,3,4,5]
> b=[1,1,1,1,1]
> c=[1,0,1,0,1]
These are not numpy arrays, they are lists of ints. Based on the error
Ana Dionísio wrote:
> Hello! I have several numpy arrays in my script and i want to add them. For
> example:
> a=[1,2,3,4,5]
> b=[1,1,1,1,1]
> c=[1,0,1,0,1]
> for i in range(5):
> d[i]=a[i]+b[i]+c[i]
> print d
> [3,3,5,5,7]
> I did it like that
Hello! I have several numpy arrays in my script and i want to add them. For
example:
a=[1,2,3,4,5]
b=[1,1,1,1,1]
c=[1,0,1,0,1]
for i in range(5):
d[i]=a[i]+b[i]+c[i]
print d
[3,3,5,5,7]
I did it like that but I get an error: "TypeError: unsupported operand type(s)
for +: '
On Mon, 22 Apr 2013 11:13:38 -0700, Ana Dionísio wrote:
> I have an array and I need pick some data from that array and put it in
> a list, for example:
>
> array= [a,b,c,1,2,3]
>
> list=array[0]+ array[3]+ array[4]
>
> list: [a,1,2]
>
> When I do it like this: list=array[0]+ array[3]+ array[4
Ana Dionísio於 2013年4月23日星期二UTC+8上午2時13分38秒寫道:
> Hello!
>
>
>
> I need your help!
>
>
>
> I have an array and I need pick some data from that array and put it in a
> list, for example:
>
>
>
> array= [a,b,c,1,2,3]
>
>
>
> list=array[0]+ array[3]+ array[4]
>
>
>
> list: [a,1,2]
>
>
"Ana Dionísio" wrote in message
news:de1cc79e-cbf7-4b0b-ae8e-18841a1ef...@googlegroups.com...
Hello!
I need your help!
I have an array and I need pick some data from that array and put it in a
list, for example:
array= [a,b,c,1,2,3]
list=array[0]+ array[3]+ array[4]
list: [a,1,2]
When
On 04/22/2013 02:13 PM, Ana Dionísio wrote:
Hello!
I need your help!
I have an array
I think you mean you have a numpy array, which is very different than a
python array.array
and I need pick some data from that array and put it in a list, for example:
array= [a,b,c,1,2,3]
That's a li
Hello!
I need your help!
I have an array and I need pick some data from that array and put it in a list,
for example:
array= [a,b,c,1,2,3]
list=array[0]+ array[3]+ array[4]
list: [a,1,2]
When I do it like this: list=array[0]+ array[3]+ array[4] I get an error:
"TypeError: unsupported operan
On 2012-09-24, JBT wrote:
> I am looking for a way to pass numeric arrays, such as *float a[100];
> double b[200];*, from C extension codes to python. The use case of
> this problem is that you have data stored in a particular format,
> NASA common data format (CDF) in my case, and
On 9/23/2012 9:39 PM, JBT wrote:
Hi,
I am looking for a way to pass numeric arrays, such as *float a[100];
double b[200];*, from C extension codes to python. The use case of
this problem is that you have data stored in a particular format,
NASA common data format (CDF) in my case, and there
On 24 September 2012 02:39, JBT wrote:
> Hi,
>
> I am looking for a way to pass numeric arrays, such as *float a[100];
> double b[200];*, from C extension codes to python. The use case of this
> problem is that you have data stored in a particular format, NASA common
> data
Hi,
I am looking for a way to pass numeric arrays, such as *float a[100]; double
b[200];*, from C extension codes to python. The use case of this problem is
that you have data stored in a particular format, NASA common data format (CDF)
in my case, and there exists an official C library to
me indices but each time
changing the array A then you should try precomputing all the indices as a
list of numpy arrays (as shown above).
On the other hand, if you're repeating with the same matrix A but different
sets of indices, you'll need to think about how you are generating t
y say that) and each element
> is
> > a list of indices to be summed. Then I parse this list with a nested loop
> > and compute each element of array B.
>
>
> > Because of the nested loop and the big arrays the process takes a minute
> or
> > so. My question is:
ted loop
> > and compute each element of array B.
>
>
> > Because of the nested loop and the big arrays the process takes a minute
> or
> > so. My question is: is there a more elegant and significantly faster way
> of
> > doing this in python?
>
> I'm sure the
rray A to be mapped to array B. The list is the
> dimension of array B (if one can technically say that) and each element is
> a list of indices to be summed. Then I parse this list with a nested loop
> and compute each element of array B.
>
> Because of the nested loop and the big
dimension of array B (if one can technically say that) and each element is
a list of indices to be summed. Then I parse this list with a nested loop
and compute each element of array B.
Because of the nested loop and the big arrays the process takes a minute or
so. My question is: is there a more elegant
I would like to calculate the max and min across many netcdf files.
I know how to create one big array and then concatenate and find the
numpy.max but when I run this on 1000's of arrays I have a memory error.
What I would prefer is to loop through the arrays and produce the maximum
without h
Peter Otten <__pete...@web.de> wrote:
> If you need lookup only I'd prefer tuples, but sometimes you may want to
> retrieve all values with a certain k1 and
>
> d[k1]
>
> is certainly more efficient than
>
> [(k2, v) for (k1, k2), v in d.items() if k1 == wanted]
This was the hidden cost of the tup
Matej Cepl wrote:
> Dne 11.11.2011 14:31, macm napsal(a):
>> def Dicty( dict[k1][k2] ):
>
> When looking at this I returned to the question which currently rolls in
> my mind:
>
> What's difference/advantage-disadvantage betweeng doing multi-level
> dicts/array
On 14/11/2011 10:05, Matej Cepl wrote:
Dne 11.11.2011 14:31, macm napsal(a):
def Dicty( dict[k1][k2] ):
When looking at this I returned to the question which currently rolls in
my mind:
What's difference/advantage-disadvantage betweeng doing multi-level
dicts/arrays like this and using
Dne 11.11.2011 14:31, macm napsal(a):
def Dicty( dict[k1][k2] ):
When looking at this I returned to the question which currently rolls in
my mind:
What's difference/advantage-disadvantage betweeng doing multi-level
dicts/arrays like this and using tuple as a key? I.e., is it more
Pyt
th
> iterators, that would, in my opinion (and see below),
That's better for not being absolute. Thank you for admitting other
possibilities.
> require use of
> temporary arrays. Since slice assignment does not use temporary arrays
> now (see below), that augmentation should be co
can't
believe that. But one of the purposes of the iterator protocol is to
reduce the number of cases where you have to create huge lists.
> Assignment remains atomic, and the generator will be unpacked into a
> temporary list at full C speed.
Which can be very slow if your list has s
On Fri, 28 Oct 2011 16:27:37 -0700, Patrick Maupin wrote:
> And, BTW, the example you give of, e.g.
>
> a,b,c = (some generator expression)
>
> ALREADY LOSES DATA if the iterator isn't the right size and it raises an
> exception.
Yes. What's your point? This fact doesn't support your proposal i
On Oct 28, 4:51 pm, Patrick Maupin wrote:
> On Oct 28, 3:19 am, Terry Reedy wrote:
>
> > On 10/28/2011 3:21 AM, Steven D'Aprano wrote:
>
> > > If the slice has too few elements, you've just blown away the entire
> > > iterator for no good reason.
> > > If the slice is the right length, but the it
On Oct 28, 3:19 am, Terry Reedy wrote:
> On 10/28/2011 3:21 AM, Steven D'Aprano wrote:
>
> > If the slice has too few elements, you've just blown away the entire
> > iterator for no good reason.
> > If the slice is the right length, but the iterator doesn't next raise
> > StopIteration, you've jus
ors, that would, in my opinion (and see below), require use of
temporary arrays. Since slice assignment does not use temporary arrays
now (see below), that augmentation should be conditional on the source
type being a non-sequence iterator.
Why would it be a problem to change this?
CPytho
On Oct 27, 10:23 pm, Terry Reedy wrote:
> I do not think everyone else should suffer substantial increase in space
> and run time to avoid surprising you.
What substantial increase? There's already a check that winds up
raising an exception. Just make it empty an iterator instead.
> > It vio
On 10/28/2011 3:21 AM, Steven D'Aprano wrote:
If the slice has too few elements, you've just blown away the entire
iterator for no good reason.
If the slice is the right length, but the iterator doesn't next raise
StopIteration, you've just thrown away one perfectly good value. Hope it
wasn't
On Thu, 27 Oct 2011 17:09:34 -0700, Patrick Maupin wrote:
> On Oct 27, 5:31 pm, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote:
>> From the outside, you can't tell how big a generator expression is. It
>> has no length:
>
> I understand that.
>
>> Since the array object has no way of te
StopIteration.
Given that a cytpe_array is a *fixed-length* array, *unlike* Python's
extensible lists and arrays, failure is a possibility due to mis-matched
lengths. So ctype_array can either look first, as it does, by calling
len(value_object), or leap first and create a temporary array
On Oct 27, 5:31 pm, Steven D'Aprano wrote:
> From the outside, you can't tell how big a generator expression is. It has no
> length:
I understand that.
> Since the array object has no way of telling whether the generator will have
> the correct size, it refuses to guess.
It doesn't have to gu
On Thu, 27 Oct 2011 13:34:28 -0700, Patrick Maupin wrote:
> Bug or misunderstanding?
>
> Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) [GCC 4.5.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
x = 32 * [0]
x[:] = (x for x in xrange(32))
from
Bug or misunderstanding?
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> x = 32 * [0]
>>> x[:] = (x for x in xrange(32))
>>> from ctypes import c_uint
>>> x = (32 * c_uint)()
>>> x[:] = xrange(32)
>>
On 07/26/2011 08:10 AM, Olenka Subota wrote:
If anyone of you can help, please do it..
Thanks!
You would probably get a better answer asking on one of the mailing
lists here: http://new.scipy.org/mailing-lists.html
--
http://mail.python.org/mailman/listinfo/python-list
Hello all,
I need your help. I have to simulate a filter whose transfer function
is a step fct, and I wrote it as a column-vector of Ns elements :
>>> h=ones(3,dtype=float)
>>> print h
[ 1. 1. 1.]
>>> h=reshape(h,(3,1))
>>> h
array([[ 1.],
[ 1.],
[ 1.]])
In this case Ns=3 for simp
On 5/25/11 3:27 PM, Catherine Moroney wrote:
Hello,
I am trying to work with a structured array and a mask, and am encountering some
problems.
You will want to ask numpy questions on the numpy mailing list:
http://www.scipy.org/Mailing_Lists
For example:
>>> xtype = numpy.dtype([("n", n
Hello,
I am trying to work with a structured array and a mask, and am
encountering some problems.
For example:
>>> xtype = numpy.dtype([("n", numpy.int32), ("x", numpy.float32)])
>>> a = numpy.zeros((4), dtype=xtype)
>>> b = numpy.arange(0,4)
>>> a2 = numpy.zeros((4), dtype=xtype)
>>> mask =
On 12/02/2011 04:49, Terry Reedy wrote:
On 2/11/2011 4:24 PM, LL.Snark wrote:
Hi,
I'm looking for a pythonic way to translate this short Ruby code :
t=[6,7,8,6,7,9,8,4,3,6,7]
i=t.index {|x| x
What does Ruby do if there is no such element?
For Python, the answer should be either None or Value
Arnaud Delobelle writes:
> "LL.Snark" writes:
>
>> Hi,
>>
>> I'm looking for a pythonic way to translate this short Ruby code :
>> t=[6,7,8,6,7,9,8,4,3,6,7]
>> i=t.index {|x| x>
>
> In Python3:
>
t = [6,7,8,6,7,9,8,4,3,6,7]
next(filter(t[0].__gt__, t))
> 4
Oops! I realised my mistake
"LL.Snark" writes:
> Hi,
>
> I'm looking for a pythonic way to translate this short Ruby code :
> t=[6,7,8,6,7,9,8,4,3,6,7]
> i=t.index {|x| x
In Python3:
>>> t = [6,7,8,6,7,9,8,4,3,6,7]
>>> next(filter(t[0].__gt__, t))
4
--
Arnaud
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 11, 1:24 pm, "LL.Snark" wrote:
> Hi,
>
> I'm looking for a pythonic way to translate this short Ruby code :
> t=[6,7,8,6,7,9,8,4,3,6,7]
> i=t.index {|x| x
> If you don't know Ruby, the second line means :
> What is the index, in array t, of the first element x such that x
> If can write it
On 11 fév, 22:24, "LL.Snark" wrote:
> Hi,
>
> I'm looking for a pythonic way to translate this short Ruby code :
> t=[6,7,8,6,7,9,8,4,3,6,7]
> i=t.index {|x| x1000), "not found")
or
next((i for i, x in enumerate(t) if x>1000), None)
or whatever matches your needs.
Note that if you use the second o
On 2/11/2011 4:24 PM, LL.Snark wrote:
Hi,
I'm looking for a pythonic way to translate this short Ruby code :
t=[6,7,8,6,7,9,8,4,3,6,7]
i=t.index {|x| x
What does Ruby do if there is no such element?
For Python, the answer should be either None or ValueError.
If can write it in python several
On 11/02/2011 22:24, LL.Snark wrote:
Hi,
I'm looking for a pythonic way to translate this short Ruby code :
t=[6,7,8,6,7,9,8,4,3,6,7]
i=t.index {|x| x=t[0] : i+=1
... not pythonic I think...
Or :
t=[6,7,8,6,7,9,8,4,3,6,7]
i=[j for j in range(len(t)) if t[j]
Thx for your answers.
May I add s
On Feb 11, 9:24 pm, "LL.Snark" wrote:
> Hi,
>
> I'm looking for a pythonic way to translate this short Ruby code :
> t=[6,7,8,6,7,9,8,4,3,6,7]
> i=t.index {|x| x
> If you don't know Ruby, the second line means :
> What is the index, in array t, of the first element x such that x
> If can write it
1 - 100 of 647 matches
Mail list logo