Exemplo n.º 1
0
 def test__setW(self):
     for f in self.test_files:
         with warnings.catch_warnings(record=True) as warn:
             # note: we are just suppressing the warnings here; individual warnings
             #       are tested in their specific readers
             warnings.simplefilter("always")
             wc = WeightConverter(f, dataFormat=self.dataformats[f])
         self.assertEqual(wc.w_set(), True)
         self.assertEqual(wc.w.n, self.ns[f])
Exemplo n.º 2
0
 def test__setW(self):
     for f in self.test_files:
         with warnings.catch_warnings(record=True) as warn:
             # note: we are just suppressing the warnings here; individual warnings
             #       are tested in their specific readers
             warnings.simplefilter("always")
             wc = WeightConverter(self.base_dir + f,
                                  dataFormat=self.dataformats[f])
         self.assertEqual(wc.w_set(), True)
         self.assertEqual(wc.w.n, self.ns[f])
Exemplo n.º 3
0
    def test_write(self):
        for f in self.test_files:
            with warnings.catch_warnings(record=True) as warn:
                # note: we are just suppressing the warnings here; individual warnings
                #       are tested in their specific readers
                warnings.simplefilter("always")
                wc = WeightConverter(self.base_dir + f,
                                     dataFormat=self.dataformats[f])

            for ext, dataformat in self.fileformats:
                if f.lower().endswith(ext):
                    continue
                temp_f = tempfile.NamedTemporaryFile(
                    suffix='.%s' % ext, dir=self.base_dir)
                temp_fname = temp_f.name
                temp_f.close()

                with warnings.catch_warnings(record=True) as warn:
                    # note: we are just suppressing the warnings here; individual warnings
                    #       are tested in their specific readers
                    warnings.simplefilter("always")
                    if ext == 'swm':
                        wc.write(temp_fname, useIdIndex=True)
                    elif dataformat is None:
                        wc.write(temp_fname)
                    elif dataformat in ['arcgis_dbf', 'arcgis_text']:
                        wc.write(temp_fname, dataFormat=dataformat,
                                 useIdIndex=True)
                    elif dataformat == 'stata_text':
                        wc.write(temp_fname, dataFormat=dataformat,
                                 matrix_form=True)
                    else:
                        wc.write(temp_fname, dataFormat=dataformat)

                with warnings.catch_warnings(record=True) as warn:
                    # note: we are just suppressing the warnings here; individual warnings
                    #       are tested in their specific readers
                    warnings.simplefilter("always")
                    if dataformat is None:
                        wnew = pysal.open(temp_fname, 'r').read()
                    else:
                        wnew = pysal.open(temp_fname, 'r', dataformat).read()

                if (ext in ['dbf', 'swm', 'dat', 'wk1', 'gwt'] or dataformat == 'arcgis_text'):
                    self.assertEqual(wnew.n, wc.w.n - len(wc.w.islands))
                else:
                    self.assertEqual(wnew.n, wc.w.n)
                os.remove(temp_fname)
Exemplo n.º 4
0
    def test_write(self):
        for f in self.test_files:
            with warnings.catch_warnings(record=True) as warn:
                # note: we are just suppressing the warnings here; individual warnings
                #       are tested in their specific readers
                warnings.simplefilter("always")
                wc = WeightConverter(f, dataFormat=self.dataformats[f])

            for ext, dataformat in self.fileformats:
                if f.lower().endswith(ext):
                    continue
                temp_f = tempfile.NamedTemporaryFile(suffix='.%s' % ext,
                                                     dir=self.base_dir)
                temp_fname = temp_f.name
                temp_f.close()

                with warnings.catch_warnings(record=True) as warn:
                    # note: we are just suppressing the warnings here; individual warnings
                    #       are tested in their specific readers
                    warnings.simplefilter("always")
                    if ext == 'swm':
                        wc.write(temp_fname, useIdIndex=True)
                    elif dataformat is None:
                        wc.write(temp_fname)
                    elif dataformat in ['arcgis_dbf', 'arcgis_text']:
                        wc.write(temp_fname,
                                 dataFormat=dataformat,
                                 useIdIndex=True)
                    elif dataformat == 'stata_text':
                        wc.write(temp_fname,
                                 dataFormat=dataformat,
                                 matrix_form=True)
                    else:
                        wc.write(temp_fname, dataFormat=dataformat)

                with warnings.catch_warnings(record=True) as warn:
                    # note: we are just suppressing the warnings here; individual warnings
                    #       are tested in their specific readers
                    warnings.simplefilter("always")
                    if dataformat is None:
                        wnew = pysal.open(temp_fname, 'r').read()
                    else:
                        wnew = pysal.open(temp_fname, 'r', dataformat).read()

                if (ext in ['dbf', 'swm', 'dat', 'wk1', 'gwt']
                        or dataformat == 'arcgis_text'):
                    self.assertEqual(wnew.n, wc.w.n - len(wc.w.islands))
                else:
                    self.assertEqual(wnew.n, wc.w.n)
                os.remove(temp_fname)