python - how to extract a zero-dimensional slice from a 1-dimensional array in numpy -


Is a 1-dimensional array slice the zero-dimensional sub-array?

ndarray arr , arr [0] (N-1 ) - Dimensional Ndarray .

However, if I have 1-dimensional ndarray x , x [0] 0-dimensional ndarray is not back Returns, rather a numpy.int64 , (if x contains int64 s).

The minimum example:

  def increment (zero_d_array): zero_ad_rere [...] = zero_a_array + 1 counter = mmp.re (0) # zero-dimensional with scalar Array increments (counter) # Success; Counter now 1 counter = numpy.zeros (3, dtype = int) # [0, 0, 0] increment (counter [1]) # failed; Counter [1] is a numpy.int64, not 0-D array   

I realize that will work with increments (counter [1: 2]) , But only because increments () works with both 0-D and 1-D input, all functions will be so flexible.

Use an oval:

  increment (counter [ 1, ...])    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -