Skip to content
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

Add Base.length to DefaultDict #1804

Merged
merged 2 commits into from
Jan 4, 2022

Conversation

Ellipse0934
Copy link
Contributor

I was going through a notebook's data structure interactively in the REPL and got:

julia> c
Pluto.DefaultDict{Pluto.Cell, Pluto.ExprAnalysisCache}Error showing value of type Pluto.DefaultDict{Pluto.Cell, Pluto.ExprAnalysisCache}:
ERROR: MethodError: no method matching length(::Pluto.DefaultDict{Pluto.Cell, Pluto.ExprAnalysisCache})
Closest candidates are:
  length(::Union{Base.KeySet, Base.ValueIterator}) at abstractdict.jl:58
  length(::Union{LinearAlgebra.Adjoint{T, S}, LinearAlgebra.Transpose{T, S}} where {T, S}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/adjtrans.jl:195
  length(::SubString) at strings/substring.jl:66
  ...
Stacktrace:
  [1] summary(io::IOContext{Base.TTY}, t::Pluto.DefaultDict{Pluto.Cell, Pluto.ExprAnalysisCache})
    @ Base ./abstractdict.jl:36
  [2] show(io::IOContext{Base.TTY}, #unused#::MIME{Symbol("text/plain")}, t::Pluto.DefaultDict{Pluto.Cell, Pluto.ExprAnalysisCache}
    @ Base ./show.jl:91
  [3] (::REPL.var"#38#39"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:220
  [4] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:462
  [5] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:213**

Appears fixed via:

julia> Base.length(aid::Pluto.DefaultDict) = Base.length(aid.container)

julia> c = nb.topology.codes
Pluto.DefaultDict{Pluto.Cell, Pluto.ExprAnalysisCache} with 1 entry:
  Cell(UUID("c91d3b62-6d84-11ec-2898-f170cc… => ExprAnalysisCache("", :($(Expr(:toplevel, :(#= line 1 =#), quote

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2022

Try this Pull Request!

Open Julia and type:

julia> import Pkg
julia> Pkg.activate(temp=true)
julia> Pkg.add(url="https://github.com/Ellipse0934/Pluto.jl", rev="ap/add-DefaultDict-length")
julia> using Pluto

@pankgeorg
Copy link
Collaborator

Awesome, thanks Aditya!

@pankgeorg pankgeorg merged commit b2005f4 into fonsp:main Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants