Add co_arm_length method to Sage partitions
There is a method arm_length(i,j)
which returns the arm length of the partition. I couldn't find a corresponding co-arm method, and for the sake of consistency, I'd like it implemented as a method. So I tried to make a derived class for Sage's partitions. To find out their original class, I tried this in my notebook:
print(type(Partition([5,4,4,1])))
which returns
<class 'sage.combinat.partition.Partitions_all_with_category.element_class'>
I think this means that the underlying class is sage.combinat.partition.Partitions_all_with_category.element_class
Now I try to write a class which takes the above as input, and Sage complains, saying
AttributeError: module 'sage.combinat.partition' has no attribute 'Partitions_all_with_category'
I cannot make any sense of this. I do not necessarily need an explanation for what's going on, but I'd like to find a way to implement co_arm_length()
so that it looks exactly the same as arm_length()
for partitions. Otherwise my code is going to get too unclean for me to read.
try
sage: P.leg_length?
That's not the same as co-arm, though. In English notation, the cells to the right constitute the arm, and the cells to the left constitute the co-arm. The leg is made of the cells beneath, correlating to neither. Now I can really just do
Par[i] - 1 - Par.arm_length(i,j)
for cell(i,j)
and while that does work in theory, the central problem here is to be able to write cleaner code.yes, right. You can use
git grep
to find where a function or method is defined, or look carefully atPar.arm_length??
which also tells you in which file to look.Just to be clear, do you want me to write the method directly into my copy of Sage @FrédéricC ? Apologies for the late reply, was caught up with something.