Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/scipy/ndimage/_ni_docstrings.py: 100%

19 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-12-12 06:31 +0000

1"""Docstring components common to several ndimage functions.""" 

2from scipy._lib import doccer 

3 

4__all__ = ['docfiller'] 

5 

6 

7_input_doc = ( 

8"""input : array_like 

9 The input array.""") 

10_axis_doc = ( 

11"""axis : int, optional 

12 The axis of `input` along which to calculate. Default is -1.""") 

13_output_doc = ( 

14"""output : array or dtype, optional 

15 The array in which to place the output, or the dtype of the 

16 returned array. By default an array of the same dtype as input 

17 will be created.""") 

18_size_foot_doc = ( 

19"""size : scalar or tuple, optional 

20 See footprint, below. Ignored if footprint is given. 

21footprint : array, optional 

22 Either `size` or `footprint` must be defined. `size` gives 

23 the shape that is taken from the input array, at every element 

24 position, to define the input to the filter function. 

25 `footprint` is a boolean array that specifies (implicitly) a 

26 shape, but also which of the elements within this shape will get 

27 passed to the filter function. Thus ``size=(n,m)`` is equivalent 

28 to ``footprint=np.ones((n,m))``. We adjust `size` to the number 

29 of dimensions of the input array, so that, if the input array is 

30 shape (10,10,10), and `size` is 2, then the actual size used is 

31 (2,2,2). When `footprint` is given, `size` is ignored.""") 

32_mode_reflect_doc = ( 

33"""mode : {'reflect', 'constant', 'nearest', 'mirror', 'wrap'}, optional 

34 The `mode` parameter determines how the input array is extended 

35 beyond its boundaries. Default is 'reflect'. Behavior for each valid 

36 value is as follows: 

37 

38 'reflect' (`d c b a | a b c d | d c b a`) 

39 The input is extended by reflecting about the edge of the last 

40 pixel. This mode is also sometimes referred to as half-sample 

41 symmetric. 

42 

43 'constant' (`k k k k | a b c d | k k k k`) 

44 The input is extended by filling all values beyond the edge with 

45 the same constant value, defined by the `cval` parameter. 

46 

47 'nearest' (`a a a a | a b c d | d d d d`) 

48 The input is extended by replicating the last pixel. 

49 

50 'mirror' (`d c b | a b c d | c b a`) 

51 The input is extended by reflecting about the center of the last 

52 pixel. This mode is also sometimes referred to as whole-sample 

53 symmetric. 

54 

55 'wrap' (`a b c d | a b c d | a b c d`) 

56 The input is extended by wrapping around to the opposite edge. 

57 

58 For consistency with the interpolation functions, the following mode 

59 names can also be used: 

60 

61 'grid-mirror' 

62 This is a synonym for 'reflect'. 

63 

64 'grid-constant' 

65 This is a synonym for 'constant'. 

66 

67 'grid-wrap' 

68 This is a synonym for 'wrap'.""") 

69 

70_mode_interp_constant_doc = ( 

71"""mode : {'reflect', 'grid-mirror', 'constant', 'grid-constant', 'nearest', \ 

72 'mirror', 'grid-wrap', 'wrap'}, optional 

73 The `mode` parameter determines how the input array is extended 

74 beyond its boundaries. Default is 'constant'. Behavior for each valid 

75 value is as follows (see additional plots and details on 

76 :ref:`boundary modes <ndimage-interpolation-modes>`): 

77 

78 'reflect' (`d c b a | a b c d | d c b a`) 

79 The input is extended by reflecting about the edge of the last 

80 pixel. This mode is also sometimes referred to as half-sample 

81 symmetric. 

82 

83 'grid-mirror' 

84 This is a synonym for 'reflect'. 

85 

86 'constant' (`k k k k | a b c d | k k k k`) 

87 The input is extended by filling all values beyond the edge with 

88 the same constant value, defined by the `cval` parameter. No 

89 interpolation is performed beyond the edges of the input. 

90 

91 'grid-constant' (`k k k k | a b c d | k k k k`) 

92 The input is extended by filling all values beyond the edge with 

93 the same constant value, defined by the `cval` parameter. Interpolation 

94 occurs for samples outside the input's extent as well. 

95 

96 'nearest' (`a a a a | a b c d | d d d d`) 

97 The input is extended by replicating the last pixel. 

98 

99 'mirror' (`d c b | a b c d | c b a`) 

100 The input is extended by reflecting about the center of the last 

101 pixel. This mode is also sometimes referred to as whole-sample 

102 symmetric. 

103 

104 'grid-wrap' (`a b c d | a b c d | a b c d`) 

105 The input is extended by wrapping around to the opposite edge. 

106 

107 'wrap' (`d b c d | a b c d | b c a b`) 

108 The input is extended by wrapping around to the opposite edge, but in a 

109 way such that the last point and initial point exactly overlap. In this 

110 case it is not well defined which sample will be chosen at the point of 

111 overlap.""") 

112_mode_interp_mirror_doc = ( 

113 _mode_interp_constant_doc.replace("Default is 'constant'", 

114 "Default is 'mirror'") 

115) 

116assert _mode_interp_mirror_doc != _mode_interp_constant_doc, \ 

117 'Default not replaced' 

118 

119_mode_multiple_doc = ( 

120"""mode : str or sequence, optional 

121 The `mode` parameter determines how the input array is extended 

122 when the filter overlaps a border. By passing a sequence of modes 

123 with length equal to the number of dimensions of the input array, 

124 different modes can be specified along each axis. Default value is 

125 'reflect'. The valid values and their behavior is as follows: 

126 

127 'reflect' (`d c b a | a b c d | d c b a`) 

128 The input is extended by reflecting about the edge of the last 

129 pixel. This mode is also sometimes referred to as half-sample 

130 symmetric. 

131 

132 'constant' (`k k k k | a b c d | k k k k`) 

133 The input is extended by filling all values beyond the edge with 

134 the same constant value, defined by the `cval` parameter. 

135 

136 'nearest' (`a a a a | a b c d | d d d d`) 

137 The input is extended by replicating the last pixel. 

138 

139 'mirror' (`d c b | a b c d | c b a`) 

140 The input is extended by reflecting about the center of the last 

141 pixel. This mode is also sometimes referred to as whole-sample 

142 symmetric. 

143 

144 'wrap' (`a b c d | a b c d | a b c d`) 

145 The input is extended by wrapping around to the opposite edge. 

146 

147 For consistency with the interpolation functions, the following mode 

148 names can also be used: 

149 

150 'grid-constant' 

151 This is a synonym for 'constant'. 

152 

153 'grid-mirror' 

154 This is a synonym for 'reflect'. 

155 

156 'grid-wrap' 

157 This is a synonym for 'wrap'.""") 

158_cval_doc = ( 

159"""cval : scalar, optional 

160 Value to fill past edges of input if `mode` is 'constant'. Default 

161 is 0.0.""") 

162_origin_doc = ( 

163"""origin : int, optional 

164 Controls the placement of the filter on the input array's pixels. 

165 A value of 0 (the default) centers the filter over the pixel, with 

166 positive values shifting the filter to the left, and negative ones 

167 to the right.""") 

168_origin_multiple_doc = ( 

169"""origin : int or sequence, optional 

170 Controls the placement of the filter on the input array's pixels. 

171 A value of 0 (the default) centers the filter over the pixel, with 

172 positive values shifting the filter to the left, and negative ones 

173 to the right. By passing a sequence of origins with length equal to 

174 the number of dimensions of the input array, different shifts can 

175 be specified along each axis.""") 

176_extra_arguments_doc = ( 

177"""extra_arguments : sequence, optional 

178 Sequence of extra positional arguments to pass to passed function.""") 

179_extra_keywords_doc = ( 

180"""extra_keywords : dict, optional 

181 dict of extra keyword arguments to pass to passed function.""") 

182_prefilter_doc = ( 

183"""prefilter : bool, optional 

184 Determines if the input array is prefiltered with `spline_filter` 

185 before interpolation. The default is True, which will create a 

186 temporary `float64` array of filtered values if `order > 1`. If 

187 setting this to False, the output will be slightly blurred if 

188 `order > 1`, unless the input is prefiltered, i.e. it is the result 

189 of calling `spline_filter` on the original input.""") 

190 

191docdict = { 

192 'input': _input_doc, 

193 'axis': _axis_doc, 

194 'output': _output_doc, 

195 'size_foot': _size_foot_doc, 

196 'mode_interp_constant': _mode_interp_constant_doc, 

197 'mode_interp_mirror': _mode_interp_mirror_doc, 

198 'mode_reflect': _mode_reflect_doc, 

199 'mode_multiple': _mode_multiple_doc, 

200 'cval': _cval_doc, 

201 'origin': _origin_doc, 

202 'origin_multiple': _origin_multiple_doc, 

203 'extra_arguments': _extra_arguments_doc, 

204 'extra_keywords': _extra_keywords_doc, 

205 'prefilter': _prefilter_doc 

206 } 

207 

208docfiller = doccer.filldoc(docdict)