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

Method content_check

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

Source from the content-addressed store, hash-verified

101 """Check the creation of unicode arrays with values"""
102
103 def content_check(self, ua, ua_scalar, nbytes):
104
105 # Check the length of the unicode base type
106 assert_(int(ua.dtype.str[2:]) == self.ulen)
107 # Check the length of the data buffer
108 assert_(buffer_length(ua) == nbytes)
109 # Small check that data in array element is ok
110 assert_(ua_scalar == self.ucs_value * self.ulen)
111 # Encode to UTF-8 and double check
112 assert_(ua_scalar.encode('utf-8') ==
113 (self.ucs_value * self.ulen).encode('utf-8'))
114 # Check buffer lengths for scalars
115 if self.ucs_value == ucs4_value:
116 # In UCS2, the \U0010FFFF will be represented using a
117 # surrogate *pair*
118 assert_(buffer_length(ua_scalar) == 2 * 2 * self.ulen)
119 else:
120 # In UCS2, the \uFFFF will be represented using a
121 # regular 2-byte word
122 assert_(buffer_length(ua_scalar) == 2 * self.ulen)
123
124 def test_values0D(self):
125 # Check creation 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