Opened 19 months ago

Last modified 5 months ago

#28180 needs_work enhancement

Sort dictionary keys and set elements in rich output

Reported by: jaanos Owned by:
Priority: major Milestone: sage-9.3
Component: user interface Keywords: fpsac2019
Cc: aram.dermenjian Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: u/jaanos/sort_dictionary_keys_in_rich_output (Commits) Commit: a03bf7a2cf294166366b5bf95500c72c1a4b82a2
Dependencies: Stopgaps:

Description (last modified by jaanos)

This ticket introduces sorting of dictionary keys and set elements (including finite Sets) in rich output, mimicking IPython's behaviour (actually, it uses IPython's _sorted_for_pprint function for sorting).

It also avoids line breaks between the key and value in the LaTeX representation of dictionaries, and introduces sorting in the plain representation of finite Sets.

Change History (9)

comment:1 Changed 19 months ago by jaanos

  • Branch set to u/jaanos/sort_dictionary_keys_in_rich_output

comment:2 Changed 19 months ago by jaanos

  • Commit set to f7afdf5b1328c78fad613165e07c10ff36d5df0f
  • Component changed from PLEASE CHANGE to user interface
  • Description modified (diff)
  • Keywords fpsac2019 added
  • Status changed from new to needs_info
  • Type changed from PLEASE CHANGE to enhancement

In the LaTeX output, the entire contents of the dictionary are now wrapped in big curly braces, as I don't know how to add them only to the first and last line (\left\{ ... \right. will not work, since there's a & in between) - besides, their sizes may not match, which could be ugly. I guess we could have a horizontal layout if the dictionary could fit in a line, but I don't know how to check it (and it may be part of a longer line anyway, thus requiring line breaks).

I will also add sorting for sets. This will require adding a new function to handle Python sets.


New commits:

52fba75Sort dict keys and align when displayed as LaTeX
ec9f716Sort dict keys in character art
f7afdf5Update doctests

comment:3 Changed 19 months ago by git

  • Commit changed from f7afdf5b1328c78fad613165e07c10ff36d5df0f to a03bf7a2cf294166366b5bf95500c72c1a4b82a2

Branch pushed to git repo; I updated commit sha1. New commits:

1d742d5Sort set elements in rich representation
dfb105eFix representations of dicts and sets
2aeb5ceFix grammatical errors in docstrings
a03bf7aSort and add rich representation for finite Sets

comment:4 Changed 19 months ago by jaanos

  • Cc aram.dermenjian added
  • Description modified (diff)
  • Status changed from needs_info to needs_review
  • Summary changed from Sort dictionary keys in rich output to Sort dictionary keys and set elements in rich output

I have now reverted the layout changes in LaTeX representation of dictionaries, instead wrapping key-value pairs in {...}, as suggested by Aram. Sorting is now also applied to Python's sets and frozensets and Sage's finite Sets (for which the representation is the same as for sets, except when the Set is empty).

comment:5 Changed 19 months ago by jaanos

  • Description modified (diff)

comment:6 Changed 14 months ago by chapoton

  • Status changed from needs_review to needs_work

red branch

comment:7 Changed 13 months ago by embray

  • Milestone changed from sage-8.9 to sage-9.1

Ticket retargeted after milestone closed

comment:8 Changed 10 months ago by mkoeppe

  • Milestone changed from sage-9.1 to sage-9.2

Batch modifying tickets that will likely not be ready for 9.1, based on a review of the ticket title, branch/review status, and last modification date.

comment:9 Changed 5 months ago by mkoeppe

  • Milestone changed from sage-9.2 to sage-9.3
Note: See TracTickets for help on using tickets.