<commit_before>#!/usr/bin/env python
# coding=utf-8
from __future__ import unicode_literals

import json
import codecs
from pyecharts import Map


def test_map():
    # show label
    value = [155, 10, 66, 78]
    attr = ["福建", "山东", "北京", "上海"]
    map = Map("全国地图示例", width=1200, height=600)
    map.add("", attr, value, maptype='china', is_label_show=True)
    map.render()

    # combine with visualMap
    value = [155, 10, 66, 78, 33, 80, 190, 53, 49.6]
    attr = ["福建", "山东", "北京", "上海", "甘肃", "新疆", "河南", "广西", "西藏"]
    map = Map("Map 结合 VisualMap 示例", width=1200, height=600)
    map.add("", attr, value, maptype='china', is_visualmap=True,
            visual_text_color='#000')
    map.render()


def test_echarts_position_in_render_html():
    value = [20, 190, 253, 77, 65]
    attr = ['汕头市', '汕尾市', '揭阳市', '阳江市', '肇庆市']
    map = Map("广东地图示例", width=1200, height=600)
    map.add("", attr, value, maptype='广东',
            is_visualmap=True, visual_text_color='#000')
    map.render()
    with codecs.open('render.html', 'r', 'utf-8') as f:
        actual_content = f.read()
        echarts_position = actual_content.find('exports.echarts')
        guangdong_position = actual_content.find(json.dumps('广东'))
        assert echarts_position < guangdong_position


def test_city_map():
    value = [1]
    attr = ["渝水区"]
    map = Map("新余地图示例", width=1200, height=600)
    map.add("", attr, value, maptype='新余', is_visualmap=True,
            visual_text_color='#000')
    # To avoid potential pinyin crash, all cities have a province prefix
    assert "jiang1_xi1_xin1_yu2" in map._repr_html_()


def test_world_map():
    value = [95.1, 23.2, 43.3, 66.4, 88.5, 0.1]
    attr = [<commit_msg>:umbrella: test the new option<commit_after>#!/usr/bin/env python
# coding=utf-8
from __future__ import unicode_literals

import json
import codecs
from pyecharts import Map


def test_map():
    # show label
    value = [155, 10, 66, 78]
    attr = ["福建", "山东", "北京", "上海"]
    map = Map("全国地图示例", width=1200, height=600)
    map.add("", attr, value, maptype='china', is_label_show=True)
    map.render()

    # combine with visualMap
    value = [155, 10, 66, 78, 33, 80, 190, 53, 49.6]
    attr = ["福建", "山东", "北京", "上海", "甘肃", "新疆", "河南", "广西", "西藏"]
    map = Map("Map 结合 VisualMap 示例", width=1200, height=600)
    map.add("", attr, value, maptype='china', is_visualmap=True,
            visual_text_color='#000')
    map.render()


def test_echarts_position_in_render_html():
    value = [20, 190, 253, 77, 65]
    attr = ['汕头市', '汕尾市', '揭阳市', '阳江市', '肇庆市']
    map = Map("广东地图示例", width=1200, height=600)
    map.add("", attr, value, maptype='广东', show_legend_symbol=False,
            is_visualmap=True, visual_text_color='#000')
    map.render()
    with codecs.open('render.html', 'r', 'utf-8') as f:
        actual_content = f.read()
        echarts_position = actual_content.find('exports.echarts')
        guangdong_position = actual_content.find(json.dumps('广东'))
        assert echarts_position < guangdong_position
        assert '"showLegendSymbol": false' in actual_content


def test_city_map():
    value = [1]
    attr = ["渝水区"]
    map = Map("新余地图示例", width=1200, height=600)
    map.add("", attr, value, maptype='新余', is_visualmap=True,
            visual_text_color='#000')
    # To avoid potential pinyin crash, all cities have a province prefix
    assert "jiang1_xi1_xin1_yu2" in map._repr_html_()


def test_world_map():
    value = [95.1, 23.2, 43.3, 66.4, 88.5, 0.1]
    attr = [
{'fraction_non_alphanumeric': 0.16647694934547524, 'fraction_numerical': 0.058622652248150255, 'mean_word_length': 3.4213836477987423, 'pattern_counts': {'":': 1, '<': 5, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1629065', 'n_tokens_mistral': 1554, 'n_tokens_neox': 1439, 'n_words': 324}