meta.py 文件源码

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

项目:gbdxtools 作者: DigitalGlobe 项目源码 文件源码
def __getattribute__(self, name):
        fn = object.__getattribute__(self, name)
        if(isinstance(fn, types.MethodType) and
           any(name in C.__dict__ for C in self.__class__.__mro__)):
            @wraps(fn)
            def wrapped(*args, **kwargs):
                result = fn(*args, **kwargs)
                if isinstance(result, da.Array) and len(result.shape) in [2,3]:
                    copy = super(DaskImage, self.__class__).__new__(self.__class__,
                                                                    result.dask, result.name, result.chunks,
                                                                    result.dtype, result.shape)
                    copy.__dict__.update(self.__dict__)
                    try:
                        copy.__dict__.update(result.__dict__)
                    except AttributeError:
                        # this means result was an object with __slots__
                        pass
                    return copy
                return result
            return wrapped
        else:
            return fn
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号