collections.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码
def __init__(self, collection_names, collection_labels=None, file_names=None, field_names=None):
        # load the collections
        if isinstance(collection_names,types.StringTypes):
            collection_names = [ collection_names ]
        if collection_labels is None:
            collection_labels = [ None ] * len(collection_names)
        self._collections = [ Collection(name,label,file_names,field_names) \
                                for name,label in zip(collection_names,collection_labels) ]

        # find the set of common galaxies and the set of common properties
        if len(self._collections) > 1:
            self._ids = sorted(reduce(lambda x,y: x&y, [ c.galaxy_ids() for c in self._collections ]))
            self._props = reduce(lambda x,y: x&y, [ c.property_names() for c in self._collections ])
        else:
            self._ids = sorted(self._collections[0].galaxy_ids())
            self._props = self._collections[0].property_names()

        # print the number of common galaxies
        print "Loaded a set of {} collections with {} common galaxies and {} common properties" \
                    .format(len(self._collections), len(self._ids), len(self._props))

    ## This function returns a two-dimensional array with the values of the specified property for all common galaxies
    # in all collections of the set. The index on the first axis iterates over the collections, the index on the last
    # axis iterates over the galaxies, in order of increasing galaxy id.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号