-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix ValueError check in ColumnDataSource.patch #14020
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## branch-3.6 #14020 +/- ##
=============================================
Coverage ? 93.20%
=============================================
Files ? 282
Lines ? 19850
Branches ? 0
=============================================
Hits ? 18501
Misses ? 1349
Partials ? 0 |
While you are at it, I would suggest adding some simple |
I have not managed to get a proper dev setup working yet on MacOS, still struggling with various issues. So would appreciate if you could add more tests if needed for now. |
There's no pressing hurry, it seems like this would be a good context to get tests up and running locally. |
I'm really not familiar with this code at all and don't know what "correct" would look like here, what inputs exactly should or shouldn't work. Would be great if someone familiar with the code can add the missing test(s) and finish this up! |
@cdeil I would expect the tests for error conditions would all look very similar to this (untested): def test_bad_negative_index() -> None:
source = ColumnDataSource(data=dict(foo=[1]))
bad_patch = dict(foo=(-1, 10))
msg = "Out-of bounds index (-1) in patch for column: foo"
with pytest.raises(ValueError, match=msg):
source.patch(bad_patch) The hierarchy for test files under I'm not sure when I would be able to add tests so we can just leave this open for the time being. |
Added some tests: b7cdbe0 |
with pytest.raises(ValueError, match=r"Can only sub-patch into columns with NumPy array items"): | ||
ds.patch(dict(foo=[[[0, 3], 5]])) | ||
with pytest.raises(ValueError, match=r"Invalid patch index: {}"): | ||
ds.patch(dict(foo=[[{}, 5]])) |
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.
Thanks for the tests! I won't hold up this PR but I will mention just for FYI that typically we would split these into multiple named tests in order to have finer grained test resolution. Gold standard for individual tests is AAA — "Arrange, Act, Assert" ideally with one assertion or only a few closely related assertions for a single case.
Thanks @cdeil ! |
* Fix ValueError check in ColumnDataSource.patch * Use f-string in src/bokeh/models/sources.py * Add TestColumnDataSource::test_bad_multi_index
* Fix ValueError check in ColumnDataSource.patch * Use f-string in src/bokeh/models/sources.py * Add TestColumnDataSource::test_bad_multi_index
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Fix an error where ColumnDataSource.patch was doing some ValueError reporting but trying to format a list
ind
as a int%d
which when executed would raise TypeError. I'm not familiar with the code (was just pointed out by PyCharm) but I suppose using the intind_0
was intended?