diff --git a/docs/source/ext/github_tools.py b/docs/source/ext/github_tools.py index 68ab43cdf..3c379467d 100644 --- a/docs/source/ext/github_tools.py +++ b/docs/source/ext/github_tools.py @@ -42,6 +42,14 @@ def fetch_url(url): + """ + Notes + ----- + 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)) @@ -50,6 +58,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) diff --git a/fury/tests/test_actors.py b/fury/tests/test_actors.py index 46fe67142..479b34f9f 100644 --- a/fury/tests/test_actors.py +++ b/fury/tests/test_actors.py @@ -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() diff --git a/fury/tests/test_convert.py b/fury/tests/test_convert.py new file mode 100644 index 000000000..3164ebf8e --- /dev/null +++ b/fury/tests/test_convert.py @@ -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) diff --git a/fury/tests/test_utils.py b/fury/tests/test_utils.py index 1d54000b6..963d83e27 100644 --- a/fury/tests/test_utils.py +++ b/fury/tests/test_utils.py @@ -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 diff --git a/fury/window.py b/fury/window.py index 4eeae0635..f6915ca72 100644 --- a/fury/window.py +++ b/fury/window.py @@ -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