Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 23 additions & 29 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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'
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion lale/datasets/data_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion lale/datasets/movie_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 5 additions & 27 deletions lale/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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 (
Expand All @@ -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"
)


Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion test/test_aif360.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
10 changes: 4 additions & 6 deletions test/test_core_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading