MCPcopy Create free account
hub / github.com/numpy/numpy / _check_for_commastring

Function _check_for_commastring

numpy/core/src/multiarray/descriptor.c:167–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165 arg == '|' || arg == '=')
166
167static int
168_check_for_commastring(const char *type, Py_ssize_t len)
169{
170 Py_ssize_t i;
171 int sqbracket;
172
173 /* Check for ints at start of string */
174 if ((type[0] >= '0'
175 && type[0] <= '9')
176 || ((len > 1)
177 && _chk_byteorder(type[0])
178 && (type[1] >= '0'
179 && type[1] <= '9'))) {
180 return 1;
181 }
182 /* Check for empty tuple */
183 if (((len > 1)
184 && (type[0] == '('
185 && type[1] == ')'))
186 || ((len > 3)
187 && _chk_byteorder(type[0])
188 && (type[1] == '('
189 && type[2] == ')'))) {
190 return 1;
191 }
192 /*
193 * Check for presence of commas outside square [] brackets. This
194 * allows commas inside of [], for parameterized dtypes to use.
195 */
196 sqbracket = 0;
197 for (i = 0; i < len; i++) {
198 switch (type[i]) {
199 case ',':
200 if (sqbracket == 0) {
201 return 1;
202 }
203 break;
204 case '[':
205 ++sqbracket;
206 break;
207 case ']':
208 --sqbracket;
209 break;
210 }
211 }
212 return 0;
213}
214
215#undef _chk_byteorder
216

Callers 1

_convert_from_strFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected