Catlab.jl icon indicating copy to clipboard operation
Catlab.jl copied to clipboard

Pretty-print for C-set transformations

Open epatters opened this issue 5 years ago • 3 comments

The default show method dumps all the type information and is therefore very unreadable.

epatters avatar Apr 18 '21 20:04 epatters

Would something like this be helpful to implement?


CSetTransformation with elements V = 3↦2, E = 2↦3


┌────┬──────┬───┐
│  V │ refl │ → │
├────┼──────┼───┤
│  1 │   1  │ 2 │
│  2 │   3  │ 2 │
│  3 │   2  │ 1 │
├────┼──────┼───┤
│  1 │   2  │ * │
│  2 │   3  │ * │
└────┴──────┴───┘

┌────┬─────┬─────┬───┐
│  E │ src │ tgt │ → │
├────┼─────┼─────┤───┤
│  1 │   1 │   1 │ 3 │
│  2 │   2 │   2 │ 2 │
│  3 │   3 │   3 │ 3 │
│  4 │   2 │   1 │ 1 │
├────┼─────┼─────┤───┤
│  1 │   1 │   2 │ * │
│  2 │   1 │   1 │ * │
│  3 │   2 │   2 │ * │
└────┴─────┴─────┴───┘

kris-brown avatar May 15 '21 05:05 kris-brown

That's an interesting idea. I was thinking that for the default show method, we would have a short and simple display mirroring the constructor, something like

ACSetTransformation((V=[...], E=[...]), [dom], [codom])

where [dom] and [codom] are some abbreviated representations of the domain and codomain ACSets, perhaps just showing their sizes.

But then we could also have a show method for MIME type text/plain with a richer, tabular display, possibly along the lines you suggest.

This would agree with the conventions on the show method for ACSets themselves (see CSetDataStructures).

epatters avatar May 15 '21 05:05 epatters

The PR above resolves the most immediate problem but I'll this issue open because I like the idea of having a show method for MIME type text/plain along the lines that Kris suggests.

epatters avatar Oct 30 '21 21:10 epatters