Add co_arm_length method to Sage partitions

asked 2024-02-19 20:13:34 +0100

yeetcode gravatar image

updated 2024-02-19 20:15:22 +0100

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.

edit retag flag offensive close merge delete

Comments

try sage: P.leg_length?

FrédéricC gravatar imageFrédéricC ( 2024-02-20 07:53:23 +0100 )edit

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.

yeetcode gravatar imageyeetcode ( 2024-02-20 09:10:26 +0100 )edit
1

yes, right. You can use git grep to find where a function or method is defined, or look carefully at Par.arm_length?? which also tells you in which file to look.

FrédéricC gravatar imageFrédéricC ( 2024-02-20 09:52:10 +0100 )edit

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.

yeetcode gravatar imageyeetcode ( 2024-02-25 14:38:36 +0100 )edit