Skip to content

Use absolute imports in Cython code #32315

@lesteve

Description

@lesteve

This is a follow-up of #31847 where we switched to absolute imports for Python files thanks to ruff but not Cython files. Maybe one day this can be enforced by cython-lint --ban-relative-imports, see MarcoGorelli/cython-lint#149

Tip

If you want to work on this, please:

  • do one Pull Request per file
  • add a comment in this issue saying which link you want to tackle so that different people can work on this issue in parallel
  • write Part of #32315 in your Pull Request description so that progress on this issue can more easily be tracked

As an example PR you can look at #32316.

Here is the list of Cython files to tackle

  • sklearn/cluster/_dbscan_inner.pyx MNT Switch to absolute imports in sklearn/cluster/_dbscan_inner.pyx #32316
  • sklearn/cluster/_hdbscan/_linkage.pyx
  • sklearn/cluster/_hdbscan/_reachability.pyx
  • sklearn/cluster/_hdbscan/_tree.pxd
  • sklearn/cluster/_hierarchical_fast.pxd
  • sklearn/cluster/_hierarchical_fast.pyx
  • sklearn/cluster/_k_means_common.pyx
  • sklearn/cluster/_k_means_elkan.pyx
  • sklearn/cluster/_k_means_lloyd.pyx
  • sklearn/decomposition/_online_lda_fast.pyx
  • sklearn/ensemble/_gradient_boosting.pyx @Ganasekhar-gif
  • sklearn/ensemble/_hist_gradient_boosting/_binning.pyx
  • sklearn/ensemble/_hist_gradient_boosting/_bitset.pxd
  • sklearn/ensemble/_hist_gradient_boosting/_bitset.pyx
  • sklearn/ensemble/_hist_gradient_boosting/common.pxd
  • sklearn/ensemble/_hist_gradient_boosting/_gradient_boosting.pyx
  • sklearn/ensemble/_hist_gradient_boosting/histogram.pyx
  • sklearn/ensemble/_hist_gradient_boosting/_predictor.pyx
  • sklearn/ensemble/_hist_gradient_boosting/splitting.pyx
  • sklearn/feature_extraction/_hashing_fast.pyx
  • sklearn/linear_model/_cd_fast.pyx
  • sklearn/linear_model/_sag_fast.pyx.tp
  • sklearn/linear_model/_sgd_fast.pyx.tp
  • sklearn/manifold/_barnes_hut_tsne.pyx
  • sklearn/manifold/_utils.pyx
  • sklearn/metrics/cluster/_expected_mutual_info_fast.pyx
  • sklearn/metrics/_dist_metrics.pxd.tp
  • sklearn/metrics/_dist_metrics.pyx.tp
  • sklearn/metrics/_pairwise_distances_reduction/_argkmin_classmode.pyx.tp
  • sklearn/metrics/_pairwise_distances_reduction/_argkmin.pxd.tp
  • sklearn/metrics/_pairwise_distances_reduction/_argkmin.pyx.tp
  • sklearn/metrics/_pairwise_distances_reduction/_base.pxd.tp
  • sklearn/metrics/_pairwise_distances_reduction/_base.pyx.tp
  • sklearn/metrics/_pairwise_distances_reduction/_datasets_pair.pxd.tp
  • sklearn/metrics/_pairwise_distances_reduction/_datasets_pair.pyx.tp
  • sklearn/metrics/_pairwise_distances_reduction/_middle_term_computer.pxd.tp
  • sklearn/metrics/_pairwise_distances_reduction/_middle_term_computer.pyx.tp
  • sklearn/metrics/_pairwise_distances_reduction/_radius_neighbors_classmode.pyx.tp
  • sklearn/metrics/_pairwise_distances_reduction/_radius_neighbors.pxd.tp
  • sklearn/metrics/_pairwise_distances_reduction/_radius_neighbors.pyx.tp
  • sklearn/metrics/_pairwise_fast.pyx
  • sklearn/neighbors/_binary_tree.pxi.tp
  • sklearn/neighbors/_partition_nodes.pxd
  • sklearn/neighbors/_quad_tree.pxd
  • sklearn/neighbors/_quad_tree.pyx
  • sklearn/preprocessing/_csr_polynomial_expansion.pyx
  • sklearn/preprocessing/_target_encoder_fast.pyx
  • sklearn/svm/_liblinear.pyx
  • sklearn/svm/_libsvm.pyx
  • sklearn/svm/_libsvm_sparse.pyx
  • sklearn/tree/_criterion.pxd
  • sklearn/tree/_criterion.pyx
  • sklearn/tree/_partitioner.pxd
  • sklearn/tree/_splitter.pxd
  • sklearn/tree/_splitter.pyx
  • sklearn/tree/_tree.pxd
  • sklearn/tree/_tree.pyx
  • sklearn/tree/_utils.pxd
  • sklearn/tree/_utils.pyx
  • sklearn/utils/arrayfuncs.pyx
  • sklearn/utils/_fast_dict.pxd
  • sklearn/utils/_fast_dict.pyx MNT Switch to absolute imports in sklearn/utils/_fast_dict.pyx #32317
  • sklearn/utils/_heap.pxd
  • sklearn/utils/_heap.pyx
  • sklearn/utils/murmurhash.pxd
  • sklearn/utils/murmurhash.pyx
  • sklearn/utils/_random.pxd
  • sklearn/utils/_random.pyx
  • sklearn/utils/_seq_dataset.pxd.tp
  • sklearn/utils/_seq_dataset.pyx.tp
  • sklearn/utils/_sorting.pxd
  • sklearn/utils/sparsefuncs_fast.pyx
  • sklearn/utils/_vector_sentinel.pxd
  • sklearn/utils/_weight_vector.pyx.tp

I got the list of files from the following git grep command:

git grep -Pl 'from \..+import|import \.' **/*.pxd **/*.pyx **/*.tp 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Meta-issueGeneral issue associated to an identified list of tasksgood first issueEasy with clear instructions to resolvehelp wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions