Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: make vega_datasets accessible from alt.datasets #872

Closed
wants to merge 5 commits into from

Conversation

jakevdp
Copy link
Collaborator

@jakevdp jakevdp commented May 18, 2018

Addresses #796

This makes the contents of vega_datasets available from Altair via alt.datasets. So, for example, you can do:

import altair as alt
cars = alt.datasets.cars()
alt.Chart(cars).mark_point()

If the vega_datasets package is not installed, an error will be raised when you try to access a dataset, but not when you import the alt.datasets object (which is present in the main namespace)

In [1]: from altair import datasets
In [2]: datasets.cars()
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-a4a02b6877f0> in <module>()
----> 1 datasets.cars()

~/github/altair-viz/altair/altair/_datasets.py in __getattr__(self, attr)
     21 
     22     def __getattr__(self, attr):
---> 23         raise ImportError(ERR_MESSAGE)
     24 
     25 

ImportError: 
The vega_datasets package must be installed in order to use altair.datasets.
See http://github.com/altair-viz/vega_datasets/ for information.

@jakevdp jakevdp changed the title Vega datasets ENH: make vega_datasets accessible from alt.datasets May 18, 2018
@jakevdp jakevdp added this to the 2.1 milestone May 18, 2018
@jakevdp
Copy link
Collaborator Author

jakevdp commented May 18, 2018

I'm still about 50/50 on this change... or maybe 60/40 in favor.

  • Pros

    • fewer imports leads to simpler examples and an easier learning curve for beginners
    • there is still no hard dependency on vega_datasets, so Altair can be used without it
    • this will open the way for more streamlined tools for things like choropleth maps, which require access to the data
  • Cons

    • this obscures the existence of the vega_datasets package and might make it less clear how to debug issues that arise, particularly for beginners

@arokem
Copy link

arokem commented May 18, 2018

You might want to also mention somewhere in the documentation (in case that's not already mentioned) that for these data to be available, users should install vega_datasets as well.

On the other hand If you don't, users will get that message on the first time they refer to alt.datasets so meh.

@jakevdp
Copy link
Collaborator Author

jakevdp commented May 18, 2018

All the installation instructions list vega_datasets, so I think we have that covered: https://altair-viz.github.io/getting_started/installation.html

@jakevdp jakevdp requested a review from ellisonbg May 18, 2018 20:50
@arokem
Copy link

arokem commented May 18, 2018

You're probably right, but to be on the safe side, in case someone shows up in the examples, instead of this page, I would add something like "Some of these examples also require an installation of vega_datasets " on this page: https://altair-viz.github.io/gallery/index.html

@palewire
Copy link
Contributor

@arokem, we've already done that in #829

@arokem
Copy link

arokem commented May 18, 2018

Whoops. Sorry about the noise!

@ellisonbg
Copy link
Collaborator

ellisonbg commented May 19, 2018 via email

@jakevdp jakevdp modified the milestones: 2.1, 2.2 Jun 6, 2018
@jakevdp
Copy link
Collaborator Author

jakevdp commented Jun 12, 2018

Having slept on this a bit, I think I'd prefer not to wrap datasets into altair.

@jakevdp jakevdp closed this Jun 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants