Exemplo n.º 1
0
def test_display_vector_extruded_ChoroplethViz(display):
    """Assert that show calls the mocked display function when using data-join technique
    for ChoroplethViz.
    """
    data = [{
        "id": "06",
        "name": "California",
        "density": 241.7
    }, {
        "id": "11",
        "name": "District of Columbia",
        "density": 10065
    }, {
        "id": "25",
        "name": "Massachusetts",
        "density": 840.2
    }, {
        "id": "30",
        "name": "Montana",
        "density": 6.858
    }, {
        "id": "36",
        "name": "New York",
        "density": 412.3
    }, {
        "id": "49",
        "name": "Utah",
        "density": 34.3
    }, {
        "id": "72",
        "name": "Puerto Rico",
        "density": 1082
    }]

    viz = ChoroplethViz(data,
                        vector_url='mapbox://mapbox.us_census_states_2015',
                        vector_layer_name='states',
                        vector_join_property='STATEFP',
                        data_join_property='id',
                        color_property='density',
                        color_stops=create_color_stops([0, 50, 100, 500, 1500],
                                                       colors='YlOrRd'),
                        height_property='density',
                        height_stops=create_numeric_stops(
                            [0, 50, 100, 500, 1500, 10000], 0, 1000000),
                        access_token=TOKEN)
    viz.show()
    display.assert_called_once()
Exemplo n.º 2
0
def test_display_vector_LinestringViz(display):
    """Assert that show calls the mocked display function when using data-join technique
    for LinestringViz.
    """
    data = [{
        "elevation": x,
        "weight": random.randint(0, 100)
    } for x in range(0, 21000, 10)]

    viz = LinestringViz(data,
                        vector_url='mapbox://mapbox.mapbox-terrain-v2',
                        vector_layer_name='contour',
                        vector_join_property='ele',
                        data_join_property='elevation',
                        color_property="elevation",
                        color_stops=create_color_stops([0, 50, 100, 500, 1500],
                                                       colors='YlOrRd'),
                        line_width_property='weight',
                        line_width_stops=create_numeric_stops(
                            [0, 25, 50, 75, 100], 1, 6),
                        access_token=TOKEN)
    viz.show()
    display.assert_called_once()
Exemplo n.º 3
0
def test_create_numeric_stops():
    """Create numeric stops from custom breaks"""
    domain = [7678.214347826088, 5793.63142857143, 1200]
    stops = create_numeric_stops(domain, 1, 10)
    assert stops == [[7678.214347826088, 1.0], [5793.63142857143, 4.0],
                     [1200, 7.0]]