-
Notifications
You must be signed in to change notification settings - Fork 165
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
Resolve warnings #317 & and Fix Issue: #355 #399
Conversation
These Checks seem to be failing cause I assumed matplotlib is installed. It's not. |
Effects of sleep deprivation
Codecov Report
@@ Coverage Diff @@
## master #399 +/- ##
==========================================
+ Coverage 89.00% 89.04% +0.04%
==========================================
Files 23 23
Lines 5376 5388 +12
Branches 695 695
==========================================
+ Hits 4785 4798 +13
Misses 411 411
+ Partials 180 179 -1
|
Uwa!!! help me please, CI is important, but in my case it takes me more time to notice and rectify my mistakes that CI catches, than it takes me to do the maintenance work... ;-; even on the Previous PR, I could not pass all the CI checks... |
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.
Hi @amitchaudhari9121,
Thank you for fixing these 2 issues! overall, it looks good. It just needs some reshaping.
Thank you
fury/tests/test_utils.py
Outdated
x0 = x_indices.astype(np.int64) | ||
y0 = y_indices.astype(np.int64) | ||
z0 = z_indices.astype(np.int64) |
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.
int
instead of np.int64
. it does not need to force 64bit
fury/tests/test_convert.py
Outdated
with TemporaryDirectory() as tmpdir: | ||
fname = os.path.join(tmpdir, 'tmp.png') | ||
dpi = 100 | ||
fig.savefig(fname, dpi=dpi, transparent=True) | ||
arr1 = load_image(fname) | ||
npt.assert_array_equal(arr1, arr2) |
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.
Nice test!
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!
I've (kindof) picked it up from the code you wrote 😅
This just tests the exact way its written in test_actors.py
But it's not redundant code. if something breaks in future. (or we add more conversion definitions) this will be useful...
fury/tests/test_convert.py
Outdated
# plt.subplot(131) | ||
# plt.bar(names, values) | ||
# plt.subplot(132) | ||
# plt.scatter(names, values) | ||
# plt.subplot(133) | ||
# plt.plot(names, values) | ||
# plt.suptitle('Categorical Plotting') |
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.
why is it commented? your figure seems empty
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.
The test failed for some reason when I added these args,
I think I could just test an empty figure, and confirm it works.
will that be the case?
I'm not sure...
I don't understand enough about matplotlib, so I can't reliably say why it fails when I uncomment it...
I'll keep researching & hopefully find a fix.
Any suggestions? any idea why this might be failing? any guess is appreciated...
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.
See below the test updated. I admit that it was tricky., you had to update the matplotlib_figure_to_numpy
option and the fig.savefig
options to make sure that both images have the same size and orientation.
fig = plt.figure(figsize=(9, 3))
plt.subplot(131)
plt.bar(names, values)
plt.subplot(132)
plt.scatter(names, values)
plt.subplot(133)
plt.plot(names, values)
plt.suptitle('Categorical Plotting')
arr2 = matplotlib_figure_to_numpy(fig, transparent=False,
flip_up_down=False)
with TemporaryDirectory() as tmpdir:
fname = os.path.join(tmpdir, 'tmp.png')
fig.savefig(fname, transparent=False, bbox_inches='tight',
pad_inches=0)
arr1 = load_image(fname)
npt.assert_array_equal(arr1, arr2)
fury/tests/test_convert.py
Outdated
# plt.subplot(133) | ||
# plt.plot(names, values) | ||
# plt.suptitle('Categorical Plotting') | ||
arr2 = matplotlib_figure_to_numpy(fig, transparent=True) |
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.
for more control in your test, use transparent=False
docs/source/ext/github_tools.py
Outdated
# This was pointed out as a Security issue in bandit. | ||
# please look at issue #355, | ||
# we fixed it, but the bandit warning might remain, | ||
# need to suppress it manually ¯\_(ツ)_/¯. |
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.
to convert to a complete docstring with a NOTE section
docs/source/ext/github_tools.py
Outdated
if url.lower().startswith('http'): | ||
f = urlopen(req) |
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.
What happens if it does not start with http? here a proposition:
if not url.lower().startswith('http'):
msg = "custom message"
raise ValueError(msg)
f= urlopen(req)
The ValueError
will need to be tested with npt.assert_raises
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.
Nice!
It didn't even cross my mind !!!
I will change in next commit, thank you for this.
concerning the tests, no worries. We will need to make some of them more robust |
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.
Hi @amitchaudhari9121,
See below for some suggestions to update your test. After those update, I think your PR will be ready to go.
Thanks!
docs/source/ext/github_tools.py
Outdated
'''This was pointed out as a Security issue in bandit. | ||
please look at issue #355, | ||
we fixed it, but the bandit warning might remain, | ||
need to suppress it manually (just ignore it)''' |
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.
The docstring is incomplete. Please, use double-quotes and follow the standard of our docstring. As an example, you can look here
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.
How do I stop making these types of mistakes?
It might be annoying for you, I'm sorry for the inconvinience.
My VScode does not pick them up ( I've been using pycodestyle as a linter)
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.
You did not address my comment above. Please, look at the example cited above and complete the docstring.
As suggested, the text should be in a NOTE
fury/tests/test_convert.py
Outdated
# plt.subplot(131) | ||
# plt.bar(names, values) | ||
# plt.subplot(132) | ||
# plt.scatter(names, values) | ||
# plt.subplot(133) | ||
# plt.plot(names, values) | ||
# plt.suptitle('Categorical Plotting') |
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.
See below the test updated. I admit that it was tricky., you had to update the matplotlib_figure_to_numpy
option and the fig.savefig
options to make sure that both images have the same size and orientation.
fig = plt.figure(figsize=(9, 3))
plt.subplot(131)
plt.bar(names, values)
plt.subplot(132)
plt.scatter(names, values)
plt.subplot(133)
plt.plot(names, values)
plt.suptitle('Categorical Plotting')
arr2 = matplotlib_figure_to_numpy(fig, transparent=False,
flip_up_down=False)
with TemporaryDirectory() as tmpdir:
fname = os.path.join(tmpdir, 'tmp.png')
fig.savefig(fname, transparent=False, bbox_inches='tight',
pad_inches=0)
arr1 = load_image(fname)
npt.assert_array_equal(arr1, arr2)
Thank you for working on this @amitchaudhari9121. merging |
This commit will hopefully close issues #317 and #355.
I did not create tests for layout.py since it looks like a helper in actors.py.
I could say the same about convert.py but even then, I tried creating basic tests.
If these files grow in future, they might need their own tests.
As for #355, it's a really simple check just before we fetch the url.
Thank you for your time!
I'd appreciate any feedback...