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

Resolve warnings #317 & and Fix Issue: #355 #399

Merged
merged 11 commits into from
Mar 31, 2021
8 changes: 8 additions & 0 deletions docs/source/ext/github_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@


def fetch_url(url):
"""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)
"""
req = Request(url)
if GH_TOKEN:
req.add_header('Authorization', 'token {0}'.format(GH_TOKEN))
Expand All @@ -50,6 +55,9 @@ def fetch_url(url):
# url = Request(url,
# headers={'Accept': 'application/vnd.github.v3+json',
# 'User-agent': 'Defined'})
if not url.lower().startswith('http'):
msg = "Please make sure you use http/https connection"
raise ValueError(msg)
f = urlopen(req)
except Exception as e:
print(e)
Expand Down
2 changes: 1 addition & 1 deletion fury/tests/test_actors.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ def test_cones_vertices_faces(interactive=False):
if interactive:
window.show(scene, order_transparent=True)
arr = window.snapshot(scene)
report = window.analyze_snapshot(arr, colors=[colors])
report = window.analyze_snapshot(arr, colors=colors)
npt.assert_equal(report.objects, 3)
scene.clear()

Expand Down
37 changes: 37 additions & 0 deletions fury/tests/test_convert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import os
import pytest
import numpy.testing as npt
from tempfile import TemporaryDirectory
from fury.io import load_image
# Optional packages
from fury.optpkg import optional_package
matplotlib, have_matplotlib, _ = optional_package('matplotlib')

if have_matplotlib:
import matplotlib.pyplot as plt
from fury.convert import matplotlib_figure_to_numpy


@pytest.mark.skipif(not have_matplotlib, reason="Requires MatplotLib")
def test_convert():
names = ['group_a', 'group_b', 'group_c']
values = [1, 10, 100]

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')
dpi = 100
fig.savefig(fname, transparent=False, bbox_inches='tight',
pad_inches=0)
arr1 = load_image(fname)
npt.assert_array_equal(arr1, arr2)
6 changes: 3 additions & 3 deletions fury/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ def trilinear_interp_numpy(input_array, indices):
y_indices = indices[:, 1]
z_indices = indices[:, 2]

x0 = x_indices.astype(np.integer)
y0 = y_indices.astype(np.integer)
z0 = z_indices.astype(np.integer)
x0 = x_indices.astype(int)
y0 = y_indices.astype(int)
z0 = z_indices.astype(int)
x1 = x0 + 1
y1 = y0 + 1
z1 = z0 + 1
Expand Down
3 changes: 2 additions & 1 deletion fury/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,8 @@ def __str__(self):
flags = [False] * len(colors)
for (i, col) in enumerate(colors):
# find if the current color exist in the array
flags[i] = np.any(np.any(np.all(im[..., :3] == col[:3], axis=-1)))
flags[i] = np.any(np.any(np.all(np.equal(im[..., :3], col[:3]),
axis=-1)))

report.colors_found = flags

Expand Down