Skip to content

Commit

Permalink
Return <invalid> for failed simple conversion of complex values
Browse files Browse the repository at this point in the history
  • Loading branch information
druzsan committed Oct 25, 2023
1 parent bec3597 commit 6d53da2
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions renumics/spotlight/dtypes/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
import trimesh
import PIL.Image
import validators
from renumics.spotlight import dtypes

from renumics.spotlight import dtypes
from renumics.spotlight.typing import PathOrUrlType, PathType
from renumics.spotlight.cache import external_data_cache
from renumics.spotlight.io import audio
Expand Down Expand Up @@ -221,15 +221,19 @@ def convert_to_dtype(
except (TypeError, ValueError) as e:
if check:
raise ConversionFailed(value, dtype) from e
else:
return None

if check:
if last_conversion_error:
raise ConversionFailed(value, dtype, last_conversion_error.reason)
else:
else:
if check:
if last_conversion_error:
raise ConversionFailed(value, dtype, last_conversion_error.reason)
raise NoConverterAvailable(value, dtype)

if simple and (
dtypes.is_array_dtype(dtype)
or dtypes.is_embedding_dtype(dtype)
or dtypes.is_sequence_1d_dtype(dtype)
or dtypes.is_filebased_dtype(dtype)
):
return "<invalid>"
return None


Expand Down

0 comments on commit 6d53da2

Please sign in to comment.