Пример #1
0
    def test_reshape(self):
        lat = np.linspace(0, 1, 12).reshape((3, 4))
        lon = np.linspace(10, 20, 12).reshape((3, 4))
        c = StackedCoordinates([lat, lon])

        assert c.reshape((4, 3)) == StackedCoordinates([lat.reshape((4, 3)), lon.reshape((4, 3))])
        assert c.flatten().reshape((3, 4)) == c
Пример #2
0
    def test_unque_shaped(self):
        lat = ArrayCoordinates1d([[0, 1, 2], [1, 0, 5]], name="lat")
        lon = ArrayCoordinates1d([[10, 20, 20], [20, 10, 60]], name="lon")
        c = StackedCoordinates([lat, lon])

        # flattens
        c2 = c.unique()
        assert_equal(c2["lat"].coordinates, [0, 1, 2, 5])
        assert_equal(c2["lon"].coordinates, [10, 20, 20, 60])

        c2, I = c.unique(return_index=True)
        assert_equal(c2["lat"].coordinates, [0, 1, 2, 5])
        assert_equal(c2["lon"].coordinates, [10, 20, 20, 60])
        assert c.flatten()[I] == c2