[sage-support] Re: Best Practices for extending functionality of a sage class

2014-06-06 Thread Nils Bruin
On Thursday, June 5, 2014 2:50:22 PM UTC-7, Dinakar Muthiah wrote: Partition.i_part = i_part Then if later I wrote: p = Partition([3,2,1]) I can call p.i_part(2) That works. Of course, without the monkey-patching (changing code on a class after its original definition), you could

[sage-support] Re: Best Practices for extending functionality of a sage class

2014-06-06 Thread Dinakar Muthiah
Ideally, I would like to define a subclass of Partition called MyPartition and include all my custom methods. I think this is a standard way to extend libraries, but for some reason this doesn't work at all. Is there a solution that is more in the spirit of subclassing? -- You received this

[sage-support] Re: Best Practices for extending functionality of a sage class

2014-06-06 Thread Nils Bruin
On Friday, June 6, 2014 7:13:50 AM UTC-7, Dinakar Muthiah wrote: Ideally, I would like to define a subclass of Partition called MyPartition and include all my custom methods. I think this is a standard way to extend libraries, but for some reason this doesn't work at all. Is there a

[sage-support] Re: Best Practices for extending functionality of a sage class

2014-06-06 Thread Andrew
On Saturday, 7 June 2014 00:13:50 UTC+10, Dinakar Muthiah wrote: Ideally, I would like to define a subclass of Partition called MyPartition and include all my custom methods. I think this is a standard way to extend libraries, but for some reason this doesn't work at all. Is there a

[sage-support] Re: Best Practices for extending functionality of a sage class

2014-06-06 Thread Andrew
Oops, cut and past the wrong bits at the end - and google's syntax highlighting was going haywire: sage: MyPartition([3,2]) [3, 2] sage: MyPartition([3,2]).cells() [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1)] sage: MyPartition([3,2]).fred() 'fred' -- You received this message because you are

[sage-support] Re: Best Practices for extending functionality of a sage class

2014-06-05 Thread kcrisman
I want to know the best practices for extending the functionality of a sage class. For example, I would like to add the following method to the Partition class in sage: #\lambda^(i) from Carrell-Goulding paper def i_part(self,i): if i==0: return self elif i0:

[sage-support] Re: Best Practices for extending functionality of a sage class

2014-06-05 Thread Dinakar Muthiah
I literally wrote the following at the top of my module: #\lambda^(i) from Carrell-Goulding paper def i_part(self,i): if i==0: return self elif i0: return (self.conjugate().i_part(-i)).conjugate() zero_one_sequence = self.zero_one_sequence() num_ones =

[sage-support] Re: Best Practices for extending functionality of a sage class

2014-06-05 Thread Andrew
Hi Dinakur, The best way of doing this would be to open a track ticket, edit partition.py, add your method to the Partition class and then submit this for review so that it can be included in a future release of sage. If you decide to go this route then you would need to add some documentation