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

PLAT-320: _fetch_records casts nan values to str #174

Merged
merged 4 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
### Fixed

- bug with forms that was preventing nullable foreign keys from being null in sci-viz[#172](https://github.com/datajoint/pharus/pull/172)
- Bug in Works where NaN values were breaking the Works frontend [#174](https://github.com/datajoint/pharus/pull/174)

## [0.8.10] - 2023-11-16

Expand Down
17 changes: 11 additions & 6 deletions pharus/interface.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Library for interfaces into DataJoint pipelines."""

import datajoint as dj
import math
from numbers import Number
from datajoint import DataJointError
from datajoint.utils import to_camel_case
from datajoint.user_tables import UserTable
Expand Down Expand Up @@ -198,13 +200,16 @@ def _fetch_records(
elif attribute_info.type[0:7] == "decimal":
# Covert decimal to string
row.append(str(non_blobs_row[attribute_name]))
else:
# Normal attribute, just return value with .item to deal with numpy
# types
if isinstance(non_blobs_row[attribute_name], np.generic):
row.append((non_blobs_row[attribute_name].item()))
# Normal attribute, just return value with .item to deal with numpy
# types
elif isinstance(non_blobs_row[attribute_name], np.generic):
val = non_blobs_row[attribute_name].item()
if isinstance(val, Number) and math.isnan(val):
row.append(str(val))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lines 207-8 are the logical change in this PR. We catch nan values and cast to str(nan).

else:
row.append(non_blobs_row[attribute_name])
row.append(val)
else:
row.append(non_blobs_row[attribute_name])
else:
# Attribute is blob type thus fill it in string instead
(
Expand Down
Loading