from __future__ import division
import numpy as np
import matplotlib.pyplot as plt


def deconv(x, y, fs):
    X = np.fft.fft(x)
    Y = np.fft.fft(y)
    H = Y / X
    h = np.fft.ifft(H)
    print("h =", h)  # complex vector?
    t = np.arange(len(x)) / fs
    plt.plot(t, h.real)
    plt.grid()
    plt.title("impulse response")
    plt.show()

"""Response calculation."""
from __future__ import division
import numpy as np


def calculate(signal_excitation, signal_out):
    """Function returns impulse response."""
    X = np.fft.fft(signal_excitation)
    Y = np.fft.fft(signal_out)
    H = Y / X
    h = np.fft.ifft(H)
    return h

Change function content and pep257
Change function content and pep257

+ """Response calculation."""
  from __future__ import division
  import numpy as np
- import matplotlib.pyplot as plt
  
  
- def deconv(x, y, fs):
-     X = np.fft.fft(x)
+ def calculate(signal_excitation, signal_out):
+     """Function returns impulse response."""
+     X = np.fft.fft(signal_excitation)
-     Y = np.fft.fft(y)
+     Y = np.fft.fft(signal_out)
      H = Y / X
      h = np.fft.ifft(H)
+     return h
-     print("h =", h)  # complex vector?
-     t = np.arange(len(x)) / fs
-     plt.plot(t, h.real)
-     plt.grid()
-     plt.title("impulse response")
-     plt.show()
  
Change function content and pep257
## Code Before:
from __future__ import division
import numpy as np
import matplotlib.pyplot as plt


def deconv(x, y, fs):
    X = np.fft.fft(x)
    Y = np.fft.fft(y)
    H = Y / X
    h = np.fft.ifft(H)
    print("h =", h)  # complex vector?
    t = np.arange(len(x)) / fs
    plt.plot(t, h.real)
    plt.grid()
    plt.title("impulse response")
    plt.show()

## Instruction:
Change function content and pep257
## Code After:
"""Response calculation."""
from __future__ import division
import numpy as np


def calculate(signal_excitation, signal_out):
    """Function returns impulse response."""
    X = np.fft.fft(signal_excitation)
    Y = np.fft.fft(signal_out)
    H = Y / X
    h = np.fft.ifft(H)
    return h
