Created
June 25, 2024 15:02
-
-
Save kgilpin/9d7e77cbd87b2fc2f8c7a69817bea6d8 to your computer and use it in GitHub Desktop.
Navie lint repair
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<lint-errors> | |
sklearn/utils/validation.py:485:26: F821 undefined name 'pd' | |
</lint-errors> | |
<diff>--- /home/runner/work/SWE-bench/SWE-bench/logs/solve/scikit-learn__scikit-learn-14878/2/diff/sklearn_utils_validation.py/pre/base 2024-06-15 20:45:28.079868186 +0000 | |
+++ /home/runner/work/SWE-bench/SWE-bench/logs/solve/scikit-learn__scikit-learn-14878/2/diff/sklearn_utils_validation.py/pre/updated 2024-06-15 20:45:28.079868186 +0000 | |
@@ -338,8 +338,7 @@ | |
dtype="numeric", order=None, copy=False, force_all_finite=True, | |
ensure_2d=True, allow_nd=False, ensure_min_samples=1, | |
ensure_min_features=1, warn_on_dtype=None, estimator=None): | |
- | |
- """Input validation on an array, list, sparse matrix or similar. | |
+ """Input validation on an array, list, sparse matrix, or pandas DataFrame. | |
By default, the input is checked to be a non-empty 2D array containing | |
only finite values. If the dtype of the array is object, attempt | |
@@ -483,6 +482,10 @@ | |
estimator_name = "Estimator" | |
context = " by %s" % estimator_name if estimator is not None else "" | |
+ if isinstance(array, pd.DataFrame): | |
+ # Convert DataFrame to numpy array | |
+ array = array.values | |
+ | |
if sp.issparse(array): | |
_ensure_no_complex_data(array) | |
array = _ensure_sparse_format(array, accept_sparse=accept_sparse, | |
</diff> | |
<file> | |
<path>sklearn/utils/validation.py | |
</path> | |
<content> | |
479: else: | |
480: estimator_name = estimator.__class__.__name__ | |
481: else: | |
482: estimator_name = "Estimator" | |
483: context = " by %s" % estimator_name if estimator is not None else "" | |
484: | |
485: if isinstance(array, pd.DataFrame): | |
486: # Convert DataFrame to numpy array | |
487: array = array.values | |
488: | |
489: if sp.issparse(array): | |
490: _ensure_no_complex_data(array) | |
491: array = _ensure_sparse_format(array, accept_sparse=accept_sparse, | |
492: dtype=dtype, copy=copy, | |
</content> | |
</file> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment