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

Method content_check

numpy/core/tests/test_unicode.py:185–204  ·  view source on GitHub ↗
(self, ua, ua_scalar, nbytes)

Source from the content-addressed store, hash-verified

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