From b993b5edd15afe2485bb81b39120e63364947e98 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Fri, 17 Sep 2021 15:14:05 -0400 Subject: [PATCH 01/28] ENH Adds feature_names_out to impute module --- sklearn/impute/_base.py | 55 +++++++++++++++++++++++++++++ sklearn/impute/_iterative.py | 24 +++++++++++++ sklearn/impute/_knn.py | 27 +++++++++++++- sklearn/impute/tests/test_common.py | 40 +++++++++++++++++++++ sklearn/tests/test_common.py | 1 - 5 files changed, 145 insertions(+), 2 deletions(-) diff --git a/sklearn/impute/_base.py b/sklearn/impute/_base.py index 13aa7a1f19c35..c25a264a66f99 100644 --- a/sklearn/impute/_base.py +++ b/sklearn/impute/_base.py @@ -15,6 +15,7 @@ from ..utils.sparsefuncs import _get_median from ..utils.validation import check_is_fitted from ..utils.validation import FLOAT_DTYPES +from ..utils.validation import _check_feature_names_in from ..utils._mask import _get_mask from ..utils import is_scalar_nan @@ -113,6 +114,14 @@ def _concatenate_indicator(self, X_imputed, X_indicator): return hstack((X_imputed, X_indicator)) + def _concatenate_indicator_feature_names_out(self, names, input_features): + if not self.add_indicator: + return names + + indicator_names = self.indicator_.get_feature_names_out(input_features) + indicator_names_with_prefix = [f"indicator_{name}" for name in indicator_names] + return np.concatenate([names, indicator_names_with_prefix], dtype=object) + def _more_tags(self): return {"allow_nan": is_scalar_nan(self.missing_values)} @@ -593,6 +602,30 @@ def inverse_transform(self, X): X_original[full_mask] = self.missing_values return X_original + def get_feature_names_out(self, input_features=None): + """Get output feature names for transformation. + + Parameters + ---------- + input_features : array-like of str or None, default=None + Input features. + + - If `input_features` is `None`, then `feature_names_in_` is + used as feature names in. If `feature_names_in_` is not defined, + then names are generated: `[x0, x1, ..., x(n_features_in_)]`. + - If `input_features` is an array-like, then `input_features` must + match `feature_names_in_` if `feature_names_in_` is defined. + + Returns + ------- + feature_names_out : ndarray of str objects + Transformed feature names. + """ + input_features = _check_feature_names_in(self, input_features) + non_missing_mask = np.logical_not(_get_mask(self.statistics_, np.nan)) + names = input_features[non_missing_mask] + return self._concatenate_indicator_feature_names_out(names, input_features) + class MissingIndicator(TransformerMixin, BaseEstimator): """Binary indicators for missing values. @@ -913,6 +946,28 @@ def fit_transform(self, X, y=None): return imputer_mask + def get_feature_names_out(self, input_features=None): + """Get output feature names for transformation. + + Parameters + ---------- + input_features : array-like of str or None, default=None + Input features. + + - If `input_features` is `None`, then `feature_names_in_` is + used as feature names in. If `feature_names_in_` is not defined, + then names are generated: `[x0, x1, ..., x(n_features_in_)]`. + - If `input_features` is an array-like, then `input_features` must + match `feature_names_in_` if `feature_names_in_` is defined. + + Returns + ------- + feature_names_out : ndarray of str objects + Transformed feature names. + """ + input_features = _check_feature_names_in(self, input_features) + return input_features[self.features_] + def _more_tags(self): return { "allow_nan": True, diff --git a/sklearn/impute/_iterative.py b/sklearn/impute/_iterative.py index d95e78ccd36d3..25365261197c9 100644 --- a/sklearn/impute/_iterative.py +++ b/sklearn/impute/_iterative.py @@ -10,6 +10,7 @@ from ..preprocessing import normalize from ..utils import check_array, check_random_state, _safe_indexing, is_scalar_nan from ..utils.validation import FLOAT_DTYPES, check_is_fitted +from ..utils.validation import _check_feature_names_in from ..utils._mask import _get_mask from ._base import _BaseImputer @@ -773,3 +774,26 @@ def fit(self, X, y=None): """ self.fit_transform(X) return self + + def get_feature_names_out(self, input_features=None): + """Get output feature names for transformation. + + Parameters + ---------- + input_features : array-like of str or None, default=None + Input features. + + - If `input_features` is `None`, then `feature_names_in_` is + used as feature names in. If `feature_names_in_` is not defined, + then names are generated: `[x0, x1, ..., x(n_features_in_)]`. + - If `input_features` is an array-like, then `input_features` must + match `feature_names_in_` if `feature_names_in_` is defined. + + Returns + ------- + feature_names_out : ndarray of str objects + Transformed feature names. + """ + input_features = _check_feature_names_in(self, input_features) + names = self.initial_imputer_.get_feature_names_out(input_features) + return self._concatenate_indicator_feature_names_out(names, input_features) diff --git a/sklearn/impute/_knn.py b/sklearn/impute/_knn.py index c2bd1410e8ecd..ad7e3537d445f 100644 --- a/sklearn/impute/_knn.py +++ b/sklearn/impute/_knn.py @@ -13,6 +13,7 @@ from ..utils import is_scalar_nan from ..utils._mask import _get_mask from ..utils.validation import check_is_fitted +from ..utils.validation import _check_feature_names_in class KNNImputer(_BaseImputer): @@ -206,6 +207,7 @@ def fit(self, X, y=None): _check_weights(self.weights) self._fit_X = X self._mask_fit_X = _get_mask(self._fit_X, self.missing_values) + self._valid_mask = ~np.all(self._mask_fit_X, axis=0) super()._fit_indicator(self._mask_fit_X) @@ -242,7 +244,7 @@ def transform(self, X): mask = _get_mask(X, self.missing_values) mask_fit_X = self._mask_fit_X - valid_mask = ~np.all(mask_fit_X, axis=0) + valid_mask = self._valid_mask X_indicator = super()._transform_indicator(mask) @@ -327,3 +329,26 @@ def process_chunk(dist_chunk, start): pass return super()._concatenate_indicator(X[:, valid_mask], X_indicator) + + def get_feature_names_out(self, input_features=None): + """Get output feature names for transformation. + + Parameters + ---------- + input_features : array-like of str or None, default=None + Input features. + + - If `input_features` is `None`, then `feature_names_in_` is + used as feature names in. If `feature_names_in_` is not defined, + then names are generated: `[x0, x1, ..., x(n_features_in_)]`. + - If `input_features` is an array-like, then `input_features` must + match `feature_names_in_` if `feature_names_in_` is defined. + + Returns + ------- + feature_names_out : ndarray of str objects + Transformed feature names. + """ + input_features = _check_feature_names_in(self, input_features) + names = input_features[self._valid_mask] + return self._concatenate_indicator_feature_names_out(names, input_features) diff --git a/sklearn/impute/tests/test_common.py b/sklearn/impute/tests/test_common.py index c35245ac8c253..f000aedba5a8c 100644 --- a/sklearn/impute/tests/test_common.py +++ b/sklearn/impute/tests/test_common.py @@ -122,3 +122,43 @@ def test_imputers_pandas_na_integer_array_support(imputer, add_indicator): X_trans = imputer.fit_transform(X_df) assert_allclose(X_trans_expected, X_trans) + + +# ConvergenceWarning will be raised by the IterativeImputer +@pytest.mark.filterwarnings("ignore::sklearn.exceptions.ConvergenceWarning") +@pytest.mark.parametrize("imputer", IMPUTERS, ids=lambda x: x.__class__.__name__) +@pytest.mark.parametrize("add_indicator", [True, False]) +def test_imputers_feature_names_out_pandas(imputer, add_indicator): + """Check feature names out for imputers.""" + pd = pytest.importorskip("pandas") + marker = np.nan + imputer = imputer.set_params(add_indicator=add_indicator, missing_values=marker) + + X = np.array( + [ + [marker, 1, 5, marker, 1], + [2, marker, 1, marker, 2], + [6, 3, marker, marker, 3], + [1, 2, 9, marker, 4], + ] + ) + X_df = pd.DataFrame(X, columns=["a", "b", "c", "d", "e"]) + imputer.fit(X_df) + + names = imputer.get_feature_names_out() + + if add_indicator: + expected_names = [ + "a", + "b", + "c", + "e", + "indicator_a", + "indicator_b", + "indicator_c", + "indicator_d", + ] + assert_array_equal(expected_names, names) + else: + expected_names = ["a", "b", "c", "e"] + assert_array_equal(expected_names, names) diff --git a/sklearn/tests/test_common.py b/sklearn/tests/test_common.py index 4f6818081c67d..139a2bfb9702a 100644 --- a/sklearn/tests/test_common.py +++ b/sklearn/tests/test_common.py @@ -365,7 +365,6 @@ def test_pandas_column_name_consistency(estimator): "decomposition", "discriminant_analysis", "ensemble", - "impute", "isotonic", "kernel_approximation", "preprocessing", From 3f95b5c4af35f31d78a766625969fcb9080cd0ad Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Fri, 17 Sep 2021 15:29:38 -0400 Subject: [PATCH 02/28] DOC Adds whats new --- doc/whats_new/v1.1.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/whats_new/v1.1.rst b/doc/whats_new/v1.1.rst index 9c1084e393e8d..2b1740e6c6483 100644 --- a/doc/whats_new/v1.1.rst +++ b/doc/whats_new/v1.1.rst @@ -38,6 +38,13 @@ Changelog :pr:`123456` by :user:`Joe Bloggs `. where 123456 is the *pull request* number, not the issue number. +:mod:`sklearn.impute` +..................... + +- |API| Adds :meth:`get_feature_names_out` to :class:`impute.SimpleImputer`, + :class:`impute.KNNImputer`, :class:`impute.IterativeImputer`, and + :class:`impute.MissingIndicator`. :pr:`21078` by `Thomas Fan`_. + :mod:`sklearn.utils` .................... From 6ebb43ff89178d639effd2025ac34c02bc4148f8 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Fri, 17 Sep 2021 16:54:09 -0400 Subject: [PATCH 03/28] BUG Remove use for dtype in concatenate --- sklearn/impute/_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/impute/_base.py b/sklearn/impute/_base.py index c25a264a66f99..5c1f9805d67a2 100644 --- a/sklearn/impute/_base.py +++ b/sklearn/impute/_base.py @@ -120,7 +120,7 @@ def _concatenate_indicator_feature_names_out(self, names, input_features): indicator_names = self.indicator_.get_feature_names_out(input_features) indicator_names_with_prefix = [f"indicator_{name}" for name in indicator_names] - return np.concatenate([names, indicator_names_with_prefix], dtype=object) + return np.concatenate([names, indicator_names_with_prefix]) def _more_tags(self): return {"allow_nan": is_scalar_nan(self.missing_values)} From 91ae2bbca2aa22f65cf09dd6923f8c1d417bfff5 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Fri, 1 Oct 2021 14:55:23 -0400 Subject: [PATCH 04/28] MAINT Allows for multiple whitespace --- .github/workflows/assign.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index 4b067135bbfdb..21aea7520f379 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -7,9 +7,11 @@ on: jobs: one: runs-on: ubuntu-latest + # toJson(github.event.comment.body) allows newline to be detected if: >- (github.event.comment.body == 'take' || - github.event.comment.body == 'Take') + github.event.comment.body == 'take ' || + toJson(github.event.comment.body) == 'take\r\n' ) && !github.event.issue.assignee steps: - run: | From 544770beae44e0a8b442e720f74e3c45e7043dbd Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Mon, 4 Oct 2021 12:45:41 -0400 Subject: [PATCH 05/28] TST Adds non-missing feature in the middle --- sklearn/impute/_base.py | 4 +++- sklearn/impute/tests/test_common.py | 23 ++++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/sklearn/impute/_base.py b/sklearn/impute/_base.py index 985714f012cf7..b0cc3733978d6 100644 --- a/sklearn/impute/_base.py +++ b/sklearn/impute/_base.py @@ -119,7 +119,9 @@ def _concatenate_indicator_feature_names_out(self, names, input_features): return names indicator_names = self.indicator_.get_feature_names_out(input_features) - indicator_names_with_prefix = [f"indicator_{name}" for name in indicator_names] + indicator_names_with_prefix = [ + f"missingindicator_{name}" for name in indicator_names + ] return np.concatenate([names, indicator_names_with_prefix]) def _more_tags(self): diff --git a/sklearn/impute/tests/test_common.py b/sklearn/impute/tests/test_common.py index f000aedba5a8c..42cb2c097d009 100644 --- a/sklearn/impute/tests/test_common.py +++ b/sklearn/impute/tests/test_common.py @@ -136,13 +136,13 @@ def test_imputers_feature_names_out_pandas(imputer, add_indicator): X = np.array( [ - [marker, 1, 5, marker, 1], - [2, marker, 1, marker, 2], - [6, 3, marker, marker, 3], - [1, 2, 9, marker, 4], + [marker, 1, 5, 3, marker, 1], + [2, marker, 1, 4, marker, 2], + [6, 3, 7, marker, marker, 3], + [1, 2, 9, 8, marker, 4], ] ) - X_df = pd.DataFrame(X, columns=["a", "b", "c", "d", "e"]) + X_df = pd.DataFrame(X, columns=["a", "b", "c", "d", "e", "f"]) imputer.fit(X_df) names = imputer.get_feature_names_out() @@ -152,13 +152,14 @@ def test_imputers_feature_names_out_pandas(imputer, add_indicator): "a", "b", "c", - "e", - "indicator_a", - "indicator_b", - "indicator_c", - "indicator_d", + "d", + "f", + "missingindicator_a", + "missingindicator_b", + "missingindicator_d", + "missingindicator_e", ] assert_array_equal(expected_names, names) else: - expected_names = ["a", "b", "c", "e"] + expected_names = ["a", "b", "c", "d", "f"] assert_array_equal(expected_names, names) From 52c220252578076cd78951785d1cd2832b5d0342 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Mon, 4 Oct 2021 13:46:42 -0400 Subject: [PATCH 06/28] ENH Use missingindicator as prefix for indicator --- sklearn/impute/_base.py | 14 +++++++++----- sklearn/impute/tests/test_impute.py | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/sklearn/impute/_base.py b/sklearn/impute/_base.py index b0cc3733978d6..c97a8d24d4578 100644 --- a/sklearn/impute/_base.py +++ b/sklearn/impute/_base.py @@ -119,10 +119,7 @@ def _concatenate_indicator_feature_names_out(self, names, input_features): return names indicator_names = self.indicator_.get_feature_names_out(input_features) - indicator_names_with_prefix = [ - f"missingindicator_{name}" for name in indicator_names - ] - return np.concatenate([names, indicator_names_with_prefix]) + return np.concatenate([names, indicator_names]) def _more_tags(self): return {"allow_nan": is_scalar_nan(self.missing_values)} @@ -977,7 +974,14 @@ def get_feature_names_out(self, input_features=None): Transformed feature names. """ input_features = _check_feature_names_in(self, input_features) - return input_features[self.features_] + prefix = self.__class__.__name__.lower() + return np.asarray( + [ + f"{prefix}_{feature_name}" + for feature_name in input_features[self.features_] + ], + dtype=object, + ) def _more_tags(self): return { diff --git a/sklearn/impute/tests/test_impute.py b/sklearn/impute/tests/test_impute.py index 2534f94116b57..9a4da4a9230a0 100644 --- a/sklearn/impute/tests/test_impute.py +++ b/sklearn/impute/tests/test_impute.py @@ -1493,3 +1493,22 @@ def test_most_frequent(expected, array, dtype, extra_value, n_repeat): assert expected == _most_frequent( np.array(array, dtype=dtype), extra_value, n_repeat ) + + +def test_missing_indicator_feature_names_out(): + """Check that missing indicator return the feature names with a prefix.""" + pd = pytest.importorskip("pandas") + + missing_values = np.nan + X = pd.DataFrame( + [ + [missing_values, missing_values, 1, missing_values], + [4, missing_values, 2, 10], + ], + columns=["a", "b", "c", "d"], + ) + + indicator = MissingIndicator(missing_values=missing_values).fit(X) + feature_names = indicator.get_feature_names_out() + expected_names = ["missingindicator_a", "missingindicator_b", "missingindicator_d"] + assert_array_equal(expected_names, feature_names) From 71705897dca5557ca377446bee35743ad0280945 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Mon, 4 Oct 2021 13:48:44 -0400 Subject: [PATCH 07/28] TST Remove covergence warning --- sklearn/impute/tests/test_common.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sklearn/impute/tests/test_common.py b/sklearn/impute/tests/test_common.py index 42cb2c097d009..0c13547ce9b4c 100644 --- a/sklearn/impute/tests/test_common.py +++ b/sklearn/impute/tests/test_common.py @@ -14,7 +14,7 @@ from sklearn.impute import SimpleImputer -IMPUTERS = [IterativeImputer(), KNNImputer(), SimpleImputer()] +IMPUTERS = [IterativeImputer(tol=0.1), KNNImputer(), SimpleImputer()] SPARSE_IMPUTERS = [SimpleImputer()] @@ -124,8 +124,6 @@ def test_imputers_pandas_na_integer_array_support(imputer, add_indicator): assert_allclose(X_trans_expected, X_trans) -# ConvergenceWarning will be raised by the IterativeImputer -@pytest.mark.filterwarnings("ignore::sklearn.exceptions.ConvergenceWarning") @pytest.mark.parametrize("imputer", IMPUTERS, ids=lambda x: x.__class__.__name__) @pytest.mark.parametrize("add_indicator", [True, False]) def test_imputers_feature_names_out_pandas(imputer, add_indicator): From 3b9c3c9d291eec572d94bc41561bb7044cdebb90 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 5 Oct 2021 10:24:04 -0400 Subject: [PATCH 08/28] MAINT Whitespace --- .github/workflows/assign.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index 21aea7520f379..13b1f955e3fd4 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -10,9 +10,7 @@ jobs: # toJson(github.event.comment.body) allows newline to be detected if: >- (github.event.comment.body == 'take' || - github.event.comment.body == 'take ' || - toJson(github.event.comment.body) == 'take\r\n' ) - && !github.event.issue.assignee + github.event.comment.body == 'take ') && !github.event.issue.assignee steps: - run: | echo "Assigning issue ${{ github.event.issue.number }} to ${{ github.event.comment.user.login }}" From ce801d0c0d3b140ee221dcbf285f0cb5c32c26fb Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 5 Oct 2021 10:37:28 -0400 Subject: [PATCH 09/28] Fix yaml --- .github/workflows/assign.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index 13b1f955e3fd4..dcb8b585f217d 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -10,7 +10,8 @@ jobs: # toJson(github.event.comment.body) allows newline to be detected if: >- (github.event.comment.body == 'take' || - github.event.comment.body == 'take ') && !github.event.issue.assignee + github.event.comment.body == 'take ' ) + && !github.event.issue.assignee steps: - run: | echo "Assigning issue ${{ github.event.issue.number }} to ${{ github.event.comment.user.login }}" From a5dfc47bb2813cc31637a050c2db0d81fb9c8ac8 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 5 Oct 2021 10:38:36 -0400 Subject: [PATCH 10/28] TST Testing --- .github/workflows/assign.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index dcb8b585f217d..7a76ae69b13be 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -8,12 +8,13 @@ jobs: one: runs-on: ubuntu-latest # toJson(github.event.comment.body) allows newline to be detected - if: >- - (github.event.comment.body == 'take' || - github.event.comment.body == 'take ' ) - && !github.event.issue.assignee + # if: >- + # (github.event.comment.body == 'take' || + # github.event.comment.body == 'take ' ) + # && !github.event.issue.assignee steps: - run: | - echo "Assigning issue ${{ github.event.issue.number }} to ${{ github.event.comment.user.login }}" - curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"assignees": ["${{ github.event.comment.user.login }}"]}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees - curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -X "DELETE" https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels/help%20wanted + echo "Wow" + # echo "Assigning issue ${{ github.event.issue.number }} to ${{ github.event.comment.user.login }}" + # curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"assignees": ["${{ github.event.comment.user.login }}"]}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees + # curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -X "DELETE" https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels/help%20wanted From ee5f2f7052ab9d107c8b0c1caaeba97231905ac3 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 5 Oct 2021 13:02:39 -0400 Subject: [PATCH 11/28] TST Testing --- .github/workflows/assign.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index 7a76ae69b13be..ab78c24d19e9b 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -8,10 +8,11 @@ jobs: one: runs-on: ubuntu-latest # toJson(github.event.comment.body) allows newline to be detected - # if: >- - # (github.event.comment.body == 'take' || - # github.event.comment.body == 'take ' ) - # && !github.event.issue.assignee + if: >- + (github.event.comment.body == 'take' || + github.event.comment.body == 'take ' || + github.event.comment.body == 'take\\n' ) + && !github.event.issue.assignee steps: - run: | echo "Wow" From 6719ad606be0e0cb4ece2a4ee7d0c548ee073478 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 5 Oct 2021 13:03:25 -0400 Subject: [PATCH 12/28] TST Testing --- .github/workflows/assign.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index ab78c24d19e9b..df846987c156b 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -11,7 +11,7 @@ jobs: if: >- (github.event.comment.body == 'take' || github.event.comment.body == 'take ' || - github.event.comment.body == 'take\\n' ) + github.event.comment.body == 'take\r\n' ) && !github.event.issue.assignee steps: - run: | From d0f2474ad6029864bf621fe2a1bb6e7f18eb13b6 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 5 Oct 2021 13:04:50 -0400 Subject: [PATCH 13/28] TST Testing --- .github/workflows/assign.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index df846987c156b..db01169eef652 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -11,7 +11,7 @@ jobs: if: >- (github.event.comment.body == 'take' || github.event.comment.body == 'take ' || - github.event.comment.body == 'take\r\n' ) + github.event.comment.body == 'take\\r\\n' ) && !github.event.issue.assignee steps: - run: | From 5ddd36dbf79b1d53fea294d2b2f1dd0a234ae981 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 5 Oct 2021 13:07:10 -0400 Subject: [PATCH 14/28] TST Testing --- .github/workflows/assign.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index db01169eef652..4d01a9c755194 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -8,14 +8,11 @@ jobs: one: runs-on: ubuntu-latest # toJson(github.event.comment.body) allows newline to be detected - if: >- - (github.event.comment.body == 'take' || - github.event.comment.body == 'take ' || - github.event.comment.body == 'take\\r\\n' ) - && !github.event.issue.assignee + # if: >- + # (github.event.comment.body == 'take' || + # github.event.comment.body == 'take ' || + # github.event.comment.body == 'take\\r\\n' ) + # && !github.event.issue.assignee steps: - run: | - echo "Wow" - # echo "Assigning issue ${{ github.event.issue.number }} to ${{ github.event.comment.user.login }}" - # curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"assignees": ["${{ github.event.comment.user.login }}"]}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees - # curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -X "DELETE" https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels/help%20wanted + echo "${{ github.event.comment.body }}"" From 31f90ed8bbf1cf6711837aec1ac23bb9c11d01d9 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 5 Oct 2021 13:09:14 -0400 Subject: [PATCH 15/28] TST Testing --- .github/workflows/assign.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index 4d01a9c755194..4697187b66064 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -15,4 +15,4 @@ jobs: # && !github.event.issue.assignee steps: - run: | - echo "${{ github.event.comment.body }}"" + echo "${{ github.event.comment.body }}" From 218db3f871b10a87f35f0bcba4016f6c5e8f7815 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 5 Oct 2021 13:10:38 -0400 Subject: [PATCH 16/28] TST Testing --- .github/workflows/assign.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index 4697187b66064..553a0332d4a48 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -15,4 +15,4 @@ jobs: # && !github.event.issue.assignee steps: - run: | - echo "${{ github.event.comment.body }}" + echo -e "${{ github.event.comment.body }}" From 57203a6c5932f5d9462523bf60d30d5c9c034392 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 5 Oct 2021 13:15:07 -0400 Subject: [PATCH 17/28] TST Testing --- .github/workflows/assign.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index 553a0332d4a48..7f10f33363c57 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -7,12 +7,13 @@ on: jobs: one: runs-on: ubuntu-latest + # Support m # toJson(github.event.comment.body) allows newline to be detected - # if: >- - # (github.event.comment.body == 'take' || - # github.event.comment.body == 'take ' || - # github.event.comment.body == 'take\\r\\n' ) - # && !github.event.issue.assignee + if: >- + (github.event.comment.body == 'take' || + github.event.comment.body == 'take ' || + github.event.comment.body == 'take\\n' ) + && !github.event.issue.assignee steps: - run: | echo -e "${{ github.event.comment.body }}" From e8c15e46288e0276d4914e75a3620779914b3fa2 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 5 Oct 2021 13:15:54 -0400 Subject: [PATCH 18/28] TST Testing --- .github/workflows/assign.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index 7f10f33363c57..f38af97797139 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -12,7 +12,7 @@ jobs: if: >- (github.event.comment.body == 'take' || github.event.comment.body == 'take ' || - github.event.comment.body == 'take\\n' ) + github.event.comment.body == 'take\\\n' ) && !github.event.issue.assignee steps: - run: | From 3a2f25c7f5544d6c731476612a8a6b36ad1e60b1 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 5 Oct 2021 13:17:24 -0400 Subject: [PATCH 19/28] TST Testing --- .github/workflows/assign.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index f38af97797139..400bbfa820dc6 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -12,7 +12,7 @@ jobs: if: >- (github.event.comment.body == 'take' || github.event.comment.body == 'take ' || - github.event.comment.body == 'take\\\n' ) + github.event.comment.body == 'take\nwow' ) && !github.event.issue.assignee steps: - run: | From ef134d1bd46afb976eb5364fe060e7148fe8a65f Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 5 Oct 2021 13:18:12 -0400 Subject: [PATCH 20/28] TST Testing --- .github/workflows/assign.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index 400bbfa820dc6..f18c04eb860d5 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -9,11 +9,11 @@ jobs: runs-on: ubuntu-latest # Support m # toJson(github.event.comment.body) allows newline to be detected - if: >- - (github.event.comment.body == 'take' || - github.event.comment.body == 'take ' || - github.event.comment.body == 'take\nwow' ) - && !github.event.issue.assignee + # if: >- + # (github.event.comment.body == 'take' || + # github.event.comment.body == 'take ' || + # github.event.comment.body == 'take\nwow' ) + # && !github.event.issue.assignee steps: - run: | echo -e "${{ github.event.comment.body }}" From 71e26ff61c2a3b205c4356d0b2d15a19591bfa34 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 5 Oct 2021 13:28:30 -0400 Subject: [PATCH 21/28] TST Testing --- .github/workflows/assign.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index f18c04eb860d5..2d8eb9b8f506a 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -16,4 +16,7 @@ jobs: # && !github.event.issue.assignee steps: - run: | - echo -e "${{ github.event.comment.body }}" + echo "${{ github.event.comment.body }}" + echo "$HEHE" + env: + HEHE: toJson(github.event.comment.body) From 1a75e5c95c7606c01576190e4f599aae304f6aac Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 5 Oct 2021 13:29:33 -0400 Subject: [PATCH 22/28] TST Testing --- .github/workflows/assign.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index 2d8eb9b8f506a..73f69058679dc 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -19,4 +19,4 @@ jobs: echo "${{ github.event.comment.body }}" echo "$HEHE" env: - HEHE: toJson(github.event.comment.body) + HEHE: ${{ toJson(github.event.comment.body) }} From df4b592dc9880d0d2df29c24f827a0d9fd1a2c33 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 5 Oct 2021 13:43:27 -0400 Subject: [PATCH 23/28] TST Testing --- .github/workflows/assign.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index 73f69058679dc..a965e2e86ee13 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -15,8 +15,11 @@ jobs: # github.event.comment.body == 'take\nwow' ) # && !github.event.issue.assignee steps: - - run: | - echo "${{ github.event.comment.body }}" - echo "$HEHE" - env: - HEHE: ${{ toJson(github.event.comment.body) }} + - run: echo "1" + if: github.event.comment.body == 'take\n' + - run: echo "2" + if: github.event.comment.body == 'take\\n' + - run: echo "3" + if: github.event.comment.body == 'take\\\n' + - run: echo "4" + if: github.event.comment.body == 'take\\\n' From 5a422e6754b8a0d4171dc9420313127d3e263abd Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 5 Oct 2021 13:46:20 -0400 Subject: [PATCH 24/28] TST Testing --- .github/workflows/assign.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index a965e2e86ee13..46d9b2869bad5 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -23,3 +23,21 @@ jobs: if: github.event.comment.body == 'take\\\n' - run: echo "4" if: github.event.comment.body == 'take\\\n' + - run: echo "5" + if: github.event.comment.body == 'take\\\\n' + - run: echo "6" + if: github.event.comment.body == 'take\r' + - run: echo "7" + if: github.event.comment.body == 'take\\r' + - run: echo "8" + if: github.event.comment.body == 'take\\\r' + - run: echo "9" + if: github.event.comment.body == 'take\\\\r' + - run: echo "10" + if: github.event.comment.body == 'take\r\n' + - run: echo "11" + if: github.event.comment.body == 'take\\r\\n' + - run: echo "12" + if: github.event.comment.body == 'take\\\r\\\n' + - run: echo "13" + if: github.event.comment.body == 'take\\\\r\\\\n' From 22d871b6ee76048bf360db9473c178ee7cdbc7ff Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 5 Oct 2021 13:54:12 -0400 Subject: [PATCH 25/28] TST Testing --- .github/workflows/assign.yml | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index 46d9b2869bad5..032193f363647 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -17,27 +17,29 @@ jobs: steps: - run: echo "1" if: github.event.comment.body == 'take\n' + - run: echo "1wo" + if: | + github.event.comment.body == 'take + ' - run: echo "2" if: github.event.comment.body == 'take\\n' - run: echo "3" if: github.event.comment.body == 'take\\\n' - run: echo "4" - if: github.event.comment.body == 'take\\\n' - - run: echo "5" if: github.event.comment.body == 'take\\\\n' - - run: echo "6" + - run: echo "5" if: github.event.comment.body == 'take\r' - - run: echo "7" + - run: echo "6" if: github.event.comment.body == 'take\\r' - - run: echo "8" + - run: echo "7" if: github.event.comment.body == 'take\\\r' - - run: echo "9" + - run: echo "8" if: github.event.comment.body == 'take\\\\r' - - run: echo "10" + - run: echo "9" if: github.event.comment.body == 'take\r\n' - - run: echo "11" + - run: echo "10" if: github.event.comment.body == 'take\\r\\n' - - run: echo "12" + - run: echo "11" if: github.event.comment.body == 'take\\\r\\\n' - - run: echo "13" + - run: echo "12" if: github.event.comment.body == 'take\\\\r\\\\n' From 39c8e00a4299793c7507149e0420d132abcd1db7 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 5 Oct 2021 13:55:52 -0400 Subject: [PATCH 26/28] TST Testing --- .github/workflows/assign.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index 032193f363647..03732766a278b 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -15,12 +15,10 @@ jobs: # github.event.comment.body == 'take\nwow' ) # && !github.event.issue.assignee steps: + - run: echo "0" + if: github.event.comment.body == 'take' - run: echo "1" if: github.event.comment.body == 'take\n' - - run: echo "1wo" - if: | - github.event.comment.body == 'take - ' - run: echo "2" if: github.event.comment.body == 'take\\n' - run: echo "3" From df6fd9a2117158da26553bfb54fd9979e02c1bd4 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Wed, 6 Oct 2021 13:54:39 -0400 Subject: [PATCH 27/28] TST Testing --- .github/workflows/assign.yml | 41 +++++++----------------------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index 03732766a278b..f59935ab9f378 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -7,37 +7,12 @@ on: jobs: one: runs-on: ubuntu-latest - # Support m - # toJson(github.event.comment.body) allows newline to be detected - # if: >- - # (github.event.comment.body == 'take' || - # github.event.comment.body == 'take ' || - # github.event.comment.body == 'take\nwow' ) - # && !github.event.issue.assignee + # Note that string comparisons is not case sensitive. + if: >- + startsWith(github.event.comment.body, '/take') + && !github.event.issue.assignee steps: - - run: echo "0" - if: github.event.comment.body == 'take' - - run: echo "1" - if: github.event.comment.body == 'take\n' - - run: echo "2" - if: github.event.comment.body == 'take\\n' - - run: echo "3" - if: github.event.comment.body == 'take\\\n' - - run: echo "4" - if: github.event.comment.body == 'take\\\\n' - - run: echo "5" - if: github.event.comment.body == 'take\r' - - run: echo "6" - if: github.event.comment.body == 'take\\r' - - run: echo "7" - if: github.event.comment.body == 'take\\\r' - - run: echo "8" - if: github.event.comment.body == 'take\\\\r' - - run: echo "9" - if: github.event.comment.body == 'take\r\n' - - run: echo "10" - if: github.event.comment.body == 'take\\r\\n' - - run: echo "11" - if: github.event.comment.body == 'take\\\r\\\n' - - run: echo "12" - if: github.event.comment.body == 'take\\\\r\\\\n' + - run: | + echo "Assigning issue ${{ github.event.issue.number }} to ${{ github.event.comment.user.login }}" + curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"assignees": ["${{ github.event.comment.user.login }}"]}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees + curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -X "DELETE" https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels/help%20wanted From 6d86dc5c301ed315b8765fe0373e5f9515bf7b9a Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Wed, 13 Oct 2021 12:08:32 -0400 Subject: [PATCH 28/28] REV Remove unrelated diff --- .github/workflows/assign.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml index f59935ab9f378..4b067135bbfdb 100644 --- a/.github/workflows/assign.yml +++ b/.github/workflows/assign.yml @@ -7,10 +7,10 @@ on: jobs: one: runs-on: ubuntu-latest - # Note that string comparisons is not case sensitive. if: >- - startsWith(github.event.comment.body, '/take') - && !github.event.issue.assignee + (github.event.comment.body == 'take' || + github.event.comment.body == 'Take') + && !github.event.issue.assignee steps: - run: | echo "Assigning issue ${{ github.event.issue.number }} to ${{ github.event.comment.user.login }}"