[Python] Support operator `%` on Array/Scalar

オープン 初心者向け
#55,659 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
67/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

Python の Array と Scalar の演算子実装、および issue で言及されている注釈スタブ array.pyi を読み、既存の演算子がチェック付きカーネルをどのように呼び出すかを比較してください。既存の modulo_checked カーネルを使って % をサポートし、スタブのエイリアスを更新してください。報告された Array/scalar 式が Python 形式の切り下げ除算の剰余で動作し、注釈に __mod__ が含まれれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Component: Python Type: enhancement
Describe the enhancement requested

Arithmetic and bitwise operators to Array and Scalar were added in

  • #48085
    This was a separate follow-up: #49606
    But % wasn't added as there was no kernel at that time.
import pyarrow as pa
pa.array([9,-9]) % 3
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    pa.array([9,-9]) % 3
    ~~~~~~~~~~~~~~~~~^~~
TypeError: unsupported operand type(s) for %: 'pyarrow.lib.Int64Array' and 'int'

Now that modulo / modulo_checked exist since #46901 (floored like Python's %) the implementation of __mod__ could call modulo_checked - similar to other operators calling their own checked kernels.

[!NOTE]
if implemented, the annotation stubs will need __mod__ added as well (per current state of #55264 as one more alias line in array.pyi __mod__ = __add__)
(and % may be re-added where just removed in #55654)

Component(s)

Python

主要言語
C++
スター
17.3k
フォーク
4.5k
平均マージ
3日 14時間
マージ済み PR(30日)
90

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/arrow のほかの issue

apache/arrow の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。