<commit_before>import os
import unittest
import pysal

class _TestWeights(unittest.TestCase):
    def setUp(self):
        """ Setup the rtree and binning contiguity weights"""
        self.polyShp = '../examples/virginia.shp'
        self.pointShp = '../examples/juvenile.shp'
    def test_iter(self):
        """ All methods names that begin with 'test' will be executed as a test case """
        self.assert_(os.path.exists(self.pointShp))
        w = pysal.rook_from_shapefile(self.polyShp)
        for i,j in zip(w,w):
            self.assertEquals(i,j)
        
    def test_B(self):
        """ All methods names that begin with 'test' will be executed as a test case """
        self.assert_(os.path.exists(self.polyShp))

suite = unittest.TestLoader().loadTestsFromTestCase(_TestWeights)

if __name__ == '__main__':
    runner = unittest.TextTestRunner()
    runner.run(suite)<commit_msg>- fillng out weight unit tests<commit_after>import os
import unittest
import pysal

class _TestWeights(unittest.TestCase):
    def setUp(self):
        """ Setup the rtree and binning contiguity weights"""
        self.polyShp = '../examples/virginia.shp'
        self.pointShp = '../examples/juvenile.shp'
        self.w25 = pysal.lat2W(5,5)
    def test_iter(self):
        """ All methods names that begin with 'test' will be executed as a test case """
        self.assert_(os.path.exists(self.pointShp))
        w = pysal.rook_from_shapefile(self.polyShp)
        for i,j in zip(w,w):
            self.assertEquals(i,j)
        
    def test_B(self):
        """ All methods names that begin with 'test' will be executed as a test case """
        self.assert_(os.path.exists(self.polyShp))

    def test_lat2W(self):
        self.assertEquals(self.w25.n,25)
        self.assertEquals(self.w25.s0,80.0)
        self.assertEquals(self.w25.s1,160.0)
        self.assertEquals(self.w25.s2array[23],36.)
        self.assertEquals(self.w25.trcW2,80.)
        self.assertEquals(self.w25.diagW2[23],3.)

    def test_w_f_shp(self):
        self.assert_(os.path.exists(self.pointShp))
        w = pysal.rook_from_shapefile(self.polyShp)
        self.assertEquals(w.n,136)
        self.assertEquals(w.s0,572.0)
        self.assertEquals(w.s1,1144.0)
        self.assertEquals(w.s2array[23],100.)
        self.assertEquals(w.trcW2,572.)
        self.assertEquals(w.diagW2[23],5.)
        self.assertEquals(w.diagWtW[23],5.)
        self.assertEquals(w.trcWtW,572.)
        self.assertEquals(w.diagWtW_WW[23],10.)
        self.assertEquals(w.trcWtW_WW,2*572.)
        self.assertEquals(w.pct_nonzero,0.030925605536332178)
        self.assertEquals(w.cardinalities[2],4)
        self.assertEquals(w.max_neighbors,10)
        self.assertEquals(w.min_neighbors,1)
        self.assertEquals(w.nonzero,572)
        self.assertEquals(w.sd,2.2495674324674049)
        self.assertEquals(w.islands,[])
        self.assertEquals(w.asymmetries,[])
        self.assertEquals(w.transform,'O')
        self.assertEquals(w.weights[2],[1.0,1.0,1.0,1.0])
        w.transform='r'
        self.assertEquals(w.weights[2],[0.25,0.25,0.25,0.25])
        self.assertEquals(w.transform,'R')
        w.transform='v'
        self.assertEquals(w.weights[2],[0.25489183373100938, 0.25489183373100938, 0.25489183373100938, 0.25489183373100938])
        w.transform='b'
        self.assertEquals(w.weights[2],[1.0,1.0,1.0,1.0])
        self.assertFalse(w.asymmetry())
        w.transform='r'
        self.assertTrue(w.asymmetry())
        wf=w.full()[0]
        self.assertEquals(wf[2,0],0.25)
        self.assertEquals(wf[2,2],0)

    def test_util(self):
        w=self.w25
        shim=w.shimbel()
        self.assertEquals(shim[0][0:4],[-1,1,2,3])
        w8=w.higher_order(8)
        self.assertEquals(w8.neighbors[0],[24])


suite = unittest.TestLoader().loadTestsFromTestCase(_TestWeights)

if __name__ == '__main__':
    runner = unittest.TextTestRunner()
    runner.run(suite)
{'fraction_non_alphanumeric': 0.142133265771472, 'fraction_numerical': 0.06460602989612364, 'mean_word_length': 2.8255813953488373, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4483248', 'n_tokens_mistral': 1528, 'n_tokens_neox': 1390, 'n_words': 202}