本文整理汇总了Python中astropy.utils.OrderedDict.fromkeys方法的典型用法代码示例。如果您正苦于以下问题:Python OrderedDict.fromkeys方法的具体用法?Python OrderedDict.fromkeys怎么用?Python OrderedDict.fromkeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astropy.utils.OrderedDict
的用法示例。
在下文中一共展示了OrderedDict.fromkeys方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _construct_ordered_GET
# 需要导入模块: from astropy.utils import OrderedDict [as 别名]
# 或者: from astropy.utils.OrderedDict import fromkeys [as 别名]
def _construct_ordered_GET(self):
"""
Construct a Global Edge Table (GET)
The GET is an OrderedDict. Keys are scan line numbers,
ordered from bbox.ymin to bbox.ymax, where bbox is the
bounding box of the polygon.
Values are lists of edges for which edge.ymin==scan_line_number.
Returns
-------
GET: OrderedDict
{scan_line: [edge1, edge2]}
"""
# edges is a list of Edge objects which define a polygon
# with these vertices
edges = self.get_edges()
GET = OrderedDict.fromkeys(self._scan_line_range)
ymin = np.asarray([e._ymin for e in edges])
for i in self._scan_line_range:
ymin_ind = (ymin == i).nonzero()[0]
if ymin_ind.any():
GET[i] = [edges[ymin_ind[0]]]
for j in ymin_ind[1:]:
GET[i].append(edges[j])
return GET