Misalignment of first line in multiline show of PyObject
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
Research direction
Start at the show(io::IO, o::PyObject) implementation and reproduce the issue with a PyObject whose pystring result contains newlines, using the provided qiskit example. Verify that single-line output keeps its spacing while multiline output places PyObject on its own line and no longer misaligns the first row.
Written by the indexing model from the issue text.
Description
PyObjects whose pystring method returns a multiline string have their first row misaligned when shown. For example
using PyCall
qiskit = pyimport("qiskit")
qc = qiskit.QuantumCircuit(1)
qc.x(0)
qc.draw()
gives
PyObject ┌───┐
q_0: ┤ X ├
└───┘
A fix would be to replace
function show(io::IO, o::PyObject)
print(io, "PyObject $(pystring(o))")
end
with
function show(io::IO, o::PyObject)
str = pystring(o)
sep = contains(str, "\n") ? "\n" : " " # Avoid misaligning the first line for multiline prints
print(io, "PyObject$sep$str")
end
which gives the following print instead.
PyObject
┌───┐
q_0: ┤ X ├
└───┘
- Dominant language
- Julia
- Stars
- 1.5k
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JuliaPy/PyCall.jl
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
All issues in JuliaPy/PyCall.jl
Similar issues
-
bug 🐞 distributed 🕸️
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
CliMA/Oceananigans.jl#6049 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
JuliaGPU/GPUArrays.jl#780 ·
-
Difficulty 2/5 Half a day Newbie friendliness 76/100
epiforecasts/EpiBranch.jl#304 ·