Skip to content

[Repo Assist] improve(gcm/ml): correct np.array → np.ndarray in method type annotations - #1745

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/improve-type-hints-np-array-to-ndarray-20260811-4d45c609e1dd83ae
Draft

[Repo Assist] improve(gcm/ml): correct np.array → np.ndarray in method type annotations#1745
github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/improve-type-hints-np-array-to-ndarray-20260811-4d45c609e1dd83ae

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This PR is created by Repo Assist, an automated AI assistant.

Problem

Four method signatures in the GCM ML layer use np.array as a type annotation:

# classification.py
def predict_probabilities(self, X: np.array) -> np.ndarray: ...   # ← wrong × 3

# regression.py
def predict(self, X: np.array) -> np.ndarray: ...                 # ← wrong

np.array is a function, not a type. Using it as a type annotation (X: np.array) is technically incorrect — it tells type checkers and IDEs that X should be the array function itself, not a NumPy array. The correct annotation for NumPy arrays is np.ndarray.

Fix

Replace the four incorrect np.array annotations with np.ndarray:

File Method Line
dowhy/gcm/ml/classification.py ClassificationModel.predict_probabilities (abstract) 34
dowhy/gcm/ml/classification.py SklearnClassificationModel.predict_probabilities 44
dowhy/gcm/ml/classification.py SklearnClassificationModelWeighted.predict_probabilities 56
dowhy/gcm/ml/regression.py SklearnRegressionModel.predict 43

No functional change — type annotations are not enforced at runtime.

Test Status

✅ All 12 tests in tests/gcm/test_fcms.py pass unchanged.
black --check clean on both modified files.
isort --check clean on both modified files.
flake8 clean on both modified files (no new errors).

Generated by 🌈 Repo Assist, see workflow run. Learn more.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@11c9a2c442e519ff2b427bf58679f5a525353f76

…ions

np.array is a function, not a type.  Using it in type annotations
(: np.array) is incorrect and misleads type-checkers and IDEs.
The correct annotation for NumPy arrays is np.ndarray.

Affected signatures:
- ClassificationModel.predict_probabilities (abstract base)
- SklearnClassificationModel.predict_probabilities
- SklearnClassificationModelWeighted.predict_probabilities
- SklearnRegressionModel.predict

No functional change — type annotations do not affect runtime behaviour.
All existing tests pass unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants