Opened 4 years ago

Last modified 4 years ago

#26931 closed defect

Predictable sorting in simplicial_complex.py — at Version 2

Reported by: Jeroen Demeyer Owned by:
Priority: major Milestone: sage-8.6
Component: python3 Keywords:
Cc: John Palmieri Merged in:
Authors: Jeroen Demeyer Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by Jeroen Demeyer)

#25932 introduced code of the form

try:
    vertices = tuple(sorted(vertex_set))
except TypeError:
    vertices = tuple(sorted(vertex_set, key=str))

The problem here is that sorting is not predictable: adding a vertex or considering a face containing only sortable vertices could suddenly change the ordering.

Instead, the sorting key should be explicitly given and the same key should always be used for the same simplicial complex.

Change History (2)

comment:1 Changed 4 years ago by Jeroen Demeyer

Description: modified (diff)

comment:2 Changed 4 years ago by Jeroen Demeyer

Description: modified (diff)
Note: See TracTickets for help on using tickets.