Skip to content

Commit

Permalink
Add codespell - config, workflow, fixed some typos and unified/remove…
Browse files Browse the repository at this point in the history
…d a few imports (#471)

Adds spell checking and fixes typos
  • Loading branch information
yarikoptic authored May 9, 2023
1 parent 9ab2625 commit ef7d75c
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 20 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Codespell

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Codespell
uses: codespell-project/actions-codespell@master
2 changes: 1 addition & 1 deletion franklab_scripts/alter_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def update_cls(cls):
# some enum definitions will prompt alter() even when there has not been a change
# NOTE: datajoint does not allow primary keys to be altered yet
# this includes changing the length of a varchar primary key
# (other tables use this primary key, so constraints would probably have to be removed and readded)
# (other tables use this primary key, so constraints would probably have to be removed and re-added)
cls.alter()
except Exception as e:
print("ERROR:", e)
Expand Down
1 change: 0 additions & 1 deletion franklab_scripts/nightly_cleanup.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import numpy as np

import spyglass as nd
from spyglass.decoding.clusterless import MarkParameters, UnitMarkParameters, UnitMarks

warnings.simplefilter("ignore", category=DeprecationWarning)
Expand Down
6 changes: 3 additions & 3 deletions franklab_scripts/sort.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from pathlib import Path

import spyglass as nd
import spyglass as sg


def main():
Expand All @@ -14,10 +14,10 @@ def main():
os.environ["SPIKE_SORTING_STORAGE_DIR"] = str(data_dir / "spikesorting")

# session_id = 'jaq_01'
# nwb_file_name = (nd.common.Session() & {'session_id': session_id}).fetch1('nwb_file_name')
# nwb_file_name = (sg.common.Session() & {'session_id': session_id}).fetch1('nwb_file_name')
nwb_file_name = "beans20190718-trim_.nwb"

nd.common.SpikeSorting().populate()
sg.common.SpikeSorting().populate()


if __name__ == "__main__":
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,8 @@ spyglass_cli = "spyglass.cli:cli"

[tool.black]
# line-length = 120

[tool.codespell]
skip = '.git,*.pdf,*.svg,*.ipynb'
# Nevers - name in Citation
ignore-words-list = 'nevers'
6 changes: 3 additions & 3 deletions src/spyglass/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def cli():
)
@click.argument("nwb_file_name")
def insert_session(nwb_file_name: str):
import spyglass as nd
import spyglass as sg

nd.insert_sessions(nwb_file_name)
sg.insert_sessions(nwb_file_name)


@click.command(help="List all sessions")
Expand Down Expand Up @@ -416,7 +416,7 @@ def run_spike_sorting(yaml_file_name: Union[str, None]):
nds.SpikeSorting.populate([(nds.SpikeSortingSelection & sorting_key).proj()])


@click.command(help="List spike sortings for a session.")
@click.command(help="List spike sorting for a session.")
@click.argument("nwb_file_name")
def list_spike_sortings(nwb_file_name: str):
import spyglass.spikesorting as nds
Expand Down
2 changes: 1 addition & 1 deletion src/spyglass/common/common_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def create_new_team(
if not len(query):
print(
f"Please add the Google user ID for {team_member} in the LabMember.LabMemberInfo table "
"if you want to give them permission to manually curate sortings by this team."
"if you want to give them permission to manually curate sorting by this team."
)
labteammember_dict = dict()
labteammember_dict["team_name"] = team_name
Expand Down
2 changes: 1 addition & 1 deletion src/spyglass/common/common_nwbfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class AnalysisNwbfile(dj.Manual):
-> Nwbfile # name of the parent NWB file. Used for naming and metadata copy
analysis_file_abs_path: filepath@analysis # the full path to the file
analysis_file_description = "": varchar(2000) # an optional description of this analysis
analysis_parameters = NULL: blob # additional relevant parmeters. Currently used only for analyses
analysis_parameters = NULL: blob # additional relevant parameters. Currently used only for analyses
# that span multiple NWB files
INDEX (analysis_file_abs_path)
"""
Expand Down
2 changes: 1 addition & 1 deletion src/spyglass/common/common_position.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ def get_video_frame(self):
@schema
class PositionVideo(dj.Computed):
"""Creates a video of the computed head position and orientation as well as
the original LED positions overlayed on the video of the animal.
the original LED positions overlaid on the video of the animal.
Use for debugging the effect of position extraction parameters."""

Expand Down
2 changes: 1 addition & 1 deletion src/spyglass/figurl_views/SpikeSortingView.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@schema
class SpikeSortingView(dj.Computed):
definition = """
# Schema for storing figurl views of spike sortings
# Schema for storing figurl views of spike sorting
-> SpikeSorting
---
figurl: varchar(10000)
Expand Down
2 changes: 1 addition & 1 deletion src/spyglass/spikesorting/curation_figurl.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def _generate_the_figurl(
max_num_snippets_per_segment=100,
channel_neighborhood_size=7,
)
# create a fake unit similiarity matrix (for future reference)
# create a fake unit similarity matrix (for future reference)
# similarity_scores = []
# for u1 in X.unit_ids:
# for u2 in X.unit_ids:
Expand Down
2 changes: 1 addition & 1 deletion src/spyglass/spikesorting/sortingview_helper_fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _generate_url(
channel_neighborhood_size=7,
)

# create a fake unit similiarity matrix
# create a fake unit similarity matrix
# similarity_scores = []
# for u1 in X.unit_ids:
# for u2 in X.unit_ids:
Expand Down
4 changes: 2 additions & 2 deletions src/spyglass/spikesorting/spikesorting_curation.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def apply_merge_groups_to_sorting(
class Curation(dj.Manual):
definition = """
# Stores each spike sorting; similar to IntervalList
curation_id: int # a number correponding to the index of this curation
curation_id: int # a number corresponding to the index of this curation
-> SpikeSorting
---
parent_curation_id=-1: int
Expand Down Expand Up @@ -994,7 +994,7 @@ def get_included_units(self, curated_sorting_key, unit_inclusion_param_name):
Parameters
----------
curated_sorting_key : dict
key to select a set of curated sortings
key to select a set of curated sorting
unit_inclusion_param_name : str
name of a unit inclusion parameter entry
Expand Down
4 changes: 2 additions & 2 deletions src/spyglass/spikesorting/spikesorting_recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def set_group_by_shank(
]
if (
omit_unitrode and len(shank_elect) == 1
): # ommit unitrodes if indicated
): # omit unitrodes if indicated
print(
f"Omitting electrode group {e_group}, shank {shank} from sort groups because unitrode."
)
Expand Down Expand Up @@ -288,7 +288,7 @@ def get_geometry(self, sort_group_id, nwb_file_name):
n_found += 1
else:
Warning(
"Relative electrode locations have three coordinates; only two are currenlty supported"
"Relative electrode locations have three coordinates; only two are currently supported"
)
return np.ndarray.tolist(geometry)

Expand Down
2 changes: 1 addition & 1 deletion src/spyglass/spikesorting/spikesorting_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def _get_sorting_name(key):
sorting_name = recording_name + "_" + str(uuid.uuid4())[0:8] + "_spikesorting"
return sorting_name

# TODO: write a function to import sortings done outside of dj
# TODO: write a function to import sorting done outside of dj

def _import_sorting(self, key):
raise NotImplementedError
2 changes: 1 addition & 1 deletion src/spyglass/utils/dj_helper_fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def fetch_nwb(query_expression, nwb_master, *attrs, **kwargs):


def _get_nwb_object(objects, object_id):
"""Retreive NWB object and try to convert to dataframe if possible"""
"""Retrieve NWB object and try to convert to dataframe if possible"""
try:
return objects[object_id].to_dataframe()
except AttributeError:
Expand Down

0 comments on commit ef7d75c

Please sign in to comment.