Skip to content

Initialization of unlisted properties #11

@stvdwtt

Description

@stvdwtt

When one of the thermophysical properties isn't listed in the JSON file, you end up not initializing the properties correctly.

mistlib/core.py, Line 80-92:

        if (file == None):
            # Set all values to None
            self.name = None
            self.notes = None
            self.composition = None
            self.single_phase_properties = None

            for p in self.thermophysical_property_names:
                self.properties[p] = None

        else:
            # Call the load from file method
            self.load_json(file)

If you try to run mat.write_markdown("export.md") after loading the JSON in the ramen example problem, then you get the following error.

Traceback:

Traceback (most recent call last): 
File "AlCu_eutectic_spacing_pdf.py", line 17, in <module> 
   mat.write_pdf(file)
File "c:\users\ygk\dev\mist\mistlib\core.py", line 273, in write_pdf 
   self.write_markdown(temp_md_file)
File "c:\users\ygk\dev\mist\mistlib\core.py", line 224, in write_markdown
   next_ref = self.properties[p].reference                                                             
KeyError: 'density'

Further errors in that code block would be thrown at print_name_str = self.properties[p].print_name and anywhere else that tries to access properties[p] for a value of p that was not initialized.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions