Skip to content

Commit

Permalink
Merge pull request #1337 from Sage-Bionetworks/develop-cross-validati…
Browse files Browse the repository at this point in the history
…on-error

Resolved issues with cross-manifest validation that occured when a manifest was only a single row
  • Loading branch information
GiaJordan authored Dec 11, 2023
2 parents 7f5fd6d + 8f2885c commit 4a6346e
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions schematic/utils/validate_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from schematic import LOADER
from typing import List
import numpy as np
from numbers import Number

def validate_schema(schema):
"""Validate schema against schema.org standard"""
Expand Down Expand Up @@ -75,11 +76,22 @@ def np_array_to_str_list(np_array):
return np.char.mod('%d', np_array).tolist()

def iterable_to_str_list(iterable):
"Parse an iterable into a list of strings"
strlist = []
"""
Parse an object into a list of strings
Accepts str, Number, and iterable inputs
"""

for element in iterable:
strlist.append(str(element))
# If object is a string, just return wrapped as a list
if isinstance(iterable, str):
return [iterable]
# If object is numberical, convert to string and wrap as a list
elif isinstance(iterable, Number):
return [str(iterable)]
# If the object is iterable and not a string, convert every element to string and wratp as a list
else:
strlist = []
for element in iterable:
strlist.append(str(element))

return strlist

0 comments on commit 4a6346e

Please sign in to comment.