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

Correct openmc.Geometry initializer to accept iterables of openmc.Cell #3081

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

johvincau
Copy link
Contributor

@johvincau johvincau commented Jul 10, 2024

Description

In #3079, it was pointed out that the openmc.Geometry constructor should accept an optional object of either openmc.Universe or Iterable[openmc.Cell], but was coded only to accept the former.

Quick Fix

With PEP 604, we can change Optional[type] = None to the no-strings-attached alternate form type | None = None made available in Python 3.10+. Since | is also another way to express typing.Union[], it's easy enough to add the other needed case for openmc.Geometry.

In any case, in the rest of the codebase, the Optional[type] syntax appears 163 more times. It shouldn't be too difficult to refactor all of that into type | None = None for conciseness and readability, though that's probably for a different PR.

Checklist

  • I have performed a self-review of my own code
  • I have run clang-format (version 15) on any C++ source files (if applicable)
  • I have followed the style guidelines for Python source files (if applicable)
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

Copy link
Contributor

@paulromano paulromano left a comment

Choose a reason for hiding this comment

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

Thanks @johvincau! If you are interested in making the change from Optional[x] to x | None elsewhere, that would be great but definitely should be a separate PR.

@paulromano paulromano enabled auto-merge (squash) July 10, 2024 21:00
@paulromano paulromano merged commit cbec1ab into openmc-dev:develop Jul 10, 2024
15 checks passed
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