@@ -83,50 +83,51 @@ class PandasPyarrowBackedBuffer(Buffer):
8383 Data in the buffer is guaranteed to be contiguous in memory.
8484 """
8585
86- def __init__ (self , x : Any , allow_copy : bool = True ) -> None :
86+ def __init__ (self , arr : Any , allow_copy : bool = True ) -> None :
8787 """
8888 Handle only regular columns (= numpy arrays) for now.
8989 """
9090
9191 # Store the numpy array in which the data resides as a private
9292 # attribute, so we can use it to retrieve the public attributes
93- self ._x = x
93+ self ._buffer = arr .chunks [0 ].buffers ()[1 ]
94+ self ._length = len (arr )
9495
9596 @property
9697 def bufsize (self ) -> int :
9798 """
9899 Buffer size in bytes.
99100 """
100- return self ._x .size
101+ return self ._buffer .size * self . _length
101102
102103 @property
103104 def ptr (self ) -> int :
104105 """
105106 Pointer to start of the buffer as an integer.
106107 """
107- return self ._x .address
108+ return self ._buffer .address
108109
109110 def __dlpack__ (self ) -> Any :
110111 """
111112 Represent this structure as DLPack interface.
112113 """
113- return self ._x .__dlpack__ ()
114+ return self ._buffer .__dlpack__ ()
114115
115116 def __dlpack_device__ (self ) -> tuple [DlpackDeviceType , int | None ]:
116117 """
117118 Device type and device ID for where the data in the buffer resides.
118119 """
119120 return (DlpackDeviceType .CPU , None )
120121
121- # def __repr__(self) -> str:
122- # return (
123- # "PandasBuffer("
124- # + str(
125- # {
126- # "bufsize": self.bufsize,
127- # "ptr": self.ptr,
128- # "device": self.__dlpack_device__()[0].name,
129- # }
130- # )
131- # + ")"
132- # )
122+ def __repr__ (self ) -> str :
123+ return (
124+ "PandasBuffer("
125+ + str (
126+ {
127+ "bufsize" : self .bufsize ,
128+ "ptr" : self .ptr ,
129+ "device" : self .__dlpack_device__ ()[0 ].name ,
130+ }
131+ )
132+ + ")"
133+ )
0 commit comments