Commit b4531533 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

do not call deprecated functions

parent d53ebdde
Pipeline #62693 passed with stages
in 7 minutes and 30 seconds
......@@ -457,7 +457,7 @@ class Field(object):
The result of the integration. If it is carried out over the
entire domain, this is a scalar, otherwise a Field.
"""
swgt = self.scalar_weight(spaces)
swgt = self._domain.scalar_weight(spaces)
if swgt is not None:
res = self.sum(spaces)
res = res*swgt
......@@ -527,7 +527,7 @@ class Field(object):
"""Determines the mean over the sub-domains given by `spaces`.
``x.mean(spaces)`` is equivalent to
``x.integrate(spaces)/x.total_volume(spaces)``.
``x.integrate(spaces)/x.domain.total_volume(spaces)``.
Parameters
----------
......@@ -541,12 +541,12 @@ class Field(object):
The result of the operation. If it is carried out over the entire
domain, this is a scalar, otherwise a Field.
"""
if self.scalar_weight(spaces) is not None:
if self._domain.scalar_weight(spaces) is not None:
return self._contraction_helper('mean', spaces)
# MR FIXME: not very efficient
# MR FIXME: do we need "spaces" here?
tmp = self.weight(1, spaces)
return tmp.sum(spaces)*(1./tmp.total_volume(spaces))
return tmp.sum(spaces)*(1./tmp._domain.total_volume(spaces))
def var(self, spaces=None):
"""Determines the variance over the sub-domains given by `spaces`.
......@@ -564,7 +564,7 @@ class Field(object):
The result of the operation. If it is carried out over the entire
domain, this is a scalar, otherwise a Field.
"""
if self.scalar_weight(spaces) is not None:
if self._domain.scalar_weight(spaces) is not None:
return self._contraction_helper('var', spaces)
# MR FIXME: not very efficient or accurate
m1 = self.mean(spaces)
......@@ -594,7 +594,7 @@ class Field(object):
domain, this is a scalar, otherwise a Field.
"""
from .sugar import sqrt
if self.scalar_weight(spaces) is not None:
if self._domain.scalar_weight(spaces) is not None:
return self._contraction_helper('std', spaces)
return sqrt(self.var(spaces))
......
......@@ -219,17 +219,17 @@ def test_weight():
f = ift.Field.full(s1, 10.)
f2 = f.weight(1)
assert_equal(f.weight(1).local_data, f2.local_data)
assert_equal(f.total_volume(), 1)
assert_equal(f.total_volume(0), 1)
assert_equal(f.total_volume((0,)), 1)
assert_equal(f.scalar_weight(), 0.1)
assert_equal(f.scalar_weight(0), 0.1)
assert_equal(f.scalar_weight((0,)), 0.1)
assert_equal(f.domain.total_volume(), 1)
assert_equal(f.domain.total_volume(0), 1)
assert_equal(f.domain.total_volume((0,)), 1)
assert_equal(f.domain.scalar_weight(), 0.1)
assert_equal(f.domain.scalar_weight(0), 0.1)
assert_equal(f.domain.scalar_weight((0,)), 0.1)
s1 = ift.GLSpace(10)
f = ift.Field.full(s1, 10.)
assert_equal(f.scalar_weight(), None)
assert_equal(f.scalar_weight(0), None)
assert_equal(f.scalar_weight((0,)), None)
assert_equal(f.domain.scalar_weight(), None)
assert_equal(f.domain.scalar_weight(0), None)
assert_equal(f.domain.scalar_weight((0,)), None)
@pmp('dom', [ift.RGSpace(10), ift.GLSpace(10)])
......
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