コード例 #1
0
    def test_density(self):
        """Test seawater's mass density.

        """
        seawater = pyseawater.seawater(density=1.04)
        message = "Density is not equal to the expected value of 1.04."
        self.assertEqual(seawater.density, 1.04, message)
コード例 #2
0
    def setUpClass(cls):
        """Reference hydrogen mass fraction

        """
        seawater = pyseawater.seawater(salinity=35e-3).fractions()
        hydrogen = {element.symbol: element for element in seawater}["H"]
        cls.fraction = seawater[hydrogen]
コード例 #3
0
    def test_less_salt(self):
        """Test hydrogen's mass fraction for less salt.

        """
        seawater = pyseawater.seawater(salinity=34e-3).fractions()
        hydrogen = {element.symbol: element for element in seawater}["H"]
        message = "Hydrogen's mass fraction is not larger for less salt."
        self.assertGreater(seawater[hydrogen], self.fraction, message)
コード例 #4
0
    def test_more_salt(self):
        """Test hydrogen's mass fraction for more salt.

        """
        seawater = pyseawater.seawater(salinity=36e-3).fractions()
        hydrogen = {element.symbol: element for element in seawater}["H"]
        message = "Hydrogen's mass fraction is not smaller for more salt."
        self.assertLess(seawater[hydrogen], self.fraction, message)
コード例 #5
0
    def test_ordering(self):
        """Test mass fractions' odering.

        """
        seawater = pyseawater.seawater(salinity=35e-3).fractions()

        fractions = sorted(
            seawater.items(), key=lambda entry: entry[1], reverse=True)

        symbols = [e.symbol for e, f in fractions]
        expected = ["O", "H", "Cl", "Na", "Mg", "S", "Ca", "K"]

        message = (
            "The sequence of the chemical elements of seawater, sorted by "
            "mass fraction, is not equal to the expectation."
            )

        self.assertListEqual(symbols, expected, message)
コード例 #6
0
 def setUpClass(cls):
     seawater = pyseawater.seawater(salinity=35e-3, density=1.)
     cls.elements = {e.symbol: e for e in seawater.fractions().keys()}