Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow differentiating between lossy and lossless object conversion #288

Open
imagejan opened this issue Aug 28, 2017 · 2 comments
Open

Allow differentiating between lossy and lossless object conversion #288

imagejan opened this issue Aug 28, 2017 · 2 comments

Comments

@imagejan
Copy link
Member

Currently we can ask ConvertService whether a certain conversion is supported via:

convertService.supports(sourceObject, targetType)

It would be great to have some possibility to differentiate what degree of conversion is desired:

  • Conversion from any Object to String is possible (via toString()) but rarely lossless. Even for bidirectional cases like (File to String) and (String to File), this can be lossless but not always desired.
  • When running a script that has an Img input, but no image is currently available, we might ask the user to supply a File instead to then load the image from file. This (File to Img) conversion won't always work, but it would be nice if some service would support it in a failure-tolerant way upon request.

How about introducing different 'modes' of conversion, like STRICT, FLEXIBLE and INSISTENT?

@imagejan
Copy link
Member Author

imagejan commented Aug 8, 2018

The lossy conversion from Dataset (or, in general, from any Object) to String is currently preventing me from providing a useful batch processing for Dataset, Img etc.: any module accepting String inputs will be recognized as "batchable", which is almost never what you want.

@imagejan
Copy link
Member Author

Knowledge about "lossiness" of a conversion would also be useful to allow choice of the best possible column type when post-processing module outputs, see scijava/scijava-table#5.

DoubleType -> DoubleColumn
double -> DoubleColumn
UnsignedByteType -> IntColumn
UnsignedIntType -> LongColumn
etc.

Currently I don't know a way to decide this, because ConvertService supports e.g. double to int conversion without complaining.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant