Esempio n. 1
0
    def test_freezethaw1d(self):

        x = np.array([0, 7, -1, 8, 0, -15, 0])
        self.assertEquals(freezethaw1d(x, 15), 0)
        x = np.array([16, -15, 0])
        self.assertEquals(freezethaw1d(x, 15), 1)

        x = np.array([0, 15, 0, -15, 0])
        self.assertEquals(freezethaw1d(x, 15), 1)

        x = np.array([0, 15, -15, 0])
        self.assertEquals(freezethaw1d(x, 15), 1)

        x = np.array([0, 7, -1, 9, 0, -15, 0])
        self.assertEquals(freezethaw1d(x, 15), 1)

        x = np.array([-10, 15, 0, -15, 0])
        self.assertEquals(freezethaw1d(x, 15), 1)

        x = np.array([0, 1, 2, 3, 0, -1, 0, 1, -2, -3, 3])
        self.assertEquals(freezethaw1d(x, 2), 2)

        x = np.array([0, 1, 2, 3, 4])
        self.assertEquals(freezethaw1d(x, 2), 0)

        x = np.array([0, -2, 0, -2, 0, -2, 2, 0, 2, 0, -2])
        self.assertEquals(freezethaw1d(x, 2), 2)

        x = np.array(
            [3, 4, 5, 2, 3, -3, 4, 5, -5, -6, -3, 0, -1, 4, 5, 2, -3, -5, 6])
        self.assertEquals(freezethaw1d(x, 2), 6)

        x = np.array([
            2,
            3,
            4,
            -1,
            0,
            2.5,
            0,
            0,
            -1,
            -1,
            -2,
            -3,
            -4,
            -5,
            1,
            -5,
            -6,
            4,
            5,
        ])
        self.assertEquals(freezethaw1d(x, 2), 2)

        x = np.array([
            3,
            4,
            5,
            2,
            3,
            -3,
            4,
            5,
            -5,
            -6,
            -3,
            0,
            -1,
            4,
            5,
            2,
            -3,
            -5,
        ])
        self.assertEquals(freezethaw1d(x, 2), 5)
Esempio n. 2
0
 def test_missing(self):
     x = np.ma.masked_values([0, -1, 1, -1, 2, -2, 0], 2)
     self.assertEquals(freezethaw1d(x, 1), 2)
Esempio n. 3
0
 def test_missing(self):
     x = np.ma.masked_values([0, -1, 1, -1, 2, -2, 0], 2)
     self.assertEquals(freezethaw1d(x, 1), 2)
Esempio n. 4
0
    def test_freezethaw1d(self):
        x = np.array([0, 7, -1, 8, 0, -15, 0])
        self.assertEquals(freezethaw1d(x, 15), 0)
        x = np.array([16, -15, 0])
        self.assertEquals(freezethaw1d(x, 15), 1)

        x = np.array([0, 15, 0, -15, 0])
        self.assertEquals(freezethaw1d(x, 15), 1)

        x = np.array([0, 15, -15, 0])
        self.assertEquals(freezethaw1d(x, 15), 1)

        x = np.array([0, 7, -1, 9, 0, -15, 0])
        self.assertEquals(freezethaw1d(x, 15), 1)

        x = np.array([-10, 15, 0, -15, 0])
        self.assertEquals(freezethaw1d(x, 15), 1)

        x = np.array([0, 1, 2, 3, 0, -1, 0, 1, -2, -3, 3])
        self.assertEquals(freezethaw1d(x, 2), 2)

        x = np.array([0, 1, 2, 3, 4])
        self.assertEquals(freezethaw1d(x, 2), 0)

        x = np.array([0, -2, 0, -2, 0, -2, 2, 0, 2, 0, -2])
        self.assertEquals(freezethaw1d(x, 2), 2)

        x = np.array([3, 4, 5, 2, 3, -3, 4, 5, -5, -6, -3, 0, -1, 4, 5, 2, -3, -5, 6])
        self.assertEquals(freezethaw1d(x, 2), 6)

        x = np.array([2, 3, 4, -1, 0, 2.5, 0, 0, -1, -1, -2, -3, -4, -5, 1, -5, -6, 4, 5, ])
        self.assertEquals(freezethaw1d(x, 2), 2)

        x = np.array([3, 4, 5, 2, 3, -3, 4, 5, -5, -6, -3, 0, -1, 4, 5, 2, -3,
                      -5, ])
        self.assertEquals(freezethaw1d(x, 2), 5)

        x = np.array([3, 4, 4, 4, 4, 4, 4, 4])
        self.assertEquals(freezethaw1d(x, 2), 0)