コード例 #1
0
 def test_get_band(self):
     band = Bands()
     self.assertEqual(band.get_bands(2, 9.8, 1),
                      [2, 3, 4, 5, 6, 7, 8, 9, 10])
     self.assertEqual(band.get_bands(700, 1253, 100),
                      [700, 800, 900, 1000, 1100, 1200, 1300])
     self.assertEqual(band.get_bands(2, 6.2, 1), [2, 3, 4, 5, 6, 7])
コード例 #2
0
 def test_get_min_value(self):
     band = Bands()
     self.assertEqual(band.get_min_value(2.4, 1), 2)
     self.assertEqual(band.get_min_value(14153, 10), 14150)
     self.assertEqual(band.get_min_value(14153, 5), 14150)
     self.assertEqual(band.get_min_value(3553, 500), 3500)
     self.assertEqual(band.get_min_value(3134, 1), 3134)
コード例 #3
0
 def test_get_chunk_size(self):
     band = Bands()
     self.assertEqual(band.get_chunk_size(2.2, 9.8), 1)
     self.assertEqual(band.get_chunk_size(20, 400), 10)
     self.assertEqual(band.get_chunk_size(400, 410), 1)
     self.assertEqual(band.get_chunk_size(400, 142410), 10000)
     self.assertEqual(band.get_chunk_size(13456, 14019), 50)
コード例 #4
0
 def test_nicen_number(self):
     band = Bands()
     self.assertEqual(band.nicen_number(1.2), 1)
     self.assertEqual(band.nicen_number(23.559), 10)
     self.assertEqual(band.nicen_number(4355.9), 5000)
     self.assertEqual(band.nicen_number(790.9), 1000)
     self.assertEqual(band.nicen_number(0.9), 1)
     self.assertEqual(band.nicen_number(3), 1)
コード例 #5
0
 def test_get_base(self):
     band = Bands()
     self.assertEqual(band.get_base(1), 0)
     self.assertEqual(band.get_base(5), 0)
     self.assertEqual(band.get_base(10), 1)
     self.assertEqual(band.get_base(10.0), 1)
     self.assertEqual(band.get_base(1234.2203), 3)
     self.assertEqual(band.get_base(2.5), 0)
コード例 #6
0
 def test_get_bands(self):
     bands = Bands()
     print(bands.get_banding(2.2, 9.8))
コード例 #7
0
 def test_get_labels(self):
     band = Bands()
     self.assertEqual(band.get_labels([100, 200, 300]), [150, 250])
     self.assertEqual(band.get_labels([2, 4, 6, 8]), [3, 5, 7])
     self.assertEqual(band.get_labels([1, 2, 3, 4]), [1.5, 2.5, 3.5])
コード例 #8
0
import pandas
from Banding import Bands
import json
import psycopg2

banding = Bands()


class Startup(object):
    def load_data(self, location, type):
        if type == 'sql':
            return self.load_from_database(location)
        elif type == 'file':
            return self.load_from_file(location)

    def load_from_database(self, sql):
        '''
        :param sql:
        :return:
        '''
        return pandas.read_sql_query(
            sql, psycopg2.connect("dbname=Bechdel user=postgres password="))

    def load_from_file(self, file):
        '''
        Queriers either the bechdel database or a raw file
        :return: Dictionary of data
        '''
        return pandas.read_json(file)

    def get_metadata(self, df):