-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better show #125
base: master
Are you sure you want to change the base?
Better show #125
Conversation
3eab54b
to
8bf0b7b
Compare
Codecov Report
@@ Coverage Diff @@
## master #125 +/- ##
==========================================
+ Coverage 95.24% 95.58% +0.34%
==========================================
Files 7 7
Lines 715 748 +33
==========================================
+ Hits 681 715 +34
+ Misses 34 33 -1
Continue to review full report at Codecov.
|
@bicycle1885 Could you merge this? This show-error makes the package unusable. MethodError: no method matching zero(::Ptr{EzXML._Node})
Closest candidates are:
zero(!Matched::Type{Missing}) at missing.jl:103
zero(!Matched::Type{LibGit2.GitHash}) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\LibGit2\src\oid.jl:220 zero(!Matched::Type{Pkg.Resolve.VersionWeight}) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\Pkg\src\Resolve\versionweights.jl:15
...
Stacktrace:
[1] unsigned(::Ptr{EzXML._Node}) at .\int.jl:158
[2] show(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Node) at C:\Users\yahyaaba\.julia\packages\EzXML\ZNwhK\src\node.jl:306
[3] show_delim_array(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Tuple{Node}, ::Char, ::Char, ::Char, ::Bool, ::Int64, ::Int64) at .\show.jl:748
[4] show_delim_array at .\show.jl:733 [inlined]
[5] show(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Tuple{Node}) at .\show.jl:766
[6] _show_default(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Any) at .\show.jl:394
[7] show_default at .\show.jl:377 [inlined]
[8] show(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Any) at .\show.jl:374
[9] sprint(::Function, ::MethodError; context::Pair{Symbol,Bool}, sizehint::Int64) at .\strings\io.jl:103
[10] Test.Error(::Any, ::Any, ::Any, ::Any, ::Any) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\Test\src\Test.jl:162
[11] do_test(::Test.ExecutionResult, ::Any) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\Test\src\Test.jl:518
[12] top-level scope at C:\Users\yahyaaba\Documents\GitHub\AcuteML.jl\test\xmlutils.jl:135
[13] top-level scope at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\Test\src\Test.jl:1113
[14] top-level scope at C:\Users\yahyaaba\Documents\GitHub\AcuteML.jl\test\xmlutils.jl:84
[15] top-level scope at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\Test\src\Test.jl:1113
[16] top-level scope at C:\Users\yahyaaba\Documents\GitHub\AcuteML.jl\test\xmlutils.jl:4
[17] include(::String) at .\client.jl:439
[18] top-level scope at C:\Users\yahyaaba\Documents\GitHub\AcuteML.jl\test\runtests.jl:41
[19] include_string(::Module, ::String, ::String) at .\loading.jl:1080
[20] (::Atom.var"#198#202"{String,String})() at C:\Users\yahyaaba\.julia\packages\Atom\N5oSJ\src\eval.jl:127
[21] withpath(::Atom.var"#198#202"{String,String}, ::String) at
C:\Users\yahyaaba\.julia\packages\CodeTools\kosGY\src\utils.jl:30
[22] withpath(::Function, ::String) at C:\Users\yahyaaba\.julia\packages\Atom\N5oSJ\src\eval.jl:9
[23] #197 at C:\Users\yahyaaba\.julia\packages\Atom\N5oSJ\src\eval.jl:124 [inlined]
[24] with_logstate(::Atom.var"#197#201"{String,String}, ::Base.CoreLogging.LogState) at .\logging.jl:398
[25] with_logger at .\logging.jl:505 [inlined]
[26] #196 at C:\Users\yahyaaba\.julia\packages\Atom\N5oSJ\src\eval.jl:123 [inlined]
[27] hideprompt(::Atom.var"#196#200"{String,String}) at C:\Users\yahyaaba\.julia\packages\Atom\N5oSJ\src\repl.jl:122
[28] macro expansion at C:\Users\yahyaaba\.julia\packages\Atom\N5oSJ\src\eval.jl:122 [inlined]
[29] macro expansion at C:\Users\yahyaaba\.julia\packages\Media\ItEPc\src\dynamic.jl:24 [inlined]
[30] evalall(::String, ::Nothing, ::String) at C:\Users\yahyaaba\.julia\packages\Atom\N5oSJ\src\eval.jl:112
[31] (::Atom.var"#194#195")(::Dict{String,Any}) at C:\Users\yahyaaba\.julia\packages\Atom\N5oSJ\src\eval.jl:106
[32] handlemsg(::Dict{String,Any}, ::Dict{String,Any}) at C:\Users\yahyaaba\.julia\packages\Atom\N5oSJ\src\comm.jl:166
[33] (::Atom.var"#19#21"{Array{Any,1}})() at .\task.jl:358 |
Bump @bicycle1885 |
I do not think pointers are uninformative because they are identifiers in a document tree. For example, if you get two nodes in a tree in two different ways and their pointers are identical, these pointers quickly tell us that those two nodes are identical. Method error of |
Nowhere else in Julia, anyone shows the address of memory for any type of variable.
You can see the error by running the tests on Julia 1.4. It is caused by showing |
If you have several node objects in your hand, you can quickly check their distinctiveness by looking at their pointer identifiers. If no pointers shown, you need to manually check comparison using
I think this is a bug introduced in Julia 1.4, so I sent a pull request to the upstream (JuliaLang/julia#34941). |
All the other types in Julia use the following information for showing a variable:
If you think that the
|
I do not think that the current way is the best, but I do not think that just removing pointers makes it better, neither. Any suggestions of printing nodes are welcomed. |
Should we follow Julia's high-level convention and print the content instead? After showing the type? julia> v = [1, 2, 3]
3-element Array{Int64,1}:
1
2
3
|
@aminya, as a tip, it is usually better for a PR to focus on one thing. This changes the printing and works around the Julia bug which are two things. A better way forward is probably to make a PR that work around the Julia bug without changing the printing so that a new version working with 1.4 can be released. Then a discussion about the exact printing style can be discussed separately. |
Edited show method to not show the node.ptr (which includes uninformative/unintuitive pointer memory location number).
This also solves the error of not having a method for
zero(::Ptr{EzXML._Node})
https://github.com/JuliaMusic/MusicXML.jl/runs/435363039?check_suite_focus=true#step:5:58
There is no single package I have ever used that shows the address of the memory. Julia is not a language for showing what happens at low-level (pointers, memory locations, etc).
All the other types in Julia use the following information for showing a variable:
If you think that the
show
needs to be more informative, then we can print the content too.Similar packages show the content of the Node:
https://juliagizmos.github.io/WebIO.jl/latest/api/node/#WebIO.Node
https://github.com/yurivish/Hyperscript.jl
https://github.com/JuliaIO/LightXML.jl
https://github.com/JuliaIO/LibExpat.jl
I would like to hear others' ideas on this too.