feat(compatibility): Python3.8 compatibility

This commit is contained in:
Alexander Engelsberger 2021-08-30 16:39:23 +02:00 committed by Alexander Engelsberger
parent bf09ff8f7f
commit 7f0a8e9bce
3 changed files with 12 additions and 6 deletions

View File

@ -1,7 +1,9 @@
dist: bionic dist: bionic
sudo: false sudo: false
language: python language: python
python: 3.9 python:
- 3.9
- 3.8
cache: cache:
directories: directories:
- "$HOME/.cache/pip" - "$HOME/.cache/pip"

View File

@ -1,8 +1,12 @@
"""ProtoFlow utilities""" """ProtoFlow utilities"""
import warnings import warnings
from collections.abc import Iterable from typing import (
from typing import Union Dict,
Iterable,
List,
Union,
)
import numpy as np import numpy as np
import torch import torch
@ -24,7 +28,7 @@ def mesh2d(x=None, border: float = 1.0, resolution: int = 100):
return mesh, xx, yy return mesh, xx, yy
def distribution_from_list(list_dist: list[int], def distribution_from_list(list_dist: List[int],
clabels: Iterable[int] = None): clabels: Iterable[int] = None):
clabels = clabels or list(range(len(list_dist))) clabels = clabels or list(range(len(list_dist)))
distribution = dict(zip(clabels, list_dist)) distribution = dict(zip(clabels, list_dist))
@ -32,7 +36,7 @@ def distribution_from_list(list_dist: list[int],
def parse_distribution(user_distribution, def parse_distribution(user_distribution,
clabels: Iterable[int] = None) -> dict[int, int]: clabels: Iterable[int] = None) -> Dict[int, int]:
"""Parse user-provided distribution. """Parse user-provided distribution.
Return a dictionary with integer keys that represent the class labels and Return a dictionary with integer keys that represent the class labels and

View File

@ -59,7 +59,7 @@ setup(
url=PROJECT_URL, url=PROJECT_URL,
download_url=DOWNLOAD_URL, download_url=DOWNLOAD_URL,
license="MIT", license="MIT",
python_requires=">=3.9", python_requires=">=3.8",
install_requires=INSTALL_REQUIRES, install_requires=INSTALL_REQUIRES,
extras_require={ extras_require={
"datasets": DATASETS, "datasets": DATASETS,