Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Koncopd committed Nov 21, 2024
1 parent f552106 commit 05474a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions lamin_utils/_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def search(
import pandas as pd
from pandas.api.types import is_object_dtype, is_string_dtype

if len(df) == 0:
return df

fields_convert = {}
if field is None:
fields = df.columns.to_list()
Expand Down
8 changes: 4 additions & 4 deletions tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def df():

def test_search_synonyms(df):
res = search(df=df, string="P cell")
assert res.iloc[0].name == "nodal myocyte"
assert res.iloc[0]["name"] == "nodal myocyte"

# search in name, without synonyms search
res = search(df=df, string="P cell", field="name")
assert res.iloc[0].name == "PP cell"
assert res.iloc[0]["name"] == "PP cell"


def test_search_limit(df):
Expand All @@ -51,12 +51,12 @@ def test_search_limit(df):
def test_search_return_df(df):
res = search(df=df, string="P cell")
assert res.shape == (2, 4)
assert res.iloc[0].name == "nodal myocyte"
assert res.iloc[0]["name"] == "nodal myocyte"


def test_search_pass_fields(df):
res = search(df=df, string="type F enteroendocrine", field=["synonyms", "children"])
assert res.iloc[0].synonyms == "type F enteroendocrine cell"
assert res.iloc[0]["synonyms"] == "type F enteroendocrine cell"


def test_search_case_sensitive(df):
Expand Down

0 comments on commit 05474a7

Please sign in to comment.