Skip to content

Commit 5580ce0

Browse files
committed
Fix voxel parsing for template terms
- Fix CoordinatesFactory.from_json_string to handle voxel fields stored as JSON arrays - Resolves issue with get_term_info for template terms like VFB_00120000 - Ensures backward compatibility with existing coordinate formats
1 parent bd4ddeb commit 5580ce0

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/vfbquery/term_info_queries.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,15 @@ def from_list(float_list: List[float]) -> Coordinates:
4242

4343
@staticmethod
4444
def from_json_string(json_str: str) -> Coordinates:
45-
return Coordinates.from_json(json_str)
45+
# Parse the JSON string first
46+
parsed = json.loads(json_str)
47+
if isinstance(parsed, list) and len(parsed) > 0:
48+
# If it's a list, take the first element
49+
return Coordinates.from_json(json.dumps(parsed[0]))
50+
elif isinstance(parsed, dict):
51+
return Coordinates.from_json(json_str)
52+
else:
53+
raise ValueError(f"Invalid voxel format: {json_str}")
4654

4755
@staticmethod
4856
def from_json_string_list(json_str_list: List[str]) -> Coordinates:

0 commit comments

Comments
 (0)