@classmethod
    def add_numpy_methods(cls):
        # Binary operations
        npops = ["__add__", "__sub__", "__mul__", "__div__", "__pow__",
                 "__neg__", "__abs__"]

        def make_opfun(op): # function nesting creates closure containing op
            def opfun(self, *args):
                return self.copy(getattr(self.data, op)(*args))
            return opfun
        
        for op in npops:
            opfun = make_opfun(op)
            opfun.__name__ = op
            setattr(cls, opfun.__name__, opfun)
Adds numpy operator methods (+, -, etc.) to this class to allow
dataset/ETHPy150Open gallantlab/pycortex/cortex/dataset/braindata.py/BrainData.add_numpy_methods