pitrou commented on code in PR #13921:
URL: https://github.com/apache/arrow/pull/13921#discussion_r952235785
##########
python/pyarrow/memory.pxi:
##########
@@ -76,6 +76,12 @@ cdef class MemoryPool(_Weakrefable):
"""
return frombytes(self.pool.backend_name())
+ def __repr__(self):
+ name = f"{self.__class__.__module__}.{self.__class__.__name__}"
+ return (f"{name}("
+ f"backend_name={self.backend_name}, "
+ f"bytes_allocated={self.bytes_allocated()}, "
+ f"max_memory={self.max_memory()})")
Review Comment:
Can we test this repr somewhere? (either a doctest or a pytest unit test)
##########
python/pyarrow/io.pxi:
##########
@@ -1053,6 +1061,14 @@ cdef class Buffer(_Weakrefable):
def __len__(self):
return self.size
+ def __repr__(self):
+ name = f"{self.__class__.__module__}.{self.__class__.__name__}"
+ return (f"{name}("
+ f"address={hex(self.address)}, "
+ f"size={self.size}, "
+ f"is_cpu={self.is_cpu}, "
+ f"is_mutable={self.is_mutable})")
Review Comment:
So, just for the record, this makes it look like the `Buffer` constructor is
callable with these arguments (which it is not).
We could instead go for: `<pyarrow.Buffer address=0x...>`
@jorisvandenbossche What do you think?
##########
python/pyarrow/table.pxi:
##########
@@ -2013,7 +2013,7 @@ cdef class RecordBatch(_PandasConvertible):
>>> batch = pa.RecordBatch.from_arrays([n_legs, animals],
... names=["n_legs", "animals"])
>>> batch.serialize()
- <pyarrow.lib.Buffer object at ...>
+ pyarrow.lib.Buffer(address=..., size=..., is_cpu=True, is_mutable=True)
Review Comment:
Perhaps:
```suggestion
pyarrow.lib.Buffer(address=0x..., size=..., is_cpu=True,
is_mutable=True)
```
##########
python/pyarrow/io.pxi:
##########
@@ -2080,6 +2098,12 @@ cdef class Codec(_Weakrefable):
return pybuf if asbytes else out_buf
+ def __repr__(self):
+ name = f"{self.__class__.__module__}.{self.__class__.__name__}"
+ return (f"{name}("
+ f"name={self.name}, "
+ f"compression_level={self.compression_level})")
Review Comment:
Add a test for this?
##########
python/pyarrow/io.pxi:
##########
@@ -1964,7 +1980,9 @@ cdef class Codec(_Weakrefable):
@property
def compression_level(self):
"""Returns the compression level parameter of the codec"""
- return frombytes(self.unwrap().compression_level())
+ if self.name == 'snappy':
+ return None
+ return self.unwrap().compression_level()
Review Comment:
Should add a test for this? (I assume this was raising for Snappy?)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]