-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Warn only when n
in not int
in tauchen
#673
Conversation
quantecon/markov/approximation.py
Outdated
" https://github.com/QuantEcon/QuantEcon.py/issues/663.", | ||
UserWarning, stacklevel=2) | ||
|
||
if not isinstance(n, int): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not isinstance(n, int): | |
if not isinstance(n, numbers.Integral): |
isinstance(n, int)
returns False
for example if n
is an np.int_
:
>>> n = np.array([1])[0]
>>> type(n)
<class 'numpy.int64'>
>>> isinstance(n, int)
False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed!
@@ -19,8 +19,7 @@ def setup_method(self): | |||
self.tol = 1e-12 | |||
self.mu = 0. | |||
|
|||
with pytest.warns(UserWarning): | |||
mc = tauchen(self.n, self.rho, self.sigma, self.mu, self.n_std) | |||
mc = tauchen(self.n, self.rho, self.sigma, self.mu, self.n_std) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Smit-create maybe we can also test the warning when the old interface is used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thanks @mmcky
thanks @Smit-create I think this is a good approach 👍 |
QuantEcon/lecture-python.myst#296 (comment)