ionelmc / python-lazy-object-proxy

A fast and thorough lazy object proxy.
BSD 2-Clause "Simplified" License
247 stars 36 forks source link

Missing operator support: matrix multiplication (@ or __matmul__) #66

Closed fyeee closed 1 year ago

fyeee commented 2 years ago

For python >= 3.5 it supports a new matrix multiplication operator @ which calls the __matmul__. However the following operation produces error

import pandas as pd
df1 = pd.DataFrame([[0,1],[2,3]])
df2 = pd.DataFrame([[4,5],[6,7]]) 
ldf1 = Proxy(lambda: df1)  
ldf2 = Proxy(lambda: df2)  
ldf1 @ ldf2

TypeError: unsupported operand type(s) for @: 'Proxy' and 'Proxy'

While operations on Proxy object and pandas DataFrame is working properly

df1 = pd.DataFrame([[0,1],[2,3]])
df2 = pd.DataFrame([[4,5],[6,7]]) 
ldf1 = Proxy(lambda: df1)
ldf1 @ df2 # runs without issue
df2 @ ldf1 # runs without issue

Checking the source code, I noticed __matmul__ is not defined in the source code, I wonder is it possible to add the operator into the package?

ionelmc commented 1 year ago

Released in version 1.9.0.