Skip to content

Commit

Permalink
MAINT: stats: fix lint and mypy checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tirthasheshpatel committed Jul 15, 2021
1 parent 01015cd commit 89c9a98
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions doc/source/tutorial/stats/sampling_dau.rst
Expand Up @@ -80,9 +80,12 @@ table which can be changed by passing a ``urn_factor`` parameter.

.. note:: It is recommended to keep this parameter under 2.

Please see [1]_ and [2]_ for more details on this method.


References
----------

.. [1] UNU.RAN reference manual, Section 5.8.2,
"DAU - (Discrete) Alias-Urn method",
http://statmath.wu.ac.at/software/unuran/doc/unuran.html#DAU
Expand Down
3 changes: 3 additions & 0 deletions doc/source/tutorial/stats/sampling_tdr.rst
Expand Up @@ -174,6 +174,9 @@ found in `Section 5.3.16 of the UNU.RAN user manual
<http://statmath.wu.ac.at/software/unuran/doc/unuran.html#TDR>`__.


Please see [1]_, [2]_, and [3]_ for more details on this method.


References
----------

Expand Down
1 change: 1 addition & 0 deletions scipy/stats/__init__.py
Expand Up @@ -379,6 +379,7 @@
NumericalInverseHermite
TransformedDensityRejection
DiscreteAliasUrn
UNURANError
Circular statistical functions
------------------------------
Expand Down
4 changes: 4 additions & 0 deletions scipy/stats/_unuran/unuran_wrapper.pyi
Expand Up @@ -12,6 +12,10 @@ ArrayLike0D = Union[bool, int, float, complex, str, bytes, np.generic]
__all__: List[str]


class UNURANError(RuntimeError):
...


class Method:
@overload
def rvs(self, size: None = ...) -> float | int: ... # type: ignore[misc]
Expand Down
1 change: 1 addition & 0 deletions scipy/stats/_unuran/unuran_wrapper.pyx.templ
Expand Up @@ -45,6 +45,7 @@ cdef extern from "unuran_callback.h":


class UNURANError(RuntimeError):
"""Raised when an error occurs in the UNU.RAN library."""
pass


Expand Down
8 changes: 4 additions & 4 deletions scipy/stats/tests/test_sampling.py
Expand Up @@ -44,7 +44,7 @@ class common_discr_dist:
# Returning wrong type
(lambda x: [], TypeError, r"must be real number, not list"),
# Undefined name inside the function
(lambda x: foo, NameError, r"name 'foo' is not defined"), # type: ignore[name-defined]
(lambda x: foo, NameError, r"name 'foo' is not defined"), # type: ignore[name-defined] # noqa: F821
# Infinite value returned => Overflow error.
(lambda x: np.inf, UNURANError, r"50 : PDF\(x\) overflow"),
# NaN value => internal error in UNU.RAN
Expand All @@ -68,7 +68,7 @@ class common_discr_dist:
# Returning wrong type
(lambda x: [], TypeError, r"must be real number, not list"),
# Undefined name inside the function
(lambda x: foo, NameError, r"name 'foo' is not defined"), # type: ignore[name-defined]
(lambda x: foo, NameError, r"name 'foo' is not defined"), # type: ignore[name-defined] # noqa: F821
# signature of dPDF wrong
(lambda: 1.0, TypeError, r"takes 0 positional arguments but 1 was given")
]
Expand All @@ -83,7 +83,7 @@ class common_discr_dist:
(lambda x: np.nan, UNURANError, r"240 : unknown error"),
(lambda x: 0.0, UNURANError, r"240 : unknown error"),
# Undefined name inside the function
(lambda x: foo, NameError, r"name 'foo' is not defined"), # type: ignore[name-defined]
(lambda x: foo, NameError, r"name 'foo' is not defined"), # type: ignore[name-defined] # noqa: F821
# Returning wrong type
(lambda x: [], TypeError, r"must be real number, not list"),
# probabilities < 0
Expand Down Expand Up @@ -509,7 +509,7 @@ def test_basic(self, distname, params):
(lambda x: 0.0, ValueError,
r"must contain at least one non-zero value"),
# Undefined name inside the function
(lambda x: foo, NameError, # type: ignore[name-defined]
(lambda x: foo, NameError, # type: ignore[name-defined] # noqa: F821
r"name 'foo' is not defined"),
# Returning wrong type.
(lambda x: [], ValueError,
Expand Down

0 comments on commit 89c9a98

Please sign in to comment.