Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: fix the hnswlib tests
Signed-off-by: Joan Fontanals Martinez <[email protected]>
  • Loading branch information
Joan Fontanals Martinez committed Jul 31, 2023
commit 46bcf5a5cf02f9c4d1c78debfe3d01a0c35e39da
13 changes: 0 additions & 13 deletions docarray/index/backends/elasticv7.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,6 @@ def execute_query(self, query: Dict[str, Any], *args, **kwargs) -> Any:
# Helpers #
###############################################

# ElasticSearch helpers
def _create_index_mapping(self, col: '_ColumnInfo') -> Dict[str, Any]:
"""Create a new HNSW index for a column, and initialize it."""

index = col.config.copy()
if 'type' not in index:
index['type'] = col.db_type

if col.db_type == 'dense_vector' and col.n_dim:
index['dims'] = col.n_dim

return index

def _form_search_body(self, query: np.ndarray, limit: int, search_field: str = '') -> Dict[str, Any]: # type: ignore
body = {
'size': limit,
Expand Down
2 changes: 1 addition & 1 deletion docarray/index/backends/hnswlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(self, db_config=None, **kwargs):
sub_docs_exist = True
if safe_issubclass(col.docarray_type, AnyDocArray):
continue
if not col.config:
if not col.config or 'dim' not in col.config:
# non-tensor type; don't create an index
continue
if not load_existing and (
Expand Down
16 changes: 8 additions & 8 deletions tests/index/base_classes/test_base_doc_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def test_create_columns():
assert index._column_infos['id'].docarray_type == ID
assert index._column_infos['id'].db_type == str
assert index._column_infos['id'].n_dim is None
assert index._column_infos['id'].config == {'hi': 'there'}
assert index._column_infos['id'].config['hi'] == 'there'

assert issubclass(index._column_infos['tens'].docarray_type, AbstractTensor)
assert index._column_infos['tens'].db_type == str
Expand All @@ -171,7 +171,7 @@ def test_create_columns():
assert index._column_infos['id'].docarray_type == ID
assert index._column_infos['id'].db_type == str
assert index._column_infos['id'].n_dim is None
assert index._column_infos['id'].config == {'hi': 'there'}
assert index._column_infos['id'].config['hi'] == 'there'

assert issubclass(index._column_infos['tens_one'].docarray_type, AbstractTensor)
assert index._column_infos['tens_one'].db_type == str
Expand All @@ -190,7 +190,7 @@ def test_create_columns():
assert index._column_infos['id'].docarray_type == ID
assert index._column_infos['id'].db_type == str
assert index._column_infos['id'].n_dim is None
assert index._column_infos['id'].config == {'hi': 'there'}
assert index._column_infos['id'].config['hi'] == 'there'

assert issubclass(index._column_infos['d__tens'].docarray_type, AbstractTensor)
assert index._column_infos['d__tens'].db_type == str
Expand All @@ -214,7 +214,7 @@ def test_create_columns():
assert index._subindices['d']._column_infos['id'].docarray_type == ID
assert index._subindices['d']._column_infos['id'].db_type == str
assert index._subindices['d']._column_infos['id'].n_dim is None
assert index._subindices['d']._column_infos['id'].config == {'hi': 'there'}
assert index._subindices['d']._column_infos['id'].config['hi'] == 'there'

assert issubclass(
index._subindices['d']._column_infos['tens'].docarray_type, AbstractTensor
Expand Down Expand Up @@ -262,10 +262,10 @@ def test_create_columns():
assert (
index._subindices['d_root']._subindices['d']._column_infos['id'].n_dim is None
)
assert index._subindices['d_root']._subindices['d']._column_infos['id'].config == {
'hi': 'there'
}

assert (
index._subindices['d_root']._subindices['d']._column_infos['id'].config['hi']
== 'there'
)
assert issubclass(
index._subindices['d_root']
._subindices['d']
Expand Down