From 875524321c6c9a7c6df13a25126c6de240eb95fc Mon Sep 17 00:00:00 2001 From: rht Date: Tue, 11 Dec 2018 04:09:13 +0000 Subject: [PATCH 1/4] quad: Import sympy only when necessary --- quantecon/quad.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantecon/quad.py b/quantecon/quad.py index 82dfcb093..7762a0d32 100644 --- a/quantecon/quad.py +++ b/quantecon/quad.py @@ -14,7 +14,6 @@ import numpy as np import scipy.linalg as la from numba import jit, vectorize -import sympy as sym from .ce_util import ckron, gridmake from .util import check_random_state @@ -141,6 +140,7 @@ def qnwequi(n, a, b, kind="N", equidist_pp=None, random_state=None): random_state = check_random_state(random_state) if equidist_pp is None: + import sympy as sym equidist_pp = np.sqrt(np.array(list(sym.primerange(0, 7920)))) n, a, b = list(map(np.atleast_1d, list(map(np.asarray, [n, a, b])))) From d869c88126085633c4615814a75c08c86094f3eb Mon Sep 17 00:00:00 2001 From: rht Date: Tue, 11 Dec 2018 14:45:15 +0000 Subject: [PATCH 2/4] util.notebooks: Import requests only when necessary --- quantecon/util/notebooks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantecon/util/notebooks.py b/quantecon/util/notebooks.py index 82c31e0e6..28f5d3532 100644 --- a/quantecon/util/notebooks.py +++ b/quantecon/util/notebooks.py @@ -20,7 +20,6 @@ """ import os -import requests import warnings #-Remote Structure-# @@ -72,6 +71,7 @@ def fetch_nb_dependencies(files, repo=REPO, raw=RAW, branch=BRANCH, folder=FOLDE by setting ``overwrite=True``. """ + import requests #-Generate Common Data Structure-# if type(files) == list: From a8e2ddc1db338713774da5926162c402b0d9b778 Mon Sep 17 00:00:00 2001 From: rht Date: Tue, 11 Dec 2018 14:59:05 +0000 Subject: [PATCH 3/4] random.utilities: Cache guvectorize --- quantecon/random/utilities.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/quantecon/random/utilities.py b/quantecon/random/utilities.py index 5312b8d10..c2d68d23d 100644 --- a/quantecon/random/utilities.py +++ b/quantecon/random/utilities.py @@ -89,10 +89,12 @@ def _probvec(r, out): out[n] = 1 - r[n-1] _probvec_parallel = guvectorize( - ['(f8[:], f8[:])'], '(n), (k)', nopython=True, target='parallel' + ['(f8[:], f8[:])'], '(n), (k)', nopython=True, target='parallel', + cache=True )(_probvec) _probvec_cpu = guvectorize( - ['(f8[:], f8[:])'], '(n), (k)', nopython=True, target='cpu' + ['(f8[:], f8[:])'], '(n), (k)', nopython=True, target='cpu', + cache=True )(_probvec) From e265b2541de8e827b7f20236b6f97ed087216aad Mon Sep 17 00:00:00 2001 From: rht Date: Wed, 12 Dec 2018 10:45:04 +0000 Subject: [PATCH 4/4] quantecon.arma: Import scipy.signal functions only when necessary --- quantecon/arma.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/quantecon/arma.py b/quantecon/arma.py index 9c6d26df2..6865bafb9 100644 --- a/quantecon/arma.py +++ b/quantecon/arma.py @@ -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 @@ -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 @@ -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 @@ -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 @@ -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