Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quad: Import sympy only when necessary #459

Merged
merged 4 commits into from
Dec 14, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
quantecon.arma: Import scipy.signal functions only when necessary
  • Loading branch information
rht committed Dec 12, 2018
commit e265b2541de8e827b7f20236b6f97ed087216aad
5 changes: 3 additions & 2 deletions quantecon/arma.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"""
import numpy as np
from numpy import conj, pi
from scipy.signal import dimpulse, freqz, dlsim
from .util import check_random_state


Expand Down Expand Up @@ -61,7 +60,6 @@ class ARMA:
processing we desire. Corresponds with the theta values

"""

def __init__(self, phi, theta=0, sigma=1):
self._phi, self._theta = phi, theta
self.sigma = sigma
Expand Down Expand Up @@ -165,6 +163,7 @@ def impulse_response(self, impulse_length=30):
We take psi[0] as unity.

"""
from scipy.signal import dimpulse
sys = self.ma_poly, self.ar_poly, 1
times, psi = dimpulse(sys, n=impulse_length)
psi = psi[0].flatten() # Simplify return value into flat array
Expand Down Expand Up @@ -205,6 +204,7 @@ def spectral_density(self, two_pi=True, res=1200):
The frequency response

"""
from scipy.signal import freqz
w, h = freqz(self.ma_poly, self.ar_poly, worN=res, whole=two_pi)
spect = h * conj(h) * self.sigma**2

Expand Down Expand Up @@ -249,6 +249,7 @@ def simulation(self, ts_length=90, random_state=None):
A simulation of the model that corresponds to this class

"""
from scipy.signal import dlsim
random_state = check_random_state(random_state)

sys = self.ma_poly, self.ar_poly, 1
Expand Down