-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sgi.insert_session crashes if first name has a space #810
Comments
Also related to #304 |
I have some suggestions for the draft above to reduce the number of checks/raises def decompose_name(full_name: str) -> tuple:
"""Return the full, first and last name parts of a full name.
Names capitalized. Decomposes either comma- or space-separated.
If name includes spaces, must use exactly one comma.
Parameters
----------
full_name: str
The full name to decompose.
Returns
-------
tuple
A tuple of the full, first, last name parts.
Raises
------
ValueError
When full_name is in an unsupported format
"""
# default to empty string if None so that .count() doesn't fail
full_trimmed = "" if not full_name else full_name.strip()
# decide case early to avoid multiple checks
# catches empty string, multiple commas, multispace w/o comma
delim = (
", "
if full_trimmed.count(", ") == 1
else " "
if full_trimmed.count(" ") == 1
else None
)
# rsplit -> split bc exactly one enforced above
# .title removed to avoid enforcing unwanted capitalization
# on names like "McDonald" -> "Mcdonald"
# running split w/None delim still works
parts = full_trimmed.split(delim)
if delim is None or len(parts) != 2: # catch unsupported format
raise ValueError(
f"Name has unsupported format for {full_name}. \n\t"
+ "Must use exactly one comma+space (i.e., ', ') or space.\n\t"
+ "And provide exactly two name parts.\n\t"
+ "For example, 'First Last' or 'Last1 Last2, First1 First2' "
+ "if name(s) includes spaces."
)
first, last = parts if delim == " " else parts[::-1]
full = f"{first} {last}"
return full, first, last |
CBroz1
added a commit
to CBroz1/spyglass
that referenced
this issue
Feb 8, 2024
Merged
4 tasks
edeno
pushed a commit
that referenced
this issue
Feb 9, 2024
* Change dependencies. See details. Across `pyproject.toml` and both `environment.yml`: - Alphabetical sort to allow for easier comparison across toml/yaml files. - Remove dependencies required by other dependencies to reduce build time. - Move `black` to `test` dependencies. Could be `dev` instead? - Move `click` to `test` dependencies. CLI should be its own package. - Add ruff config to `pyproject.toml`. Flake8 replacement to allow removal of `setup.cfg`. - Remove `tqdm`, as it is required by `datajoint` Standard environment: - Add comments for all dependencies specific to position environment to allow for easier comparison across yaml files. - Remove `dask`, as it is required by `ghostipy` - Remove `hdmf`, as it is required by `pynwb` - Remove `pymysql`, as it is required by `datajoint` - Remove `pyyaml`, as it is required by `sortingview` - Remove `pydotplus` from `pip` section, as it is already in `conda` section Position environment: - Rename `_position` or `-position` to `_dlc` or `-dlc` to be more precise. - Remove `ipython`, `numba`, and `tensorflow`, as they are all required by `deeplabcut` - Add items present in standard environment but not in position environment. * Add pybind11 for std env.yml * Change dependencies. See details. - `trajectory_analysis_tools` and `replay_trajectory_classification` are superceded by `non_local_detector`. - `dask-cuda` not in use, per @edeno * Fixes for running notebooks up to 41 * Further dependency adjustments following PR review @edeno * Depedencies for panel * #810
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
if experimenter has a space in hs/her first name in the NWB file, like "Kyu Hyun" (this is Kyu's real first name), spyglass crashes in sgi.insert_session. This is related is #809 and may be a band-aid for it.
To Reproduce
Expected behavior
sgi.insert_session to not crash and populate relevant tables
Potential solution
I am trying to meet a deadline and no one else is identifying this issue. So, I will polish up the potential fix, write unit test and make a PR later in the week. A potential untested solution is common_lab.py -
The text was updated successfully, but these errors were encountered: