Commit ad417b24 authored by Daniel Boeckenhoff's avatar Daniel Boeckenhoff
Browse files

python2 doctests fixed

parent 994893e5
......@@ -971,6 +971,7 @@ class Tensors(AbstractNdarray):
moment (int): n-th moment
Examples:
>>> import tfields
>>> import numpy as np
Skalars
>>> t = tfields.Tensors(range(1, 6))
......@@ -979,11 +980,10 @@ class Tensors(AbstractNdarray):
Vectors
>>> t = tfields.Tensors(list(zip(range(1, 6), range(1, 6))))
>>> t.moment(1, weights=[-2, -1, 20, 1, 2])
Tensors([0.5, 0.5])
>>> t.moment(1, weights=list(zip([-2, -1, 10, 1, 2],
... [-2, -1, 20, 1, 2])))
Tensors([1. , 0.5])
>>> assert Tensors([0.5, 0.5]).equal(t.moment(1, weights=[-2, -1, 20, 1, 2]))
>>> assert Tensors([1. , 0.5]).equal(
... t.moment(1, weights=list(zip([-2, -1, 10, 1, 2],
... [-2, -1, 20, 1, 2]))))
"""
array = tfields.lib.stats.moment(self, moment, weights=weights)
......
......@@ -172,8 +172,8 @@ def moment(a, moment=1, axis=0, weights=None, nan_policy='propagate'):
2.0
>>> moment([1, 2, 3, 4, 5], moment=2, weights=[5, 4, 3, 2, 1])
2.0
>>> moment([1, 2, 3, 4, 5], moment=2, weights=[0.25, 1, 17.5, 1, 0.25])
0.2
>>> assert moment([1, 2, 3, 4, 5], moment=2,
... weights=[0.25, 1, 17.5, 1, 0.25]) == 0.2
>>> moment([1, 2, 3, 4, 5], moment=2, weights=[0, 0, 1, 0, 0])
0.0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment