Skip to content

Commit 669f368

Browse files
Use older dependencies and make tests pass
1 parent 337ab54 commit 669f368

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

mplaltair/_data.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ def _normalize_data(chart):
3434
df = pd.DataFrame(_fetch(spec['data']['url']))
3535
elif spec['data'].get('values'):
3636
return
37+
elif spec['data'].get('name'):
38+
datasets = spec.get('datasets', {})
39+
if spec['data'].get('name') in datasets.keys():
40+
return
41+
else:
42+
raise ValidationError('Named Data is provided but no corresponding dataset is found')
3743
else:
3844
raise NotImplementedError('Given data specification is unsupported at the moment.')
3945

mplaltair/tests/test_data.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import pandas as pd
33
import matplotlib.dates as mdates
44
import mplaltair._data as _data
5+
from mplaltair._exceptions import ValidationError
56
import pytest
67
from vega_datasets import data
78

@@ -26,6 +27,12 @@ def test_data_url():
2627
_data._normalize_data(chart)
2728
assert type(chart.data) == pd.DataFrame
2829

30+
31+
def test_named_data():
32+
chart = alt.Chart(alt.NamedData('test-dataset')).mark_point()
33+
with pytest.raises(ValidationError):
34+
_data._normalize_data(chart)
35+
2936
# test date conversion:
3037

3138
df_nonstandard = pd.DataFrame({

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
version='0.0.0',
3232
description="Convert altair objects to Matplotlib Figures",
3333
author="Matplotlib Development Team",
34-
install_requires=['matplotlib>=2.2.0', 'altair>=2'],
34+
install_requires=['matplotlib<3.0', 'altair<3.0','pandas<0.25'],
3535
author_email="[email protected]",
3636
url="https://github.com/matplotlib/mpl-altair",
3737
packages=['mplaltair'],

0 commit comments

Comments
 (0)