Re: [sage-devel] Inverse of discrete functions

2013-09-26 Thread Tom Boothby
1. I agree that "discrete" was a poor name choice 2. Would we want to add a package that implements a single (very elementary) class? (no) 3. I, for one, would like to keep Sage's documentation apolitical -- I'd rather to see some mathematical examples than those provided. On Thu, Sep 26, 2013 at

Re: [sage-devel] Inverse of discrete functions

2013-09-26 Thread Nils Bruin
On Wednesday, September 25, 2013 9:59:46 AM UTC-7, Tom wrote: > > For iso/automorphisms of graphs, I often wish that dictionaries were > both callable and invertible. In general, yes, I think > DiscreteFunction and DiscreteBijection classes would be very useful. > Does https://pypi.python.org/

Re: [sage-devel] Inverse of discrete functions

2013-09-25 Thread Tom Boothby
If the dictionary is a bijection, I use: {v:k for k,v in d.iteritems()} Otherwise, I use defaultdict: d_inv=defaultdict(list) map(lambda(k,v):d_inv[v].append(k), d.items()) For iso/automorphisms of graphs, I often wish that dictionaries were both callable and invertible. In general, yes, I think

[sage-devel] Inverse of discrete functions

2013-09-25 Thread Nathann Cohen
Hell everybody ! I was just messing with dictionaries and lists, and I wonder if we could solve the problem once and for all with an inefficient generic solution. Here's the thing : I often have to define both a function, and its inverse. Something like : d = { 'a' : 1, 'b' : 2, 'c' :