Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control parallel column transformer in filter columns #277

Merged
merged 4 commits into from
Oct 22, 2024
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
21 changes: 21 additions & 0 deletions docs/api/config.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Config
======

.. automodule:: julearn.config
:no-members:
:no-inherited-members:


See :ref:`configuration` for more information on the flags that can be set.

Functions
---------

.. currentmodule:: julearn.config

.. autosummary::
:toctree: generated/
:template: function.rst

set_config
get_config
1 change: 1 addition & 0 deletions docs/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ API Reference
prepare.rst
stats.rst
viz.rst
config.rst
1 change: 1 addition & 0 deletions docs/changes/newsfragments/277.enh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid parallel calls in :class:`.FilterColumns` if not specified by the user in the :mod:`.config` module by `Fede Raimondo`_
8 changes: 7 additions & 1 deletion julearn/transformers/dataframe/filter_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
JuTransformer,
ensure_column_types,
)
from ...config import get_config
from ...utils.typing import DataLike


Expand Down Expand Up @@ -53,7 +54,9 @@ def __init__(
)

def _fit(
self, X: pd.DataFrame, y: Optional[DataLike] = None # noqa: N803
self,
X: pd.DataFrame, # noqa: N803
y: Optional[DataLike] = None,
) -> "FilterColumns":
"""Fit the transformer.

Expand All @@ -75,6 +78,9 @@ def _fit(
transformers=[("keep", "passthrough", apply_to_selector)],
remainder="drop",
verbose_feature_names_out=False,
n_jobs=None
if get_config("enable_parallel_column_transformers")
else 1,
)
self.filter_columns_.fit(X, y)
return self
Expand Down
Loading