Ejemplo n.º 1
0
    def test_stack_agg(self):
        query = vl2asp({
            "mark": "bar",
            "encoding": {
                "x": {
                    "type": "nominal",
                    "field": "n1"
                },
                "y": {
                    "type": "quantitative",
                    "field": "q1",
                    "stack": "zero",
                    "aggregate": "sum",
                },
                "detail": {
                    "type": "nominal",
                    "field": "n2"
                },
                "color": {
                    "type": "quantitative",
                    "field": "q2",
                    "aggregate": "mean",
                },
            },
        })

        assert is_valid(data_schema + query, True) == True
Ejemplo n.º 2
0
    def test_one_bar(self):
        query = vl2asp({
            "mark": "bar",
            "encoding": {
                "y": {
                    "type": "quantitative",
                    "field": "q1"
                }
            }
        })

        assert is_valid(data_schema + query, True) == True
Ejemplo n.º 3
0
    def test_row_only(self):
        query = vl2asp({
            "mark": "point",
            "encoding": {
                "row": {
                    "type": "nominal",
                    "field": "n1"
                }
            }
        })

        assert is_valid(data_schema + query, True) == False
Ejemplo n.º 4
0
    def test_q_q_bar(self):
        query = vl2asp({
            "mark": "bar",
            "encoding": {
                "x": {
                    "type": "quantitative",
                    "field": "q1"
                },
                "y": {
                    "type": "quantitative",
                    "field": "q2"
                },
            },
        })

        assert is_valid(data_schema + query, True) == False
Ejemplo n.º 5
0
    def test_only_one_agg(self):
        query = vl2asp({
            "mark": "point",
            "encoding": {
                "x": {
                    "type": "quantitative",
                    "field": "q1"
                },
                "y": {
                    "type": "quantitative",
                    "field": "q2",
                    "aggregate": "mean"
                },
            },
        })

        assert is_valid(data_schema + query, True) == False
Ejemplo n.º 6
0
    def test_heatmap(self):
        query = vl2asp({
            "mark": "rect",
            "encoding": {
                "x": {
                    "type": "nominal",
                    "field": "n1"
                },
                "y": {
                    "type": "ordinal",
                    "field": "q1",
                    "bin": True
                },
            },
        })

        assert is_valid(data_schema + query, True) == True
Ejemplo n.º 7
0
    def test_hist(self):
        query = vl2asp({
            "mark": "bar",
            "encoding": {
                "x": {
                    "type": "quantitative",
                    "field": "q1",
                    "bin": True
                },
                "y": {
                    "type": "quantitative",
                    "aggregate": "count"
                },
            },
        })

        assert is_valid(data_schema + query, True) == True
Ejemplo n.º 8
0
    def test_scatter(self):
        query = vl2asp({
            "mark": "point",
            "encoding": {
                "x": {
                    "type": "quantitative",
                    "field": "q1"
                },
                "y": {
                    "type": "quantitative",
                    "field": "q2"
                },
                "color": {
                    "type": "nominal",
                    "field": "n2"
                },
                "size": {
                    "type": "quantitative",
                    "field": "q3"
                },
            },
        })

        assert is_valid(data_schema + query, True) == True
Ejemplo n.º 9
0
    def test_stack_q_q(self):
        query = vl2asp({
            "mark": "area",
            "encoding": {
                "x": {
                    "type": "quantitative",
                    "field": "q1",
                    "scale": {
                        "zero": False
                    },
                },
                "y": {
                    "type": "quantitative",
                    "field": "q2",
                    "stack": "zero"
                },
                "color": {
                    "type": "nominal",
                    "field": "n1"
                },
            },
        })

        assert is_valid(data_schema + query, True) == True