diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 12b8b2172..d698b1b48 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.8, 3.9, '3.10', '3.11'] + python-version: [3.9, '3.10', '3.11'] steps: - uses: actions/checkout@v4 @@ -49,7 +49,7 @@ jobs: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: 3.9 - name: Cache pip uses: actions/cache@v4 with: @@ -103,14 +103,14 @@ jobs: - test/test_snapml.py - test/test_relational.py - test/test_category_encoders.py - python-version: [3.9] + python-version: ['3.10'] setup-target: ['.[full,test]'] include: - test-case: test/test_core_misc.py - python-version: 3.8 + python-version: 3.9 setup-target: '.[full,test]' - test-case: test/test_core_misc.py - python-version: 3.9 + python-version: '3.10' setup-target: '.[full,test]' - test-case: test/test_core_misc.py python-version: '3.10' @@ -122,13 +122,13 @@ jobs: python-version: '3.11' setup-target: '.[test]' - test-case: test/test_halving_gridsearchcv.py - python-version: 3.8 - setup-target: '.[test]' + python-version: 3.9 + setup-target: '.[full,test]' - test-case: test/test_aif360.py - python-version: 3.8 + python-version: 3.9 setup-target: '.[full,test]' - test-case: test/test_relational_sklearn.py - python-version: 3.8 + python-version: 3.9 setup-target: '.[full,test]' steps: @@ -159,9 +159,6 @@ jobs: - name: Install deps for test_snapml if: ${{ matrix.test-case == 'test/test_snapml.py' }} run: pip install 'numpy>=1.20.1,<1.24' - - name: Imbalanced learn version for Python 3.8 - if: ${{ matrix.test-case == 'test/test_interoperability.py' && matrix.python-version == 3.8}} - run: pip install 'imbalanced-learn==0.9.0' 'scikit-learn==1.0.2' - name: pip list packages run: pip list - name: show pip dependencies @@ -193,11 +190,11 @@ jobs: - test/test_pipeline.py - test/test_relational.py - test/test_category_encoders.py - python-version: [3.8, 3.9, '3.10', '3.11'] + python-version: [3.9, '3.10', '3.11'] setup-target: ['.[full,test]'] include: - test-case: test/test_core_transformers.py - python-version: 3.9 + python-version: '3.10' setup-target: '.[full,test]' - test-case: test/test_core_transformers.py python-version: '3.10' @@ -209,19 +206,19 @@ jobs: python-version: '3.11' setup-target: '.[test]' - test-case: test/test_halving_gridsearchcv.py - python-version: 3.8 - setup-target: '.[test]' + python-version: 3.9 + setup-target: '.[full,test]' - test-case: test/test_aif360.py - python-version: 3.8 + python-version: 3.9 setup-target: '.[full,test]' - test-case: test/test_relational_sklearn.py - python-version: 3.8 + python-version: 3.9 setup-target: '.[test]' - test-case: test/test_snapml.py - python-version: 3.8 + python-version: 3.9 setup-target: '.[full,test]' - test-case: test/test_snapml.py - python-version: 3.9 + python-version: '3.10' setup-target: '.[full,test]' steps: @@ -252,9 +249,6 @@ jobs: - name: Install deps for test_snapml if: ${{ matrix.test-case == 'test/test_snapml.py' }} run: pip install 'numpy>=1.20.1,<1.24' - - name: Imbalanced learn version for Python 3.8 - if: ${{ matrix.test-case == 'test/test_interoperability.py' && matrix.python-version == 3.8}} - run: pip install 'imbalanced-learn==0.9.0' 'scikit-learn==1.0.2' - name: pip list packages run: pip list - name: show pip dependencies @@ -392,24 +386,24 @@ jobs: - demo_ - docs_ - talk_ - python-version: [3.8, 3.9, '3.10', '3.11'] + python-version: [3.9, '3.10', '3.11'] setup-target: ['.[full,test]'] test-case: ['test/test_notebooks.py'] dir: ['examples'] nbexcludes: [''] include: - dir: 'examples' - python-version: 3.8 + python-version: 3.9 setup-target: '.[full,test]' test-case: 'test/test_notebooks.py' nbexcludes: 'demo_auto_pipeline.ipynb' - dir: 'examples/kdd22' - python-version: 3.8 + python-version: 3.9 setup-target: '.[tutorial,test]' test-case: 'test/test_notebooks.py' nbexcludes: '02_total.ipynb' - dir: 'examples/kdd22' - python-version: 3.9 + python-version: '3.9' setup-target: '.[tutorial,test]' test-case: 'test/test_notebooks.py' # nbexcludes: '06_multobj.ipynb' @@ -473,7 +467,7 @@ jobs: test-case: - test/test_aif360.py - test/test_aif360_ensembles.py - python-version: [3.8] + python-version: [3.9] setup-target: ['.[fairness]'] steps: - uses: actions/checkout@v4 @@ -504,7 +498,7 @@ jobs: needs: [static, test_matrix_master, test_newer, test_fairness, test_notebooks_master, docs] strategy: matrix: - python-version: [3.8] + python-version: [3.9] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cc443edd9..a9e08ef53 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8] + python-version: [3.9] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} diff --git a/lale/datasets/data_schemas.py b/lale/datasets/data_schemas.py index c185c37bc..847870d20 100644 --- a/lale/datasets/data_schemas.py +++ b/lale/datasets/data_schemas.py @@ -360,7 +360,7 @@ def _dtype_to_schema(typ) -> JSON_TYPE: result = {"type": "integer"} elif issubdtype(typ, np.number): result = {"type": "number"} - elif issubdtype(typ, np.string_) or issubdtype(typ, np.unicode_): + elif issubdtype(typ, np.str_) or issubdtype(typ, np.bytes_): result = {"type": "string"} elif isinstance(typ, np.dtype): if typ.fields: diff --git a/lale/datasets/movie_review.py b/lale/datasets/movie_review.py index eebb73b15..a8f37d15b 100644 --- a/lale/datasets/movie_review.py +++ b/lale/datasets/movie_review.py @@ -52,7 +52,7 @@ def load_movie_review(): X.append(str(line)) y.append(1) - X = np.asarray(X, dtype=np.string_) + X = np.asarray(X, dtype=np.str_) y = np.asarray(y) from sklearn.utils import shuffle diff --git a/lale/expressions.py b/lale/expressions.py index 0dd22ded7..66b773e9f 100644 --- a/lale/expressions.py +++ b/lale/expressions.py @@ -16,7 +16,6 @@ import pprint import typing from copy import deepcopy -from io import StringIO from typing import Any, Dict, Literal, Optional, Union, overload import astunparse @@ -49,27 +48,6 @@ ] -# !! WORKAROUND !! -# There is a bug with astunparse and Python 3.8. -# https://github.com/simonpercivall/astunparse/issues/43 -# Until it is fixed (which may be never), here is a workaround, -# based on the workaround found in https://github.com/juanlao7/codeclose -class FixUnparser(astunparse.Unparser): - def _Constant(self, t): - if not hasattr(t, "kind"): - setattr(t, "kind", None) - - super()._Constant(t) - - -# !! WORKAROUND !! -# This method should be called instead of astunparse.unparse -def fixedUnparse(tree): - v = StringIO() - FixUnparser(tree, file=v) - return v.getvalue() - - class Expr: _expr: AstExpr @@ -245,7 +223,7 @@ def __ne__(self, other): return False def __str__(self) -> str: - result = fixedUnparse(self._expr).strip() + result = astunparse.unparse(self._expr).strip() if isinstance(self._expr, (ast.UnaryOp, ast.BinOp, ast.Compare, ast.BoolOp)): if result.startswith("(") and result.endswith(")"): result = result[1:-1] @@ -601,7 +579,7 @@ def _it_column(expr): return expr.attr else: raise ValueError( - f"Illegal {fixedUnparse(expr)}. Only the access to `it` is supported" + f"Illegal {astunparse.unparse(expr)}. Only the access to `it` is supported" ) elif isinstance(expr, ast.Subscript): if isinstance(expr.slice, ast.Constant) or ( @@ -616,15 +594,15 @@ def _it_column(expr): return v.s else: raise ValueError( - f"Illegal {fixedUnparse(expr)}. Only the access to `it` is supported" + f"Illegal {astunparse.unparse(expr)}. Only the access to `it` is supported" ) else: raise ValueError( - f"Illegal {fixedUnparse(expr)}. Only the access to `it` is supported" + f"Illegal {astunparse.unparse(expr)}. Only the access to `it` is supported" ) else: raise ValueError( - f"Illegal {fixedUnparse(expr)}. Only the access to `it` is supported" + f"Illegal {astunparse.unparse(expr)}. Only the access to `it` is supported" ) diff --git a/setup.py b/setup.py index 03c56daf9..354dabf68 100644 --- a/setup.py +++ b/setup.py @@ -131,7 +131,6 @@ "Operating System :: Unix", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -148,7 +147,7 @@ long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/IBM/lale", - python_requires=">=3.8", + python_requires=">=3.9", package_data={"lale": ["py.typed"]}, packages=find_packages(), license="Apache License 2.0", diff --git a/test/test_aif360.py b/test/test_aif360.py index 4b4c83657..2e20d1d70 100644 --- a/test/test_aif360.py +++ b/test/test_aif360.py @@ -622,7 +622,7 @@ def test_disparate_impact_remover_pd_num(self): trainable_remi = DisparateImpactRemover(**fairness_info) >> LogisticRegression( max_iter=1000 ) - self._attempt_remi_creditg_pd_num(fairness_info, trainable_remi, 0.78, 0.88) + self._attempt_remi_creditg_pd_num(fairness_info, trainable_remi, 0.75, 0.88) def test_eq_odds_postprocessing_pd_num(self): fairness_info = self.creditg_pd_num["fairness_info"] diff --git a/test/test_core_misc.py b/test/test_core_misc.py index 497e33bda..0de6bd12e 100644 --- a/test/test_core_misc.py +++ b/test/test_core_misc.py @@ -76,14 +76,12 @@ def test_transformers(self): class TestUnparseExpr(unittest.TestCase): def test_unparse_const38(self): - from lale.expressions import fixedUnparse, it + import astunparse + + from lale.expressions import it test_expr = it.hello["hi"] - # This fails on 3.8 with some versions of the library - # which is why we use the fixed version - # import astunparse - # astunparse.unparse(he._expr) - str(fixedUnparse(test_expr._expr)) + str(astunparse.unparse(test_expr._expr)) class TestOperatorWithoutSchema(unittest.TestCase):