Skip to content

Add codegen handling for infinity and NaN values. Make generic codege… #166

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

Merged
merged 1 commit into from
May 20, 2021

Conversation

enragedginger
Copy link
Contributor

…n method a bit cleaner.

Copy link
Collaborator

@cnuernber cnuernber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is one more case, when the constant is a long integer. If that is handled elsewhere let me know and disregard.

(and (number? vv) (neg? vv) (Double/isInfinite vv)) "##-Inf"
;;Anything else should be derefed by name from Python
:else (format "(as-jvm/generic-pyobject (py-global-delay (py/get-attr @src-obj* \"%s\")))" k)
)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about long integers? Perhaps that first 'or' should also have (integer? vv).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check will handle longs:

;;Finite, non NAN numbers should be treated as literals
(and (number? vv) (Double/isFinite vv)) vv

Example:

(let [vv (long 1)]
  (and (number? vv) (Double/isFinite vv)))
=> true

Or should we output longs as something other than their literal values?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh perfect, I didn't realize Clojure would marshal the value in this case. OK, that is great.

@cnuernber cnuernber merged commit 9939ccf into clj-python:master May 20, 2021
@enragedginger enragedginger deleted the number-literals branch May 20, 2021 14:44
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