Skip to content

Commit 2ddf149

Browse files
author
Matthias Koeppe
committed
src/sage/stats: sage -fixdoctests --only-tags
1 parent 2639932 commit 2ddf149

File tree

7 files changed

+58
-58
lines changed

7 files changed

+58
-58
lines changed

src/sage/stats/basic_stats.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,22 @@ def mean(v):
6868
6969
EXAMPLES::
7070
71-
sage: mean([pi, e]) # optional - sage.symbolic
71+
sage: mean([pi, e]) # needs sage.symbolic
7272
doctest:warning...
7373
DeprecationWarning: sage.stats.basic_stats.mean is deprecated;
7474
use numpy.mean or numpy.nanmean instead
7575
See https://github.com/sagemath/sage/issues/29662 for details.
7676
1/2*pi + 1/2*e
77-
sage: mean([]) # optional - sage.symbolic
77+
sage: mean([]) # needs sage.symbolic
7878
NaN
79-
sage: mean([I, sqrt(2), 3/5]) # optional - sage.symbolic
79+
sage: mean([I, sqrt(2), 3/5]) # needs sage.symbolic
8080
1/3*sqrt(2) + 1/3*I + 1/5
8181
sage: mean([RIF(1.0103,1.0103), RIF(2)])
8282
1.5051500000000000?
8383
sage: mean(range(4))
8484
3/2
85-
sage: v = stats.TimeSeries([1..100]) # optional - numpy
86-
sage: mean(v) # optional - numpy
85+
sage: v = stats.TimeSeries([1..100]) # needs numpy
86+
sage: mean(v) # needs numpy
8787
50.5
8888
"""
8989
deprecation(29662, 'sage.stats.basic_stats.mean is deprecated; use numpy.mean or numpy.nanmean instead')
@@ -198,8 +198,8 @@ def std(v, bias=False):
198198
199199
EXAMPLES::
200200
201-
sage: # optional - sage.symbolic
202-
sage: std([1..6], bias=True) # optional - sage.symbolic
201+
sage: # needs sage.symbolic
202+
sage: std([1..6], bias=True)
203203
doctest:warning...
204204
DeprecationWarning: sage.stats.basic_stats.std is deprecated;
205205
use numpy.std or numpy.nanstd instead
@@ -213,25 +213,25 @@ def std(v, bias=False):
213213
use numpy.mean or numpy.nanmean instead
214214
See https://github.com/sagemath/sage/issues/29662 for details.
215215
1/2*sqrt(35/3)
216-
sage: std([1..6], bias=False) # optional - sage.symbolic
216+
sage: std([1..6], bias=False)
217217
sqrt(7/2)
218-
sage: std([e, pi]) # optional - sage.symbolic
218+
sage: std([e, pi])
219219
sqrt(1/2)*abs(pi - e)
220-
sage: std([]) # optional - sage.symbolic
220+
sage: std([])
221221
NaN
222-
sage: std([I, sqrt(2), 3/5]) # optional - sage.symbolic
222+
sage: std([I, sqrt(2), 3/5])
223223
1/15*sqrt(1/2)*sqrt((10*sqrt(2) - 5*I - 3)^2
224224
+ (5*sqrt(2) - 10*I + 3)^2 + (5*sqrt(2) + 5*I - 6)^2)
225225
sage: std([RIF(1.0103, 1.0103), RIF(2)])
226226
0.6998235813403261?
227227
228-
sage: # optional - numpy
229-
sage: import numpy # optional - numpy
230-
sage: x = numpy.array([1,2,3,4,5]) # optional - numpy
231-
sage: std(x, bias=False) # optional - numpy
228+
sage: # needs numpy
229+
sage: import numpy
230+
sage: x = numpy.array([1,2,3,4,5])
231+
sage: std(x, bias=False)
232232
1.5811388300841898
233-
sage: x = stats.TimeSeries([1..100]) # optional - numpy
234-
sage: std(x) # optional - numpy
233+
sage: x = stats.TimeSeries([1..100])
234+
sage: std(x)
235235
29.011491975882016
236236
237237
TESTS::
@@ -294,18 +294,18 @@ def variance(v, bias=False):
294294
7/2
295295
sage: variance([1..6], bias=True)
296296
35/12
297-
sage: variance([e, pi]) # optional - sage.symbolic
297+
sage: variance([e, pi]) # needs sage.symbolic
298298
1/2*(pi - e)^2
299299
sage: variance([])
300300
NaN
301-
sage: variance([I, sqrt(2), 3/5]) # optional - sage.symbolic
301+
sage: variance([I, sqrt(2), 3/5]) # needs sage.symbolic
302302
1/450*(10*sqrt(2) - 5*I - 3)^2 + 1/450*(5*sqrt(2) - 10*I + 3)^2
303303
+ 1/450*(5*sqrt(2) + 5*I - 6)^2
304304
sage: variance([RIF(1.0103, 1.0103), RIF(2)])
305305
0.4897530450000000?
306-
sage: import numpy # optional - numpy
307-
sage: x = numpy.array([1,2,3,4,5]) # optional - numpy
308-
sage: variance(x, bias=False) # optional - numpy
306+
sage: import numpy # needs numpy
307+
sage: x = numpy.array([1,2,3,4,5]) # needs numpy
308+
sage: variance(x, bias=False) # needs numpy
309309
2.5
310310
sage: x = stats.TimeSeries([1..100])
311311
sage: variance(x)
@@ -398,11 +398,11 @@ def median(v):
398398
use numpy.median or numpy.nanmedian instead
399399
See https://github.com/sagemath/sage/issues/29662 for details.
400400
3
401-
sage: median([e, pi]) # optional - sage.symbolic
401+
sage: median([e, pi]) # needs sage.symbolic
402402
1/2*pi + 1/2*e
403403
sage: median(['sage', 'linux', 'python'])
404404
'python'
405-
sage: median([]) # optional - sage.symbolic
405+
sage: median([]) # needs sage.symbolic
406406
NaN
407407
sage: class MyClass:
408408
....: def median(self):
@@ -459,7 +459,7 @@ def moving_average(v, n):
459459
[5/2, 7/2, 9/2, 11/2, 13/2, 15/2, 17/2]
460460
sage: moving_average([], 1)
461461
[]
462-
sage: moving_average([pi, e, I, sqrt(2), 3/5], 2) # optional - sage.symbolic
462+
sage: moving_average([pi, e, I, sqrt(2), 3/5], 2) # needs sage.symbolic
463463
[1/2*pi + 1/2*e, 1/2*e + 1/2*I, 1/2*sqrt(2) + 1/2*I,
464464
1/2*sqrt(2) + 3/10]
465465
@@ -468,10 +468,10 @@ def moving_average(v, n):
468468
different) meaning as defined above (the point is that the
469469
:meth:`simple_moving_average` on time series returns `n` values::
470470
471-
sage: a = stats.TimeSeries([1..10]) # optional - numpy
472-
sage: stats.moving_average(a, 3) # optional - numpy
471+
sage: a = stats.TimeSeries([1..10]) # needs numpy
472+
sage: stats.moving_average(a, 3) # needs numpy
473473
[2.0000, 3.0000, 4.0000, 5.0000, 6.0000, 7.0000, 8.0000, 9.0000]
474-
sage: stats.moving_average(list(a), 3) # optional - numpy
474+
sage: stats.moving_average(list(a), 3) # needs numpy
475475
[2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]
476476
477477
"""

src/sage/stats/distributions/discrete_gaussian_lattice.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class DiscreteGaussianDistributionLatticeSampler(SageObject):
139139
sage: D = DiscreteGaussianDistributionLatticeSampler(identity_matrix(2), 3.0)
140140
sage: S = [D() for _ in range(2^12)]
141141
sage: l = [vector(v.list() + [S.count(v)]) for v in set(S)]
142-
sage: list_plot3d(l, point_list=True, interpolation='nn') # optional - sage.plot
142+
sage: list_plot3d(l, point_list=True, interpolation='nn') # needs sage.plot
143143
Graphics3d Object
144144
145145
REFERENCES:
@@ -205,7 +205,7 @@ def _normalisation_factor_zz(self, tau=3):
205205
sage: n = 3; sigma = 1.0
206206
sage: D = DiscreteGaussianDistributionLatticeSampler(ZZ^n, sigma)
207207
sage: f = D.f
208-
sage: c = D._normalisation_factor_zz(); c # optional - sage.symbolic
208+
sage: c = D._normalisation_factor_zz(); c # needs sage.symbolic
209209
15.528...
210210
211211
sage: from collections import defaultdict
@@ -222,15 +222,15 @@ def _normalisation_factor_zz(self, tau=3):
222222
sage: while v not in counter:
223223
....: add_samples(1000)
224224
225-
sage: while abs(m*f(v)*1.0/c/counter[v] - 1.0) >= 0.1: # optional - sage.symbolic
225+
sage: while abs(m*f(v)*1.0/c/counter[v] - 1.0) >= 0.1: # needs sage.symbolic
226226
....: add_samples(1000)
227227
228228
sage: v = vector(ZZ, n, (-1, 2, 3))
229229
sage: v.set_immutable()
230230
sage: while v not in counter:
231231
....: add_samples(1000)
232232
233-
sage: while abs(m*f(v)*1.0/c/counter[v] - 1.0) >= 0.2: # long time, optional - sage.symbolic
233+
sage: while abs(m*f(v)*1.0/c/counter[v] - 1.0) >= 0.2: # long time, needs sage.symbolic
234234
....: add_samples(1000)
235235
"""
236236
if self.B != identity_matrix(ZZ, self.B.nrows()):
@@ -265,7 +265,7 @@ def __init__(self, B, sigma=1, c=None, precision=None):
265265
sage: n = 2; sigma = 3.0
266266
sage: D = DiscreteGaussianDistributionLatticeSampler(ZZ^n, sigma)
267267
sage: f = D.f
268-
sage: c = D._normalisation_factor_zz(); c # optional - sage.symbolic
268+
sage: c = D._normalisation_factor_zz(); c # needs sage.symbolic
269269
56.2162803067524
270270
271271
sage: from collections import defaultdict
@@ -281,25 +281,25 @@ def __init__(self, B, sigma=1, c=None, precision=None):
281281
sage: v.set_immutable()
282282
sage: while v not in counter:
283283
....: add_samples(1000)
284-
sage: while abs(m*f(v)*1.0/c/counter[v] - 1.0) >= 0.1: # optional - sage.symbolic
284+
sage: while abs(m*f(v)*1.0/c/counter[v] - 1.0) >= 0.1: # needs sage.symbolic
285285
....: add_samples(1000)
286286
287287
sage: v = vector(ZZ, n, (0, 0))
288288
sage: v.set_immutable()
289289
sage: while v not in counter:
290290
....: add_samples(1000)
291-
sage: while abs(m*f(v)*1.0/c/counter[v] - 1.0) >= 0.1: # optional - sage.symbolic
291+
sage: while abs(m*f(v)*1.0/c/counter[v] - 1.0) >= 0.1: # needs sage.symbolic
292292
....: add_samples(1000)
293293
294294
sage: from sage.stats.distributions.discrete_gaussian_lattice import DiscreteGaussianDistributionLatticeSampler
295295
sage: qf = QuadraticForm(matrix(3, [2, 1, 1, 1, 2, 1, 1, 1, 2]))
296-
sage: D = DiscreteGaussianDistributionLatticeSampler(qf, 3.0); D # optional - sage.symbolic
296+
sage: D = DiscreteGaussianDistributionLatticeSampler(qf, 3.0); D # needs sage.symbolic
297297
Discrete Gaussian sampler with σ = 3.000000, c=(0, 0, 0) over lattice with basis
298298
<BLANKLINE>
299299
[2 1 1]
300300
[1 2 1]
301301
[1 1 2]
302-
sage: D().parent() is D.c.parent() # optional - sage.symbolic
302+
sage: D().parent() is D.c.parent() # needs sage.symbolic
303303
True
304304
"""
305305
precision = DiscreteGaussianDistributionLatticeSampler.compute_precision(precision, sigma)

src/sage/stats/distributions/discrete_gaussian_polynomial.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
sage: sigma = 3.0; n = 1000
1818
sage: l = [DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], 64, sigma)()
1919
....: for _ in range(n)]
20-
sage: l = [vector(f).norm().n() for f in l] # optional - sage.symbolic
21-
sage: from numpy import mean # optional - numpy
22-
sage: mean(l), sqrt(64)*sigma # abs tol 5e-1 # optional - numpy sage.symbolic
20+
sage: l = [vector(f).norm().n() for f in l] # needs sage.symbolic
21+
sage: from numpy import mean # needs numpy
22+
sage: mean(l), sqrt(64)*sigma # abs tol 5e-1 # needs numpy sage.symbolic
2323
(24.0, 24.0)
2424
2525
"""

src/sage/stats/hmm/distributions.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ cdef class Distribution:
134134
EXAMPLES::
135135
136136
sage: P = hmm.GaussianMixtureDistribution([(.2,-10,.5),(.6,1,1),(.2,20,.5)])
137-
sage: P.plot(-10,30) # optional - sage.plot
137+
sage: P.plot(-10,30) # needs sage.plot
138138
Graphics object consisting of 1 graphics primitive
139139
"""
140140
from sage.plot.all import plot

src/sage/stats/hmm/hmm.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,11 @@ cdef class HiddenMarkovModel:
148148
sage: m = hmm.DiscreteHiddenMarkovModel([[.3,0,.7],[0,0,1],[.5,.5,0]],
149149
....: [[.5,.5,.2]]*3,
150150
....: [1/3]*3)
151-
sage: G = m.graph(); G # optional - sage.graphs
151+
sage: G = m.graph(); G # needs sage.graphs
152152
Looped digraph on 3 vertices
153-
sage: G.edges(sort=True) # optional - sage.graphs
153+
sage: G.edges(sort=True) # needs sage.graphs
154154
[(0, 0, 0.3), (0, 2, 0.7), (1, 2, 1.0), (2, 0, 0.5), (2, 1, 0.5)]
155-
sage: G.plot() # optional - sage.graphs sage.plot
155+
sage: G.plot() # needs sage.graphs sage.plot
156156
Graphics object consisting of 11 graphics primitives
157157
"""
158158
cdef int i, j
@@ -314,7 +314,7 @@ cdef class DiscreteHiddenMarkovModel(HiddenMarkovModel):
314314
Initial probabilities: [0.0000, 1.0000]
315315
sage: m.sample(10)
316316
[0, 1, 0, 1, 0, 1, 0, 1, 0, 1]
317-
sage: m.graph().plot() # optional - sage.plot
317+
sage: m.graph().plot() # needs sage.plot
318318
Graphics object consisting of 6 graphics primitives
319319
320320
A 3-state model that happens to always outputs 'b'::

src/sage/stats/intlist.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,9 @@ cdef class IntList:
520520
521521
EXAMPLES::
522522
523-
sage: stats.IntList([3,7,19,-2]).plot() # optional - sage.plot
523+
sage: stats.IntList([3,7,19,-2]).plot() # needs sage.plot
524524
Graphics object consisting of 1 graphics primitive
525-
sage: stats.IntList([3,7,19,-2]).plot(color='red', # optional - sage.plot
525+
sage: stats.IntList([3,7,19,-2]).plot(color='red', # needs sage.plot
526526
....: pointsize=50, points=True)
527527
Graphics object consisting of 1 graphics primitive
528528
"""
@@ -538,7 +538,7 @@ cdef class IntList:
538538
539539
EXAMPLES::
540540
541-
sage: stats.IntList([1..15]).plot_histogram() # optional - sage.plot
541+
sage: stats.IntList([1..15]).plot_histogram() # needs sage.plot
542542
Graphics object consisting of 50 graphics primitives
543543
"""
544544
return self.time_series().plot_histogram(*args, **kwds)

0 commit comments

Comments
 (0)