On Sat, Jun 28, 2008 at 11:47 AM, David Joyner <[EMAIL PROTECTED]> wrote:
>
> If you attach a file containing
>
> ##################################################################
>
> def PermutationGroupRing(R,G):
> return PermutationGroupRing_generic(R,G)
>
> class PermutationGroupRing_generic(CombinatorialAlgebra):
> def __init__(self, R, G):
> self.group = G
> self._combinatorial_class = G
> self._one = G.identity()
> self._name = 'Group ring of %s'%str(G)
> self._prefix = ''
> CombinatorialAlgebra.__init__(self, R)
> def _multiply_basis(self, a, b):
> c = a*b
> return c
> def group(self):
> return self.group
>
>
> ##################################################################
>
> then you get the following error:
>
> sage: F = GF(11)
> sage: G = PermutationGroup([(1,2,3),(3,4,5)])
> sage: attach "/home/wdj/sagefiles/codes/group_rings.sage"
> sage: R = PermutationGroupRing(F,G)
> sage: R.basis()
> ---------------------------------------------------------------------------
> TypeError Traceback (most recent call last)
>
> /home/wdj/sagefiles/sage-3.0.3.rc0/<ipython console> in <module>()
>
> /home/wdj/sagefiles/sage-3.0.3.rc0/local/lib/python2.5/site-packages/sage/combinat/combinatorial_algebra.py
> in basis(self)
> 701
> 702 """
> --> 703 return [self(x) for x in self._combinatorial_class]
> 704
> 705 def __call__(self, x):
>
> /home/wdj/sagefiles/sage-3.0.3.rc0/local/lib/python2.5/site-packages/sage/combinat/combinatorial_algebra.py
> in __call__(self, x)
> 738 return eclass(self, dict([ (e1,R(e2)) for
> e1,e2 in x._monomial_coefficients.items()]))
> 739 #x is an element of the basis combinatorial class
> --> 740 elif isinstance(x, self._combinatorial_class.object_class):
> 741 return eclass(self, {x:R(1)})
> 742 elif x in self._combinatorial_class:
>
> TypeError: isinstance() arg 2 must be a class, type, or tuple of
> classes and types
> sage:
>
> I added the method
>
> def object_class(self):
> return PermutationGroup_generic
>
> to PermutationGroup_generic so now,
>
> sage: R._combinatorial_class.object_class
> <bound method PermutationGroup_generic.object_class of Permutation
> Group with generators [(1,2,3), (3,4,5)]>
> sage: R._combinatorial_class.object_class()
> <class 'sage.groups.perm_gps.permgroup.PermutationGroup_generic'>
> sage: isinstance(G,R._combinatorial_class.object_class())
> True
>
> It seems to me the traceback error indicates I've defined object_class
> incorrectly.
> Does anyone have a hint as to the right way to go here?
Maybe you should change
elif isinstance(x, self._combinatorial_class.object_class):
to
elif isinstance(x, self._combinatorial_class.object_class()):
William
>
>
>
> On Sat, Jun 28, 2008 at 12:59 PM, David Joyner <[EMAIL PROTECTED]> wrote:
>> On Sat, Jun 28, 2008 at 12:48 PM, Robert Bradshaw
>> <[EMAIL PROTECTED]> wrote:
>>>
>>> On Jun 28, 2008, at 9:33 AM, David Joyner wrote:
>>>
>>>> On Sat, Jun 28, 2008 at 11:00 AM, John Cremona
>>>> <[EMAIL PROTECTED]> wrote:
>>>>>
>>>>> It seems that what Dan Bump's instructions did not specify is what
>>>>> properties the class assigned to ._combinatorial_class must have.
>>>>> And it needs something which PermutationGroupElement does not have.
>>>>>
>>>>> Does that help?
>>>>
>>>> Okay. Maybe the best thing is to write a wrapper to GAP's GroupRing
>>>> function.
>>>
>>> I disagree, using CombinatorialAlgebra will be a much better option.
>>>
>>>>>> Can anyone explain "AttributeError: type object
>>>>>> 'sage.groups.perm_gps.permgroup_element.Permutation' has no
>>>>>> attribute
>>>>>> 'count'"
>>>>>> (in words of two syllables or less, if possible:-)?
>>>
>>> Sure. It means that it's trying to use a method called "count" but
>>> the class "Permutation" found in sage/groups/perm_gps/
>>> permgroup_element doesn't define one. What you need to do is make a
>>> method called count.
>>>
>>> Actually, looking at the code (and someone more familiar with sage-
>>> combinat should correct me) it looks like _combinatorial_class should
>>> be the Parent (i.e. the group) rather than the element. It would
>>> probably make sense to do something like
>>>
>>>> class PermutationGroupRing(CombinatorialAlgebra):
>>>> def __init__(self, R, G):
>>>> self.group = G
>>>> self._combinatorial_class = G # NOTE the change
>>>> self._one = G.identity()
>>>> self._name = 'Group ring of %s'%str(G)
>>>> self._prefix = ''
>>>> CombinatorialAlgebra.__init__(self, R)
>>>> def _multiply_basis(self, a, b):
>>>> c = a*b
>>>> return c
>>>
>>> and add a count method to the group class.
>>
>> That worked! Thank you!
>>
>>>
>>> - Robert
>>>
>>>
>>> >>
>>>
>>
>
> >
>
--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---