Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

characteristic() should be an integer #12988

Closed
saraedum opened this issue May 21, 2012 · 14 comments
Closed

characteristic() should be an integer #12988

saraedum opened this issue May 21, 2012 · 14 comments

Comments

@saraedum
Copy link
Member

Currently characteristic() does not return an Integer for some rings:

sage: type(ZZ.characteristic())
<type 'int'>

This is annoying because one cannot for example do:

sage: ZZ.characteristic().is_prime()
AttributeError: 'int' object has no attribute 'is_prime'

I don't see a good reason not to make characteristic always an Integer. The minimal performance loss should not be an issue in any computation that I can imagine.

Depends on #13043

Component: algebra

Keywords: ZZ characteristic sd40.5

Author: Julian Rueth

Reviewer: David Roe, Jeroen Demeyer

Merged: sage-5.1.beta2

Issue created by migration from https://trac.sagemath.org/ticket/12988

@saraedum saraedum added this to the sage-5.1 milestone May 21, 2012
@saraedum
Copy link
Member Author

comment:1

I believe it is easiest to check that this is correct through the test framework of the categories.

I added a test to Rings and also one to Fields() checking that it's a prime or zero.

@jdemeyer
Copy link

Changed keywords from ZZ, characteristic to ZZ characteristic sd40.5

@jdemeyer
Copy link

Author: Julian Rueth

@saraedum
Copy link
Member Author

comment:4

That's strange. I'll run the doctests again to see if this also happens here.

Actually _test_characteristic didn't catch wrong characteristic() implementations in some cases which is related to #13043. I'll upload an updated patch soon.

@saraedum
Copy link
Member Author

Dependencies: #13043

@saraedum
Copy link
Member Author

Attachment: trac_12988.patch.gz

move characteristic() to the category of rings and check that it is in ZZ

@roed314
Copy link
Contributor

roed314 commented May 28, 2012

comment:7

This looks good to me.

@jdemeyer
Copy link

Reviewer: David Roe

@jdemeyer
Copy link

comment:9

3 doctest failures with sage-5.1.beta1:

sage -t  "devel/sage-main/sage/rings/padics/padic_base_leaves.py"
**********************************************************************
File "/usr/local/src/sage-5.1.beta1/devel/sage-main/sage/rings/padics/padic_base_leaves.py", line 168:
    sage: TestSuite(R).run()
Expected nothing
Got:
    Failure in _test_characteristic:
    Traceback (most recent call last):
      File "/usr/local/src/sage-5.1.beta1/local/lib/python/site-packages/sage/misc/sage_unittest.py", line 275, in run
        test_method(tester = tester)
      File "/usr/local/src/sage-5.1.beta1/local/lib/python/site-packages/sage/categories/rings.py", line 258, in _test_characteristic
        tester.assertEqual(type(characteristic),sage.rings.integer.Integer)
      File "/usr/local/src/sage-5.1.beta1/local/lib/python2.7/unittest/case.py", line 509, in assertEqual
        assertion_func(first, second, msg=msg)
      File "/usr/local/src/sage-5.1.beta1/local/lib/python2.7/unittest/case.py", line 502, in _baseAssertEqual
        raise self.failureException(msg)
    AssertionError: <type 'int'> != <type 'sage.rings.integer.Integer'>
    ------------------------------------------------------------
    The following tests failed: _test_characteristic
**********************************************************************
File "/usr/local/src/sage-5.1.beta1/devel/sage-main/sage/rings/padics/padic_base_leaves.py", line 175:
    sage: TestSuite(R).run()
Expected nothing
Got:
    Failure in _test_characteristic:
    Traceback (most recent call last):
      File "/usr/local/src/sage-5.1.beta1/local/lib/python/site-packages/sage/misc/sage_unittest.py", line 275, in run
        test_method(tester = tester)
      File "/usr/local/src/sage-5.1.beta1/local/lib/python/site-packages/sage/categories/rings.py", line 258, in _test_characteristic
        tester.assertEqual(type(characteristic),sage.rings.integer.Integer)
      File "/usr/local/src/sage-5.1.beta1/local/lib/python2.7/unittest/case.py", line 509, in assertEqual
        assertion_func(first, second, msg=msg)
      File "/usr/local/src/sage-5.1.beta1/local/lib/python2.7/unittest/case.py", line 502, in _baseAssertEqual
        raise self.failureException(msg)
    AssertionError: <type 'int'> != <type 'sage.rings.integer.Integer'>
    ------------------------------------------------------------
    The following tests failed: _test_characteristic
**********************************************************************
File "/usr/local/src/sage-5.1.beta1/devel/sage-main/sage/rings/padics/padic_base_leaves.py", line 182:
    sage: TestSuite(R).run()
Expected nothing
Got:
    Failure in _test_characteristic:
    Traceback (most recent call last):
      File "/usr/local/src/sage-5.1.beta1/local/lib/python/site-packages/sage/misc/sage_unittest.py", line 275, in run
        test_method(tester = tester)
      File "/usr/local/src/sage-5.1.beta1/local/lib/python/site-packages/sage/categories/rings.py", line 258, in _test_characteristic
        tester.assertEqual(type(characteristic),sage.rings.integer.Integer)
      File "/usr/local/src/sage-5.1.beta1/local/lib/python2.7/unittest/case.py", line 509, in assertEqual
        assertion_func(first, second, msg=msg)
      File "/usr/local/src/sage-5.1.beta1/local/lib/python2.7/unittest/case.py", line 502, in _baseAssertEqual
        raise self.failureException(msg)
    AssertionError: <type 'int'> != <type 'sage.rings.integer.Integer'>
    ------------------------------------------------------------
    The following tests failed: _test_characteristic
**********************************************************************

@saraedum
Copy link
Member Author

Attachment: trac_12988_padic.patch.gz

fix characteristic for padics

@jdemeyer
Copy link

jdemeyer commented Jun 1, 2012

Changed reviewer from David Roe to David Roe, Jeroen Demeyer

@jdemeyer
Copy link

jdemeyer commented Jun 2, 2012

Merged: sage-5.1.beta2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
@roed314 @saraedum @aghitza @jdemeyer and others