Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scalar broadcasting isn't commutative #208

Closed
4 tasks done
beckernick opened this issue Aug 17, 2018 · 2 comments
Closed
4 tasks done

Scalar broadcasting isn't commutative #208

beckernick opened this issue Aug 17, 2018 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@beckernick
Copy link
Member

beckernick commented Aug 17, 2018

  • I am using the latest version of PyGDF from conda or built from master.
  • I have included the following environment details:
    Linux Distro, Linux Kernel, GPU Model
  • I have included the following version information for:
    Arrow, CUDA, Numpy, Pandas, Python
  • I have included below a minimal working reproducer (if you are unsure how
    to write one see http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports).
Operating System:
Linux version 3.10.0-862.9.1.el7.x86_64
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.5 LTS"

GPU:  Tesla V100

CUDA 9.2

Python 3.5.5

Arrow: N/A
pandas==0.20.3
numpy==1.14.5

Issue 46 related to scalar broadcasting appears to have been implemented, but the syntax doesn't appear to be commutative.

The code snippet below works correctly:

import pandas as pd
import numpy as np
import pygdf


df = pd.DataFrame({'a': np.arange(10)})
gdf = pygdf.DataFrame.from_pandas(df)

gdf['b'] = gdf['a'] + 0.5

print(
    gdf['a'] + 2
)

The code snippet below results in an error withthe following traceback:

import pandas as pd
import numpy as np
import pygdf


df = pd.DataFrame({'a': np.arange(10)})
gdf = pygdf.DataFrame.from_pandas(df)

gdf['b'] = gdf['a'] + 0.5

print(
    2 + gdf['a']
)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-43-c1812ae3df00> in <module>()
      1 print(
----> 2     2 + gdf.a
      3 )

TypeError: unsupported operand type(s) for +: 'int' and 'Series'

The same TypeError occurs with both attribute and square bracket Series access, and with both addition and multiplication.

@beckernick beckernick changed the title Scalar broadcasting operations syntax isn't transitive Scalar broadcasting operations syntax isn't commutative Aug 17, 2018
@beckernick beckernick changed the title Scalar broadcasting operations syntax isn't commutative Scalar broadcasting isn't commutative Aug 17, 2018
@kkraus14 kkraus14 added Needs Triage Need team to review and classify bug Something isn't working good first issue Good for newcomers and removed Needs Triage Need team to review and classify labels Aug 17, 2018
@kkraus14
Copy link
Collaborator

This is due to the lack of implementations for builtin functions of __radd__, __rsub__, __rmul__, etc. Should be an easy fix and a great first issue for someone!

@beckernick
Copy link
Member Author

beckernick commented Aug 21, 2018

Fantastic. I'm happy to take this on, too. @kkraus14, do you envision implementing reflected operations for every operation currently implemented or only those that are commutative (addition / multiplication)?

In pandas, the non-commutative operators are implemented -- though I wonder how frequently they are ultimately used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants