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

Confusing and inconsistent array-of-dicts display #2417

Open
aplavin opened this issue Dec 20, 2022 · 7 comments
Open

Confusing and inconsistent array-of-dicts display #2417

aplavin opened this issue Dec 20, 2022 · 7 comments
Labels
bug Something isn't working display & PlutoRunner & AbstractPlutoDingetjes.jl good first issue Good for newcomers other packages Integration with other Julia packages

Comments

@aplavin
Copy link
Contributor

aplavin commented Dec 20, 2022

These three arrays of dicts are displayed in totally different ways:
image
Structurally they are the same, and REPL shows them in very similar ways.

I would expect all of them to display as the first one, with the Pluto explorer. The second seems outright wrong, and the third just confusing and inconvenient.

More generally, I often find the table viewer too "eager" to engage. Maybe, there should be an override toggle (display as table or with interactive explorer) in each cell output? It would be useful both ways: sometimes tables don't get recognized.

Notebook file
### A Pluto.jl notebook ###
# v0.19.18

using Markdown
using InteractiveUtils

# ╔═╡ cd19d0b9-d038-40a3-8b5f-e5ac50af3045
using StructArrays

# ╔═╡ 7abef450-8091-11ed-0d95-5b0ca33aadc4
[Dict(1 => 2), Dict(3 => 4)]

# ╔═╡ f73f0bae-3fd6-48d0-8e8a-5f41d0c538a0
[Dict(1 => 2), Dict(3 => 4)] |> StructArray

# ╔═╡ a95d68d0-b6e0-4845-a5cc-b6afa5c33176
[Dict("a" => 2), Dict("b" => 4)]

# ╔═╡ 00000000-0000-0000-0000-000000000001
PLUTO_PROJECT_TOML_CONTENTS = """
[deps]
StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"

[compat]
StructArrays = "~0.6.14"
"""

# ╔═╡ 00000000-0000-0000-0000-000000000002
PLUTO_MANIFEST_TOML_CONTENTS = """
# This file is machine-generated - editing it directly is not advised

julia_version = "1.8.3"
manifest_format = "2.0"
project_hash = "8e30e14200747e20846286370d32183fac038aac"

[[deps.Adapt]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "195c5505521008abea5aee4f96930717958eac6f"
uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
version = "3.4.0"

[[deps.Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"

[[deps.Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[deps.CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
version = "0.5.2+0"

[[deps.DataAPI]]
git-tree-sha1 = "e8119c1a33d267e16108be441a287a6981ba1630"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
version = "1.14.0"

[[deps.DataValueInterfaces]]
git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6"
uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464"
version = "1.0.0"

[[deps.GPUArraysCore]]
deps = ["Adapt"]
git-tree-sha1 = "6872f5ec8fd1a38880f027a26739d42dcda6691f"
uuid = "46192b85-c4d5-4398-a991-12ede77f4527"
version = "0.1.2"

[[deps.InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[deps.IteratorInterfaceExtensions]]
git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856"
uuid = "82899510-4779-5014-852e-03e436cf321d"
version = "1.0.0"

[[deps.Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[[deps.LinearAlgebra]]
deps = ["Libdl", "libblastrampoline_jll"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[[deps.Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[deps.Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[deps.OpenBLAS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
version = "0.3.20+0"

[[deps.OrderedCollections]]
git-tree-sha1 = "85f8e6578bf1f9ee0d11e7bb1b1456435479d47c"
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
version = "1.4.1"

[[deps.Random]]
deps = ["SHA", "Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[deps.SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
version = "0.7.0"

[[deps.Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

[[deps.StaticArraysCore]]
git-tree-sha1 = "6b7ba252635a5eff6a0b0664a41ee140a1c9e72a"
uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
version = "1.4.0"

[[deps.StructArrays]]
deps = ["Adapt", "DataAPI", "GPUArraysCore", "StaticArraysCore", "Tables"]
git-tree-sha1 = "b03a3b745aa49b566f128977a7dd1be8711c5e71"
uuid = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
version = "0.6.14"

[[deps.TableTraits]]
deps = ["IteratorInterfaceExtensions"]
git-tree-sha1 = "c06b2f539df1c6efa794486abfb6ed2022561a39"
uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c"
version = "1.0.1"

[[deps.Tables]]
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "OrderedCollections", "TableTraits", "Test"]
git-tree-sha1 = "c79322d36826aa2f4fd8ecfa96ddb47b174ac78d"
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
version = "1.10.0"

[[deps.Test]]
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[deps.libblastrampoline_jll]]
deps = ["Artifacts", "Libdl", "OpenBLAS_jll"]
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
version = "5.1.1+0"
"""

# ╔═╡ Cell order:
# ╠═cd19d0b9-d038-40a3-8b5f-e5ac50af3045
# ╠═7abef450-8091-11ed-0d95-5b0ca33aadc4
# ╠═f73f0bae-3fd6-48d0-8e8a-5f41d0c538a0
# ╠═a95d68d0-b6e0-4845-a5cc-b6afa5c33176
# ╟─00000000-0000-0000-0000-000000000001
# ╟─00000000-0000-0000-0000-000000000002
@fonsp fonsp added bug Something isn't working other packages Integration with other Julia packages display & PlutoRunner & AbstractPlutoDingetjes.jl labels Dec 22, 2022
@aplavin
Copy link
Contributor Author

aplavin commented Feb 10, 2024

Wonder if any solutions are in sight/planned...

More generally, I often find the table viewer too "eager" to engage.

I see this very often. Like this basic example displays in a weird way:

image

Compare to REPL:

image

Also relevant #2324 #2472

@fonsp
Copy link
Owner

fonsp commented Oct 4, 2024

@ReubenJ something for you? 😗

@ReubenJ
Copy link
Contributor

ReubenJ commented Oct 7, 2024

Ok, just to make sure I understand, we want these three:

[Dict(1 => 2), Dict(3 => 4)]
[Dict(1 => 2), Dict(3 => 4)] |> StructArray
StructArray(rand(10^1) + im * rand(10^1))

to all display in the vector form like so:

afbeelding

and these:

StructArray((a = [rand(Bool, 3) for i = 1:3, j = 1:2], b = [rand(Bool) for i = 1:3, j = 1:2]))
[1 2; 2 3; 3 4]

to display in the Matrix form like so:

afbeelding

Did I get that right?

ReubenJ added a commit to ReubenJ/Pluto.jl that referenced this issue Oct 7, 2024
@ReubenJ
Copy link
Contributor

ReubenJ commented Oct 7, 2024

@laggvar @aplavin can you check that this is the behavior you'd expect?

@aplavin
Copy link
Contributor Author

aplavin commented Oct 7, 2024

Sounds right to me!

@laggvar
Copy link

laggvar commented Oct 7, 2024

Looks great!

@fonsp
Copy link
Owner

fonsp commented Oct 22, 2024

@ReubenJ Can you make a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working display & PlutoRunner & AbstractPlutoDingetjes.jl good first issue Good for newcomers other packages Integration with other Julia packages
Projects
None yet
Development

No branches or pull requests

4 participants