-
Notifications
You must be signed in to change notification settings - Fork 31
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
Added sanitize_np function, which is faster than sanitize_doc #71
base: main
Are you sure you want to change the base?
Conversation
This does not look like it will catch: d = {'a': {'b': np.arange(5)}} |
Can this be updated to handle a list of arrays? Example: In [3]: sanitize_np({'a': [numpy.arange(5)]})
Out[3]: {'a': [array([0, 1, 2, 3, 4])]} We encountered that in the wild at some point and that was our reason for switching to the approach currently used in |
Codecov Report
@@ Coverage Diff @@
## master #71 +/- ##
==========================================
- Coverage 79.89% 79.08% -0.81%
==========================================
Files 3 3
Lines 1104 1119 +15
==========================================
+ Hits 882 885 +3
- Misses 222 234 +12
Continue to review full report at Codecov.
|
It would be better to duck-type if we can. Resorting to |
I'll add some tests before trying to merge, I'll work on that later. |
else: | ||
return sanitize_item(doc) | ||
|
||
return sanitize_np(doc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unreachable line
sanitize_doc was a bottleneck for mongo inserting. sanitize_np fixes this problem. I made it a separate function because sanitize_doc also changes tuples to lists in addition to sanitizing numpy, and this feature is useful for some tests.