Skip to content

Commit fef4f64

Browse files
authored
Improve position coverage (#1315)
* WIP: improve position coverage * ✅ : improve position coverage * Fix import * Revise skipping dlc tests * WIP: Add import coverage * WIP: Fix import tests * more tests * Fix tests * Fix test * Omit position from cov report in gh-action run * Update changelog * Fix alternate gh-action coverage report * Add alt coverage config * imported_pose insert transaction * Incorporate feedback * Imported pose: no nested transaction * Abort tests if can't insert session
1 parent 1143eda commit fef4f64

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1853
-710
lines changed

.github/workflows/test-conda.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,13 @@ jobs:
7676
curl_opts $RAW_DIR $NWBFILE $NWB_URL
7777
curl_opts $VID_DIR $VID_ONE $VID1URL
7878
curl_opts $VID_DIR $VID_TWO $VID2URL
79+
- name: Move actions coveragerc
80+
run: mv tests/.coveragerc .coveragerc
7981
- name: Run tests
8082
run: |
81-
pytest --no-docker --no-dlc --cov=spyglass-neuro --cov-report=xml tests/
83+
pytest --no-docker --no-dlc \
84+
--cov-config=.coveragerc --cov=spyglass-neuro --cov-report=xml \
85+
tests/
8286
- name: Upload coverage reports to Codecov
8387
uses: codecov/codecov-action@v5
8488
with:

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ ImportedLFP().drop()
8686
- Track Spyglass version in dedicated table for enforcing updates #1281
8787
- Pin to `datajoint>=0.14.4` for `dj.Top` and long make call fix #1281
8888
- Remove outdated code comments #1304
89-
- Add code coverage badge #1305
89+
- Add code coverage badge, and increase position coverage #1305, #1315
9090

9191
### Documentation
9292

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,18 @@ filterwarnings = [
166166
"ignore::MissingRequiredBuildWarning:.*",
167167
]
168168

169-
[tool.coverage.run]
169+
[tool.coverage.run] # NOTE: changes need to be mirrored in tests/.coveragerc
170170
source = ["*/src/spyglass/*"]
171171
omit = [ # which submodules have no tests
172172
"*/__init__.py",
173173
"*/_version.py",
174+
# "*/behavior/*",
175+
"*/cli/*",
174176
# "*/common/*",
175177
"*/data_import/*",
176178
"*/decoding/v0/*",
177-
# "*/decoding/*",
178179
"*/figurl_views/*",
180+
# "*/decoding/*",
179181
# "*/lfp/*",
180182
# "*/linearization/*",
181183
"*/lock/*",

src/spyglass/behavior/v1/moseq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def make(self, key):
403403
self.insert1(key)
404404

405405
def fetch1_dataframe(self):
406-
self.ensure_single_entry()
406+
_ = self.ensure_single_entry()
407407
dataframe = self.fetch_nwb()[0]["moseq"]
408408
dataframe.set_index("time", inplace=True)
409409
return dataframe

src/spyglass/common/common_ephys.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ def nwb_object(self, key):
575575

576576
def fetch1_dataframe(self, *attrs, **kwargs) -> pd.DataFrame:
577577
"""Fetch the LFP data as a pandas DataFrame."""
578-
self.ensure_single_entry()
578+
_ = self.ensure_single_entry()
579579
nwb_lfp = self.fetch_nwb()[0]
580580
return pd.DataFrame(
581581
nwb_lfp["lfp"].data,
@@ -952,7 +952,7 @@ def make(self, key):
952952

953953
def fetch1_dataframe(self, *attrs, **kwargs) -> pd.DataFrame:
954954
"""Fetch the LFP band data as a pandas DataFrame."""
955-
self.ensure_single_entry()
955+
_ = self.ensure_single_entry()
956956
filtered_nwb = self.fetch_nwb()[0]
957957
return pd.DataFrame(
958958
filtered_nwb["filtered_data"].data,

src/spyglass/common/common_position.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ def calculate_position_info(
489489

490490
def fetch1_dataframe(self) -> pd.DataFrame:
491491
"""Fetches the position data as a pandas dataframe."""
492-
self.ensure_single_entry()
492+
_ = self.ensure_single_entry()
493493
return self._data_to_df(self.fetch_nwb()[0])
494494

495495
@staticmethod

src/spyglass/common/common_sensors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def fetch1_dataframe(
105105
"""
106106
if len(self) == 0:
107107
return None
108-
self.ensure_single_entry()
108+
_ = self.ensure_single_entry()
109109

110110
nwb = self.fetch_nwb()[0]
111111
columns = nwb["sensor_data"].description.split()

src/spyglass/common/common_subject.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def insert_from_nwbfile(cls, nwbf: NWBFile, config: dict = None):
5757
"sex",
5858
]
5959
}
60-
if (sex := subject_dict["sex"][0].upper()) in ("M", "F"):
60+
sex_field = subject_dict.get("sex") or ["U"] # If not provided
61+
if (sex := sex_field[0].upper()) in ("M", "F", "U"):
6162
subject_dict["sex"] = sex
6263
else:
6364
subject_dict["sex"] = "U"

src/spyglass/decoding/v0/clusterless.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ def plot_all_marks(
451451

452452
def fetch1_dataframe(self) -> pd.DataFrame:
453453
"""Convenience function for returning the first dataframe"""
454-
self.ensure_single_entry()
454+
_ = self.ensure_single_entry()
455455
return self.fetch_dataframe()[0]
456456

457457
def fetch_dataframe(self) -> list[pd.DataFrame]:

src/spyglass/decoding/v0/sorted_spikes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def make(self, key):
164164

165165
def fetch1_dataframe(self) -> pd.DataFrame:
166166
"""Return the first spike indicator as a dataframe."""
167-
self.ensure_single_entry()
167+
_ = self.ensure_single_entry()
168168
return self.fetch_dataframe()[0]
169169

170170
def fetch_dataframe(self) -> list[pd.DataFrame]:

0 commit comments

Comments
 (0)