Skip to content

Add CI | Fix '(array (signed-byte 8)) is not of type (array (signed-byte *))' #7

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

digikar99
Copy link
Contributor

@digikar99 digikar99 commented Dec 30, 2020

As mentioned here and evident with this commit, #6 was not good!

Here's another attempt - tests included this time!

I was also playing around with OpenCV via py4cl2 and the current fixes seem okay. Check the tests! CCL fails on (signed-byte 64) case though. (See this.)

@marcoheisig
Copy link
Owner

I have incorporated your changes (after simplifying the test-suite a bit). But I am not sure I want to use the Github CI. Not because I don't want to have CI, but because I don't want to have a .github directory in my repository.

I will think some more about how this CI issue can be solved gracefully.

Thanks for writing a test suite!

@digikar99
Copy link
Contributor Author

digikar99 commented Jan 8, 2021

Hmm, the given test suite turns out to be non-exhaustive. I had added this part because the floats are actually encoded as (unsigned-byte 32) rather than (signed-byte 32). But the same logic should be applicable to (complex single-float) and (complex double-float).

And indeed, this fails

(store-array (make-array 1 :initial-element #c(-1.0e15 0)
                         :element-type '(complex single-float))
             "/tmp/nff")

So, the overall logic for stream-element-type should be:

(if (or (member element-type '(single-float double-float
                               (complex single-float)
                               (complex double-float))
                :test #'equal) ; might require type= some other time
        (subtypep element-type '(unsigned-byte *)))
    `(unsigned-byte ,chunk-size)
    `(signed-byte ,chunk-size))

Alternatively, the tests pass (they shouldn't pass!) even if stream-element-type was given solely by

(if (subtypep element-type '(unsigned-byte *))
    `(unsigned-byte ,chunk-size)
    `(signed-byte ,chunk-size))

So, the tests for complex/floats should involve numbers like -1e15 and -1d15 that are not of type (signed-byte 32) and (signed-byte 64) respectively.


Could add something that says this in a comment:

Intuitively, it feels as if a simpler logic should be applicable, but can't think of any at the moment. Prime reasoning seems to be

  • Even if the element-type is not unsigned, we need the stream to be unsigned in the case of complex/floats. So, an approach that simply checks for (not (subtypep element-type '(unsigned-byte *))) fails, since this does not account for element-type being a complex/float.
  • Another approach that'd check for (subtypep element-type '(signed-byte *)) also fails because (unsigned-byte *) is a subtype of (signed-byte *), so this path would be taken regardless of whether element-type is a signed-byte or unsigned-byte.

And, TIL uiop:with-temporary-file!

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.

2 participants