From 70b2f968f830d72ac727c982d43a4d0109907cd1 Mon Sep 17 00:00:00 2001 From: Paul Cosgrove Date: Thu, 27 Feb 2020 12:50:44 +0000 Subject: [PATCH] Even more elegant error check on element names --- openmc/material.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openmc/material.py b/openmc/material.py index 2bb461b02..d6147b341 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -530,9 +530,8 @@ class Material(IDManagerMixin): # Allow for element identifier to be given as a symbol or name if len(element)>2: el = element.lower() - if el in openmc.data.ELEMENT_SYMBOL: - element = openmc.data.ELEMENT_SYMBOL[el] - else: + element = openmc.data.ELEMENT_SYMBOL.get(el) + if element is None: msg = 'Element name "{}" not recognised'.format(el) raise ValueError(msg)