[ https://issues.apache.org/jira/browse/SPARK-26638?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sean Owen resolved SPARK-26638. ------------------------------- Resolution: Fixed Fix Version/s: 2.4.1 3.0.0 2.3.3 Issue resolved by pull request 23570 [https://github.com/apache/spark/pull/23570] > 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, 3.0.0, 2.4.1 > > > 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-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org