Talip7/scikit-learn-issues-multilabel huggingface dataset:
Array API tests fail on main

### Describe the bug

I ran the Array API tests on main and got 10 failing tests. 
(Last week, with an older main and everything else the same, I had 4 failing tests.)

array_api_compat==1.7.1

I only ran the cpu tests.

### Steps/Code to Reproduce

`pytest sklearn/utils/tests/test_array_api.py`

### Expected Results

all tests pass

### Actual Results

```
FAILED sklearn/utils/tests/test_array_api.py::test_get_namespace_ndarray_with_dispatch - AssertionError
FAILED sklearn/utils/tests/test_array_api.py::test_average[None-None-False-21-numpy-None-None] - AssertionError
FAILED sklearn/utils/tests/test_array_api.py::test_average_raises_with_invalid_parameters[0-weights1-TypeError-1D weights expected-numpy-None-None] - ValueError: Shape of weights must be consistent with shape of a along specified axis.
FAILED sklearn/utils/tests/test_array_api.py::test_average_raises_with_invalid_parameters[0-weights2-ValueError-Length of weights-numpy-None-None] - AssertionError: Regex pattern did not match.
FAILED sklearn/utils/tests/test_array_api.py::test_count_nonzero[None-None-csr_matrix-numpy-None-None] - AssertionError
FAILED sklearn/utils/tests/test_array_api.py::test_count_nonzero[None-None-csr_array-numpy-None-None] - AssertionError
FAILED sklearn/utils/tests/test_array_api.py::test_count_nonzero[int-None-csr_matrix-numpy-None-None] - AssertionError
FAILED sklearn/utils/tests/test_array_api.py::test_count_nonzero[int-None-csr_array-numpy-None-None] - AssertionError
FAILED sklearn/utils/tests/test_array_api.py::test_count_nonzero[float-None-csr_matrix-numpy-None-None] - AssertionError
FAILED sklearn/utils/tests/test_array_api.py::test_count_nonzero[float-None-csr_array-numpy-None-None] - AssertionError
```


### Versions

```shell
System:
    python: 3.12.2 (main, Apr 18 2024, 11:14:27) [GCC 13.2.1 20230801]
executable: /home/stefanie/.pyenv/versions/3.12.2/envs/scikit-learn_dev/bin/python
   machine: Linux-6.9.5-arch1-1-x86_64-with-glibc2.39

Python dependencies:
      sklearn: 1.6.dev0
          pip: 24.0
   setuptools: 69.5.1
        numpy: 2.1.0.dev0
        scipy: 1.13.0
       Cython: 3.0.10
       pandas: 2.2.2
   matplotlib: 3.8.4
       joblib: 1.4.0
threadpoolctl: 3.4.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 14
         prefix: libopenblas
       filepath: /home/stefanie/.pyenv/versions/3.12.2/envs/scikit-learn_dev/lib/python3.12/site-packages/scipy.libs/libopenblasp-r0-24bff013.3.26.dev.so
        version: 0.3.26.dev
threading_layer: pthreads
   architecture: Haswell

       user_api: openmp
   internal_api: openmp
    num_threads: 14
         prefix: libgomp
       filepath: /usr/lib/libgomp.so.1.0.0
        version: None
```

Also just tested with numpy==2.0.0, and the same failures.

COMMENT:
> About lock-files, I think we should merge https://github.com/scikit-learn/scikit-learn/pull/29388 first.

Merged. I will update my PR with `main`.

Labels: Bug, Array API
Array API tests fail on main

### Describe the bug

I ran the Array API tests on main and got 10 failing tests. 
(Last week, with an older main and everything else the same, I had 4 failing tests.)

array_api_compat==1.7.1

I only ran the cpu tests.

### Steps/Code to Reproduce

`pytest sklearn/utils/tests/test_array_api.py`

### Expected Results

all tests pass

### Actual Results

```
FAILED sklearn/utils/tests/test_array_api.py::test_get_namespace_ndarray_with_dispatch - AssertionError
FAILED sklearn/utils/tests/test_array_api.py::test_average[None-None-False-21-numpy-None-None] - AssertionError
FAILED sklearn/utils/tests/test_array_api.py::test_average_raises_with_invalid_parameters[0-weights1-TypeError-1D weights expected-numpy-None-None] - ValueError: Shape of weights must be consistent with shape of a along specified axis.
FAILED sklearn/utils/tests/test_array_api.py::test_average_raises_with_invalid_parameters[0-weights2-ValueError-Length of weights-numpy-None-None] - AssertionError: Regex pattern did not match.
FAILED sklearn/utils/tests/test_array_api.py::test_count_nonzero[None-None-csr_matrix-numpy-None-None] - AssertionError
FAILED sklearn/utils/tests/test_array_api.py::test_count_nonzero[None-None-csr_array-numpy-None-None] - AssertionError
FAILED sklearn/utils/tests/test_array_api.py::test_count_nonzero[int-None-csr_matrix-numpy-None-None] - AssertionError
FAILED sklearn/utils/tests/test_array_api.py::test_count_nonzero[int-None-csr_array-numpy-None-None] - AssertionError
FAILED sklearn/utils/tests/test_array_api.py::test_count_nonzero[float-None-csr_matrix-numpy-None-None] - AssertionError
FAILED sklearn/utils/tests/test_array_api.py::test_count_nonzero[float-None-csr_array-numpy-None-None] - AssertionError
```


### Versions

```shell
System:
    python: 3.12.2 (main, Apr 18 2024, 11:14:27) [GCC 13.2.1 20230801]
executable: /home/stefanie/.pyenv/versions/3.12.2/envs/scikit-learn_dev/bin/python
   machine: Linux-6.9.5-arch1-1-x86_64-with-glibc2.39

Python dependencies:
      sklearn: 1.6.dev0
          pip: 24.0
   setuptools: 69.5.1
        numpy: 2.1.0.dev0
        scipy: 1.13.0
       Cython: 3.0.10
       pandas: 2.2.2
   matplotlib: 3.8.4
       joblib: 1.4.0
threadpoolctl: 3.4.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 14
         prefix: libopenblas
       filepath: /home/stefanie/.pyenv/versions/3.12.2/envs/scikit-learn_dev/lib/python3.12/site-packages/scipy.libs/libopenblasp-r0-24bff013.3.26.dev.so
        version: 0.3.26.dev
threading_layer: pthreads
   architecture: Haswell

       user_api: openmp
   internal_api: openmp
    num_threads: 14
         prefix: libgomp
       filepath: /usr/lib/libgomp.so.1.0.0
        version: None
```

Also just tested with numpy==2.0.0, and the same failures.

COMMENT:
I will add `array-api-strict` without pytorch to one of the CPU builds on the CI as part of  #29436.

Labels: Bug, Array API
Assign (aka `/take` in comment) workflow broken for non maintainers

See https://github.com/scikit-learn/scikit-learn/actions/workflows/assign.yml

Edit: so actually this works as a maintainer but not as a normal user. It is more useful as a normal user ... maybe a permission thing that was changed at one point to be read (and not write) for security reasons?

```
Run echo "Assigning issue 29395 to test-lesteve"
  echo "Assigning issue 29395 to test-lesteve"
  gh issue edit $ISSUE --add-assignee test-lesteve
  gh issue edit $ISSUE --remove-label "help wanted"
  shell: /usr/bin/bash -e {0}
  env:
    GH_TOKEN: ***
    ISSUE: https://github.com/scikit-learn/scikit-learn/issues/29395
Assigning issue 29395 to test-lesteve
failed to update [https://github.com/scikit-learn/scikit-learn/issues/29395:](https://github.com/scikit-learn/scikit-learn/issues/29395:?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen) 'test-lesteve' not found
failed to update 1 issue
Error: Process completed with exit code 1.
```

COMMENT:
/take

Labels: Build / CI
Assign (aka `/take` in comment) workflow broken for non maintainers

See https://github.com/scikit-learn/scikit-learn/actions/workflows/assign.yml

Edit: so actually this works as a maintainer but not as a normal user. It is more useful as a normal user ... maybe a permission thing that was changed at one point to be read (and not write) for security reasons?

```
Run echo "Assigning issue 29395 to test-lesteve"
  echo "Assigning issue 29395 to test-lesteve"
  gh issue edit $ISSUE --add-assignee test-lesteve
  gh issue edit $ISSUE --remove-label "help wanted"
  shell: /usr/bin/bash -e {0}
  env:
    GH_TOKEN: ***
    ISSUE: https://github.com/scikit-learn/scikit-learn/issues/29395
Assigning issue 29395 to test-lesteve
failed to update [https://github.com/scikit-learn/scikit-learn/issues/29395:](https://github.com/scikit-learn/scikit-learn/issues/29395:?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen) 'test-lesteve' not found
failed to update 1 issue
Error: Process completed with exit code 1.
```

COMMENT:
It looks like the permissions for the workflow are correct. I wonder if it has to do with `test-lesteve` containing a `-`? And/or something else that means we should be escaping or quoting the argument to `gh issue edit 42 --add-assignee`?

Labels: Build / CI
Assign (aka `/take` in comment) workflow broken for non maintainers

See https://github.com/scikit-learn/scikit-learn/actions/workflows/assign.yml

Edit: so actually this works as a maintainer but not as a normal user. It is more useful as a normal user ... maybe a permission thing that was changed at one point to be read (and not write) for security reasons?

```
Run echo "Assigning issue 29395 to test-lesteve"
  echo "Assigning issue 29395 to test-lesteve"
  gh issue edit $ISSUE --add-assignee test-lesteve
  gh issue edit $ISSUE --remove-label "help wanted"
  shell: /usr/bin/bash -e {0}
  env:
    GH_TOKEN: ***
    ISSUE: https://github.com/scikit-learn/scikit-learn/issues/29395
Assigning issue 29395 to test-lesteve
failed to update [https://github.com/scikit-learn/scikit-learn/issues/29395:](https://github.com/scikit-learn/scikit-learn/issues/29395:?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen) 'test-lesteve' not found
failed to update 1 issue
Error: Process completed with exit code 1.
```

COMMENT:
Interesting suggestion but it has happened a while ago to a user without `-` see https://github.com/scikit-learn/scikit-learn/actions/runs/8831329895/job/24246316170

I would also guess that using a `-` in the middle of an argument is fine, at the beginning of an argument it may be more problematic.

Let me try to debug this a bit more ...

Labels: Build / CI
Assign (aka `/take` in comment) workflow broken for non maintainers

See https://github.com/scikit-learn/scikit-learn/actions/workflows/assign.yml

Edit: so actually this works as a maintainer but not as a normal user. It is more useful as a normal user ... maybe a permission thing that was changed at one point to be read (and not write) for security reasons?

```
Run echo "Assigning issue 29395 to test-lesteve"
  echo "Assigning issue 29395 to test-lesteve"
  gh issue edit $ISSUE --add-assignee test-lesteve
  gh issue edit $ISSUE --remove-label "help wanted"
  shell: /usr/bin/bash -e {0}
  env:
    GH_TOKEN: ***
    ISSUE: https://github.com/scikit-learn/scikit-learn/issues/29395
Assigning issue 29395 to test-lesteve
failed to update [https://github.com/scikit-learn/scikit-learn/issues/29395:](https://github.com/scikit-learn/scikit-learn/issues/29395:?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen) 'test-lesteve' not found
failed to update 1 issue
Error: Process completed with exit code 1.
```

COMMENT:
Sorry for the pinged people :sweat_smile:

I was able to add `@Charlie-XIAO` which has a `-` in its name with
```
gh issue edit 29395 --add-assignee Charlie-XIAO 
```

On the other hand not `@StefanieSenger`
```
gh issue edit 29395 --add-assignee StefanieSenger
```

My best guess right now is that assigning through `gh` only works for people in one of the [scikit-learn teams](https://github.com/orgs/scikit-learn/teams) :thinking:

Labels: Build / CI
Assign (aka `/take` in comment) workflow broken for non maintainers

See https://github.com/scikit-learn/scikit-learn/actions/workflows/assign.yml

Edit: so actually this works as a maintainer but not as a normal user. It is more useful as a normal user ... maybe a permission thing that was changed at one point to be read (and not write) for security reasons?

```
Run echo "Assigning issue 29395 to test-lesteve"
  echo "Assigning issue 29395 to test-lesteve"
  gh issue edit $ISSUE --add-assignee test-lesteve
  gh issue edit $ISSUE --remove-label "help wanted"
  shell: /usr/bin/bash -e {0}
  env:
    GH_TOKEN: ***
    ISSUE: https://github.com/scikit-learn/scikit-learn/issues/29395
Assigning issue 29395 to test-lesteve
failed to update [https://github.com/scikit-learn/scikit-learn/issues/29395:](https://github.com/scikit-learn/scikit-learn/issues/29395:?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen) 'test-lesteve' not found
failed to update 1 issue
Error: Process completed with exit code 1.
```

COMMENT:
> My best guess right now is that assigning through `gh` only works for people in one of the [scikit-learn teams](https://github.com/orgs/scikit-learn/teams) 🤔

So weird!

Labels: Build / CI
Assign (aka `/take` in comment) workflow broken for non maintainers

See https://github.com/scikit-learn/scikit-learn/actions/workflows/assign.yml

Edit: so actually this works as a maintainer but not as a normal user. It is more useful as a normal user ... maybe a permission thing that was changed at one point to be read (and not write) for security reasons?

```
Run echo "Assigning issue 29395 to test-lesteve"
  echo "Assigning issue 29395 to test-lesteve"
  gh issue edit $ISSUE --add-assignee test-lesteve
  gh issue edit $ISSUE --remove-label "help wanted"
  shell: /usr/bin/bash -e {0}
  env:
    GH_TOKEN: ***
    ISSUE: https://github.com/scikit-learn/scikit-learn/issues/29395
Assigning issue 29395 to test-lesteve
failed to update [https://github.com/scikit-learn/scikit-learn/issues/29395:](https://github.com/scikit-learn/scikit-learn/issues/29395:?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen) 'test-lesteve' not found
failed to update 1 issue
Error: Process completed with exit code 1.
```

COMMENT:
Would you believe it, it seems like a gh bug: https://github.com/cli/cli/issues/6235#issuecomment-1243487651 says that there is some kind of assignable user list when using `gh`. For scikit-learn you get it from:
```
gh api graphql -f query='query($endCursor:String){repository(owner:"scikit-learn",name:"scikit-learn"){assignableUsers(first:100,after:$endCursor){nodes{login}pageInfo{endCursor,hasNextPage}}}}' --paginate --jq '.data.repository.assignableUsers.nodes[].login'
```

That lists about 40 people who indeed look like people in [scikit-learn teams](https://github.com/orgs/scikit-learn/teams). Anyone outside of it can not be assigned to an issue through `gh` ...

See pandas workflow to assign (IIRC we took the idea from pandas) that use the REST API:
https://github.com/pandas-dev/pandas/blob/dcb5494e511cee9643ce3748d4450a97ed1a7c03/.github/workflows/comment-commands.yml#L12-L20

Labels: Build / CI
Single-sourcing the package version?

If `version` is declared as a dynamic attribute in the `pyproject.toml`, meson will use the one specified in `meson.build`. This would avoid having to update the version in both `__init__.py` and `pyproject.toml`:

```diff
diff --git a/pyproject.toml b/pyproject.toml
index ff7df45c1d..1b613ae561 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [project]
 name = "scikit-learn"
-version = "1.6.dev0"
+dynamic = ["version"]
 description = "A set of python modules for machine learning and data mining"
 readme = "README.rst"
 maintainers = [
```

COMMENT:
Seems like a no brainer, thanks! Do you want to do a PR?

I guess one think to double-check is the wheel naming. According to what you are saying it sounds fine, but this would be nice to make sure there are no autogenerated things like the git commit hash in the wheel name. IIRC we don't currently clean-up https://anaconda.org/scientific-python-nightly-wheels/scikit-learn/files, and rely on the name to be always the same on each nightly upload to avoid having too many wheels there, which would take up space.

Labels: Enhancement, Build / CI
Single-sourcing the package version?

If `version` is declared as a dynamic attribute in the `pyproject.toml`, meson will use the one specified in `meson.build`. This would avoid having to update the version in both `__init__.py` and `pyproject.toml`:

```diff
diff --git a/pyproject.toml b/pyproject.toml
index ff7df45c1d..1b613ae561 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [project]
 name = "scikit-learn"
-version = "1.6.dev0"
+dynamic = ["version"]
 description = "A set of python modules for machine learning and data mining"
 readme = "README.rst"
 maintainers = [
```

COMMENT:
> Do you want to do a PR?

sure!

> I guess one think to double-check is the wheel naming

when I build it locally this is the wheel (and source archive) I get:

```
dist
├── scikit_learn-1.6.dev0-cp311-cp311-linux_x86_64.whl
└── scikit_learn-1.6.dev0.tar.gz
```

so it seems like the usual naming.

IIUC if the version is dynamic, meson will rely on the value in `meson.build` (I couldn't find that explicitly in the doc but I may have missed something, I checked it seems to be the case and it is stated in [this comment](https://github.com/mesonbuild/meson-python/issues/159#issuecomment-1709119433)), which gets it by running `sklearn/_build_utils/version.py`, which in turns reads it from `sklearn/__init__.py`.
I am completely new to meson though; I've never used it before so I could easily have misunderstood something

Labels: Enhancement, Build / CI
⚠️ CI failed on Wheel builder (last failure: Jul 03, 2024) ⚠️

**CI failed on [Wheel builder](https://github.com/scikit-learn/scikit-learn/actions/runs/9771534239)** (Jul 03, 2024)

COMMENT:
## CI is no longer failing! ✅

[Successful run](https://github.com/scikit-learn/scikit-learn/actions/runs/9771534239) on Jul 03, 2024

Labels: Needs Triage
Broken ref in datasets.rst

There's a reference in `datasets.rst` that no longer points to anything after #29104 was merged:
https://github.com/scikit-learn/scikit-learn/blob/5bbe346de43fd402b9a4af7b6383cd644d7fb7b6/doc/datasets.rst?plain=1#L9-L10

I don't understand why it wasn't caught by the CI in #29104. I saw it in the 1.5.1 release branch (#29382), see https://output.circle-artifacts.com/output/job/b0d90a86-a5d1-4ac2-b9b5-c3e6397555da/artifacts/0/doc/_changed.html.

I will ignore it for the release, but we need to rephrase this paragraph because it references a part of the doc that no longer exists.

COMMENT:
> I don't understand why it wasn't caught by the CI in https://github.com/scikit-learn/scikit-learn/pull/29104.

My guess: since we do partial builds in PRs we probably don't turn sphinx warnings into errors?

Labels: Documentation
Broken ref in datasets.rst

There's a reference in `datasets.rst` that no longer points to anything after #29104 was merged:
https://github.com/scikit-learn/scikit-learn/blob/5bbe346de43fd402b9a4af7b6383cd644d7fb7b6/doc/datasets.rst?plain=1#L9-L10

I don't understand why it wasn't caught by the CI in #29104. I saw it in the 1.5.1 release branch (#29382), see https://output.circle-artifacts.com/output/job/b0d90a86-a5d1-4ac2-b9b5-c3e6397555da/artifacts/0/doc/_changed.html.

I will ignore it for the release, but we need to rephrase this paragraph because it references a part of the doc that no longer exists.

COMMENT:
> we probably don't turn sphinx warnings into errors?

we do for warnings coming from files that are modified in the PR, that's why circle ci failed in the release branch.
see https://github.com/scikit-learn/scikit-learn/blob/038bbc17ba06ea5180e0cd027749772d605af2e4/build_tools/circle/build_doc.sh#L248-L253

Labels: Documentation
DOC Improve maintainers page

I've found the [maintainers page](https://scikit-learn.org/stable/developers/maintainer.html) a bit messy and badly structured for a while. It gives a lot of room for mistakes. The recent switch to the new pydata sphinx theme is good opportunity to rework it. I imagine that we could have tabs and selectors for the different kind of release: major, RC, bug-fix. Something like what we did for the [install docs](https://scikit-learn.org/stable/install.html#installing-the-latest-release).

ping @Charlie-XIAO, maybe you'd be interested ? You're already pretty familiar with all this stuff :)

COMMENT:
Yes sure, I think I will do it some time this week.

Labels: Documentation
DOC Improve maintainers page

I've found the [maintainers page](https://scikit-learn.org/stable/developers/maintainer.html) a bit messy and badly structured for a while. It gives a lot of room for mistakes. The recent switch to the new pydata sphinx theme is good opportunity to rework it. I imagine that we could have tabs and selectors for the different kind of release: major, RC, bug-fix. Something like what we did for the [install docs](https://scikit-learn.org/stable/install.html#installing-the-latest-release).

ping @Charlie-XIAO, maybe you'd be interested ? You're already pretty familiar with all this stuff :)

COMMENT:
done in #29412

Labels: Documentation
`IterativeImputer` skip iterative part if `keep_empty_features` is set to `True`

### Describe the bug

The mask is set to all True, so that the iterative imputation will be skipped.

https://github.com/scikit-learn/scikit-learn/blob/a4ebe19a95ffbb3cf6abf3e98d737d0d097f5de3/sklearn/impute/_iterative.py#L649-L651

### Steps/Code to Reproduce

```python
import numpy as np
from sklearn.experimental import enable_iterative_imputer
from sklearn.impute import IterativeImputer

imp = IterativeImputer(keep_empty_features=True)
X = [[np.nan, 0, 1], [2, np.nan, 3], [4, 5, np.nan]]
print(imp.fit_transform(X))
print(imp.imputation_sequence_)
```

### Expected Results

Should act the same as `keep_empty_features=False`

### Actual Results

```
# transformed X
[[3.  0.  1. ]
 [2.  2.5 3. ]
 [4.  5.  2. ]]

# imputation_sequence_
[]
```

### Versions

```shell
System:
    python: 3.9.16 | packaged by conda-forge | (main, Feb  1 2023, 21:38:11)  [Clang 14.0.6 ]
executable: /Users/xxf/miniconda3/envs/sklearn-env/bin/python
   machine: macOS-14.5-arm64-arm-64bit

Python dependencies:
      sklearn: 1.6.dev0
          pip: 23.2.1
   setuptools: 68.0.0
        numpy: 1.26.4
        scipy: 1.13.0
       Cython: 3.0.8
       pandas: 2.1.0
   matplotlib: 3.7.2
       joblib: 1.3.0
threadpoolctl: 3.5.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 8
         prefix: libopenblas
       filepath: /Users/xxf/miniconda3/envs/sklearn-env/lib/libopenblas.0.dylib
        version: 0.3.23
threading_layer: openmp
   architecture: VORTEX

       user_api: openmp
   internal_api: openmp
    num_threads: 8
         prefix: libomp
       filepath: /Users/xxf/miniconda3/envs/sklearn-env/lib/libomp.dylib
        version: None
```

COMMENT:
/take

Can any member check this and remove needs triage. 
Then assign me the issue.

Labels: Bug