Skip to content

Commit ca6c400

Browse files
authored
Merge pull request #269 from seequent/fix/slow_vector3array_validation
Fix slow vector3array validation
2 parents b2014e3 + fc425e7 commit ca6c400

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# -*- coding: utf-8 -*-
1+
# -*- coding: utf-8 -*-
22
#
33
# properties documentation build configuration file, created by
44
# sphinx-quickstart on Thu May 12 10:22:17 2016.

properties/math.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -418,15 +418,16 @@ def validate(self, instance, value):
418418
"""
419419
if not isinstance(value, (tuple, list, np.ndarray)):
420420
self.error(instance, value)
421-
for i, val in enumerate(value):
422-
if isinstance(val, string_types):
423-
if val.upper() not in VECTOR_DIRECTIONS:
424-
self.error(
425-
instance=instance,
426-
value=val,
427-
extra='This is an invalid Vector3 representation.',
428-
)
429-
value[i] = VECTOR_DIRECTIONS[val.upper()]
421+
if isinstance(value, (tuple, list)):
422+
for i, val in enumerate(value):
423+
if isinstance(val, string_types):
424+
if val.upper() not in VECTOR_DIRECTIONS:
425+
self.error(
426+
instance=instance,
427+
value=val,
428+
extra='This is an invalid Vector3 representation.',
429+
)
430+
value[i] = VECTOR_DIRECTIONS[val.upper()]
430431

431432
return super(Vector3Array, self).validate(instance, value)
432433

0 commit comments

Comments
 (0)