Avoid converting objects when not necessary#60
Merged
Conversation
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. @@ Coverage Diff @@
## main #60 +/- ##
==========================================
+ Coverage 54.70% 55.72% +1.02%
==========================================
Files 11 11
Lines 1179 1213 +34
==========================================
+ Hits 645 676 +31
- Misses 534 537 +3
|
705307b to
010ffd3
Compare
This is accomplished by keeping the converters sorted by priority, then invoking them one by one in order until we find a working one. Co-authored-by: Gabriel Selzer <gjselzer@wisc.edu>
And make str(Converter) yield a representation helpful for debugging.
The DEBUG level is too granular for normal use. In particular, the message "The JVM is already running" appears many times when running in debug mode. We could change that message to print only in JPYPE mode, but I think INFO is a better fit for CI generally anyway.
010ffd3 to
3b5c27a
Compare
ctrueden
added a commit
to imagej/napari-imagej
that referenced
this pull request
Jul 25, 2023
And bump minimum scyjava version to 1.9.1. As of scyjava 1.9.1, the work from scijava/scyjava#60 is integrating, meaning such defensive checks around conversion are no longer necessary. This reverts commit 85f0d5c, titled "Work around jpype convert limitation", and closes #220. It also removes some other usages of isjava, which are also not needed.
ctrueden
added a commit
to imagej/napari-imagej
that referenced
this pull request
Jul 25, 2023
And bump minimum scyjava version to 1.9.1. As of scyjava 1.9.1, the work from scijava/scyjava#60 is integrated, meaning such defensive checks around conversion are no longer necessary. This reverts commit 85f0d5c, titled "Work around jpype convert limitation", and closes #220. It also removes some other usages of isjava, which are also not needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
to_pythonandto_javaassume that their arguments are in the other language. But, as described in imagej/napari-imagej#220,Converters have to defensively program against arguments that are already in the desired language.This PR does a sanity check on the argument to convert, ensuring that the argument to a
to_javacall is actually a python data structure, and that the argument to ato_pythoncall is actually a java data structure. When the argument is not, this change will save us a bit of computation at the least, and save us from some errors in more severe cases.