Skip to content

Commit 242b3fb

Browse files
committed
Addressed copilot comments
1 parent 59950ff commit 242b3fb

4 files changed

Lines changed: 18 additions & 4 deletions

File tree

docs/search_details.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ Basic search scales sub-linearly because vectorized regex amortises overhead acr
214214

215215
Per-string median search time (ms) across string sizes. Tag counts: tiny = 1, small = 5, medium = 10, large = 25, xlarge = 50, xxlarge = 100. Larger strings also contain nested groups (e.g. large = 5 groups at depth 2). The table below is filtered to the `bare_term` query (`Event` / `@Event`) to isolate parse and tree-walk cost from query complexity; see the query heatmap image below for all 12 queries.
216216

217-
(Example 10-tag string: `Gentalia, Move, Computed-feature, Age, Aroused, 3D-shape, Little-toe, To-right-of, Brain-region, DarkSeaGreen`)
217+
(Example 10-tag string: `Human-agent, Move, Computed-feature, Age, Aroused, 3D-shape, Little-toe, To-right-of, Brain-region, DarkSeaGreen`)
218218

219219
| String size | Object search (ms) | String search (ms) | Basic search (ms) |
220220
| ------------------ | -----------------: | -----------------: | ----------------: |
@@ -400,7 +400,7 @@ Search over 200 rows of the `eeg_ds003645s_hed` BIDS test dataset.
400400

401401
Number of tags in the HED string (1 to 100), query `Event`. Basic search time is dominated by regex compilation overhead and stays roughly constant; tree-based engines scale linearly with the number of nodes to traverse.
402402

403-
(Example 10-tag string: `Gentalia, Move, Computed-feature, Age, Aroused, 3D-shape, Little-toe, To-right-of, Brain-region, DarkSeaGreen`)
403+
(Example 10-tag string: `Human-agent, Move, Computed-feature, Age, Aroused, 3D-shape, Little-toe, To-right-of, Brain-region, DarkSeaGreen`)
404404

405405
| Tags | Object search (ms) | String search (ms) | Basic search (ms) |
406406
| ---: | -----------------: | -----------------: | ----------------: |
@@ -468,7 +468,7 @@ More top-level parenthesised groups increase the number of children the tree mus
468468

469469
![Group count sweep](_static/images/benchmark_sweep_group_count.png)
470470

471-
**Query complexity** (1-clause bare term → 8-clause composite. Example string: `Gentalia, Move, Computed-feature, Age, Aroused, 3D-shape, Little-toe, To-right-of, Brain-region, DarkSeaGreen, (FireBrick, (Flex, Move-body)), (Categorical-value, (Eyelid, Comatose)), (Robotic-agent, (Catamenial, Background-subtask)), (Keyboard, (Cough, River)), (ForestGreen, (Green-color, Locked-in))`):
471+
**Query complexity** (1-clause bare term → 8-clause composite. Example string: `Human-agent, Move, Computed-feature, Age, Aroused, 3D-shape, Little-toe, To-right-of, Brain-region, DarkSeaGreen, (FireBrick, (Flex, Move-body)), (Categorical-value, (Eyelid, Comatose)), (Robotic-agent, (Catamenial, Background-subtask)), (Keyboard, (Cough, River)), (ForestGreen, (Green-color, Locked-in))`):
472472

473473
| Complexity | Object search (ms) | String search (ms) | Basic search |
474474
| --------------------- | -----------------: | -----------------: | ------------ |

hed/models/model_constants.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ class TopTagReturnType(IntEnum):
88
99
Pass one of these constants as the ``include_groups`` argument to control
1010
whether the method returns anchor tags, containing groups, or (tag, group) pairs.
11+
12+
Attributes:
13+
TAGS: Return only the anchor :class:`~hed.models.HedTag` objects.
14+
GROUPS: Return only the :class:`~hed.models.HedGroup` objects that contain each anchor tag.
15+
BOTH: Return ``(tag, group)`` tuples pairing each anchor tag with its containing group.
1116
"""
1217

1318
TAGS = 0

hed/models/string_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,5 +418,5 @@ def string_search(strings, query, schema_lookup=None):
418418
"""
419419
handler = StringQueryHandler(query)
420420
return [
421-
bool(handler.search(s, schema_lookup=schema_lookup)) if s and isinstance(s, str) else False for s in strings
421+
bool(handler.search(s, schema_lookup=schema_lookup)) if isinstance(s, str) and s else False for s in strings
422422
]

tests/models/test_string_search.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,15 @@ def test_none_rows(self):
10791079
self.assertFalse(mask[2])
10801080
self.assertFalse(mask[3])
10811081

1082+
def test_pandas_na_row(self):
1083+
import pandas as pd
1084+
1085+
data = ["A, B", pd.NA, "B, C"]
1086+
mask = string_search(data, "A")
1087+
self.assertTrue(mask[0])
1088+
self.assertFalse(mask[1])
1089+
self.assertFalse(mask[2])
1090+
10821091
def test_empty_string_row(self):
10831092
data = ["A", "", "B"]
10841093
mask = string_search(data, "A")

0 commit comments

Comments
 (0)