feat: add ECharts BoxPlot chart (#11199)

* feat: add ECharts BoxPlot chart

* lint

* fix cypress tests

* lint

* remove viz.py shim

* bump plugin package

* skip non-legacy plugin cypress dashboard tests

* fix cypress tests

* disable cypress tests for non-leagcy charts

* fix bad rebase

* use midpoint interpolation for quartile calculation

* bump packages and add support for no groupby

* whitespace

* whitespace

* linting

* fix tests

* xit mathjs load test

* bump mathjs to 8.0.1

* disable cypress filter test for v1 charts
This commit is contained in:
Ville Brofeldt
2020-11-12 10:01:04 +02:00
committed by GitHub
parent 302c9603c4
commit 2718909314
17 changed files with 522 additions and 329 deletions

View File

@@ -24,10 +24,20 @@ import pytest
from superset.exceptions import QueryObjectValidationError
from superset.utils import pandas_postprocessing as proc
from superset.utils.core import DTTM_ALIAS, PostProcessingContributionOrientation
from superset.utils.core import (
DTTM_ALIAS,
PostProcessingContributionOrientation,
PostProcessingBoxplotWhiskerType,
)
from .base_tests import SupersetTestCase
from .fixtures.dataframes import categories_df, lonlat_df, timeseries_df, prophet_df
from .fixtures.dataframes import (
categories_df,
lonlat_df,
names_df,
timeseries_df,
prophet_df,
)
AGGREGATES_SINGLE = {"idx_nulls": {"operator": "sum"}}
AGGREGATES_MULTIPLE = {
@@ -607,3 +617,103 @@ class TestPostProcessing(SupersetTestCase):
periods=10,
confidence_interval=0.8,
)
def test_boxplot_tukey(self):
df = proc.boxplot(
df=names_df,
groupby=["region"],
whisker_type=PostProcessingBoxplotWhiskerType.TUKEY,
metrics=["cars"],
)
columns = {column for column in df.columns}
assert columns == {
"cars__mean",
"cars__median",
"cars__q1",
"cars__q3",
"cars__max",
"cars__min",
"cars__count",
"cars__outliers",
"region",
}
assert len(df) == 4
def test_boxplot_min_max(self):
df = proc.boxplot(
df=names_df,
groupby=["region"],
whisker_type=PostProcessingBoxplotWhiskerType.MINMAX,
metrics=["cars"],
)
columns = {column for column in df.columns}
assert columns == {
"cars__mean",
"cars__median",
"cars__q1",
"cars__q3",
"cars__max",
"cars__min",
"cars__count",
"cars__outliers",
"region",
}
assert len(df) == 4
def test_boxplot_percentile(self):
df = proc.boxplot(
df=names_df,
groupby=["region"],
whisker_type=PostProcessingBoxplotWhiskerType.PERCENTILE,
metrics=["cars"],
percentiles=[1, 99],
)
columns = {column for column in df.columns}
assert columns == {
"cars__mean",
"cars__median",
"cars__q1",
"cars__q3",
"cars__max",
"cars__min",
"cars__count",
"cars__outliers",
"region",
}
assert len(df) == 4
def test_boxplot_percentile_incorrect_params(self):
with pytest.raises(QueryObjectValidationError):
proc.boxplot(
df=names_df,
groupby=["region"],
whisker_type=PostProcessingBoxplotWhiskerType.PERCENTILE,
metrics=["cars"],
)
with pytest.raises(QueryObjectValidationError):
proc.boxplot(
df=names_df,
groupby=["region"],
whisker_type=PostProcessingBoxplotWhiskerType.PERCENTILE,
metrics=["cars"],
percentiles=[10],
)
with pytest.raises(QueryObjectValidationError):
proc.boxplot(
df=names_df,
groupby=["region"],
whisker_type=PostProcessingBoxplotWhiskerType.PERCENTILE,
metrics=["cars"],
percentiles=[90, 10],
)
with pytest.raises(QueryObjectValidationError):
proc.boxplot(
df=names_df,
groupby=["region"],
whisker_type=PostProcessingBoxplotWhiskerType.PERCENTILE,
metrics=["cars"],
percentiles=[10, 90, 10],
)