Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit af823cc

Browse files
author
Matthias Koeppe
committed
src/sage/misc/lazy_import.pyx: Fix doctests
1 parent d1ca407 commit af823cc

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

src/sage/misc/lazy_import.pyx

+32-5
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ cdef class LazyImport():
174174
EXAMPLES::
175175
176176
sage: from sage.misc.lazy_import import LazyImport
177-
sage: my_integer = LazyImport('sage.rings.integer_ring', 'Integer')
177+
sage: my_integer = LazyImport('sage.rings.integer', 'Integer')
178178
sage: my_integer(4)
179179
4
180180
sage: my_integer('101', base=2)
@@ -365,7 +365,7 @@ cdef class LazyImport():
365365
EXAMPLES::
366366
367367
sage: from sage.misc.lazy_import import LazyImport
368-
sage: my_integer = LazyImport('sage.rings.integer_ring', 'Integer')
368+
sage: my_integer = LazyImport('sage.rings.integer', 'Integer')
369369
sage: my_integer.sqrt is Integer.sqrt
370370
True
371371
"""
@@ -395,7 +395,7 @@ cdef class LazyImport():
395395
EXAMPLES::
396396
397397
sage: from sage.misc.lazy_import import LazyImport
398-
sage: my_isprime = LazyImport('sage.rings.integer_ring', 'is_prime')
398+
sage: my_isprime = LazyImport('sage.arith.misc', 'is_prime')
399399
sage: is_prime(12) == my_isprime(12)
400400
True
401401
sage: is_prime(13) == my_isprime(13)
@@ -485,6 +485,7 @@ cdef class LazyImport():
485485
example, we add manually a function in :mod:`sage.all__sagemath_objects`::
486486
487487
sage: def my_method(self): return self
488+
sage: import sage.all__sagemath_objects
488489
sage: sage.all__sagemath_objects.my_method = my_method
489490
490491
Now we lazy import it as a method of a new class ``Foo``::
@@ -568,6 +569,7 @@ cdef class LazyImport():
568569
TESTS::
569570
570571
sage: from sage.misc.lazy_import import LazyImport
572+
sage: import sage.all__sagemath_objects
571573
sage: sage.all__sagemath_objects.foo = list(range(10))
572574
sage: lazy_foo = LazyImport('sage.all__sagemath_objects', 'foo')
573575
sage: lazy_foo[1] = 100
@@ -583,7 +585,8 @@ cdef class LazyImport():
583585
TESTS::
584586
585587
sage: from sage.misc.lazy_import import LazyImport
586-
sage: sage.all.foo = list(range(10))
588+
sage: import sage.all__sagemath_objects
589+
sage: sage.all__sagemath_objects.foo = list(range(10))
587590
sage: lazy_foo = LazyImport('sage.all__sagemath_objects', 'foo')
588591
sage: del lazy_foo[1]
589592
sage: print(lazy_foo)
@@ -623,6 +626,7 @@ cdef class LazyImport():
623626
"""
624627
TESTS::
625628
629+
sage: import sage.all__sagemath_objects
626630
sage: sage.all__sagemath_objects.foo = 10
627631
sage: lazy_import('sage.all__sagemath_objects', 'foo')
628632
sage: foo + 1
@@ -634,6 +638,7 @@ cdef class LazyImport():
634638
"""
635639
TESTS::
636640
641+
sage: import sage.all__sagemath_objects
637642
sage: sage.all__sagemath_objects.foo = 10
638643
sage: lazy_import('sage.all__sagemath_objects', 'foo')
639644
sage: foo - 1
@@ -645,6 +650,7 @@ cdef class LazyImport():
645650
"""
646651
TESTS::
647652
653+
sage: import sage.all__sagemath_objects
648654
sage: sage.all__sagemath_objects.foo = 10
649655
sage: lazy_import('sage.all__sagemath_objects', 'foo')
650656
sage: foo * 2
@@ -657,6 +663,7 @@ cdef class LazyImport():
657663
TESTS::
658664
659665
sage: from sympy import Matrix
666+
sage: import sage.all__sagemath_objects
660667
sage: sage.all__sagemath_objects.foo = Matrix([[1,1],[0,1]])
661668
sage: lazy_import('sage.all__sagemath_objects', 'foo')
662669
sage: foo.__matmul__(foo)
@@ -670,6 +677,7 @@ cdef class LazyImport():
670677
"""
671678
TESTS::
672679
680+
sage: import sage.all__sagemath_objects
673681
sage: sage.all__sagemath_objects.foo = 10
674682
sage: lazy_import('sage.all__sagemath_objects', 'foo')
675683
sage: foo // 3
@@ -681,6 +689,7 @@ cdef class LazyImport():
681689
"""
682690
TESTS::
683691
692+
sage: import sage.all__sagemath_objects
684693
sage: sage.all__sagemath_objects.foo = 10
685694
sage: lazy_import('sage.all__sagemath_objects', 'foo')
686695
sage: operator.truediv(foo, 3)
@@ -692,6 +701,7 @@ cdef class LazyImport():
692701
"""
693702
TESTS::
694703
704+
sage: import sage.all__sagemath_objects
695705
sage: sage.all__sagemath_objects.foo = 10
696706
sage: lazy_import('sage.all__sagemath_objects', 'foo')
697707
sage: foo ** 2
@@ -703,6 +713,7 @@ cdef class LazyImport():
703713
"""
704714
TESTS::
705715
716+
sage: import sage.all__sagemath_objects
706717
sage: sage.all__sagemath_objects.foo = 10
707718
sage: lazy_import('sage.all__sagemath_objects', 'foo')
708719
sage: foo % 7
@@ -714,6 +725,7 @@ cdef class LazyImport():
714725
"""
715726
TESTS::
716727
728+
sage: import sage.all__sagemath_objects
717729
sage: sage.all__sagemath_objects.foo = 10
718730
sage: lazy_import('sage.all__sagemath_objects', 'foo')
719731
sage: foo << 3
@@ -725,6 +737,7 @@ cdef class LazyImport():
725737
"""
726738
TESTS::
727739
740+
sage: import sage.all__sagemath_objects
728741
sage: sage.all__sagemath_objects.foo = 10
729742
sage: lazy_import('sage.all__sagemath_objects', 'foo')
730743
sage: foo >> 2
@@ -736,6 +749,7 @@ cdef class LazyImport():
736749
"""
737750
TESTS::
738751
752+
sage: import sage.all__sagemath_objects
739753
sage: sage.all__sagemath_objects.foo = 10
740754
sage: lazy_import('sage.all__sagemath_objects', 'foo')
741755
sage: foo & 7
@@ -747,6 +761,7 @@ cdef class LazyImport():
747761
"""
748762
TESTS::
749763
764+
sage: import sage.all__sagemath_objects
750765
sage: sage.all__sagemath_objects.foo = 10
751766
sage: lazy_import('sage.all__sagemath_objects', 'foo')
752767
sage: foo | 7
@@ -758,6 +773,7 @@ cdef class LazyImport():
758773
"""
759774
TESTS::
760775
776+
sage: import sage.all__sagemath_objects
761777
sage: sage.all__sagemath_objects.foo = 10
762778
sage: lazy_import('sage.all__sagemath_objects', 'foo')
763779
sage: foo ^^ 7
@@ -769,6 +785,7 @@ cdef class LazyImport():
769785
"""
770786
TESTS::
771787
788+
sage: import sage.all__sagemath_objects
772789
sage: sage.all__sagemath_objects.foo = 10
773790
sage: lazy_import('sage.all__sagemath_objects', 'foo')
774791
sage: -foo
@@ -780,6 +797,7 @@ cdef class LazyImport():
780797
"""
781798
TESTS::
782799
800+
sage: import sage.all__sagemath_objects
783801
sage: sage.all__sagemath_objects.foo = 10
784802
sage: lazy_import('sage.all__sagemath_objects', 'foo')
785803
sage: +foo
@@ -791,6 +809,7 @@ cdef class LazyImport():
791809
"""
792810
TESTS::
793811
812+
sage: import sage.all__sagemath_objects
794813
sage: sage.all__sagemath_objects.foo = -1000
795814
sage: lazy_import('sage.all__sagemath_objects', 'foo')
796815
sage: abs(foo)
@@ -802,6 +821,7 @@ cdef class LazyImport():
802821
"""
803822
TESTS::
804823
824+
sage: import sage.all__sagemath_objects
805825
sage: sage.all__sagemath_objects.foo = 10
806826
sage: lazy_import('sage.all__sagemath_objects', 'foo')
807827
sage: ~foo
@@ -813,6 +833,7 @@ cdef class LazyImport():
813833
"""
814834
TESTS::
815835
836+
sage: import sage.all__sagemath_objects
816837
sage: sage.all__sagemath_objects.foo = 10
817838
sage: lazy_import('sage.all__sagemath_objects', 'foo')
818839
sage: complex(foo)
@@ -824,6 +845,7 @@ cdef class LazyImport():
824845
"""
825846
TESTS::
826847
848+
sage: import sage.all__sagemath_objects
827849
sage: sage.all__sagemath_objects.foo = 10
828850
sage: lazy_import('sage.all__sagemath_objects', 'foo')
829851
sage: int(foo)
@@ -835,6 +857,7 @@ cdef class LazyImport():
835857
"""
836858
TESTS::
837859
860+
sage: import sage.all__sagemath_objects
838861
sage: sage.all__sagemath_objects.foo = 10
839862
sage: lazy_import('sage.all__sagemath_objects', 'foo')
840863
sage: float(foo)
@@ -846,6 +869,7 @@ cdef class LazyImport():
846869
"""
847870
TESTS::
848871
872+
sage: import sage.all__sagemath_objects
849873
sage: sage.all__sagemath_objects.foo = 10
850874
sage: lazy_import('sage.all__sagemath_objects', 'foo')
851875
sage: oct(foo)
@@ -857,6 +881,7 @@ cdef class LazyImport():
857881
"""
858882
TESTS::
859883
884+
sage: import sage.all__sagemath_objects
860885
sage: sage.all__sagemath_objects.foo = 10
861886
sage: lazy_import('sage.all__sagemath_objects', 'foo')
862887
sage: hex(foo)
@@ -868,6 +893,7 @@ cdef class LazyImport():
868893
"""
869894
TESTS::
870895
896+
sage: import sage.all__sagemath_objects
871897
sage: sage.all__sagemath_objects.foo = 10
872898
sage: lazy_import('sage.all__sagemath_objects', 'foo')
873899
sage: list(range(100))[foo]
@@ -881,8 +907,8 @@ cdef class LazyImport():
881907
882908
TESTS::
883909
884-
885910
sage: from sage.misc.lazy_import import LazyImport
911+
sage: import sage.all__sagemath_objects
886912
sage: sage.all__sagemath_objects.foo = [[1,2], 3]
887913
sage: lazy_foo = LazyImport('sage.all__sagemath_objects', 'foo')
888914
sage: a = copy(lazy_foo)
@@ -903,6 +929,7 @@ cdef class LazyImport():
903929
TESTS::
904930
905931
sage: from sage.misc.lazy_import import LazyImport
932+
sage: import sage.all__sagemath_objects
906933
sage: sage.all__sagemath_objects.foo = [[1,2], 3]
907934
sage: lazy_foo = LazyImport('sage.all__sagemath_objects', 'foo')
908935
sage: a = deepcopy(lazy_foo)

0 commit comments

Comments
 (0)