From febd2efa417feba35b57ca41481b18c0992fd9c8 Mon Sep 17 00:00:00 2001 From: Miles Granger Date: Tue, 23 Aug 2022 11:01:02 +0200 Subject: [PATCH] Update reprs appearance --- python/pyarrow/io.pxi | 32 ++++++++++++++++---------------- python/pyarrow/memory.pxi | 10 +++++----- python/pyarrow/table.pxi | 2 +- python/pyarrow/types.pxi | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/python/pyarrow/io.pxi b/python/pyarrow/io.pxi index 02daca33d3bde..b576fc8ece745 100644 --- a/python/pyarrow/io.pxi +++ b/python/pyarrow/io.pxi @@ -122,12 +122,12 @@ cdef class NativeFile(_Weakrefable): self.close() def __repr__(self): - name = f"{self.__class__.__module__}.{self.__class__.__name__}" - return (f"{name}(" - f"own_file={self.own_file}, " - f"is_seekable={self.is_seekable}, " - f"is_writable={self.is_writable}, " - f"is_readable={self.is_readable})") + name = f"pyarrow.{self.__class__.__name__}" + return (f"<{name} " + f"own_file={self.own_file} " + f"is_seekable={self.is_seekable} " + f"is_writable={self.is_writable} " + f"is_readable={self.is_readable}>") @property def mode(self): @@ -1062,12 +1062,12 @@ cdef class Buffer(_Weakrefable): 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})") + name = f"pyarrow.{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}>") @property def size(self): @@ -2099,10 +2099,10 @@ 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})") + name = f"pyarrow.{self.__class__.__name__}" + return (f"<{name} " + f"name={self.name} " + f"compression_level={self.compression_level}>") def compress(object buf, codec='lz4', asbytes=False, memory_pool=None): diff --git a/python/pyarrow/memory.pxi b/python/pyarrow/memory.pxi index fb7acd33e1f98..8e95f2a02423c 100644 --- a/python/pyarrow/memory.pxi +++ b/python/pyarrow/memory.pxi @@ -77,11 +77,11 @@ 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()})") + name = f"pyarrow.{self.__class__.__name__}" + return (f"<{name} " + f"backend_name={self.backend_name} " + f"bytes_allocated={self.bytes_allocated()} " + f"max_memory={self.max_memory()}>") cdef CMemoryPool* maybe_unbox_memory_pool(MemoryPool memory_pool): if memory_pool is None: diff --git a/python/pyarrow/table.pxi b/python/pyarrow/table.pxi index a4233a13f11bd..be3a7deaef7bc 100644 --- a/python/pyarrow/table.pxi +++ b/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(address=..., size=..., is_cpu=True, is_mutable=True) + """ cdef shared_ptr[CBuffer] buffer cdef CIpcWriteOptions options = CIpcWriteOptions.Defaults() diff --git a/python/pyarrow/types.pxi b/python/pyarrow/types.pxi index cb53fb4e79226..d263e96c65197 100644 --- a/python/pyarrow/types.pxi +++ b/python/pyarrow/types.pxi @@ -2065,7 +2065,7 @@ cdef class Schema(_Weakrefable): Write schema to Buffer: >>> schema.serialize() - pyarrow.lib.Buffer(address=..., size=..., is_cpu=True, is_mutable=True) + """ cdef: shared_ptr[CBuffer] buffer