Skip to content

Commit a380d08

Browse files
committed
TST: Reuse test inputs in test_docscrape_sphinx.py.
1 parent effcf01 commit a380d08

File tree

1 file changed

+1
-194
lines changed

1 file changed

+1
-194
lines changed

numpydoc/tests/test_docscrape_sphinx.py

Lines changed: 1 addition & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -19,155 +19,14 @@
1919
from numpydoc.numpydoc import update_config
2020
from numpydoc.xref import DEFAULT_LINKS
2121

22-
doc_txt = """\
23-
numpy.multivariate_normal(mean, cov, shape=None, spam=None)
24-
25-
Draw values from a multivariate normal distribution with specified
26-
mean and covariance.
27-
28-
The multivariate normal or Gaussian distribution is a generalisation
29-
of the one-dimensional normal distribution to higher dimensions.
30-
31-
Parameters
32-
----------
33-
mean : (N,) ndarray
34-
Mean of the N-dimensional distribution.
35-
36-
.. math::
37-
38-
(1+2+3)/3
39-
40-
cov : (N, N) ndarray
41-
Covariance matrix of the distribution.
42-
shape : tuple of ints
43-
Given a shape of, for example, (m,n,k), m*n*k samples are
44-
generated, and packed in an m-by-n-by-k arrangement. Because
45-
each sample is N-dimensional, the output shape is (m,n,k,N).
46-
dtype : data type object, optional (default : float)
47-
The type and size of the data to be returned.
48-
49-
Returns
50-
-------
51-
out : ndarray
52-
The drawn samples, arranged according to `shape`. If the
53-
shape given is (m,n,...), then the shape of `out` is
54-
(m,n,...,N).
55-
56-
In other words, each entry ``out[i,j,...,:]`` is an N-dimensional
57-
value drawn from the distribution.
58-
list of str
59-
This is not a real return value. It exists to test
60-
anonymous return values.
61-
no_description
62-
63-
Other Parameters
64-
----------------
65-
spam : parrot
66-
A parrot off its mortal coil.
67-
68-
Raises
69-
------
70-
RuntimeError
71-
Some error
72-
73-
Warns
74-
-----
75-
RuntimeWarning
76-
Some warning
77-
78-
Warnings
79-
--------
80-
Certain warnings apply.
81-
82-
Notes
83-
-----
84-
Instead of specifying the full covariance matrix, popular
85-
approximations include:
86-
87-
- Spherical covariance (`cov` is a multiple of the identity matrix)
88-
- Diagonal covariance (`cov` has non-negative elements only on the diagonal)
89-
90-
This geometrical property can be seen in two dimensions by plotting
91-
generated data-points:
92-
93-
>>> mean = [0,0]
94-
>>> cov = [[1,0],[0,100]] # diagonal covariance, points lie on x or y-axis
95-
96-
>>> x,y = multivariate_normal(mean,cov,5000).T
97-
>>> plt.plot(x,y,'x'); plt.axis('equal'); plt.show()
98-
99-
Note that the covariance matrix must be symmetric and non-negative
100-
definite.
101-
102-
References
103-
----------
104-
.. [1] A. Papoulis, "Probability, Random Variables, and Stochastic
105-
Processes," 3rd ed., McGraw-Hill Companies, 1991
106-
.. [2] R.O. Duda, P.E. Hart, and D.G. Stork, "Pattern Classification,"
107-
2nd ed., Wiley, 2001.
108-
109-
See Also
110-
--------
111-
some, other, funcs
112-
otherfunc : relationship
113-
:py:meth:`spyder.widgets.mixins.GetHelpMixin.show_object_info`
114-
115-
Examples
116-
--------
117-
>>> mean = (1,2)
118-
>>> cov = [[1,0],[1,0]]
119-
>>> x = multivariate_normal(mean,cov,(3,3))
120-
>>> print(x.shape)
121-
(3, 3, 2)
122-
123-
The following is probably true, given that 0.6 is roughly twice the
124-
standard deviation:
125-
126-
>>> print(list((x[0, 0, :] - mean) < 0.6))
127-
[True, True]
128-
129-
.. index:: random
130-
:refguide: random;distributions, random;gauss
131-
132-
"""
133-
22+
from test_docscrape import doc_txt, doc_yields_txt, doc_sent_txt, class_doc_txt
13423

13524
@pytest.fixture(params=["", "\n "], ids=["flush", "newline_indented"])
13625
def doc(request):
13726
return SphinxDocString(request.param + doc_txt)
13827

13928

140-
doc_yields_txt = """
141-
Test generator
142-
143-
Yields
144-
------
145-
a : int
146-
The number of apples.
147-
b : int
148-
The number of bananas.
149-
int
150-
The number of unknowns.
151-
"""
15229
doc_yields = SphinxDocString(doc_yields_txt)
153-
154-
155-
doc_sent_txt = """
156-
Test generator
157-
158-
Yields
159-
------
160-
a : int
161-
The number of apples.
162-
163-
Receives
164-
--------
165-
b : int
166-
The number of bananas.
167-
c : int
168-
The number of oranges.
169-
170-
"""
17130
doc_sent = SphinxDocString(doc_sent_txt)
17231

17332

@@ -956,58 +815,6 @@ def test_duplicate_signature():
956815
assert doc["Signature"].strip() == "z(a, theta)"
957816

958817

959-
class_doc_txt = """
960-
Foo
961-
962-
Parameters
963-
----------
964-
f : callable ``f(t, y, *f_args)``
965-
Aaa.
966-
jac : callable ``jac(t, y, *jac_args)``
967-
968-
Bbb.
969-
970-
Attributes
971-
----------
972-
t : float
973-
Current time.
974-
y : ndarray
975-
Current variable values.
976-
977-
* hello
978-
* world
979-
an_attribute : float
980-
The docstring is printed instead
981-
no_docstring : str
982-
But a description
983-
no_docstring2 : str
984-
multiline_sentence
985-
midword_period
986-
no_period
987-
988-
Methods
989-
-------
990-
a
991-
b
992-
c
993-
994-
Other Parameters
995-
----------------
996-
997-
another parameter : str
998-
This parameter is less important.
999-
1000-
Notes
1001-
-----
1002-
1003-
Some notes about the class.
1004-
1005-
Examples
1006-
--------
1007-
For usage examples, see `ode`.
1008-
"""
1009-
1010-
1011818
def test_class_members_doc_sphinx():
1012819
class Foo:
1013820
@property

0 commit comments

Comments
 (0)