diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7bc6e7ad6..dc3621f0e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,7 @@ jobs: "3.9", "3.10", "3.11", - # "3.12", # Numba not available for Python 3.12: https://github.com/numba/numba/issues/9197 + "3.12", ] runs-on: ${{ matrix.os }} steps: diff --git a/pyproject.toml b/pyproject.toml index 824739835..9e11af6aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "scikit-lego" -version = "0.8.0" +version = "0.8.1" description="A collection of lego bricks for scikit-learn pipelines" license = {file = "LICENSE"} @@ -23,6 +23,7 @@ dependencies = [ "pandas>=1.1.5", "scikit-learn>=1.0", "importlib-metadata >= 1.0; python_version < '3.8'", + "importlib-resources; python_version < '3.9'", ] classifiers = [ @@ -31,6 +32,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", "Topic :: Scientific/Engineering", "Topic :: Scientific/Engineering :: Artificial Intelligence", diff --git a/sklego/datasets.py b/sklego/datasets.py index f62f1dfa8..0fb0d9ffe 100644 --- a/sklego/datasets.py +++ b/sklego/datasets.py @@ -1,8 +1,14 @@ -import os +import sys import numpy as np import pandas as pd -from pkg_resources import resource_filename + +if sys.version_info >= (3, 9): + import importlib.resources as importlib_resources # pragma: no cover +else: + import importlib_resources as importlib_resources # pragma: no cover + + from sklearn.datasets import fetch_openml @@ -92,7 +98,7 @@ def load_penguins(return_X_y=False, as_frame=False): (Accessed 2020-06-08). """ - filepath = resource_filename("sklego", os.path.join("data", "penguins.zip")) + filepath = importlib_resources.files("sklego") / "data" / "penguins.zip" df = pd.read_csv(filepath) if as_frame: return df @@ -151,7 +157,7 @@ def load_arrests(return_X_y=False, as_frame=False): - Personal communication from Michael Friendly, York University. """ - filepath = resource_filename("sklego", os.path.join("data", "arrests.zip")) + filepath = importlib_resources.files("sklego") / "data" / "arrests.zip" df = pd.read_csv(filepath) if as_frame: return df @@ -198,7 +204,7 @@ def load_chicken(return_X_y=False, as_frame=False): - Crowder, M. and Hand, D. (1990), Analysis of Repeated Measures, Chapman and Hall (example 5.3) - Hand, D. and Crowder, M. (1996), Practical Longitudinal Data Analysis, Chapman and Hall (table A.2) """ - filepath = resource_filename("sklego", os.path.join("data", "chickweight.zip")) + filepath = importlib_resources.files("sklego") / "data" / "chickweight.zip" df = pd.read_csv(filepath) if as_frame: return df @@ -244,7 +250,7 @@ def load_abalone(return_X_y=False, as_frame=False): Sea Fisheries Division, Technical Report No. 48 (ISSN 1034-3288) """ - filepath = resource_filename("sklego", os.path.join("data", "abalone.zip")) + filepath = importlib_resources.files("sklego") / "data" / "abalone.zip" df = pd.read_csv(filepath) if as_frame: return df @@ -294,7 +300,7 @@ def load_heroes(return_X_y=False, as_frame=False): # Index(['name', 'attack_type', 'role', 'health', 'attack', 'attack_spd'], dtype='object') ``` """ - filepath = resource_filename("sklego", os.path.join("data", "heroes.zip")) + filepath = importlib_resources.files("sklego") / "data" / "heroes.zip" df = pd.read_csv(filepath) if as_frame: return df @@ -351,7 +357,7 @@ def load_hearts(return_X_y=False, as_frame=False): The documentation of the dataset can be viewed at: https://archive.ics.uci.edu/ml/machine-learning-databases/heart-disease/heart-disease.names """ - filepath = resource_filename("sklego", os.path.join("data", "hearts.zip")) + filepath = importlib_resources.files("sklego") / "data" / "hearts.zip" df = pd.read_csv(filepath) if as_frame: return df