Skip to content

Commit

Permalink
Merge pull request altair-viz#33 from jakevdp/bye-py2
Browse files Browse the repository at this point in the history
Drop support for Python 2
  • Loading branch information
jakevdp authored Dec 14, 2019
2 parents 5ded717 + 4b6386f commit f13bc49
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 29 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ env:

matrix:
include:
- python: 2.7
- python: 3.5
- python: 3.6
- python: 3.7
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def version(path):
download_url="http://github.com/altair-viz/vega_datasets",
license="MIT",
install_requires=["pandas"],
python_requires=">=3.5",
tests_require=["pytest"],
packages=find_packages(exclude=["tools"]),
package_data={
Expand All @@ -59,10 +60,10 @@ def version(path):
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
],
project_urls={
"Bug Reports": "https://github.com/altair-viz/vega_datasets/issues",
Expand Down
3 changes: 2 additions & 1 deletion tools/download_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
$ python download_datasets.py
"""

import json
from os.path import abspath, join, dirname
import sys
from urllib.request import urlretrieve
import json

sys.path.insert(1, abspath(join(dirname(__file__), "..")))
from vega_datasets.core import Dataset
from vega_datasets._compat import urlretrieve

DATASETS_TO_DOWNLOAD = [
"airports",
Expand Down
19 changes: 0 additions & 19 deletions vega_datasets/_compat.py

This file was deleted.

12 changes: 6 additions & 6 deletions vega_datasets/core.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from io import BytesIO
import os
import json
import pkgutil
import textwrap
from urllib.request import urlopen

import pandas as pd

from vega_datasets._compat import urlopen, BytesIO, bytes_decode


def _load_dataset_info():
"""This loads dataset info from three package files:
Expand All @@ -20,7 +20,7 @@ def _load_dataset_info():

def load_json(path):
raw = pkgutil.get_data("vega_datasets", path)
return json.loads(bytes_decode(raw))
return json.loads(raw.decode())

info = load_json("datasets.json")
descriptions = load_json("dataset_info.json")
Expand Down Expand Up @@ -337,7 +337,7 @@ class Miserables(Dataset):

def __call__(self, use_local=True, **kwargs):
__doc__ = super(Miserables, self).__call__.__doc__ # noqa:F841
dct = json.loads(bytes_decode(self.raw(use_local=use_local)), **kwargs)
dct = json.loads(self.raw(use_local=use_local).decode(), **kwargs)
nodes = pd.DataFrame.from_records(dct["nodes"], index="index")
links = pd.DataFrame.from_records(dct["links"])
return nodes, links
Expand Down Expand Up @@ -379,7 +379,7 @@ class US_10M(Dataset):

def __call__(self, use_local=True, **kwargs):
__doc__ = super(US_10M, self).__call__.__doc__ # noqa:F841
return json.loads(bytes_decode(self.raw(use_local=use_local)), **kwargs)
return json.loads(self.raw(use_local=use_local).decode(), **kwargs)


class World_110M(Dataset):
Expand All @@ -393,7 +393,7 @@ class World_110M(Dataset):

def __call__(self, use_local=True, **kwargs):
__doc__ = super(World_110M, self).__call__.__doc__ # noqa:F841
return json.loads(bytes_decode(self.raw(use_local=use_local)), **kwargs)
return json.loads(self.raw(use_local=use_local).decode(), **kwargs)


class ZIPCodes(Dataset):
Expand Down
2 changes: 1 addition & 1 deletion vega_datasets/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from vega_datasets.core import Dataset
from vega_datasets._compat import urlopen, HTTPError, URLError
from urllib.request import urlopen, HTTPError, URLError


def connection_ok():
Expand Down

0 comments on commit f13bc49

Please sign in to comment.