#๐Ÿ”’ np.zeros() not working as expected

10 messages ยท Page 1 of 1 (latest)

terse lava
#

The following function is a part of a bigger program I am working on

def separateBands(IrawFFT,phaOff,bands,fac):
    phaPerBand = np.int32((bands*2)-1)     
    phases = np.zeros(1,phaPerBand)
    for p in range(phaPerBand):
        phases[p]=(2*np.pi*(p))/phaPerBand + phaOff  
    separate=separateBands_final(IrawFFT,phases,bands,fac)
    return separate```
With `phaPerBand=3`, I expected phases to be `array([0,0,0])`. But when I run this I get the error
`IndexError: index 1 is out of bounds for axis 0 with size 1`
Because for some unknown reason I am getting `phases = array([0])`. Help me
static mothBOT
#

@terse lava

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

fervent sun
terse lava
#

so when i pass it as
np.zeros((1,phaPerBand))
it still throws me the same error

#

does the indexing have to change as well?

#

oh wait

#

i can just do
np.zeros(phaPerBand)

static mothBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.