def merge(self, rhs, lhs_filter=None, rhs_filter=None):
if lhs_filter or rhs_filter:<EOL><INDENT>get_ = self.get___method<EOL>set_ = self.set___method<EOL>max_value = _madoka.Sketch_max_value(self)<EOL>for table_id in range(self.depth):<EOL><INDENT>for cell_id in range(self.width):<EOL><INDENT>lhs_val = get_(self, table_id, cell_id)<EOL>rhs_val = get_(rhs, table_id, cell_id)<EOL>if lhs_filter:<EOL><INDENT>lhs_val = lhs_filter(lhs_val)<EOL><DEDENT>if rhs_filter:<EOL><INDENT>rhs_val = rhs_filter(rhs_val)<EOL><DEDENT>if (lhs_val >= max_value) or (rhs_val >= (max_value - lhs_val)):<EOL><INDENT>lhs_val = self.max_value<EOL><DEDENT>else:<EOL><INDENT>lhs_val += rhs_val<EOL><DEDENT>set_(self, table_id, cell_id, lhs_val)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>self.merge_method(self, rhs)<EOL>if rhs.k:<EOL><INDENT>for (key, val) in rhs.most_common(rhs.k):<EOL><INDENT>self._update(key, val)<EOL><DEDENT><DEDENT><DEDENT>
Merge two sketches
        Params:
            <Sketch> sketch
            <lambda> | <function> lhs_filter
            <lambda> | <function> rhs_filter