Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

''' 

Tests for the IPython integration 

 

First, test the pinfo magic for Python code. This is what IPython 

calls when you ask for the single-questionmark help, like `foo?` :: 

 

sage: from sage.repl.interpreter import get_test_shell 

sage: shell = get_test_shell() 

sage: shell.run_cell(u'from sage.repl.ipython_tests import dummy') 

sage: shell.run_cell(u'%pinfo dummy') 

Signature: dummy(argument, optional=None) 

Docstring: 

Dummy Docstring Title 

<BLANKLINE> 

Dummy docstring explanation. 

<BLANKLINE> 

INPUT: 

<BLANKLINE> 

* "argument" -- anything. Dummy argument. 

<BLANKLINE> 

* "optional" -- anything (optional). Dummy optional. 

<BLANKLINE> 

EXAMPLES: 

<BLANKLINE> 

... 

Init docstring: x.__init__(...) initializes x; see help(type(x)) for signature 

File: .../sage/repl/ipython_tests.py 

Type: function 

 

Next, test the pinfo magic for Cython code:: 

 

sage: from sage.repl.interpreter import get_test_shell 

sage: shell = get_test_shell() 

sage: shell.run_cell(u'from sage.tests.stl_vector import stl_int_vector') 

sage: shell.run_cell(u'%pinfo stl_int_vector') 

Docstring: 

Example class wrapping an STL vector 

<BLANKLINE> 

EXAMPLES: 

<BLANKLINE> 

... 

Init docstring: x.__init__(...) initializes x; see help(type(x)) for signature 

File: .../sage/tests/stl_vector.pyx 

Type: type 

 

Next, test the pinfo2 magic for Python code. This is what IPython 

calls when you ask for the double-questionmark help, like `foo??` :: 

 

sage: from sage.repl.interpreter import get_test_shell 

sage: shell = get_test_shell() 

sage: shell.run_cell(u'from sage.repl.ipython_tests import dummy') 

sage: shell.run_cell(u'%pinfo2 dummy') 

Signature: dummy(argument, optional=None) 

Source: 

def dummy(argument, optional=None): 

""" 

Dummy Docstring Title 

<BLANKLINE> 

Dummy docstring explanation. 

<BLANKLINE> 

INPUT: 

<BLANKLINE> 

- ``argument`` -- anything. Dummy argument. 

<BLANKLINE> 

- ``optional`` -- anything (optional). Dummy optional. 

<BLANKLINE> 

EXAMPLES:: 

<BLANKLINE> 

... 

""" 

return 'Source code would be here' 

File: .../sage/repl/ipython_tests.py 

Type: function 

 

Next, test the pinfo2 magic for Cython code:: 

 

sage: from sage.repl.interpreter import get_test_shell 

sage: shell = get_test_shell() 

sage: shell.run_cell(u'from sage.tests.stl_vector import stl_int_vector') 

sage: shell.run_cell(u'%pinfo2 stl_int_vector') 

Source: 

cdef class stl_int_vector(SageObject): 

""" 

Example class wrapping an STL vector 

<BLANKLINE> 

EXAMPLES:: 

<BLANKLINE> 

... 

""" 

<BLANKLINE> 

cdef vector[int] *data 

cdef string *name 

<BLANKLINE> 

def __cinit__(self): 

""" 

The Cython constructor. 

<BLANKLINE> 

EXAMPLES:: 

<BLANKLINE> 

... 

File: .../sage/tests/stl_vector.pyx 

Type: type 

 

Test that there are no warnings being ignored internally:: 

 

sage: import warnings 

sage: warnings.simplefilter('error'); get_test_shell() 

<sage.repl.interpreter.SageTestShell object at 0x...> 

''' 

 

 

def dummy(argument, optional=None): 

""" 

Dummy Docstring Title 

 

Dummy docstring explanation. 

 

INPUT: 

 

- ``argument`` -- anything. Dummy argument. 

 

- ``optional`` -- anything (optional). Dummy optional. 

 

EXAMPLES:: 

 

sage: from sage.repl.ipython_tests import dummy 

sage: dummy(1) 

'Source code would be here'  

""" 

return 'Source code would be here'