Skip to content
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

ticket:PSB-19: Fixup typing #2642

Merged
merged 1 commit into from
Jan 17, 2023
Merged

ticket:PSB-19: Fixup typing #2642

merged 1 commit into from
Jan 17, 2023

Conversation

morriscb
Copy link
Contributor

No description provided.

@morriscb morriscb marked this pull request as ready for review January 12, 2023 19:59
@@ -123,6 +123,10 @@ def postprocess_additional(self):
self._df['date_of_acquisition_behavior']
self._df = self._df.drop(['date_of_acquisition_behavior',
'date_of_acquisition_ophys'], axis=1)
# Enforce an integer type on ophys_session_id due to many
# columns being NaN.
self._df['ophys_session_id'] = self._df['ophys_session_id'].astype(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand the comment here. Isn't it returned as int from the database?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll clarify. This ends up being a pandas issue as you are merging in a column that doesn't have values for all the behavior_sessions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not know about the Int64 dtype. Thanks

@@ -9,17 +9,19 @@
class MouseId(DataObject, LimsReadableInterface, JsonReadableInterface,
NwbReadableInterface):
"""the LabTracks ID"""
def __init__(self, mouse_id: int):
def __init__(self, mouse_id: str):
if not isinstance(mouse_id, str):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This goes against the type. It expects string, so if it is not string, then the caller is passing the wrong type and it should be corrected there. Or the type needs to be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly this was to enforce the type and avoid unittest failures from elsewhere, specifically, from_json calls on ecephys tests. I'll remove the line and see if I can find where the typing is going wrong there specifically.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, hold on, would you be cool if I moved this type check to the from_json method?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, that works

super().__init__(name="mouse_id", value=mouse_id)

@classmethod
def from_json(cls, dict_repr: dict) -> "MouseId":
mouse_id = dict_repr['external_specimen_name']
mouse_id = int(mouse_id)
mouse_id = mouse_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line needs to be removed

return cls(mouse_id=mouse_id)

@classmethod
def from_lims(cls, behavior_session_id: int,
def from_lims(cls, behavior_session_id: str,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure about this? BehaviorSessionId.value is an int.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, sorry, trigger happy replace all. thanks for the catch.

@morriscb morriscb merged commit 9760f03 into rc/2.15.0 Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants