<commit_before>__author__ = '<NAME>'

from biome import *
import pickle
from basic_map_operations import *


class World(object):

    def __init__(self, name, width, height):
        self.name = name
        self.width = width
        self.height = height

    def is_mountain(self, pos):
        if not self.is_land(pos):
            return False
        if len(self.elevation['thresholds']) == 4:
            mi = 2
        else:
            mi = 1
        mountain_level = self.elevation['thresholds'][mi][1]
        x, y = pos
        return self.elevation['data'][y][x] > mountain_level

    def is_low_mountain(self, pos):
        if not self.is_mountain(pos):
            return False
        if len(self.elevation['thresholds']) == 4:
            mi = 2
        else:
            mi = 1
        mountain_level = self.elevation['thresholds'][mi][1]
        x, y = pos
        return self.elevation['data'][y][x] < mountain_level + 2.0

    def level_of_mountain(self, pos):
        if not self.is_land(pos):
            return False
        if len(self.elevation['thresholds']) == 4:
            mi = 2
        else:
            mi = 1
        mountain_level = self.elevation['thresholds'][mi][1]
        x, y = pos
        if self.elevation['data'][y][x] <= mountain_level:
            return 0
        else:
            return self.elevation['data'][y][x] - mountain_level

    def is_high_mountain(self, pos):
        if not self.is_mountain(pos):
            return False
        if len(self.elevation['thresholds']) == 4:
            mi = 2
        else:
            mi = 1
        mountain_level = self.elevation['thresholds'][mi][1]
        x, y = pos
        return self.elevation['data'][y][x] > mountain_level + 4.0

    def is_hill(self, pos):
        if not self.is_land(pos):
            return False
        if len(self.elevation['thresholds']) == 4:
            hi = 1
        else:
            hi = 0
        hill_level = self.elevation['thresholds'][hi][1]
        mountain_level = self.elevation['thresholds'][hi + 1][1]
        x, y = pos
        return self.elevation['data'][y][x] > hill_level and self.elevation['data'][y][x] < mountain_level

    def is_temperature_very_low(self, pos):
        th_max = self.temperature['thresholds'][0][1]
        x, y = pos
        t = self.temperature['data'][y][x]
        return t < th_max

    def is_temperature_low(self, pos):
        th_min = self.temperature['thresholds'][0][1]
        th_max = self.temperature['thresholds'][1][1]
        x, y = pos
        t = self.temperature['data'][y][x]
        return t < th_max and t >= th_min

    def is_temperature_medium(self, pos):
        th_min = self.temperature['thresholds'][1][1]
        th_max = self.temperature['thresholds'][2][1]
        x, y = pos
        t = self.temperature['data'][y][x]
        return t < th_max and t >= th_min

    def is_temperature_high(self, pos):
        th_min = self.temperature['thresholds'][2][1]
        x, y = pos
        t = self.temperature['data'][y][x]
        return t >= th_min

    def is_temperature_polar(self, pos):
        th_max = self.temperature['thresholds'][4][1]
        x, y = pos
        t = self.temperature['data'][y][x]
        return t < th_max

    def is_temperature_alpine(self, pos):
        th_min = self.temperature['thresholds'][4][1]
        th_max = self.temperature['thresholds'][5][1]
        x, y = pos
        t = self.temperature['data'][y][x]
        return t < th_max and t >= th_min

    def is_temperature_boreal(self, pos):
        th_min = self.temperature['thresholds'][5][1]
        th_max = self.temperature['thresholds'][6][1]
        x, y = pos
        t = self.temperature['data'][y][x]
        return t < th_max and t >= th_min

    def is_temperature_cool(self, pos):
        th_min = self.temperature['thresholds'][6][1]
        th_max = self.temperature['thresholds'][7][1]
        x, y = pos
        t = self.temperature['data'][y][x]
        return t < th_max and t >= th_min

    def is_temperature_warm(self, pos):
        th_min = self.temperature['thresholds'][7][1]
        th_max = self.temperature['thresholds'][8][1]
        x, y = pos
        t = self.temperature['data'][y][x]
        return t < th_max and t >= th_min

    def is_temperature_subtropical(self, pos):
        th_min = self.temperature['thresholds'][8][1]
        th_max = self.temperature['thresholds'][9][1]
        x, y = pos
        t = self.temperature['data'][y][x]
        return t < th_max and t >= th_min

    def is_temperature_tropical(self, pos):
        th_min = self.temperature['thresholds'][9][1]
        x, y = pos
        t = self.temperature['data'][y][x]
        return t >= th_min

    def is_humidity_very_low(self, pos):
        th_max = self.humidity['quantiles']['75']
        # print('Humidity Q10 %f' % th_max)
        x, y = pos
        t = self.humidity['data'][y][x]
        return t < th_max

    def is_humidity_low(self, pos):
        th_min = self.humidity['quantiles']['75']
        th_max = self.humidity['quantiles']['66']
        # print('Humidity Q10 %f' % th_min)
        #print('Humidity Q33 %f' % th_max)
        x, y = pos
        t = self.humidity['data'][y][x]
        return t < th_max and t >= th_min

    def is_humidity_medium(self, pos):
        th_min = self.humidity['quantiles']['66']
        th_max = self.humidity['quantiles']['33']
        # print('Humidity Q33 %f' % th_min)
        #print('Humidity Q66 %f' % th_max)
        x, y = pos
        t = self.humidity['data'][y][x]
        return t < th_max and t >= th_min

    def is_humidity_above_quantile(self, pos, q):
        th = self.humidity['quantiles'][str(q)]
        x, y = pos
        v = self.humidity['data'][y][x]
        return v >= th

    def is_humidity_high(self, pos):
        th_min = self.humidity['quantiles']['33']
        th_max = self.humidity['quantiles']['10']
        # print('Humidity Q66 %f' % th_min)
        #print('Humidity Q75 %f' % th_max)
        x, y = pos
        t = self.humidity['data'][y][x]
        return t >= th_min and t < th_max

    def is_humidity_very_high(self, pos):
        th_min = self.humidity['quantiles']['10']
        # print('Humidity Q75 %f' % th_min)
        x, y = pos
        t = self.humidity['data'][y][x]
        return t >= th_min

    def is_humidity_superarid(self, pos):
        th_max = self.humidity['quantiles']['87']
        # print('Humidity Q10 %f' % th_max)
        x, y = pos
        t = self.humidity['data'][y][x]
        return t < th_max

    def is_humidity_perarid(self, pos):
        th_min = self.humidity['quantiles']['87']
        th_max = self.humidity['quantiles']['75']
        # print('Humidity Q66 %f' % th_min)
        #print('Humidity Q75 %f' % th_max)<commit_msg>Fixed references to old temperature thresholds. Removed checks for old temperature levels and old humidity levels.<commit_after>__author__ = '<NAME>'

from biome import *
import pickle
from basic_map_operations import *


class World(object):

    def __init__(self, name, width, height):
        self.name = name
        self.width = width
        self.height = height

    def is_mountain(self, pos):
        if not self.is_land(pos):
            return False
        if len(self.elevation['thresholds']) == 4:
            mi = 2
        else:
            mi = 1
        mountain_level = self.elevation['thresholds'][mi][1]
        x, y = pos
        return self.elevation['data'][y][x] > mountain_level

    def is_low_mountain(self, pos):
        if not self.is_mountain(pos):
            return False
        if len(self.elevation['thresholds']) == 4:
            mi = 2
        else:
            mi = 1
        mountain_level = self.elevation['thresholds'][mi][1]
        x, y = pos
        return self.elevation['data'][y][x] < mountain_level + 2.0

    def level_of_mountain(self, pos):
        if not self.is_land(pos):
            return False
        if len(self.elevation['thresholds']) == 4:
            mi = 2
        else:
            mi = 1
        mountain_level = self.elevation['thresholds'][mi][1]
        x, y = pos
        if self.elevation['data'][y][x] <= mountain_level:
            return 0
        else:
            return self.elevation['data'][y][x] - mountain_level

    def is_high_mountain(self, pos):
        if not self.is_mountain(pos):
            return False
        if len(self.elevation['thresholds']) == 4:
            mi = 2
        else:
            mi = 1
        mountain_level = self.elevation['thresholds'][mi][1]
        x, y = pos
        return self.elevation['data'][y][x] > mountain_level + 4.0

    def is_hill(self, pos):
        if not self.is_land(pos):
            return False
        if len(self.elevation['thresholds']) == 4:
            hi = 1
        else:
            hi = 0
        hill_level = self.elevation['thresholds'][hi][1]
        mountain_level = self.elevation['thresholds'][hi + 1][1]
        x, y = pos
        return self.elevation['data'][y][x] > hill_level and self.elevation['data'][y][x] < mountain_level

    #def is_temperature_very_low(self, pos):
    #    th_max = self.temperature['thresholds'][0][1]
    #    x, y = pos
    #    t = self.temperature['data'][y][x]
    #    return t < th_max

    #def is_temperature_low(self, pos):
    #    th_min = self.temperature['thresholds'][0][1]
    #    th_max = self.temperature['thresholds'][1][1]
    #    x, y = pos
    #    t = self.temperature['data'][y][x]
    #    return t < th_max and t >= th_min

    #def is_temperature_medium(self, pos):
    #    th_min = self.temperature['thresholds'][1][1]
    #    th_max = self.temperature['thresholds'][2][1]
    #    x, y = pos
    #    t = self.temperature['data'][y][x]
    #    return t < th_max and t >= th_min

    #def is_temperature_high(self, pos):
    #    th_min = self.temperature['thresholds'][2][1]
    #    x, y = pos
    #    t = self.temperature['data'][y][x]
    #    return t >= th_min

    def is_temperature_polar(self, pos):
        th_max = self.temperature['thresholds'][0][1]
        x, y = pos
        t = self.temperature['data'][y][x]
        return t < th_max

    def is_temperature_alpine(self, pos):
        th_min = self.temperature['thresholds'][0][1]
        th_max = self.temperature['thresholds'][1][1]
        x, y = pos
        t = self.temperature['data'][y][x]
        return t < th_max and t >= th_min

    def is_temperature_boreal(self, pos):
        th_min = self.temperature['thresholds'][1][1]
        th_max = self.temperature['thresholds'][2][1]
        x, y = pos
        t = self.temperature['data'][y][x]
        return t < th_max and t >= th_min

    def is_temperature_cool(self, pos):
        th_min = self.temperature['thresholds'][2][1]
        th_max = self.temperature['thresholds'][3][1]
        x, y = pos
        t = self.temperature['data'][y][x]
        return t < th_max and t >= th_min

    def is_temperature_warm(self, pos):
        th_min = self.temperature['thresholds'][3][1]
        th_max = self.temperature['thresholds'][4][1]
        x, y = pos
        t = self.temperature['data'][y][x]
        return t < th_max and t >= th_min

    def is_temperature_subtropical(self, pos):
        th_min = self.temperature['thresholds'][4][1]
        th_max = self.temperature['thresholds'][5][1]
        x, y = pos
        t = self.temperature['data'][y][x]
        return t < th_max and t >= th_min

    def is_temperature_tropical(self, pos):
        th_min = self.temperature['thresholds'][5][1]
        x, y = pos
        t = self.temperature['data'][y][x]
        return t >= th_min

    #def is_humidity_very_low(self, pos):
    #    th_max = self.humidity['quantiles']['75']
    #    # print('Humidity Q10 %f' % th_max)
    #    x, y = pos
    #    t = self.humidity['data'][y][x]
    #    return t < th_max

    #def is_humidity_low(self, pos):
    #    th_min = self.humidity['quantiles']['75']
    #    th_max = self.humidity['quantiles']['66']
    #    # print('Humidity Q10 %f' % th_min)
    #    #print('Humidity Q33 %f' % th_max)
    #    x, y = pos
    #    t = self.humidity['data'][y][x]
    #    return t < th_max and t >= th_min

    #def is_humidity_medium(self, pos):
    #    th_min = self.humidity['quantiles']['66']
    #    th_max = self.humidity['quantiles']['33']
    #    # print('Humidity Q33 %f' % th_min)
    #    #print('Humidity Q66 %f' % th_max)
    #    x, y = pos
    #    t = self.humidity['data'][y][x]
    #    return t < th_max and t >= th_min

    def is_humidity_above_quantile(self, pos, q):
        th = self.humidity['quantiles'][str(q)]
        x, y = pos
        v = self.humidity['data'][y][x]
        return v >= th

    #def is_humidity_high(self, pos):
    #    th_min = self.humidity['quantiles']['33']
    #    th_max = self.humidity['quantiles']['10']
    #    # print('Humidity Q66 %f' % th_min)
    #    #print('Humidity Q75 %f' % th_max)
    #    x, y = pos
    #    t = self.humidity['data'][y][x]
    #    return t >= th_min and t < th_max

    #def is_humidity_very_high(self, pos):
    #    th_min = self.humidity['quantiles']['10']
    #    # print('Humidity Q75 %f' % th_min)
    #    x, y = pos
    #    t = self.humidity['data'][y][x]
    #    return t >= th_min

    def is_humidity_superarid(self, pos):
        th_max = self.humidity['quantiles']['87']
        # print('Humidity Q10 %f' % th_max)
        x, y = pos
        t = self.humidity['data'][y][x]
        return t < th_max

    def is_humidity_perarid(self, pos):
        th_min = self.humidity['quantiles']['87']
        th_max = self.humidity['quantiles']['75']
        # print('Humidity Q66 %f' % th_min)
        #print('Humidity Q75 %f' % th_max)
{'fraction_non_alphanumeric': 0.14904654051289545, 'fraction_numerical': 0.015635274347921384, 'mean_word_length': 2.252851711026616, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, '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': '294660', 'n_tokens_mistral': 4888, 'n_tokens_neox': 4647, 'n_words': 1000}