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

Python bindings: usability improvements #4979

Closed
jmarrec opened this issue Sep 22, 2023 · 0 comments · Fixed by #4987
Closed

Python bindings: usability improvements #4979

jmarrec opened this issue Sep 22, 2023 · 0 comments · Fixed by #4987

Comments

@jmarrec
Copy link
Collaborator

jmarrec commented Sep 22, 2023

Enhancement Request

  • Add a __bool__ method for optionals

__bool__

#ifndef SWIGPYTHON
operator bool() const;
#endif

test for it:

import openstudio


def test_optional_not_initialized():
    d = openstudio.OptionalDouble()
    assert not d.is_initialized()
    assert not bool(d)


def test_optionalinitialized():
    d = openstudio.OptionalDouble(10.0)
    assert d.is_initialized()
    assert bool(d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant