From 3ef6501c3cb1d6ef3ed2351812e51226a88e9701 Mon Sep 17 00:00:00 2001 From: Samuel Hoffman Date: Tue, 11 Jul 2023 16:43:26 -0400 Subject: [PATCH 1/3] Bump versions ubuntu-18.04 and python 3.7 no longer supported Signed-off-by: Samuel Hoffman --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 611e18a4..3b1ac5cd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,12 +16,12 @@ on: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: build-py: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest strategy: fail-fast: false matrix: - python-version: [3.7, 3.8, 3.9, '3.10'] + python-version: [3.8, 3.9, '3.10', 3.11] env: UCI_DB: "https://archive.ics.uci.edu/ml/machine-learning-databases" @@ -70,12 +70,12 @@ jobs: run: pytest tests --cov=aif360 --cov-report=term-missing build-r: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest strategy: fail-fast: false matrix: - python-version: [3.7, 3.8, 3.9, '3.10'] + python-version: [3.8, 3.9, '3.10', 3.11] steps: - name: Check out repo From bc5e29f3b4b05a2e074ca374d34980b7277634fc Mon Sep 17 00:00:00 2001 From: Samuel Hoffman Date: Mon, 17 Jul 2023 11:48:59 -0400 Subject: [PATCH 2/3] bump readme versions Signed-off-by: Samuel Hoffman --- README.md | 13 +++++-------- aif360/aif360-r/R/utils.R | 6 +++--- setup.py | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 382d17dd..53b369ce 100644 --- a/README.md +++ b/README.md @@ -76,9 +76,9 @@ Supported Python Configurations: | OS | Python version | | ------- | -------------- | -| macOS | 3.7 – 3.10 | -| Ubuntu | 3.7 – 3.10 | -| Windows | 3.7 – 3.10 | +| macOS | 3.8 – 3.11 | +| Ubuntu | 3.8 – 3.11 | +| Windows | 3.8 – 3.11 | ### (Optional) Create a virtual environment @@ -95,10 +95,10 @@ is sufficient (see [the difference between Anaconda and Miniconda](https://conda.io/docs/user-guide/install/download.html#anaconda-or-miniconda) if you are curious) if you do not already have conda installed. -Then, to create a new Python 3.7 environment, run: +Then, to create a new Python 3.11 environment, run: ```bash -conda create --name aif360 python=3.7 +conda create --name aif360 python=3.11 conda activate aif360 ``` @@ -110,9 +110,6 @@ The shell should now look like `(aif360) $`. To deactivate the environment, run: The prompt will return to `$ `. -Note: Older versions of conda may use `source activate aif360` and `source -deactivate` (`activate aif360` and `deactivate` on Windows). - ### Install with `pip` To install the latest stable version from PyPI, run: diff --git a/aif360/aif360-r/R/utils.R b/aif360/aif360-r/R/utils.R index c2b694d8..a6443c7a 100755 --- a/aif360/aif360-r/R/utils.R +++ b/aif360/aif360-r/R/utils.R @@ -20,7 +20,7 @@ #' only occur within RStudio). #' #' @param conda_python_version the python version installed in the created conda -#' environment. Python 3.6 is installed by default. +#' environment. Python 3.11 is installed by default. #' #' @param ... other arguments passed to [reticulate::conda_install()] or #' [reticulate::virtualenv_install()]. @@ -33,13 +33,13 @@ install_aif360 <- function(method = c("auto", "virtualenv", "conda"), envname = NULL, extra_packages = NULL, restart_session = TRUE, - conda_python_version = "3.7", + conda_python_version = "3.11", ...) { method <- match.arg(method) reticulate::py_install( - packages = c("aif360", "numba", "BlackBoxAuditing", "tensorflow>=1.13.1,<2", "pandas", + packages = c("aif360", "numba", "BlackBoxAuditing", "tensorflow>=1.13.1,<2", "pandas", "fairlearn==0.4.6", "protobuf==3.20.1"), envname = envname, method = method, diff --git a/setup.py b/setup.py index 45cc6ddf..b2245c28 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,7 @@ long_description_content_type='text/markdown', license='Apache License 2.0', packages=[pkg for pkg in find_packages() if pkg.startswith('aif360')], - python_requires='>=3.7', + python_requires='>=3.8', install_requires=[ 'numpy>=1.16', 'scipy>=1.2.0', From b5f2c51406acfc35508eb3a7d7ce9cd8b1a1d485 Mon Sep 17 00:00:00 2001 From: Samuel Hoffman Date: Mon, 17 Jul 2023 11:49:16 -0400 Subject: [PATCH 3/3] fix tests Signed-off-by: Samuel Hoffman --- .../postprocessing/eq_odds_postprocessing.py | 16 ++++++++-------- tests/sklearn/test_datasets.py | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/aif360/algorithms/postprocessing/eq_odds_postprocessing.py b/aif360/algorithms/postprocessing/eq_odds_postprocessing.py index 016b6f8b..4c28a59a 100644 --- a/aif360/algorithms/postprocessing/eq_odds_postprocessing.py +++ b/aif360/algorithms/postprocessing/eq_odds_postprocessing.py @@ -143,29 +143,29 @@ def fit(self, dataset_true, dataset_pred): sm_tn = np.logical_and(sflip, y_true[cond_vec_priv] == dataset_true.unfavorable_label, - dtype=np.float64) + ).astype(np.float64) sm_fn = np.logical_and(sflip, y_true[cond_vec_priv] == dataset_true.favorable_label, - dtype=np.float64) + ).astype(np.float64) sm_fp = np.logical_and(sconst, y_true[cond_vec_priv] == dataset_true.unfavorable_label, - dtype=np.float64) + ).astype(np.float64) sm_tp = np.logical_and(sconst, y_true[cond_vec_priv] == dataset_true.favorable_label, - dtype=np.float64) + ).astype(np.float64) om_tn = np.logical_and(oflip, y_true[cond_vec_unpriv] == dataset_true.unfavorable_label, - dtype=np.float64) + ).astype(np.float64) om_fn = np.logical_and(oflip, y_true[cond_vec_unpriv] == dataset_true.favorable_label, - dtype=np.float64) + ).astype(np.float64) om_fp = np.logical_and(oconst, y_true[cond_vec_unpriv] == dataset_true.unfavorable_label, - dtype=np.float64) + ).astype(np.float64) om_tp = np.logical_and(oconst, y_true[cond_vec_unpriv] == dataset_true.favorable_label, - dtype=np.float64) + ).astype(np.float64) # A_eq - 2-D array which, when matrix-multiplied by x, # gives the values of the equality constraints at x diff --git a/tests/sklearn/test_datasets.py b/tests/sklearn/test_datasets.py index f7dad27e..0fefc835 100644 --- a/tests/sklearn/test_datasets.py +++ b/tests/sklearn/test_datasets.py @@ -233,7 +233,7 @@ def test_cache_meps(panel): meps_raw = fetch_meps(panel, cache=False, accept_terms=True)[0] fetch_meps(panel, cache=True, accept_terms=True) meps_cached = fetch_meps(panel, cache=True)[0] - assert_frame_equal(meps_raw, meps_cached, check_dtype=False) + assert_frame_equal(meps_raw, meps_cached, check_dtype=False, check_categorical=False) assert_array_equal(meps_raw.to_numpy(), meps_cached.to_numpy()) @pytest.mark.parametrize(