<commit_before>'''
Make nice graphs on maps.
'''

from collections import abc
import itertools
import os.path

import cartopy
from matplotlib import animation
from matplotlib import cm
from matplotlib import patches
from matplotlib import pyplot
import numpy
import seaborn
import shapely.geometry
import shapely.ops

from . import locators


# Change cartopy cache from ~/.local/share
# to a subdirectory so it'll go in Google Drive.
cartopy.config['data_dir'] = os.path.normpath(os.path.join(
    os.path.dirname(__file__),
    '_cartopy'))


_east_hemis = shapely.geometry.box(180, -90, 0, 90)
_west_hemis = shapely.geometry.box(-180, -90, 0, 90)


country_replacements = {
    'Bolivia (Plurinational State of)': 'Bolivia',
    'Bahamas': 'The Bahamas',
    'Congo': 'Republic of Congo',
    "Côte d'Ivoire": 'Ivory Coast',
    'Iran (Islamic Republic of)': 'Iran',
    "Lao People's Democratic Republic": 'Laos',
    'Republic of Moldova': 'Moldova',
    'Russian Federation': 'Russia',
    'Timor-Leste': 'East Timor',
    'United Kingdom of Great Britain and Northern Ireland': 'United Kingdom',
    'Venezuela (Bolivarian Republic of)': 'Venezuela',
    'Viet Nam': 'Vietnam',
    # Some screwed up regions.
    'Eastern and Southern Africa': 'East and Southern Africa',
    'Asia and The Pacific': 'Asia Pacific',
    'The Caribbean': 'Caribbean',
    'Western and Central Europe': 'Western Europe',
}

country_replacements_inv = {v: k for (k, v) in country_replacements.items()}


def convert_country(country, inverse = False):
    '''
    Convert country names used in the datasheet to those used in the maps
    or vice versa.
    '''
    if inverse:
        return country_replacements_inv.get(country, country)<commit_msg>I think I finished merging with master.<commit_after>'''
Make nice graphs on maps.
'''

from collections import abc
import itertools

import cartopy
from matplotlib import animation
from matplotlib import cm
from matplotlib import patches
from matplotlib import pyplot
import numpy
import seaborn
import shapely.geometry
import shapely.ops

from . import locators


_east_hemis = shapely.geometry.box(180, -90, 0, 90)
_west_hemis = shapely.geometry.box(-180, -90, 0, 90)


country_replacements = {
    'Bolivia (Plurinational State of)': 'Bolivia',
    'Congo': 'Republic of Congo',
    "Côte d'Ivoire": 'Ivory Coast',
    'Iran (Islamic Republic of)': 'Iran',
    "Lao People's Democratic Republic": 'Laos',
    'Republic of Moldova': 'Moldova',
    'Russian Federation': 'Russia',
    'Timor-Leste': 'East Timor',
    'United Kingdom of Great Britain and Northern Ireland': 'United Kingdom',
    'Venezuela (Bolivarian Republic of)': 'Venezuela',
    'Viet Nam': 'Vietnam',
}

country_replacements_inv = {v: k for (k, v) in country_replacements.items()}


def convert_country(country, inverse = False):
    '''
    Convert country names used in the datasheet to those used in the maps
    or vice versa.
    '''
    if inverse:
        return country_replacements_inv.get(country, country)
{'fraction_non_alphanumeric': 0.11133135117277833, 'fraction_numerical': 0.010571522960026428, 'mean_word_length': 4.0890756302521005, 'pattern_counts': {'":': 4, '<': 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': '4246398', 'n_tokens_mistral': 1027, 'n_tokens_neox': 956, 'n_words': 327}