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

Replace Doubles with Integers #7

Merged
merged 2 commits into from
Sep 22, 2021
Merged

Replace Doubles with Integers #7

merged 2 commits into from
Sep 22, 2021

Conversation

joshmoore
Copy link
Member

With this change (and finding a way to deal with the non-opening of directories) ome/ome_zarr_test_suite#16 passes for:

pytest -svxk create-reader

Without this change the error is:

ZarrReader initializing /private/var/folders/z5/txc_jj6x5l5cm81r56ck1n9c0000gn/T/pytest-of-jamoore/pytest-13/test_create_reader_0/ome_zarr_create.zarr/.zattrs
Exception in thread "main" java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.Double (java.lang.Integer and java.lang.Double are in module java.base of loader 'bootstrap')
	at loci.formats.in.ZarrReader.parseOmeroMetadata(ZarrReader.java:616)
	at loci.formats.in.ZarrReader.initFile(ZarrReader.java:223)
	at loci.formats.FormatReader.setId(FormatReader.java:1421)
	at loci.formats.ImageReader.setId(ImageReader.java:849)
	at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:650)
	at loci.formats.tools.ImageInfo.testRead(ImageInfo.java:1035)
	at loci.formats.tools.ImageInfo.main(ImageInfo.java:1121)
FAILED

============================================================== FAILURES ===============================================================
_________________________________________________________ test[create-reader] _________________________________________________________

source = <test_suite.GeneratedSource object at 0x1a39ff430>, suite = <test_suite.Suite object at 0x1a39ff670>

    def test(source: Source, suite: Suite) -> None:
        """
        Primary test matching all sources with all suites.
        """
        source.setup()
        try:
>           suite(source)

/Users/jamoore/opt/ome_zarr_test_suite/test_suite.py:195:

@joshmoore
Copy link
Member Author

Doh. And now testing on 6001240.zarr I get:

Initializing reader
Exception in thread "main" java.lang.ClassCastException: class java.lang.Double cannot be cast to class java.lang.Integer (java.lang.Double and java.lang.Integer are in module java.base of loader 'bootstrap')
	at loci.formats.in.ZarrReader.parseOmeroMetadata(ZarrReader.java:616)
	at loci.formats.in.ZarrReader.initFile(ZarrReader.java:223)
	at loci.formats.FormatReader.setId(FormatReader.java:1421)
	at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:650)
	at loci.formats.tools.ImageInfo.testRead(ImageInfo.java:1035)
	at loci.formats.tools.ImageInfo.main(ImageInfo.java:1121)

The JSON library sometimes returns a Double and sometimes
an Integer. Since we expect this field to be a double, we
forcefully cast.

see: https://stackoverflow.com/questions/21965828/why-double-is-converted-to-int-in-json-string/21965943
@dgault dgault merged commit 578bb27 into ome:main Sep 22, 2021
@joshmoore joshmoore deleted the fix-doubles branch September 22, 2021 11:13
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

Successfully merging this pull request may close these issues.

3 participants