def mjcore ( z , c , niter , func , bound = 2 , bound_func = None ): if bound_func is not None : print ( 'Warning: bound_func not None. Ignoring r bound' ) M = zeros ( z . shape ) Mf = M . flat zf = z . flat cf = c . flat for _ in range ( niter ): if bound_func is not None : mask = find ( bound_func ( z )) else : mask = find ( abs ( z ) < bound ) Mf [ mask ] += 1 zf [ mask ] = func ( zf [ mask ], cf [ mask ]) Mf [ mask ] = 0 return M