Example #1
0
class TestNoisedValueDivisionWithOtherPositiveNoisedValue(
        TestCase, NoisedValueBaseTestCase):
    v = NoisedValue(val=1.5, var=0.5) / NoisedValue(val=1.12, var=0.2)
    expected_val = 1.339285
    expected_var = 0.68458
    expected_err = 0.82739
    expected_relative_err = 0.617787
Example #2
0
class TestNoisedValueMultiplicationWithOtherNegativeNoisedValue(
        TestCase, NoisedValueBaseTestCase):
    v = NoisedValue(val=1.5, var=0.5) * NoisedValue(val=-2.3, var=2.75)
    expected_val = -3.45
    expected_var = 8.8325
    expected_err = 2.97195
    expected_relative_err = 0.861435
Example #3
0
class TestNoisedValueLeftDivisionWithNegativeConstant(TestCase,
                                                      NoisedValueBaseTestCase):
    v = -1.12 / NoisedValue(val=1.5, var=0.5)
    expected_val = -0.746666
    expected_var = 0.12389
    expected_err = 0.35198
    expected_relative_err = 0.4714
Example #4
0
class TestNoisedValueInitializationWithoutVarianceOrError(
        TestCase, NoisedValueBaseTestCase):
    v = NoisedValue(val=1.5)
    expected_val = 1.5
    expected_var = 0
    expected_err = 0
    expected_relative_err = 0
 def test_representation_of_zero_error(self):
     v = NoisedValue(val=1.5)
     self.assertEqual(
         "1.5 \u00B1 0 (0.000% error)",
         str(v),
         msg="NoisedValue representation is different than expected",
     )
Example #6
0
class TestNoisedValueInitializationWithError(TestCase,
                                             NoisedValueBaseTestCase):
    v = NoisedValue(val=1.5, err=0.5)
    expected_val = 1.5
    expected_var = 0.25
    expected_err = 0.5
    expected_relative_err = 0.33333
 def test_representation_of_non_zero(self):
     v = NoisedValue(val=1.5, err=0.5)
     self.assertEqual(
         "1.5 \u00B1 0.5 (33.333% error)",
         str(v),
         msg="NoisedValue representation is different than expected",
     )
Example #8
0
class TestNoisedValueRightMultiplicationWithPositiveConstant(
        TestCase, NoisedValueBaseTestCase):
    v = NoisedValue(val=1.5, var=0.5) * 1.12
    expected_val = 1.68
    expected_var = 0.6272
    expected_err = 0.79196
    expected_relative_err = 0.4714
Example #9
0
class TestNoisedValueInitializationWithValueZero(TestCase,
                                                 NoisedValueBaseTestCase):
    v = NoisedValue(val=0, err=0.5)
    expected_val = 0
    expected_var = 0.25
    expected_err = 0.5
    expected_relative_err = None
Example #10
0
class TestNoisedValueLeftMultiplicationWithNegativeConstant(
        TestCase, NoisedValueBaseTestCase):
    v = -1.12 * NoisedValue(val=1.5, var=0.5)
    expected_val = -1.68
    expected_var = 0.6272
    expected_err = 0.79196
    expected_relative_err = 0.4714
 def test_representation_of_zero_value(self):
     v = NoisedValue(val=0, err=0.5)
     self.assertEqual(
         "0 \u00B1 0.5 (\u221E% error)",
         str(v),
         msg="NoisedValue representation is different than expected",
     )
Example #12
0
class TestNoisedValueRightDivisionWithPositiveConstant(TestCase,
                                                       NoisedValueBaseTestCase
                                                       ):
    v = NoisedValue(val=1.5, var=0.5) / 1.12
    expected_val = 1.339285
    expected_var = 0.3986
    expected_err = 0.631345
    expected_relative_err = 0.4714
Example #13
0
class TestNoisedValueLeftConstantSubtraction(TestCase, NoisedValueBaseTestCase):
    v = 2.2 - NoisedValue(val=1.5, var=0.5)
    expected_val = 0.7
    expected_var = 0.5
    expected_err = 0.70711
    expected_relative_err = 1.010157
Example #14
0
class TestNoisedValueExponential(TestCase, NoisedValueBaseTestCase):
    v = np.exp(NoisedValue(val=1.5, err=0.5))
    expected_val = 4.48169
    expected_var = 5.02138
    expected_err = 2.24084
    expected_relative_err = 0.5
Example #15
0
class TestNoisedValueInteger3Power(TestCase, NoisedValueBaseTestCase):
    v = NoisedValue(val=1.5, err=0.5) ** 3
    expected_val = 3.375
    expected_var = 11.390625
    expected_err = 3.375
    expected_relative_err = 1
Example #16
0
class TestNoisedValueSin(TestCase, NoisedValueBaseTestCase):
    v = np.sin(NoisedValue(val=np.pi / 6, err=0.5))
    expected_val = 0.5
    expected_var = 0.1875
    expected_err = 0.433013
    expected_relative_err = 0.866025
Example #17
0
class TestNoisedValueCos(TestCase, NoisedValueBaseTestCase):
    v = np.cos(NoisedValue(val=np.pi / 6, err=0.5))
    expected_val = 0.866025
    expected_var = 0.0625
    expected_err = 0.25
    expected_relative_err = 0.288675
Example #18
0
class TestNoisedValueSubtractionWithOtherNoisedValue(TestCase, NoisedValueBaseTestCase):
    v = NoisedValue(val=1.5, var=0.5) - NoisedValue(val=2.2, var=2.75)
    expected_val = -0.7
    expected_var = 3.25
    expected_err = 1.802775
    expected_relative_err = 2.57539
Example #19
0
class TestNoisedValueRightConstantSubtraction(TestCase, NoisedValueBaseTestCase):
    v = NoisedValue(val=1.5, var=0.5) - 2.2
    expected_val = -0.7
    expected_var = 0.5
    expected_err = 0.70711
    expected_relative_err = 1.010157
Example #20
0
class TestNoisedValueInteger2Power(TestCase, NoisedValueBaseTestCase):
    v = NoisedValue(val=1.5, err=0.5) ** 2
    expected_val = 2.25
    expected_var = 2.25
    expected_err = 1.5
    expected_relative_err = 0.666666
Example #21
0
class TestNoisedValueIntegerNegativePower(TestCase, NoisedValueBaseTestCase):
    v = NoisedValue(val=1.5, err=0.5) ** -1
    expected_val = 0.666666
    expected_var = 0.049382
    expected_err = 0.222222
    expected_relative_err = 0.333333
Example #22
0
class TestNoisedValueInteger1Power(TestCase, NoisedValueBaseTestCase):
    v = NoisedValue(val=1.5, err=0.5) ** 1
    expected_val = 1.5
    expected_var = 0.25
    expected_err = 0.5
    expected_relative_err = 0.33333
Example #23
0
class TestNoisedValueAdditionWithOtherNoisedValue(TestCase, NoisedValueBaseTestCase):
    v = NoisedValue(val=1.5, var=0.5) + NoisedValue(val=2.2, var=2.75)
    expected_val = 3.7
    expected_var = 3.25
    expected_err = 1.802775
    expected_relative_err = 0.487236
Example #24
0
class TestNoisedValueRightConstantAddition(TestCase, NoisedValueBaseTestCase):
    v = NoisedValue(val=1.5, var=0.5) + 2.2
    expected_val = 3.7
    expected_var = 0.5
    expected_err = 0.70711
    expected_relative_err = 0.19111
Example #25
0
class TestNoisedValueNegativeValue(TestCase, NoisedValueBaseTestCase):
    v = -NoisedValue(val=1.5, var=0.5)
    expected_val = -1.5
    expected_var = 0.5
    expected_err = 0.70711
    expected_relative_err = 0.4714
Example #26
0
from noised_value import NoisedValue

rho_b = NoisedValue(val=7.812, err=0.055)
rho_l = NoisedValue(val=1.26, err=5.7e-4)
g = NoisedValue(val=981, err=10)
L = NoisedValue(val=22.22, err=2.8e-3)
a = NoisedValue(val=0.1964, err=0.0091)

eta = (2 * g * a * (rho_b - rho_l)) / (9 * L)
expected_eta = NoisedValue(val=12.5, err=1.44)
print(f"experiment eta is: {eta}")
print(f"expected eta is: {expected_eta}")
print(f"n sigma is: {expected_eta.n_sigma(eta)}")

print(NoisedValue(val=0, err=1))