Skip to content

Allow convert nil to NaN when making Numo::DFloat #207

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mrkn
Copy link
Contributor

@mrkn mrkn commented Aug 28, 2022

Before

% irb -rnumo/narray
irb(main):001:0> Numo::DFloat[1, nil, 3]
(irb):1:in `[]': no implicit conversion to float from nil (TypeError)
        from (irb):1:in `<main>'
        from /Users/mrkn/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
        from /Users/mrkn/.rbenv/versions/3.1.2/bin/irb:25:in `load'
        from /Users/mrkn/.rbenv/versions/3.1.2/bin/irb:25:in `<main>'
irb(main):002:0> Numo::RObject[1, nil, 3].cast_to(Numo::DFloat)
(irb):2:in `cast': no implicit conversion to float from nil (TypeError)
        from (irb):2:in `cast_to'
        from (irb):2:in `<main>'
        from /Users/mrkn/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
        from /Users/mrkn/.rbenv/versions/3.1.2/bin/irb:25:in `load'
        from /Users/mrkn/.rbenv/versions/3.1.2/bin/irb:25:in `<main>'
irb(main):003:0>

After

% irb -Ilib -rnumo/narray
irb(main):001:0> Numo::DFloat[1, nil, 3]
=>
Numo::DFloat#shape=[3]
[1, nan, 3]
irb(main):002:0> Numo::RObject[1, nil, 3].cast_to(Numo::DFloat)
=>
Numo::DFloat#shape=[3]
[1, nan, 3]
irb(main):003:0>

TODO

  • Add test cases of Numo::SFloat

@mrkn mrkn marked this pull request as draft August 28, 2022 08:19
@mrkn mrkn force-pushed the allow_make_dfloat_with_nil branch from 8edd9b2 to 44f4a86 Compare August 28, 2022 08:23
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.

1 participant