Ejemplo n.º 1
0
 def mass(self, value):
     if value is None or value == "":
         return
     mass = self._calc_mass()
     if mass is not None and not ct.isclose(
             mass, value, rel_tol=self._tolerance):
         raise ModelError("Mass inconsistent with set density")
     self._mass = float(value)
     self._add_to_stack('mass', self._mass)
     density = self._calc_mass_density()
     if density is not None and not ct.isclose(
             density, self.density, rel_tol=self._tolerance):
         self.mass_density = density
Ejemplo n.º 2
0
def test_isclose():
    assert not ct.isclose(1, None)
    assert not ct.isclose(1, 2)
    assert not ct.isclose(0, 1)
    assert ct.isclose(0, 0)
    assert ct.isclose(0.00, 0.00)
    assert ct.isclose(1.1, 1., rel_tol=1.2)
    assert ct.isclose(1.1, 1., abs_tol=0.2)
Ejemplo n.º 3
0
 def mass_density(self, value):
     if value is None or value == "":
         return
     density = self._calc_mass_density()
     if density is not None and not np.isclose(
             density, value, rtol=self._tolerance):
         raise ModelError("Density inconsistent with set mass")
     self._mass_density = float(value)
     self._add_to_stack('mass_density', float(value))
     mass = self._calc_mass()
     if mass is not None and not ct.isclose(mass, self.mass):
         self.mass = mass
Ejemplo n.º 4
0
 def override_mass(self, value):
     self._mass = float(value)
     density = self._calc_mass_density()
     if density is not None and not ct.isclose(
             density, self.density, rel_tol=self._tolerance):
         self.density = density
Ejemplo n.º 5
0
 def override_density(self, value):
     self._density = float(value)
     mass = self._calc_mass()
     if mass is not None and not ct.isclose(mass, self.mass):
         self.mass = mass