Repository navigation
[WIP][PYTHON] Fix PySpark Vector dot product typing - #59349
Draft
bearomorphism wants to merge 1 commit into
Draft
bearomorphism wants to merge 1 commit into
bearomorphism wants to merge 1 commit into
Conversation
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
dot()onpyspark.mllib.linalg.Vector, following the base class's existingNotImplementedErrorpattern.Vector,DenseVector, andSparseVector: vector/list/tuple/range operands returnnp.float64, while NumPy/SciPy operands may return a scalar or array.type: ignore[attr-defined]comments from classification and regression callers.dev/lint-python.The concrete dot-product implementations are unchanged. The separate
.sizedeclaration fix is not included.Why are the changes needed?
Both concrete vector classes implement
dot(), but the baseVectordoes not declare it. Valid calls through aVectorreference therefore require attribute-error suppressions.The existing concrete return annotations also describe only scalar results, although matrix operands can produce arrays. The overloads expose the shared method without incorrectly treating every result as a scalar.
Does this PR introduce any user-facing change?
Static typing changes only: type checkers recognize
Vector.dot()and distinguish scalar-only operand types from potentially array-valued operands. Dense and sparse dot-product runtime behavior is unchanged.How was this patch tested?
Added one focused typing regression checking return-type inference through the base and concrete vector classes.
The following checks passed:
Also passed 93 existing doctest examples (89 in
mllib.linalgand four inLinearRegressionModelBase) using NumPy's legacy1.13output formatting, plus the existingVectorTests.test_dotmethod body without JVM fixtures. No JVM-backed test suites were run.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Pi 1.1.0