Convert function result value to over pi

Asked 2 weeks ago, Updated 2 weeks ago, 1 views

import numpy as np

u = np.random.randint(2,size=(1,100))


def turbo_enc(u):
    K = np.size(u,1)
    enc = np.zeros_like(u)
    enc = u
    return enc
enc1 = turbo_enc(u)

def add(x,y,z):
    if((x+y+z) % 2 == 0):
        return 0
        return 1

a1 = np.array((0))
a2 = np.array((0))
def loop(u):
    global a1
    global a2
    for i in range(99):
            print(add(enc1[0][i],a1,a2),end ='')
        elif(i == 1):
            a1 = enc1[0][0]
            print(add(enc1[0][i],a1,a2),end = '')
            a1 = enc1[0][i-1]
            a2 = enc1[0][i-2]
    return print(add(enc1[0][i],a1,a2),end='')


'add function' = 0 return if added value is even, 1 return if odd

That's the code I've written so far. I am writing 'Turbo code with interleaver', which is a college assignment, in Python. The overall process is as follows:

numpy def

2022-09-20 10:23

1 Answers

I don't know exactly what it means. First of all, I will explain the reason why the error.

def loop(u):
  return print(add(...))

In this way, the return value of the loop function passes the return value of the print function as it is. The return value of the print function is None.

Thus, loop(u) becomes None, and loop(u).Reshape(10,10) is the same as None.reshape(10,10). However, since None does not have a method called reshape, the error 'NoneType' object has no attribute 'reshape' occurred.

I think it's a difficult explanation for the questioner, but read it 10 times.

2022-09-20 10:23

If you have any answers or tips

© 2022 pinfo. All rights reserved.