示例#1
0
    def test_localCorr_1Indexing(self):

        dataLocal = [((1, 1, 1), array([1.0, 2.0, 3.0])),
                     ((1, 2, 1), array([2.0, 2.0, 4.0])),
                     ((1, 3, 1), array([9.0, 2.0, 1.0])),
                     ((2, 1, 1), array([5.0, 2.0, 5.0])),
                     ((3, 1, 1), array([4.0, 2.0, 6.0])),
                     ((2, 2, 1), array([4.0, 2.0, 8.0])),
                     ((2, 3, 1), array([5.0, 4.0, 1.0])),
                     ((3, 2, 1), array([6.0, 3.0, 2.0])),
                     ((3, 3, 1), array([0.0, 2.0, 1.0]))]

        # get ground truth by correlating mean with the center
        ts = map(lambda x: x[1], dataLocal)
        mn = mean(ts, axis=0)
        truth = corrcoef(mn, array([4.0, 2.0, 8.0]))[0, 1]

        data = SpatialSeries(self.sc.parallelize(dataLocal))

        corr = data.localCorr(1)

        assert (allclose(corr.collect()[4][1], truth))
示例#2
0
    def test_localcorr_1_indexing(self):

        data_local = [
            ((1, 1, 1), array([1.0, 2.0, 3.0])),
            ((1, 2, 1), array([2.0, 2.0, 4.0])),
            ((1, 3, 1), array([9.0, 2.0, 1.0])),
            ((2, 1, 1), array([5.0, 2.0, 5.0])),
            ((3, 1, 1), array([4.0, 2.0, 6.0])),
            ((2, 2, 1), array([4.0, 2.0, 8.0])),
            ((2, 3, 1), array([5.0, 4.0, 1.0])),
            ((3, 2, 1), array([6.0, 3.0, 2.0])),
            ((3, 3, 1), array([0.0, 2.0, 1.0]))
        ]

        # get ground truth by correlating mean with the center
        ts = map(lambda x: x[1], data_local)
        mn = mean(ts, axis=0)
        truth = corrcoef(mn, array([4.0, 2.0, 8.0]))[0, 1]

        data = SpatialSeries(self.sc.parallelize(data_local))

        corr = data.localCorr(1)

        assert(allclose(corr.collect()[4][1], truth))
示例#3
0
 def toSpatialSeries(self):
     """
     Convert Series to SpatialSeries
     """
     from thunder.rdds.spatialseries import SpatialSeries
     return SpatialSeries(self.rdd).__finalize__(self)