From c70baf4fd683a5fb9e241646551b9a6f11548c8d Mon Sep 17 00:00:00 2001 From: HagonChan <77165006+HagonChan@users.noreply.github.com> Date: Thu, 26 Sep 2024 17:46:10 +0800 Subject: [PATCH 01/11] Create acr_bot.yml --- .github/workflows/acr_bot.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/acr_bot.yml diff --git a/.github/workflows/acr_bot.yml b/.github/workflows/acr_bot.yml new file mode 100644 index 0000000000000..90ee6c8cef412 --- /dev/null +++ b/.github/workflows/acr_bot.yml @@ -0,0 +1,31 @@ +name: "AutoCodeRover Bot" + +permissions: + issues: write + contents: write # change to `read` if you do not want to use open-pr + pull-requests: write # (optional) remove if you do not want to use open-pr + +on: + issue_comment: + types: [created] + issues: + types: [opened] + +jobs: + acr-bot: + runs-on: ubuntu-latest + if: ${{ contains(github.event.comment.body || github.event.issue.body, '@acr-bot') }} + steps: + - name: Check out + uses: actions/checkout@v4 + + - id: set-var + run: echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT + + - name: ACR bot + uses: AutoCodeRoverSG/code-rover-bot@v2.0.0 + env: + TARGET_REPO_PATH: ${{ steps.set-var.outputs.GITHUB_WORKSPACE }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} From d37506723012f34e43dcafa3dfe399b7b59d5696 Mon Sep 17 00:00:00 2001 From: HagonChan <77165006+HagonChan@users.noreply.github.com> Date: Thu, 26 Sep 2024 17:51:27 +0800 Subject: [PATCH 02/11] Update acr_bot.yml --- .github/workflows/acr_bot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/acr_bot.yml b/.github/workflows/acr_bot.yml index 90ee6c8cef412..f3e527dfb01de 100644 --- a/.github/workflows/acr_bot.yml +++ b/.github/workflows/acr_bot.yml @@ -23,7 +23,7 @@ jobs: run: echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT - name: ACR bot - uses: AutoCodeRoverSG/code-rover-bot@v2.0.0 + uses: AutoCodeRoverSG/code-rover-bot@v1.1.0 env: TARGET_REPO_PATH: ${{ steps.set-var.outputs.GITHUB_WORKSPACE }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 5b726d981751f6a9179dadea58c5e25b61fe3289 Mon Sep 17 00:00:00 2001 From: HagonChan <77165006+HagonChan@users.noreply.github.com> Date: Fri, 4 Oct 2024 15:33:54 +0800 Subject: [PATCH 03/11] Update acr_bot.yml v2.0.0 --- .github/workflows/acr_bot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/acr_bot.yml b/.github/workflows/acr_bot.yml index f3e527dfb01de..90ee6c8cef412 100644 --- a/.github/workflows/acr_bot.yml +++ b/.github/workflows/acr_bot.yml @@ -23,7 +23,7 @@ jobs: run: echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT - name: ACR bot - uses: AutoCodeRoverSG/code-rover-bot@v1.1.0 + uses: AutoCodeRoverSG/code-rover-bot@v2.0.0 env: TARGET_REPO_PATH: ${{ steps.set-var.outputs.GITHUB_WORKSPACE }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 4a26cee8f4be93ca95af31e263c39db5fd778abd Mon Sep 17 00:00:00 2001 From: HagonChan <77165006+HagonChan@users.noreply.github.com> Date: Fri, 4 Oct 2024 15:54:11 +0800 Subject: [PATCH 04/11] Update acr_bot.yml v1.1.0 --- .github/workflows/acr_bot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/acr_bot.yml b/.github/workflows/acr_bot.yml index 90ee6c8cef412..f3e527dfb01de 100644 --- a/.github/workflows/acr_bot.yml +++ b/.github/workflows/acr_bot.yml @@ -23,7 +23,7 @@ jobs: run: echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT - name: ACR bot - uses: AutoCodeRoverSG/code-rover-bot@v2.0.0 + uses: AutoCodeRoverSG/code-rover-bot@v1.1.0 env: TARGET_REPO_PATH: ${{ steps.set-var.outputs.GITHUB_WORKSPACE }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 98f5b96b621f7b73847fb2c9de048d9a7cff1833 Mon Sep 17 00:00:00 2001 From: acr-bot Date: Fri, 4 Oct 2024 09:24:35 +0000 Subject: [PATCH 05/11] Fix #2 --- pandas/core/tools/numeric.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/core/tools/numeric.py b/pandas/core/tools/numeric.py index 982851d0557c3..e02e694a07a71 100644 --- a/pandas/core/tools/numeric.py +++ b/pandas/core/tools/numeric.py @@ -189,6 +189,8 @@ def to_numeric( return float(arg) if is_number(arg): return arg + if isinstance(arg, Timedelta): # Handle Timedelta + return arg.value is_scalars = True values = np.array([arg], dtype="O") elif getattr(arg, "ndim", 1) > 1: From 4a7a4e52cb67bcfaf2d0544758e0d17e9357306f Mon Sep 17 00:00:00 2001 From: HagonChan <77165006+HagonChan@users.noreply.github.com> Date: Fri, 4 Oct 2024 17:33:28 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E5=88=A0=E9=99=A4acr=5Fbot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/acr_bot.yml | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 .github/workflows/acr_bot.yml diff --git a/.github/workflows/acr_bot.yml b/.github/workflows/acr_bot.yml deleted file mode 100644 index f3e527dfb01de..0000000000000 --- a/.github/workflows/acr_bot.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: "AutoCodeRover Bot" - -permissions: - issues: write - contents: write # change to `read` if you do not want to use open-pr - pull-requests: write # (optional) remove if you do not want to use open-pr - -on: - issue_comment: - types: [created] - issues: - types: [opened] - -jobs: - acr-bot: - runs-on: ubuntu-latest - if: ${{ contains(github.event.comment.body || github.event.issue.body, '@acr-bot') }} - steps: - - name: Check out - uses: actions/checkout@v4 - - - id: set-var - run: echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT - - - name: ACR bot - uses: AutoCodeRoverSG/code-rover-bot@v1.1.0 - env: - TARGET_REPO_PATH: ${{ steps.set-var.outputs.GITHUB_WORKSPACE }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} From 3a203ed5a06a87be443e0f3eabac186d83d8ae2d Mon Sep 17 00:00:00 2001 From: HagonChan <77165006+HagonChan@users.noreply.github.com> Date: Fri, 4 Oct 2024 17:56:30 +0800 Subject: [PATCH 07/11] Update numeric.py --- pandas/core/tools/numeric.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pandas/core/tools/numeric.py b/pandas/core/tools/numeric.py index e02e694a07a71..982851d0557c3 100644 --- a/pandas/core/tools/numeric.py +++ b/pandas/core/tools/numeric.py @@ -189,8 +189,6 @@ def to_numeric( return float(arg) if is_number(arg): return arg - if isinstance(arg, Timedelta): # Handle Timedelta - return arg.value is_scalars = True values = np.array([arg], dtype="O") elif getattr(arg, "ndim", 1) > 1: From fa5686710ff577edd3272c99130f32286dee9ebb Mon Sep 17 00:00:00 2001 From: HagonChan <77165006+HagonChan@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:00:11 +0800 Subject: [PATCH 08/11] Add files via upload --- .github/workflows/acr_bot.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/acr_bot.yml diff --git a/.github/workflows/acr_bot.yml b/.github/workflows/acr_bot.yml new file mode 100644 index 0000000000000..f3e527dfb01de --- /dev/null +++ b/.github/workflows/acr_bot.yml @@ -0,0 +1,31 @@ +name: "AutoCodeRover Bot" + +permissions: + issues: write + contents: write # change to `read` if you do not want to use open-pr + pull-requests: write # (optional) remove if you do not want to use open-pr + +on: + issue_comment: + types: [created] + issues: + types: [opened] + +jobs: + acr-bot: + runs-on: ubuntu-latest + if: ${{ contains(github.event.comment.body || github.event.issue.body, '@acr-bot') }} + steps: + - name: Check out + uses: actions/checkout@v4 + + - id: set-var + run: echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT + + - name: ACR bot + uses: AutoCodeRoverSG/code-rover-bot@v1.1.0 + env: + TARGET_REPO_PATH: ${{ steps.set-var.outputs.GITHUB_WORKSPACE }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} From e67d66b541dce8ee3b75df29d94535ad3ccdff15 Mon Sep 17 00:00:00 2001 From: acr-bot Date: Fri, 4 Oct 2024 10:01:35 +0000 Subject: [PATCH 09/11] Fix #1 --- pandas/core/arrays/categorical.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index a69e197df851d..2e545cdd041a7 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -549,7 +549,7 @@ def astype(self, dtype: ExtensionDtype, copy: bool = ...) -> ExtensionArray: ... @overload def astype(self, dtype: AstypeArg, copy: bool = ...) -> ArrayLike: ... - def astype(self, dtype: AstypeArg, copy: bool = True) -> ArrayLike: + def astype(self, dtype: AstypeArg, copy: bool = True, errors: str = "raise") -> ArrayLike: """ Coerce this type to another dtype @@ -560,6 +560,11 @@ def astype(self, dtype: AstypeArg, copy: bool = True) -> ArrayLike: By default, astype always returns a newly allocated object. If copy is set to False and dtype is categorical, the original object is returned. + errors : {'raise', 'ignore'}, default 'raise' + Control raising of exceptions on invalid data for provided dtype. + + - 'raise' : allow exceptions to be raised + - 'ignore' : suppress exceptions. On error return original object """ dtype = pandas_dtype(dtype) result: Categorical | np.ndarray @@ -603,6 +608,9 @@ def astype(self, dtype: AstypeArg, copy: bool = True) -> ArrayLike: msg = f"Cannot cast {self.categories.dtype} dtype to {dtype}" raise ValueError(msg) from err + if errors == "raise" and not np.all(np.isin(self.codes, new_cats)): + raise ValueError("Cannot convert to CategoricalDtype with undefined values") + result = take_nd( new_cats, ensure_platform_int(self._codes), fill_value=fill_value ) From ccb363e858e299da73a558a03ec29319ecd03852 Mon Sep 17 00:00:00 2001 From: HagonChan <77165006+HagonChan@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:06:51 +0800 Subject: [PATCH 10/11] =?UTF-8?q?=E5=88=A0=E9=99=A4acr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/acr_bot.yml | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 .github/workflows/acr_bot.yml diff --git a/.github/workflows/acr_bot.yml b/.github/workflows/acr_bot.yml deleted file mode 100644 index f3e527dfb01de..0000000000000 --- a/.github/workflows/acr_bot.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: "AutoCodeRover Bot" - -permissions: - issues: write - contents: write # change to `read` if you do not want to use open-pr - pull-requests: write # (optional) remove if you do not want to use open-pr - -on: - issue_comment: - types: [created] - issues: - types: [opened] - -jobs: - acr-bot: - runs-on: ubuntu-latest - if: ${{ contains(github.event.comment.body || github.event.issue.body, '@acr-bot') }} - steps: - - name: Check out - uses: actions/checkout@v4 - - - id: set-var - run: echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT - - - name: ACR bot - uses: AutoCodeRoverSG/code-rover-bot@v1.1.0 - env: - TARGET_REPO_PATH: ${{ steps.set-var.outputs.GITHUB_WORKSPACE }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} From 8d9f3f3e188d549f0055c072b099e1e75560e87a Mon Sep 17 00:00:00 2001 From: HagonChan <77165006+HagonChan@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:23:13 +0800 Subject: [PATCH 11/11] fix code too long --- pandas/core/arrays/categorical.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index 2e545cdd041a7..d246329104f6d 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -549,7 +549,9 @@ def astype(self, dtype: ExtensionDtype, copy: bool = ...) -> ExtensionArray: ... @overload def astype(self, dtype: AstypeArg, copy: bool = ...) -> ArrayLike: ... - def astype(self, dtype: AstypeArg, copy: bool = True, errors: str = "raise") -> ArrayLike: + def astype( + self, dtype: AstypeArg, copy: bool = True, errors: str = "raise" + ) -> ArrayLike: """ Coerce this type to another dtype @@ -609,7 +611,9 @@ def astype(self, dtype: AstypeArg, copy: bool = True, errors: str = "raise") -> raise ValueError(msg) from err if errors == "raise" and not np.all(np.isin(self.codes, new_cats)): - raise ValueError("Cannot convert to CategoricalDtype with undefined values") + raise ValueError( + "Cannot convert to CategoricalDtype with undefined values" + ) result = take_nd( new_cats, ensure_platform_int(self._codes), fill_value=fill_value