本文整理匯總了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