ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 12 Feb 2016 16:24:16 -0600string monoid class should define one()http://ask.sagemath.org/question/32438/string-monoid-class-should-define-one/ Method 'one' is supposed to return the identity element of a monoid (or I guess of any magma). String monoids should define it to be the empty string. Not only have they not, the default implementation throws an error:
sage: BinaryStrings().one()
TypeError: Argument x (= 1) is of the wrong type.
Wed, 03 Feb 2016 20:56:00 -0600http://ask.sagemath.org/question/32438/string-monoid-class-should-define-one/Answer by tmonteil for <p>Method 'one' is supposed to return the identity element of a monoid (or I guess of any magma). String monoids should define it to be the empty string. Not only have they not, the default implementation throws an error:</p>
<p>sage: BinaryStrings().one()</p>
<p>TypeError: Argument x (= 1) is of the wrong type.</p>
http://ask.sagemath.org/question/32438/string-monoid-class-should-define-one/?answer=32442#post-id-32442Good catch ! Looking at the code, it seems that this class was not touched for a while (created in 2007, last touched in 2009), so i guess nobody took care of it when the `one()` was created for all monoids (probably through the sategory mechanism). May i encourage you to open a ticket and fix it yourself ?
Actually, it is not correct to say that the monoid is not able to provide an identity element, you can get is as follows:
sage: b('')
sage: b('110') == b('') * b('110')
True
Thu, 04 Feb 2016 04:50:59 -0600http://ask.sagemath.org/question/32438/string-monoid-class-should-define-one/?answer=32442#post-id-32442Comment by tmonteil for <p>Good catch ! Looking at the code, it seems that this class was not touched for a while (created in 2007, last touched in 2009), so i guess nobody took care of it when the <code>one()</code> was created for all monoids (probably through the sategory mechanism). May i encourage you to open a ticket and fix it yourself ?</p>
<p>Actually, it is not correct to say that the monoid is not able to provide an identity element, you can get is as follows:</p>
<pre><code>sage: b('')
sage: b('110') == b('') * b('110')
True
</code></pre>
http://ask.sagemath.org/question/32438/string-monoid-class-should-define-one/?comment=32554#post-id-32554It is now positively reviewed, so the fix should enter the next Sage release.Fri, 12 Feb 2016 16:24:16 -0600http://ask.sagemath.org/question/32438/string-monoid-class-should-define-one/?comment=32554#post-id-32554Comment by kcrisman for <p>Good catch ! Looking at the code, it seems that this class was not touched for a while (created in 2007, last touched in 2009), so i guess nobody took care of it when the <code>one()</code> was created for all monoids (probably through the sategory mechanism). May i encourage you to open a ticket and fix it yourself ?</p>
<p>Actually, it is not correct to say that the monoid is not able to provide an identity element, you can get is as follows:</p>
<pre><code>sage: b('')
sage: b('110') == b('') * b('110')
True
</code></pre>
http://ask.sagemath.org/question/32438/string-monoid-class-should-define-one/?comment=32451#post-id-32451And indeed there is already a branch on it! Though it needs docstring/tests.Thu, 04 Feb 2016 10:53:48 -0600http://ask.sagemath.org/question/32438/string-monoid-class-should-define-one/?comment=32451#post-id-32451Comment by kcrisman for <p>Good catch ! Looking at the code, it seems that this class was not touched for a while (created in 2007, last touched in 2009), so i guess nobody took care of it when the <code>one()</code> was created for all monoids (probably through the sategory mechanism). May i encourage you to open a ticket and fix it yourself ?</p>
<p>Actually, it is not correct to say that the monoid is not able to provide an identity element, you can get is as follows:</p>
<pre><code>sage: b('')
sage: b('110') == b('') * b('110')
True
</code></pre>
http://ask.sagemath.org/question/32438/string-monoid-class-should-define-one/?comment=32445#post-id-32445Since the OP may not have an account, I've taken the liberty of opening http://trac.sagemath.org/ticket/20009 for this.Thu, 04 Feb 2016 07:46:27 -0600http://ask.sagemath.org/question/32438/string-monoid-class-should-define-one/?comment=32445#post-id-32445