-
Notifications
You must be signed in to change notification settings - Fork 932
Closed
Labels
Description
pymatgen/pymatgen/analysis/chemenv/coordination_environments/structure_environments.py
Line 1630 in 7a51c9b
| ce_dict["permutation"] = ce_and_neighbors["ce_dict"]["permutation"] |
The following code exits with a fairly cryptic error message:
from pymatgen.analysis.bond_valence import BVAnalyzer
from pymatgen.analysis.chemenv.coordination_environments.chemenv_strategies import SimplestChemenvStrategy
from pymatgen.analysis.chemenv.coordination_environments.coordination_geometry_finder import LocalGeometryFinder
from pymatgen.analysis.chemenv.coordination_environments.structure_environments import LightStructureEnvironments
from pymatgen.analysis.chemenv.utils.defs_utils import AdditionalConditions
#oxides = mp_icsd_query("Q0tUKnAE52sy7hVO", experimental_data = True)
#structure = oxides[1270]['structure']
from pymatgen.ext.matproj import MPRester
mid = 'mp-554015'
with MPRester("Q0tUKnAE52sy7hVO") as m:
structure = m.get_structure_by_material_id(mid, conventional_unit_cell=True)
strategy = SimplestChemenvStrategy(distance_cutoff=1.4, angle_cutoff=0.3)
bv = BVAnalyzer()
oxid_states = bv.get_valences(structure)
lgf = LocalGeometryFinder()
lgf.setup_structure(structure = structure)
se = lgf.compute_structure_environments(only_cations = True, valences = oxid_states, additional_conditions = [AdditionalConditions.ONLY_ANION_CATION_BONDS])
# BUG:
lse = LightStructureEnvironments.from_structure_environments(strategy = strategy, structure_environments = se)
# Traceback (most recent call last):
# File ".../pymatgen/analysis/chemenv/coordination_environments/structure_environments.py", line 1630, in from_structure_environments
# ce_dict["permutation"] = ce_and_neighbors["ce_dict"]["permutation"]
# TypeError: 'NoneType' object is not subscriptableThe following checks should be included (with appropriate error handling):
for isite, site in enumerate(structure):
site_ces_and_nbs_list = strategy.get_site_ce_fractions_and_neighbors(site, strategy_info=True)
# Fix 1: Check if site_ces_and_nbs_list is None
if site_ces_and_nbs_list is not None:
for ce_and_neighbors in site_ces_and_nbs_list:
# Fix 2: Check if ce_dict is None or ce_symbol is 'UNKNOWN:14'
if ce_and_neighbors['ce_dict'] is not None:
# Now we can safely access 'permuation'
print(ce_and_neighbors['ce_dict']['permutation'])Reactions are currently unavailable