本文整理汇总了Python中libtbx.containers.OrderedDict.pop方法的典型用法代码示例。如果您正苦于以下问题:Python OrderedDict.pop方法的具体用法?Python OrderedDict.pop怎么用?Python OrderedDict.pop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libtbx.containers.OrderedDict
的用法示例。
在下文中一共展示了OrderedDict.pop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: miller_array_builder
# 需要导入模块: from libtbx.containers import OrderedDict [as 别名]
# 或者: from libtbx.containers.OrderedDict import pop [as 别名]
#.........这里部分代码省略.........
phase_key = label
key = alt_key2+key_suffix
else: phase_key = None
if phase_key is not None:
phases = array.data()
if key in self._arrays:
array = self._arrays[key]
array = as_flex_double(array, key)
check_array_sizes(array, phases, key, phase_key)
info = self._arrays[key].info()
self._arrays[key] = array.phase_transfer(phases, deg=True)
self._arrays[key].set_info(
info.customized_copy(labels=info.labels+[phase_key]))
else:
array = self.flex_std_string_as_miller_array(
refln_loop[label], wavelength_id=w_id, crystal_id=crys_id,
scale_group_code=scale_group)
check_array_sizes(array, phases, key, phase_key)
array.phase_transfer(phases, deg=True)
labels = labels+[label, phase_key]
if base_array_info.labels is not None:
labels = base_array_info.labels + labels
def rstrip_substrings(string, substrings):
for substr in substrings:
if substr == '': continue
if string.endswith(substr):
string = string[:-len(substr)]
return string
# determine observation type
stripped_key = rstrip_substrings(
key, [key_suffix, '_au', '_meas', '_calc', '_plus', '_minus'])
if (stripped_key.endswith('F_squared') or
stripped_key.endswith('intensity') or
stripped_key.endswith('.I') or
stripped_key.endswith('_I')) and (
array.is_real_array() or array.is_integer_array()):
array.set_observation_type_xray_intensity()
elif (stripped_key.endswith('F') and (
array.is_real_array() or array.is_integer_array())):
array.set_observation_type_xray_amplitude()
if (array.is_xray_amplitude_array() or
array.is_xray_amplitude_array()):
# e.g. merge_equivalents treats integer arrays differently, so must
# convert integer observation arrays here to be safe
if isinstance(array.data(), flex.int):
array = array.customized_copy(data=array.data().as_double())
array.set_info(base_array_info.customized_copy(labels=labels))
if (array.is_xray_amplitude_array() or
array.is_xray_amplitude_array()):
info = array.info()
array.set_info(info.customized_copy(wavelength=wavelength))
self._arrays.setdefault(key, array)
for key, array in self._arrays.copy().iteritems():
if ( key.endswith('_minus') or '_minus_' in key
or key.endswith('_plus') or '_plus_' in key):
if '_minus' in key:
minus_key = key
plus_key = key.replace('_minus', '_plus')
elif '_plus' in key:
plus_key = key
minus_key = key.replace('_plus', '_minus')
if plus_key in self._arrays and minus_key in self._arrays:
plus_array = self._arrays.pop(plus_key)
minus_array = self._arrays.pop(minus_key)
minus_array = minus_array.customized_copy(
indices=-minus_array.indices()).set_info(minus_array.info())
array = plus_array.concatenate(
minus_array, assert_is_similar_symmetry=False)
array = array.customized_copy(anomalous_flag=True)
array.set_info(minus_array.info().customized_copy(
labels=list(
OrderedSet(plus_array.info().labels+minus_array.info().labels))))
array.set_observation_type(plus_array.observation_type())
self._arrays.setdefault(key, array)
if len(self._arrays) == 0:
raise CifBuilderError("No reflection data present in cif block")
def get_miller_indices_containing_loops(self):
loops = []
for loop in self.cif_block.loops.values():
for key in loop.keys():
if 'index_h' not in key: continue
hkl_str = [loop.get(key.replace('index_h', 'index_%s' %i)) for i in 'hkl']
if hkl_str.count(None) > 0:
raise CifBuilderError(
"Miller indices missing from current CIF block (%s)"
%key.replace('index_h', 'index_%s' %'hkl'[hkl_str.index(None)]))
hkl_int = []
for i,h_str in enumerate(hkl_str):
try:
h_int = flex.int(h_str)
except ValueError, e:
raise CifBuilderError(
"Invalid item for Miller index %s: %s" % ("HKL"[i], str(e)))
hkl_int.append(h_int)
indices = flex.miller_index(*hkl_int)
loops.append((indices, loop))
break
return loops