Well, rank is really the standard term in computational combinatorics. It seems to me that index is already quite overloaded: for example, `CombinatorialObject` defines it. I cannot find `index` as an alias for `rank`, where did you see that?
I think that the main use for rank and unrank is to have an arbitrary, but deterministic total order on the elements, and to be able to create elements at random. So, I would say they are of "technical" use, as opposed to "mathematical" use, apologies for my vague language. Therefore, I'd prefer a method name that makes this clear. Martin On Wednesday, 20 August 2025 at 11:32:36 UTC+2 vdelecroix wrote: > The name index follows Python convention > > >>> [1, 2, 5, -2, 3].index(-2) > 3 > > sounds like a much better name than rank. > > Note that rank could also refer to the dimension of a vector > space/free module or the number of generators of a free group. > > On Tue, 19 Aug 2025 at 22:32, Nils Bruin <nbr...@sfu.ca> wrote: > > > > Agreed! In fact, looking at the docstring, it seems like "rank" is just > an alias for "index". Of course, "index" is going to be a similarly > overloaded term, but at least "rank" can be freed up by just dropping it as > an alias of "index". You can then solve the problems of "index" separately. > > > > For "unrank" (which according to the doc should give the position of an > element in the enumeration) you could use "ordinal" instead, but "unrank" > is such an ugly word that I don't think you'll run into many clashes for > that one. > > > > On Tuesday, 19 August 2025 at 07:33:03 UTC-7 axio...@yahoo.de wrote: > >> > >> Dear all, > >> > >> in the category for `EnumeratedSets` we have methods `rank` and > `unrank` that provide a bijection between the set and the natural numbers > (or some interval [0,n], if the cardinality is n). These methods are mostly > used in the category framework, I think, to provide generic implementations > of `random_element` and the like. > >> > >> Unfortunately, this conflicts with the method `rank` in Posets and > WeylGroups, as I realized while adding a test_rank method (which in turn > uncovered quite a few bugs). > >> > >> Even though `rank` and `unrank` were introduced very early in the game, > I think it would make sense to rename them to something less confusing and > deprecate them. I don't think they are used much by users. For example, I > think `total_order_rank` and `total_order_unrank` would be OK. > >> > >> I don't think it is wise to rename `Poset.rank` or `WeylGroup.rank`, > because these are really extremely standard. We do have > `StandardTableau.standard_descents` and > `StandardTableau.standard_major_index`, because of an historical accident, > and I think it's a pain. However, if very many people think it is better to > do `Poset.standard_rank`, than this would also be an option. > >> > >> I am also open to other suggestions, but I really think that these > methods should be tested systematically. > >> > >> Martin > > > > -- > > You received this message because you are subscribed to the Google > Groups "sage-devel" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to sage-devel+...@googlegroups.com. > > To view this discussion visit > https://groups.google.com/d/msgid/sage-devel/c97ab592-3a65-4fa9-8dc4-34b8176585b9n%40googlegroups.com > . > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/sage-devel/6eb57d55-f9da-4886-8ef2-c5b8dac9d7b0n%40googlegroups.com.