ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 25 Feb 2024 14:38:36 +0100Add co_arm_length method to Sage partitionshttps://ask.sagemath.org/question/76097/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.Mon, 19 Feb 2024 20:13:34 +0100https://ask.sagemath.org/question/76097/add-co_arm_length-method-to-sage-partitions/Comment by yeetcode for <p>There is a method <code>arm_length(i,j)</code> 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:</p>
<p><code>print(type(Partition([5,4,4,1])))</code></p>
<p>which returns</p>
<p><code><class 'sage.combinat.partition.Partitions_all_with_category.element_class'></code></p>
<p>I think this means that the underlying class is <code>sage.combinat.partition.Partitions_all_with_category.element_class</code></p>
<p>Now I try to write a class which takes the above as input, and Sage complains, saying</p>
<p><code>AttributeError: module 'sage.combinat.partition' has no attribute 'Partitions_all_with_category'</code></p>
<p>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 <code>co_arm_length()</code> so that it looks exactly the same as <code>arm_length()</code> for partitions. Otherwise my code is going to get too unclean for me to read.</p>
https://ask.sagemath.org/question/76097/add-co_arm_length-method-to-sage-partitions/?comment=76221#post-id-76221Just 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.Sun, 25 Feb 2024 14:38:36 +0100https://ask.sagemath.org/question/76097/add-co_arm_length-method-to-sage-partitions/?comment=76221#post-id-76221Comment by FrédéricC for <p>There is a method <code>arm_length(i,j)</code> 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:</p>
<p><code>print(type(Partition([5,4,4,1])))</code></p>
<p>which returns</p>
<p><code><class 'sage.combinat.partition.Partitions_all_with_category.element_class'></code></p>
<p>I think this means that the underlying class is <code>sage.combinat.partition.Partitions_all_with_category.element_class</code></p>
<p>Now I try to write a class which takes the above as input, and Sage complains, saying</p>
<p><code>AttributeError: module 'sage.combinat.partition' has no attribute 'Partitions_all_with_category'</code></p>
<p>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 <code>co_arm_length()</code> so that it looks exactly the same as <code>arm_length()</code> for partitions. Otherwise my code is going to get too unclean for me to read.</p>
https://ask.sagemath.org/question/76097/add-co_arm_length-method-to-sage-partitions/?comment=76111#post-id-76111yes, 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.Tue, 20 Feb 2024 09:52:10 +0100https://ask.sagemath.org/question/76097/add-co_arm_length-method-to-sage-partitions/?comment=76111#post-id-76111Comment by yeetcode for <p>There is a method <code>arm_length(i,j)</code> 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:</p>
<p><code>print(type(Partition([5,4,4,1])))</code></p>
<p>which returns</p>
<p><code><class 'sage.combinat.partition.Partitions_all_with_category.element_class'></code></p>
<p>I think this means that the underlying class is <code>sage.combinat.partition.Partitions_all_with_category.element_class</code></p>
<p>Now I try to write a class which takes the above as input, and Sage complains, saying</p>
<p><code>AttributeError: module 'sage.combinat.partition' has no attribute 'Partitions_all_with_category'</code></p>
<p>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 <code>co_arm_length()</code> so that it looks exactly the same as <code>arm_length()</code> for partitions. Otherwise my code is going to get too unclean for me to read.</p>
https://ask.sagemath.org/question/76097/add-co_arm_length-method-to-sage-partitions/?comment=76110#post-id-76110That'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.Tue, 20 Feb 2024 09:10:26 +0100https://ask.sagemath.org/question/76097/add-co_arm_length-method-to-sage-partitions/?comment=76110#post-id-76110Comment by FrédéricC for <p>There is a method <code>arm_length(i,j)</code> 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:</p>
<p><code>print(type(Partition([5,4,4,1])))</code></p>
<p>which returns</p>
<p><code><class 'sage.combinat.partition.Partitions_all_with_category.element_class'></code></p>
<p>I think this means that the underlying class is <code>sage.combinat.partition.Partitions_all_with_category.element_class</code></p>
<p>Now I try to write a class which takes the above as input, and Sage complains, saying</p>
<p><code>AttributeError: module 'sage.combinat.partition' has no attribute 'Partitions_all_with_category'</code></p>
<p>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 <code>co_arm_length()</code> so that it looks exactly the same as <code>arm_length()</code> for partitions. Otherwise my code is going to get too unclean for me to read.</p>
https://ask.sagemath.org/question/76097/add-co_arm_length-method-to-sage-partitions/?comment=76109#post-id-76109try `sage: P.leg_length?`Tue, 20 Feb 2024 07:53:23 +0100https://ask.sagemath.org/question/76097/add-co_arm_length-method-to-sage-partitions/?comment=76109#post-id-76109