Skip to content

Commit

Permalink
align isort with black
Browse files Browse the repository at this point in the history
  • Loading branch information
chayim committed Aug 31, 2023
1 parent 8dde72a commit 30c1179
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/doctests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
pip install -r dev_requirements.txt
pip install -r requirements.txt
pip install -r doctests/requirements.txt
isort --check-only --diff doctests/*.py
black --target-version py39 --check --diff doctests/*.py
isort i-l 80 --profile black --check-only --diff doctests/*.py
black -l 80 --target-version py39 --check --diff doctests/*.py
- name: run tests
run: |
Expand Down
12 changes: 9 additions & 3 deletions doctests/search_quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@
# REMOVE_END

# STEP_START query_single_term_limit_fields
res = index.search(Query("@model:Jigger").return_field("$.price", as_field="price"))
res = index.search(
Query("@model:Jigger").return_field("$.price", as_field="price")
)
print(res)
# >>> [Document {'id': 'bicycle:0', 'payload': None, 'price': '270'}]
# STEP_END
Expand Down Expand Up @@ -284,7 +286,9 @@

# STEP_START query_fuzzy_matching
res = index.search(
Query("@description:%analitics%").dialect( # Note the typo in the word "analytics"
Query(
"@description:%analitics%"
).dialect( # Note the typo in the word "analytics"
2
)
)
Expand All @@ -308,7 +312,9 @@

# STEP_START query_fuzzy_matching_level2
res = index.search(
Query("@description:%%analitycs%%").dialect( # Note 2 typos in the word "analytics"
Query(
"@description:%%analitycs%%"
).dialect( # Note 2 typos in the word "analytics"
2
)
)
Expand Down
27 changes: 21 additions & 6 deletions doctests/search_vss.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
import pandas as pd
import redis
import requests
from redis.commands.search.field import NumericField, TagField, TextField, VectorField
from redis.commands.search.field import (
NumericField,
TagField,
TextField,
VectorField,
)
from redis.commands.search.indexDefinition import IndexDefinition, IndexType
from redis.commands.search.query import Query
from sentence_transformers import SentenceTransformer
Expand Down Expand Up @@ -131,7 +136,9 @@
),
)
definition = IndexDefinition(prefix=["bikes:"], index_type=IndexType.JSON)
res = client.ft("idx:bikes_vss").create_index(fields=schema, definition=definition)
res = client.ft("idx:bikes_vss").create_index(
fields=schema, definition=definition
)
# >>> 'OK'
# STEP_END
# REMOVE_START
Expand Down Expand Up @@ -159,7 +166,8 @@
# REMOVE_START

assert all(
item in [x.__dict__["id"] for x in res] for item in ["bikes:008", "bikes:009"]
item in [x.__dict__["id"] for x in res]
for item in ["bikes:008", "bikes:009"]
)
# REMOVE_END

Expand All @@ -171,7 +179,8 @@
# STEP_END
# REMOVE_START
assert all(
item in [x.__dict__["id"] for x in res] for item in ["bikes:008", "bikes:009"]
item in [x.__dict__["id"] for x in res]
for item in ["bikes:008", "bikes:009"]
)
# REMOVE_END

Expand Down Expand Up @@ -221,7 +230,11 @@ def create_query_table(query, queries, encoded_queries, extra_params={}):
client.ft("idx:bikes_vss")
.search(
query,
{"query_vector": np.array(encoded_query, dtype=np.float32).tobytes()}
{
"query_vector": np.array(
encoded_query, dtype=np.float32
).tobytes()
}
| extra_params,
)
.docs
Expand Down Expand Up @@ -288,6 +301,8 @@ def create_query_table(query, queries, encoded_queries, extra_params={}):
.paging(0, 4)
.dialect(2)
)
create_query_table(range_query, queries[:1], encoded_queries[:1], {"range": 0.55})
create_query_table(
range_query, queries[:1], encoded_queries[:1], {"range": 0.55}
)
# >>> | Bike for small kids | 0.52 | bikes:001 | Velorim |... (+1 more result)
# STEP_END

0 comments on commit 30c1179

Please sign in to comment.