-
Notifications
You must be signed in to change notification settings - Fork 8
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
Report orphaned objects #128
Comments
In GitLab by @tjlaboss on Feb 3, 2023, 12:48 unused = {s for s in problem.surfaces if not len(s.cells)} |
To research: if generator yields nothing is that falsey? |
In GitLab by @tjlaboss on Feb 3, 2023, 12:55 Yes |
Nope in my testing it's truthy: test = []
def func():
for val in test:
yield val
bool(func()) is True, but |
In GitLab by @tjlaboss on Feb 3, 2023, 13:01 Whoa, I guess it only works for |
Right so thinking about it more it makes complete sense. Iterators in python are super basic. They only need to implement |
So this raises a new longer but funner way to do things: unused = set()
for surface in problem:
try:
next(surface.cells)
except StopIteration:
unused.add(surface) |
Upon further inspection I don't know if a Generator is every falsy with codespace from above test I did: >>> handle = func()
>>> bool(handle)
True
>>> next(handle)
.... STopIteration
>>> bool(handle)
True. |
Back on topic: thoughts on the proposed function signature? |
In GitLab by @bascandr on Feb 3, 2023, 13:58 Let's take a second to think about what these unused objects could be:
|
I'm nervous about universes though, because it would meaning shifting a lot of things out into a new universe (0) that wasn't expecting it. Very good point about materials. I'm thinking only support objects once MCNPy can parse all dependent use cases. |
In GitLab by @bascandr on Feb 3, 2023, 16:28 The universes may need to just start out as an identify only type of thing. I still want a tool for figuring out what may be safe to delete, but the process of modifying them is more complex. The surface use of transforms is one of the things that really slowed me down this week. Any tool that can recognize (and replace) these would be helpful. |
So first, I think this function should never just delete them, just ID them. How would you replace them though? Kind of by definition they shouldn't need to be replaced. |
In GitLab by @bascandr on Feb 6, 2023, 13:05 In the case of some of these older ATR models, I would consider either renumbering them to reclaim the universe numbers or deleting them and reclaiming the cell/surface numbers that they contain. |
Create a tool to quickly see objects such as transforms, materials, surfaces.
In the immediate create a tips and tricks for this hack:
Proposed solution in MCNP_Problem:
@bascandr
The text was updated successfully, but these errors were encountered: