def test_modified_knox(self):
     result = interaction.modified_knox(self.events.space,
                                        self.events.t,
                                        delta=20,
                                        tau=5,
                                        permutations=1)
     self.assertAlmostEqual(result['stat'], 2.810160, 6)
        filename = dataobjects.exportVectorLayer(layer)
        provider = layer.dataProvider()
		
		### Input for attribute table fields 
        fields = provider.fields()
        fields.append(QgsField('STAT', QVariant.Float))
        fields.append(QgsField('PVALUE', QVariant.Float))

        writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
            fields, provider.geometryType(), layer.crs() )
			
		events = interaction.SpaceTimeEvents(self.INPUT,'T')

        f = pysal.open(filename.replace('.shp','.dbf'))
        y=np.array(f.by_col[str(field)])
        mkt = interaction.modified_knox(events.space, events.t,delta=20,tau=5,permutations=99)

        self.setOutputValue(self.P_SIM, str(mkt.p_sim))

		outFeat = QgsFeature()
        i = 0
        for inFeat in processing.features(layer):
            inGeom = inFeat.geometry()
            outFeat.setGeometry(inGeom)
            attrs = inFeat.attributes()
            attrs.append(float(mkt.p_sim[i]))
            outFeat.setAttributes(attrs)
            writer.addFeature(outFeat)
            i+=1

        del writer
예제 #3
0
 def test_modified_knox(self):
     result = interaction.modified_knox(self.events.space, self.events.t, delta=20, tau=5, permutations=1)
     self.assertAlmostEquals(result["stat"], 2.810160, 6)