Skip to content

PwOutput.get_output: improve error message for incorrect name #121

@mbercx

Description

@mbercx

Running

from qe_tools.outputs import PwOutput

pw_out = PwOutput.from_dir('/Users/mbercx/project/qetools/jupyter/dos_dir/collinear')
structure = pw_out.get_output('incorrect')

only gives a generic KeyError:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[14], [line 4](vscode-notebook-cell:?execution_count=14&line=4)
      1 from qe_tools.outputs import PwOutput
      3 pw_out = PwOutput.from_dir('/Users/mbercx/project/qetools/jupyter/dos_dir/collinear')
----> [4](vscode-notebook-cell:?execution_count=14&line=4) structure = pw_out.get_output('incorrect')

File ~/project/qetools/git-repos/qe-tools/src/qe_tools/outputs/base.py:41, in BaseOutput.get_output(self, name, to)
     28 def get_output(self, name: str, to=None):
     29     """Return a parsed output by key, optionally converted to a library object.
     30 
     31     Args:
   (...)     39         >>> parser.get_output(name="structure", to="pymatgen")
     40     """
---> [41](https://file+.vscode-resource.vscode-cdn.net/Users/mbercx/project/qetools/jupyter/~/project/qetools/git-repos/qe-tools/src/qe_tools/outputs/base.py:41)     output_data = glom(self.raw_outputs, self._output_spec_mapping[name])
     43     if to is None:
     44         return output_data

KeyError: 'incorrect'

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