From 8dcb5c18da6981209bdf3145973fa6e075253487 Mon Sep 17 00:00:00 2001 From: xgdgsc Date: Fri, 28 Feb 2025 22:19:21 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20show=20more=20arr=20inline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Core/Py.jl | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Core/Py.jl b/src/Core/Py.jl index e56d74fa..2816a16c 100644 --- a/src/Core/Py.jl +++ b/src/Core/Py.jl @@ -192,9 +192,24 @@ function Base.show(io::IO, ::MIME"text/plain", o::Py) hasprefix = (get(io, :typeinfo, Any) != Py)::Bool compact = get(io, :compact, false)::Bool multiline = '\n' in str + multilinePrefix = "Python:" + if multiline + if pyhasattr(o, "shape") + multilinePrefix *= " " * pyrepr(String, o.shape) + end + if pyhasattr(o, "dtype") + multilinePrefix *= " " * pyrepr(String, o.dtype) + end + if pyhasattr(o, "flags") + if pytruth(o.flags["F_CONTIGUOUS"]) + multilinePrefix *= " (F order)" + end + end + end prefix = hasprefix ? - compact ? "Py:$(multiline ? '\n' : ' ')" : "Python:$(multiline ? '\n' : ' ')" : "" + compact ? "Py:$(multiline ? '\n' : ' ')" : + "$(multilinePrefix)$(multiline ? '\n' : ' ')" : "" print(io, prefix) h, w = displaysize(io) if get(io, :limit, true) From 752852581ec0c5f07bc47c95d7f0a7bbe855cfe9 Mon Sep 17 00:00:00 2001 From: xgdgsc Date: Sat, 1 Mar 2025 09:48:40 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20fix=20for=20df?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Core/Py.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Core/Py.jl b/src/Core/Py.jl index 2816a16c..864c5ea5 100644 --- a/src/Core/Py.jl +++ b/src/Core/Py.jl @@ -201,8 +201,10 @@ function Base.show(io::IO, ::MIME"text/plain", o::Py) multilinePrefix *= " " * pyrepr(String, o.dtype) end if pyhasattr(o, "flags") - if pytruth(o.flags["F_CONTIGUOUS"]) - multilinePrefix *= " (F order)" + if haskey(o.flags, "F_CONTIGUOUS") + if pytruth(o.flags["F_CONTIGUOUS"]) + multilinePrefix *= " (F order)" + end end end end