Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_assign_properties_error(tet_ply_txt):
vertex = tet_ply_txt['vertex']
with Raises(ValueError) as e:
vertex.properties = (vertex.properties +
(PlyProperty('xx', 'i4'),))
assert str(e) == "dangling property 'xx'"
def test_element_parse_error_repr():
prop = PlyProperty('x', 'f4')
elt = PlyElement('test', [prop], 0)
e = PlyElementParseError('text', elt, 0, prop)
assert repr(e)
"{len_type} {val_type} {name}\"")
try:
properties.append(
PlyListProperty(fields[3], fields[1], fields[2])
)
except ValueError as e:
self._error(str(e))
else:
if len(fields) != 2:
self._error("expected \"property {type} {name}\"")
try:
properties.append(
PlyProperty(fields[1], fields[0])
)
except ValueError as e:
self._error(str(e))
'''
Write data to a binary stream.
'''
_write_array(stream, _np.dtype(self.dtype(byte_order)).type(data))
def __str__(self):
val_str = _data_type_reverse[self.val_dtype]
return 'property %s %s' % (val_str, self.name)
def __repr__(self):
return 'PlyProperty(%r, %r)' % (self.name,
_lookup_type(self.val_dtype))
class PlyListProperty(PlyProperty):
'''
PLY list property description.
'''
def __init__(self, name, len_dtype, val_dtype):
PlyProperty.__init__(self, name, val_dtype)
self.len_dtype = len_dtype
def _get_len_dtype(self):
return self._len_dtype
def _set_len_dtype(self, len_dtype):
self._len_dtype = _data_types[_lookup_type(len_dtype)]
if t[1][1] == 'O':
if len(t) != 2:
raise ValueError("non-scalar object fields not "
"supported")
len_str = _data_type_reverse[len_types.get(t[0], 'u1')]
if t[1][1] == 'O':
val_type = val_types.get(t[0], 'i4')
val_str = _lookup_type(val_type)
else:
val_str = _lookup_type(t[1][1:])
prop = PlyListProperty(t[0], len_str, val_str)
else:
val_str = _lookup_type(t[1][1:])
prop = PlyProperty(t[0], val_str)
properties.append(prop)
elt = PlyElement(name, properties, count, comments)
elt.data = data
return elt