-
Notifications
You must be signed in to change notification settings - Fork 18
Feature/525 detect empty lines #819
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
base: develop
Are you sure you want to change the base?
Feature/525 detect empty lines #819
Conversation
…tart. Raising warning only once for the excessive block
…ordusas/MontePy into feature/525-detect-empty-lines
…tart. Raising warning only once for the excessive block
…ordusas/MontePy into feature/525-detect-empty-lines
so the
I assume this is not the expected behaviour? the importance should have been missing in this test? |
There's a list of "bad" input files that should be excluded from that test in |
Yes the new input is part of "BAD_INPUTS" and i have added it there, thank you. I meant something else. the
The output adds an extra blank line before the importances in the data block:
|
Thanks for extracting that. That's definitely broken. So was this bug always in the tests, but now that warnings are being raised it's being flagged as an error? This might be related to #523? I think I might have seen this error before. Do you want to try and fix it, or open an issue and bug me to fix it? I'm going to convert this to a draft while this is figured out. |
Sure no problem. I think it's been there all the time, just now it raises warning due to the extra line present. |
Go for it. I just figured I probably created the bug, so it's not strictly your responsibility to fix it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for getting back to this @kordusas. Just one slight concern for now.
Obviously we have discussed the test suite issues. Let me know if you have questions.
I ran coverage locally and confirmed that you have 100% patch coverage:
montepy/input_parser/input_syntax_reader.py 115 1 99.13% 181
I think I fixed it, see if you approve. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to think more about how the line insertion error is handled. Also could you write up in the PR description
- the feature added, and how it works.
- The bug that is fixed, what is causing it, and how it was fixed.
Also CI failures is due to a 500 with coveralls that they are currently dealing with.
… 3 BLOCK is parsed
…ataInputAbstract if so then we can trigger writting CELL data into DATA BLOCK if the flags are set
…ordusas/MontePy into feature/525-detect-empty-lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more thoughts; thanks for your patience. I'm still a bit skeptical with write_problem
functioning as desired, but I may need to just see it work to be convinced.
UndefinedBlock, | ||
stacklevel=6, | ||
) | ||
terminate_reading = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this will keep generating inputs until it hits a new block (which may never occur). I think it might be easiest to not have the flag, and rather just return right here? That may break some things, but the point would just terminate the generator early.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually have tried adding return, but as you mentioned it breakes some things.
There was an error parsing "26056". sly: Syntax error at line 12, token=NUMBER
Adding return doesn’t stop the parser cleanly — it just fails instead of continuing.
Is that the preferred behavior, or should we handle this case more gracefully?
This would create a lot of extra errors for every line of text in the 5th block, making messages less readible. Users may have things there on purpose since MCNP just doesnt read it.
Regarding the comment about “keep generating inputs until it hits a new block” — I’m not sure I fully understand what you mean by this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the comment about “keep generating inputs until it hits a new block” — I’m not sure I fully understand what you mean by this.
Right so it seems like when it finds an extra input it does:
- Flag it
- Create a warning
- check that flag only in
flush_block
, so it will continue to generate inputs until it needs to flush a block again
Looking into it I think raise StopIteration
will more cleanly terminate the generator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will try to look into this a bit more, just raise StopIteration
crashes the code. I think this shouldnt stop the python code from running.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm yeah. Interesting. I might play around with it a bit as well. This should work. That's how iterators are implemented. You just need a __next__
function that either gives the next item, or raise StopIterator
and then the for
loop should handle it. I wonder if something is causing the StopIterator
to raise multiple times? read_input_file
does use yield from
and I'm not sure how these things interact.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I understand the bug fix now, and am happy with it.
We don't need to add extra tests for that bug, because your previous commits showed that this new warning is very effective at finding this bug.
I think you will fix #703. Could you try to replicate this bug on your branch and see if you fixed it, and update the comments appropriately? |
Pull Request Checklist for MontePy
Description
TODO
Fixes #525
General Checklist
black
version 25.LLM Disclosure
Were any large language models (LLM or "AI") used in to generate any of this code?
Documentation Checklist
- [ ] For infrastructure updates, I have updated the developer's guide.- [ ] For significant new features, I have added a section to the getting started guide.Additional Notes for Reviewers
Ensure that:
📚 Documentation preview 📚: https://montepy--819.org.readthedocs.build/en/819/