-
Notifications
You must be signed in to change notification settings - Fork 7
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
Material Specifications: cannot unpack non-iterable ValueNode object #365
Comments
This seems like a bug most likely. MontePy should be able to handle a material definition as long as the parameters come at the end. So this should work
This syntax breaks it:
These object types that you are seeing are data types from the syntax tree. A bad syntax should be handled with syntax errors. So this is definitely odd. Could you provide an example made up material that causes this bug? |
Is the
|
No That looks like it should work. I'll have to look into this further. |
I've never used SLY so I'm just throwing ideas at the wall but is the issue possibly linked to |
That example code I just dropped in MontePy and it didn't have any issues as I suspected. Could you get us a stack trace and MWE? As for:
So Dynamic typing strikes again. Test I ran: In [1]: import montepy
In [2]: input = montepy.input_parser.mcnp_input.Input("""m1 1001.80c 0.33
...: 8016.80c 0.666667""".split("\n"), montepy.input_parser.block_type.BlockType.DATA)
In [3]: material = montepy.data_inputs.material.Material(input)
In [4]:
In [4]: material
Out[4]:
MATERIAL: 1 fractions: atom
H-1 (80c) 0.33
O-16 (80c) 0.666667 |
@MicahGale Ahah! Found the issue - I lied to you. I did not, in fact, supply the
|
@MicahGale By the way, are we adding of these to your unit tests (or maybe these aren't worthy)? |
So to confirm the problem is:
Yes I know this absolutely valid and can't believe I missed this as a test. So yes we will absolutely add this to our test suite. It is the expectation for any bug fixes. What I will usually do first is write/modify a test to replicate the bug. Ensure that it fails, then push that test to the PR so that way a record of the test failing is preserved. This just makes it nicer for the |
Error confirmed. Full stack trace: ---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[3], line 1
----> 1 material = montepy.data_inputs.material.Material(input)
File ~/dev/montepy/montepy/data_inputs/material.py:40, in Material.__init__(self, input)
38 set_atom_frac = False
39 isotope_fractions = self._tree["data"]
---> 40 for isotope_node, fraction in isotope_fractions:
41 isotope = Isotope(node=isotope_node)
42 fraction.is_negatable_float = True
TypeError: cannot unpack non-iterable ValueNode object |
@MicahGale How are material cards supposed to be formatted for MontePy to parse them? I keep getting the error in the subject line. When I inspect the
isotope_fractions
variable in\data_inputs\material.py
, it is aListNode
object containingValueNode
objects. For anyValueNode
object, I see no attribute that corresponds to the isotopic fraction (at least not one intuitively named). Additionally this object is non-iterable so the usage isn't correct either. Am I missing something?The text was updated successfully, but these errors were encountered: