Opened 6 months ago
Last modified 5 months ago
#27829 needs_work enhancement
Mark some tests involving `long` using the `# py2` tag
Reported by:  jhpalmieri  Owned by:  

Priority:  major  Milestone:  sage8.9 
Component:  python3  Keywords:  
Cc:  Merged in:  
Authors:  John Palmieri  Reviewers:  
Report Upstream:  N/A  Work issues:  
Branch:  u/jhpalmieri/longpy2 (Commits)  Commit:  feac66d673a6786d58c25698f9614832f9161648 
Dependencies:  Stopgaps: 
Description
Since long
is not available in Python 3, we should mark tests involving it as for Python 2 only. This is part of #27696.
Change History (9)
comment:1 Changed 6 months ago by
 Branch set to u/jhpalmieri/longpy2
comment:2 Changed 6 months ago by
 Commit set to 422e759ac14469033937e9c12a1d77e2b4e31344
 Status changed from new to needs_review
comment:3 Changed 6 months ago by
There are a few cases I didn't know what to do with. In the following, I don't think long(...)
adds much, so I think it's okay to make these changes. I have not yet done so. Opinions?

src/sage/rings/complex_double.pyx
diff git a/src/sage/rings/complex_double.pyx b/src/sage/rings/complex_double.pyx index ec43d0e199..21c9818780 100644
a b cdef class ComplexDoubleField_class(sage.rings.ring.Field): 398 398 399 399 sage: CDF(1) + RR(1) 400 400 2.0 401 sage: CDF.0  CC(1)  long(1)  RR(1)  QQbar(1)401 sage: CDF.0  CC(1)  ZZ(1)  RR(1)  QQbar(1) 402 402 4.0 + 1.0*I 403 403 sage: CDF.has_coerce_map_from(ComplexField(20)) 404 404 False 
src/sage/modules/free_module_element.pyx
diff git a/src/sage/modules/free_module_element.pyx b/src/sage/modules/free_module_element.pyx index 03d4d57a28..e069377806 100644
a b def vector(arg0, arg1=None, arg2=None, sparse=None): 382 382 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) 383 383 sage: v[3].parent() 384 384 Integer Ring 385 sage: v = vector([float(23.4), int(2), complex(2+7*I), long(1)]); v385 sage: v = vector([float(23.4), int(2), complex(2+7*I), 1]); v 386 386 (23.4, 2.0, 2.0 + 7.0*I, 1.0) 387 387 sage: v[1].parent() 388 388 Complex Double Field 
src/sage/rings/real_mpfr.pyx
diff git a/src/sage/rings/real_mpfr.pyx b/src/sage/rings/real_mpfr.pyx index ae74119795..a579b5a575 100644
a b cdef class RealField_class(sage.rings.ring.Field): 719 719 720 720 TESTS:: 721 721 722 sage: 1.0  ZZ(1)  int(1)  long(1) QQ(1)  RealField(100)(1)  AA(1)  RLF(1)722 sage: 1.0  ZZ(1)  int(1)  1  QQ(1)  RealField(100)(1)  AA(1)  RLF(1) 723 723 6.00000000000000 724 724 sage: R = RR['x'] # Hold reference to avoid garbage collection, see Trac #24709 725 725 sage: R.get_action(ZZ)
comment:4 Changed 6 months ago by
 Commit changed from 422e759ac14469033937e9c12a1d77e2b4e31344 to feac66d673a6786d58c25698f9614832f9161648
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
feac66d  trac 27829: add "# py2" to some tests involving "long(...)"

comment:5 followup: ↓ 7 Changed 6 months ago by
I don't think that # optional  fricas py2
works the way you think it does: you need # py2
not # optional  py2
.
comment:6 Changed 6 months ago by
For large numbers (which don't fit in a Python 2 int
anyway), you can replace long()
by int()
, for example
a = long(901824309821093821093812093810928309183091832091)
becomes
a = int(901824309821093821093812093810928309183091832091)
(unless the goal of the doctest is precisely testing __long__
which is not the case here).
comment:7 in reply to: ↑ 5 Changed 6 months ago by
Replying to jdemeyer:
I don't think that
# optional  fricas py2
works the way you think it does: you need# py2
not# optional  py2
.
It works exactly the way I think it does, I just made a mistake.
comment:8 Changed 6 months ago by
 Status changed from needs_review to needs_work
comment:9 Changed 5 months ago by
 Milestone changed from sage8.8 to sage8.9
Tickets still needing working or clarification should be moved to the next release milestone at the soonest (please feel free to revert if you think the ticket is close to being resolved).
New commits:
trac 27829: add "# py2" to some tests involving "long(...)"