You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Sean Owen (JIRA)" <ji...@apache.org> on 2019/02/06 16:53:00 UTC
[jira] [Updated] (SPARK-26638) Pyspark vector classes always return
error for unary negation
[ https://issues.apache.org/jira/browse/SPARK-26638?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sean Owen updated SPARK-26638:
------------------------------
Fix Version/s: (was: 2.3.4)
2.3.3
> Pyspark vector classes always return error for unary negation
> -------------------------------------------------------------
>
> Key: SPARK-26638
> URL: https://issues.apache.org/jira/browse/SPARK-26638
> Project: Spark
> Issue Type: Bug
> Components: ML, PySpark
> Affects Versions: 2.3.2, 2.4.0
> Reporter: Sean Owen
> Assignee: Sean Owen
> Priority: Major
> Fix For: 2.3.3, 2.4.1, 3.0.0
>
>
> It looks like the implementation of {{__neg__}} for Pyspark vector classes is wrong:
> {code}
> def _delegate(op):
> def func(self, other):
> if isinstance(other, DenseVector):
> other = other.array
> return DenseVector(getattr(self.array, op)(other))
> return func
> __neg__ = _delegate("__neg__")
> {code}
> This delegation works for binary operators but not for unary, and indeed, it doesn't work at all:
> {code}
> from pyspark.ml.linalg import DenseVector
> v = DenseVector([1,2,3])
> -v
> ...
> TypeError: func() missing 1 required positional argument: 'other'
> {code}
> This was spotted by static analyis on lgtm.com:
> https://lgtm.com/projects/g/apache/spark/alerts/?mode=tree&lang=python&ruleFocus=7850093
> Easy to fix and add a test for, as I presume we want this to be implemented.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org