Ejemplo n.º 1
0
 def test_wrong_value(self):
     check_words_example = {
         'sun': 1,
         'cloud': 2,
         'fsdf': 'ewerwr',
         'shower': 4,
         'thunderstorm': 5,
         'fog': 6,
         'snow': 7,
     }
     with self.assertRaises(ValueError):
         processor = Word2ClassPreprocessor(check_words_example)
Ejemplo n.º 2
0
 def test_call(self):
     check_words_example = {
         'sun': 1,
         'cloud': 2,
         'rain': 3,
         'shower': 4,
         'thunderstorm': 5,
         'fog': 6,
         'snow': 7,
     }
     test_sentence = "great thunderstorm and clouing wind"
     processor = Word2ClassPreprocessor(check_words_example)
     self.assertEqual(processor(test_sentence), 5)
Ejemplo n.º 3
0
 def test_none_len(self):
     with self.assertRaises(IndexError):
         processor = Word2ClassPreprocessor({})
Ejemplo n.º 4
0
 def test_wrong_type(self):
     with self.assertRaises(TypeError):
         processor = Word2ClassPreprocessor(None)
Ejemplo n.º 5
0
MONGO_DB = 'weather_db_test'

CHECK_WORDS = {
    'sun': 1,
    'cloud': 2,
    'rain': 3,
    'shower': 4,
    'thunderstorm': 5,
    'fog': 6,
    'snow': 7,
}

KEY_MAP = {
    't_min': (('temperature', 'min'), ),
    't_max': (('temperature', 'max'), ),
    'class': (('description', ), (Word2ClassPreprocessor(CHECK_WORDS), )),
}


class TestPredModel(unittest.TestCase):
    def test_to_vector(self):
        s: pandas.Series = pandas.Series(data=[3, 4, 5, 6, 7, 8, 1, 2, 3, 4])
        vec = to_vector(s)
        self.assertEqual(vec.shape, (len(s), 1))

    def test_normalization(self):
        vec = numpy.array([2, 2]).reshape((2, 1))
        no = reverse_norma(vec)
        for v in no:
            self.assertEqual(v, 0.5)
Ejemplo n.º 6
0
    key_map_object = {
        'temperature_max': (('temperature', 'max'), ),
        'temperature_min': (('temperature', 'min'), ),
        'feels_temperature_max': (('feels_temperature', 'max'), ),
        'feels_temperature_min': (('feels_temperature', 'min'), ),
        'pressure_max': (('pressure', 'max'), ),
        'pressure_min': (('pressure', 'min'), ),
        'humidity_max': (('humidity', 'max'), ),
        'humidity_min': (('humidity', 'min'), ),
        'precipitation_max': (('precipitation', 'max'), ),
        'precipitation_min': (('precipitation', 'min'), ),
        'wind_direction_max': (('wind_direction', 'max'), ),
        'wind_direction_min': (('wind_direction', 'min'), ),
        'wind_speed_max': (('wind_speed', 'max'), ),
        'wind_speed_min': (('wind_speed', 'min'), ),
        'class': (('description', ), (Word2ClassPreprocessor(
            retrieve_check_words(CHECK_WORDS_COLLECTION)), ))
    }

    if not args.city:
        print(
            'City name is empty. Please, Honorable Sir, provide it or pass to command line argument --city'
        )
    elif not args.country:
        print(
            'Country name is empty. Please, Honorable Sir, provide it or pass to command line argument --country'
        )
    else:
        if args.script.upper() == 'REDUCE':
            reduce(args.city, args.country, args.max, args.limit,
                   key_map_object)
        elif args.script.upper() == 'PRODUCE':