def foreign_key_is_in_primary_key(primary_key, foreign_key): val._check_is_reader_or_ndarray('primary_key', primary_key) val._check_is_reader_or_ndarray('foreign_key', foreign_key) if isinstance(primary_key, rw.Reader): pk = primary_key[:] else: pk = primary_key if isinstance(foreign_key, rw.Reader): fk = foreign_key[:] else: fk = foreign_key result = np.zeros(len(fk), dtype=bool) return _filter_non_orphaned_foreign_keys(pk, fk, result)
def get_spans(self, field=None, fields=None): if field is None and fields is None: raise ValueError("One of 'field' and 'fields' must be set") if field is not None and fields is not None: raise ValueError("Only one of 'field' and 'fields' may be set") raw_field = None raw_fields = None if field is not None: val._check_is_reader_or_ndarray('field', field) raw_field = field[:] if isinstance(field, rw.Reader) else field return ops.get_spans_for_field(raw_field) else: raw_fields = [] for f in fields: val._check_is_reader_or_ndarray('elements of tuple/list fields', f) raw_fields.append(f[:] if isinstance(f, rw.Reader) else f) return ops._get_spans_for_2_fields(raw_fields[0], raw_fields[1])
def apply_spans_index_of_max(self, spans, reader, writer=None): val._check_is_reader_or_ndarray('reader', reader) val._check_is_reader_or_ndarray_if_set('writer', reader) if isinstance(reader, rw.Reader): raw_reader = reader[:] else: raw_reader = reader if writer is not None: if isinstance(writer, rw.Writer): raw_writer = writer[:] else: raw_writer = writer else: raw_writer = np.zeros(len(spans)-1, dtype=np.int64) _apply_spans_index_of_max(spans, raw_reader, raw_writer) if isinstance(writer, rw.Writer): writer.write(raw_writer) else: return raw_writer