MCPcopy Index your code
hub / github.com/numpy/numpy / content_check

Method content_check

numpy/_core/tests/test_unicode.py:186–205  ·  view source on GitHub ↗
(self, ua, ua_scalar, nbytes)

Source from the content-addressed store, hash-verified

184 """Check the assignment of unicode arrays with values"""
185
186 def content_check(self, ua, ua_scalar, nbytes):
187
188 # Check the length of the unicode base type
189 assert_(int(ua.dtype.str[2:]) == self.ulen)
190 # Check the length of the data buffer
191 assert_(buffer_length(ua) == nbytes)
192 # Small check that data in array element is ok
193 assert_(ua_scalar == self.ucs_value * self.ulen)
194 # Encode to UTF-8 and double check
195 assert_(ua_scalar.encode('utf-8') ==
196 (self.ucs_value * self.ulen).encode('utf-8'))
197 # Check buffer lengths for scalars
198 if self.ucs_value == ucs4_value:
199 # In UCS2, the \U0010FFFF will be represented using a
200 # surrogate *pair*
201 assert_(buffer_length(ua_scalar) == 2 * 2 * self.ulen)
202 else:
203 # In UCS2, the \uFFFF will be represented using a
204 # regular 2-byte word
205 assert_(buffer_length(ua_scalar) == 2 * self.ulen)
206
207 def test_values0D(self):
208 # Check assignment of 0-dimensional objects with values

Callers 3

test_values0DMethod · 0.95
test_valuesSDMethod · 0.95
test_valuesMDMethod · 0.95

Calls 3

assert_Function · 0.90
buffer_lengthFunction · 0.85
encodeMethod · 0.80

Tested by

no test coverage detected