idaholab / MontePy

MontePy is the most user friendly Python library (API) to read, edit, and write MCNP input files.
https://www.montepy.org/
MIT License
27 stars 6 forks source link

Implementing Read Cards - [merged] #209

Closed MicahGale closed 8 months ago

MicahGale commented 2 years ago

Merges issue5ReadCard -> develop

MicahGale commented 2 years ago

changed target branch from main to develop

MicahGale commented 2 years ago

added 2 commits

Compare with previous version

MicahGale commented 2 years ago

added 1 commit

Compare with previous version

MicahGale commented 2 years ago

added 2 commits

Compare with previous version

MicahGale commented 2 years ago

added 3 commits

Compare with previous version

MicahGale commented 2 years ago

In GitLab by @tjlaboss on Jan 24, 2022, 17:51

Commented on mcnpy/input_parser/input_syntax_reader.py line 65

def read_data(fh, block_type: int=None, recursion=False):

Docstring needs to include block_type and recursion.

MicahGale commented 2 years ago

In GitLab by @tjlaboss on Jan 24, 2022, 17:51

Commented on mcnpy/input_parser/input_syntax_reader.py line 143

I think this will work as written. Let's verify that with a test case at least 3 files deep.

MicahGale commented 2 years ago

In GitLab by @tjlaboss on Jan 24, 2022, 17:51

Commented on mcnpy/input_parser/mcnp_input.py line 39

        self._words = words
        self._block_type = block_type

Misuse of private variables. Only use double underscore if children should not have access to these attributes. Otherwise, use single-underscore for private variables.

MicahGale commented 2 years ago

In GitLab by @tjlaboss on Jan 24, 2022, 17:51

Commented on mcnpy/input_parser/mcnp_input.py line 74

        self._words = card.words
        self._block_type = card.block_type

Don't use name mangling except for debugging.

MicahGale commented 2 years ago

In GitLab by @tjlaboss on Jan 24, 2022, 17:51

Commented on mcnpy/input_parser/mcnp_input.py line 70

I don't understand the inheritance here: if ReadCard is a Card, why not keep its parent's __init__?

MicahGale commented 2 years ago

In GitLab by @tjlaboss on Jan 24, 2022, 17:51

Commented on mcnpy/mcnp_problem.py line 250

        self.__surfaces += surfaces
        self.__materials += materials
        self.__data_cards += materials

Do these need to be double-underscore privates?

MicahGale commented 2 years ago

In GitLab by @tjlaboss on Jan 24, 2022, 17:53

The recursive read function looks good on inspection. I'll have to play around with a test case and see if it behaves as expected.

The suggested changes are primarily on the use of private variables.

MicahGale commented 2 years ago

You mean having three levels of files having read cards?

I really need to start a testing plan. Is integration testing the main way to go?

MicahGale commented 2 years ago

Yes I learned this the hard way with subclassing. At this point it's just Protected right?

MicahGale commented 2 years ago

The goal with the init is to extract the filename. I'm not tackling this the best way I agree. Are you suggesting the same function signature and then using super?

MicahGale commented 2 years ago

You saw right through my first attempt at private variables ever.

MicahGale commented 2 years ago

In GitLab by @tjlaboss on Jan 25, 2022, 11:57

Commented on mcnpy/input_parser/mcnp_input.py line 70

Yes.

MicahGale commented 2 years ago

In GitLab by @tjlaboss on Jan 25, 2022, 12:01

Commented on mcnpy/input_parser/mcnp_input.py line 39

Essentially yes. Python doesn't officially use Private/Protected terminology.

MicahGale commented 2 years ago

In GitLab by @tjlaboss on Jan 25, 2022, 12:03

Generally speaking, I always use single-underscores for _private variables. It's pretty rare when something needs to be name-mangled __private.

MicahGale commented 2 years ago

In GitLab by @tjlaboss on Jan 25, 2022, 12:07

Commented on mcnpy/input_parser/input_syntax_reader.py line 143

Right. File 1 reads File 2, which reads File 3.

Good practice is to start with unit tests. I am ~sometimes~ usually lazy and start with just one big integration test, filling in the unit tests once it starts working.

MicahGale commented 2 years ago

added 1 commit

Compare with previous version

MicahGale commented 2 years ago

marked this merge request as ready

MicahGale commented 2 years ago

block type is actually an enum, noted.

MicahGale commented 2 years ago

In GitLab by @tjlaboss on Feb 19, 2022, 11:20

This needs !6. Let's apply that and then merge.

MicahGale commented 2 years ago

This is covered by tests.test_integration.test_read_card_recursion in !11.

MicahGale commented 2 years ago

And I think !6 needs !8 and !10 to merge safely. So I'm thinking: !10 + !8 -> !6 -> !4.

MicahGale commented 2 years ago

I think this should be covered now.

MicahGale commented 2 years ago

Covered by !6.

MicahGale commented 2 years ago

Should be included in !6

MicahGale commented 2 years ago

changed this line in version 7 of the diff

MicahGale commented 2 years ago

changed this line in version 7 of the diff

MicahGale commented 2 years ago

changed this line in version 7 of the diff

MicahGale commented 2 years ago

added 33 commits

Compare with previous version

MicahGale commented 2 years ago

added 29 commits

Compare with previous version

MicahGale commented 2 years ago

changed this line in version 9 of the diff

MicahGale commented 2 years ago

changed this line in version 9 of the diff

MicahGale commented 2 years ago

added 13 commits

Compare with previous version

MicahGale commented 2 years ago

added 1 commit

Compare with previous version

MicahGale commented 2 years ago

added 1 commit

Compare with previous version

MicahGale commented 2 years ago

Is this resolved by: 6bda4b48?

MicahGale commented 2 years ago

Resolved by !6 and 3fb99a0.

MicahGale commented 2 years ago

mentioned in commit f5ba9b44bba752d4da5230e06f09107972ac7632