diff --git a/.gitattributes b/.gitattributes index f98bf80ed3142d1caeb54978590c3ba395133ae7..f9f596ccef3dfdb5ba4a251e7c9e9b0db5e8f73e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -421,3 +421,5 @@ material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space: material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908278/1908279.tif filter=lfs diff=lfs merge=lfs -text material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_Manual_4connected/1908280_m.tif filter=lfs diff=lfs merge=lfs -text material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_Manual_4connected/1908316_m.tif filter=lfs diff=lfs merge=lfs -text +material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908308/1908309.tif filter=lfs diff=lfs merge=lfs -text +material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908324/1908324.tif filter=lfs diff=lfs merge=lfs -text diff --git a/material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908324/1908324.tif b/material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908324/1908324.tif new file mode 100644 index 0000000000000000000000000000000000000000..68bb1a22a7eb94e5598ced327c66ba075371b5cd --- /dev/null +++ b/material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908324/1908324.tif @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a450ad560a5fd5352b1114a257cd034c36538432f3fe5d442bcbca539a8e9af0 +size 729295 diff --git a/material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908308/1908309.tif b/material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908308/1908309.tif new file mode 100644 index 0000000000000000000000000000000000000000..b0ce7f223a4d61114b1610a44e63f46dcbbab9ea --- /dev/null +++ b/material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908308/1908309.tif @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eaef6653c52e327764552d87dd5ecbd5a35497e18c2287dac167f9666ad033ff +size 732796 diff --git a/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__init__.py b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/__init__.cpython-310.pyc b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d5eadfd5835a444df33804664d6237ea43397c27 Binary files /dev/null and b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/__init__.cpython-310.pyc differ diff --git a/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_backgroundjobs.cpython-310.pyc b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_backgroundjobs.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5e678976de435a88f431c0af46e30b7a67218aa7 Binary files /dev/null and b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_backgroundjobs.cpython-310.pyc differ diff --git a/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_clipboard.cpython-310.pyc b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_clipboard.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4f3313fc5eccdaf09a5e49cbdbe86dbeab77bc52 Binary files /dev/null and b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_clipboard.cpython-310.pyc differ diff --git a/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_deepreload.cpython-310.pyc b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_deepreload.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..99b307d14721f06f65f3c3384c3da1473c138fc6 Binary files /dev/null and b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_deepreload.cpython-310.pyc differ diff --git a/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_display.cpython-310.pyc b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_display.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9969d4339f47186337acc4950c857fb28ab7bab7 Binary files /dev/null and b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_display.cpython-310.pyc differ diff --git a/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_editorhooks.cpython-310.pyc b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_editorhooks.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2a26d88cc0c6fa7cd0d732d187ec6de4bc80c800 Binary files /dev/null and b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_editorhooks.cpython-310.pyc differ diff --git a/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_imports.cpython-310.pyc b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_imports.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..30e072948ec629e37d5c49260375c43e1ada25dc Binary files /dev/null and b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_imports.cpython-310.pyc differ diff --git a/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_latextools.cpython-310.pyc b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_latextools.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..eaed69e18f4181d5842870ad0dfc121912b820ab Binary files /dev/null and b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_latextools.cpython-310.pyc differ diff --git a/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_lexers.cpython-310.pyc b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_lexers.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..63887e84ef1655146e7ea2875c1a40bad910e46b Binary files /dev/null and b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_lexers.cpython-310.pyc differ diff --git a/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_pretty.cpython-310.pyc b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_pretty.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cf93419ab70546756d8ca6fb43fdf5dab1a19db0 Binary files /dev/null and b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_pretty.cpython-310.pyc differ diff --git a/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_pygments.cpython-310.pyc b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_pygments.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7b2de8757258257333bdbf2c990726b92305925a Binary files /dev/null and b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_pygments.cpython-310.pyc differ diff --git a/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/test_deepreload.py b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/test_deepreload.py new file mode 100644 index 0000000000000000000000000000000000000000..5da606cb8b7a4f7887ce0a45de2e227eeda05a24 --- /dev/null +++ b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/test_deepreload.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +"""Test suite for the deepreload module.""" + +# Copyright (c) IPython Development Team. +# Distributed under the terms of the Modified BSD License. + +import types +from pathlib import Path + +import pytest +from tempfile import TemporaryDirectory + +from IPython.lib.deepreload import modules_reloading +from IPython.lib.deepreload import reload as dreload +from IPython.utils.syspathcontext import prepended_to_syspath + + +def test_deepreload(): + "Test that dreload does deep reloads and skips excluded modules." + with TemporaryDirectory() as tmpdir: + with prepended_to_syspath(tmpdir): + tmpdirpath = Path(tmpdir) + with open(tmpdirpath / "A.py", "w", encoding="utf-8") as f: + f.write("class Object:\n pass\nok = True\n") + with open(tmpdirpath / "B.py", "w", encoding="utf-8") as f: + f.write("import A\nassert A.ok, 'we are fine'\n") + import A + import B + + # Test that A is not reloaded. + obj = A.Object() + dreload(B, exclude=["A"]) + assert isinstance(obj, A.Object) is True + + # Test that an import failure will not blow-up us. + A.ok = False + with pytest.raises(AssertionError, match="we are fine"): + dreload(B, exclude=["A"]) + assert len(modules_reloading) == 0 + assert not A.ok + + # Test that A is reloaded. + obj = A.Object() + A.ok = False + dreload(B) + assert A.ok + assert isinstance(obj, A.Object) is False + + +def test_not_module(): + pytest.raises(TypeError, dreload, "modulename") + + +def test_not_in_sys_modules(): + fake_module = types.ModuleType("fake_module") + with pytest.raises(ImportError, match="not in sys.modules"): + dreload(fake_module) diff --git a/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/test_display.py b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/test_display.py new file mode 100644 index 0000000000000000000000000000000000000000..f5ed34c912b396703931362f1f6de5e9b12f4e91 --- /dev/null +++ b/material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/test_display.py @@ -0,0 +1,272 @@ +"""Tests for IPython.lib.display. + +""" +#----------------------------------------------------------------------------- +# Copyright (c) 2012, the IPython Development Team. +# +# Distributed under the terms of the Modified BSD License. +# +# The full license is in the file COPYING.txt, distributed with this software. +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# Imports +#----------------------------------------------------------------------------- +from tempfile import NamedTemporaryFile, mkdtemp +from os.path import split, join as pjoin, dirname +import pathlib +from unittest import TestCase, mock +import struct +import wave +from io import BytesIO + +# Third-party imports +import pytest + +try: + import numpy +except ImportError: + pass + +# Our own imports +from IPython.lib import display + +from IPython.testing.decorators import skipif_not_numpy + +#----------------------------------------------------------------------------- +# Classes and functions +#----------------------------------------------------------------------------- + +#-------------------------- +# FileLink tests +#-------------------------- + +def test_instantiation_FileLink(): + """FileLink: Test class can be instantiated""" + fl = display.FileLink('example.txt') + # TODO: remove if when only Python >= 3.6 is supported + fl = display.FileLink(pathlib.PurePath('example.txt')) + +def test_warning_on_non_existent_path_FileLink(): + """FileLink: Calling _repr_html_ on non-existent files returns a warning""" + fl = display.FileLink("example.txt") + assert fl._repr_html_().startswith("Path (example.txt)") + + +def test_existing_path_FileLink(): + """FileLink: Calling _repr_html_ functions as expected on existing filepath + """ + tf = NamedTemporaryFile() + fl = display.FileLink(tf.name) + actual = fl._repr_html_() + expected = "%s
" % (tf.name, tf.name) + assert actual == expected + + +def test_existing_path_FileLink_repr(): + """FileLink: Calling repr() functions as expected on existing filepath + """ + tf = NamedTemporaryFile() + fl = display.FileLink(tf.name) + actual = repr(fl) + expected = tf.name + assert actual == expected + + +def test_error_on_directory_to_FileLink(): + """FileLink: Raises error when passed directory + """ + td = mkdtemp() + pytest.raises(ValueError, display.FileLink, td) + +#-------------------------- +# FileLinks tests +#-------------------------- + +def test_instantiation_FileLinks(): + """FileLinks: Test class can be instantiated + """ + fls = display.FileLinks('example') + +def test_warning_on_non_existent_path_FileLinks(): + """FileLinks: Calling _repr_html_ on non-existent files returns a warning""" + fls = display.FileLinks("example") + assert fls._repr_html_().startswith("Path (example)") + + +def test_existing_path_FileLinks(): + """FileLinks: Calling _repr_html_ functions as expected on existing dir + """ + td = mkdtemp() + tf1 = NamedTemporaryFile(dir=td) + tf2 = NamedTemporaryFile(dir=td) + fl = display.FileLinks(td) + actual = fl._repr_html_() + actual = actual.split('\n') + actual.sort() + # the links should always have forward slashes, even on windows, so replace + # backslashes with forward slashes here + expected = ["%s/
" % td, + "  %s
" %\ + (tf2.name.replace("\\","/"),split(tf2.name)[1]), + "  %s
" %\ + (tf1.name.replace("\\","/"),split(tf1.name)[1])] + expected.sort() + # We compare the sorted list of links here as that's more reliable + assert actual == expected + + +def test_existing_path_FileLinks_alt_formatter(): + """FileLinks: Calling _repr_html_ functions as expected w/ an alt formatter + """ + td = mkdtemp() + tf1 = NamedTemporaryFile(dir=td) + tf2 = NamedTemporaryFile(dir=td) + def fake_formatter(dirname,fnames,included_suffixes): + return ["hello","world"] + fl = display.FileLinks(td,notebook_display_formatter=fake_formatter) + actual = fl._repr_html_() + actual = actual.split('\n') + actual.sort() + expected = ["hello","world"] + expected.sort() + # We compare the sorted list of links here as that's more reliable + assert actual == expected + + +def test_existing_path_FileLinks_repr(): + """FileLinks: Calling repr() functions as expected on existing directory """ + td = mkdtemp() + tf1 = NamedTemporaryFile(dir=td) + tf2 = NamedTemporaryFile(dir=td) + fl = display.FileLinks(td) + actual = repr(fl) + actual = actual.split('\n') + actual.sort() + expected = ['%s/' % td, ' %s' % split(tf1.name)[1],' %s' % split(tf2.name)[1]] + expected.sort() + # We compare the sorted list of links here as that's more reliable + assert actual == expected + + +def test_existing_path_FileLinks_repr_alt_formatter(): + """FileLinks: Calling repr() functions as expected w/ alt formatter + """ + td = mkdtemp() + tf1 = NamedTemporaryFile(dir=td) + tf2 = NamedTemporaryFile(dir=td) + def fake_formatter(dirname,fnames,included_suffixes): + return ["hello","world"] + fl = display.FileLinks(td,terminal_display_formatter=fake_formatter) + actual = repr(fl) + actual = actual.split('\n') + actual.sort() + expected = ["hello","world"] + expected.sort() + # We compare the sorted list of links here as that's more reliable + assert actual == expected + + +def test_error_on_file_to_FileLinks(): + """FileLinks: Raises error when passed file + """ + td = mkdtemp() + tf1 = NamedTemporaryFile(dir=td) + pytest.raises(ValueError, display.FileLinks, tf1.name) + + +def test_recursive_FileLinks(): + """FileLinks: Does not recurse when recursive=False + """ + td = mkdtemp() + tf = NamedTemporaryFile(dir=td) + subtd = mkdtemp(dir=td) + subtf = NamedTemporaryFile(dir=subtd) + fl = display.FileLinks(td) + actual = str(fl) + actual = actual.split('\n') + assert len(actual) == 4, actual + fl = display.FileLinks(td, recursive=False) + actual = str(fl) + actual = actual.split('\n') + assert len(actual) == 2, actual + +def test_audio_from_file(): + path = pjoin(dirname(__file__), 'test.wav') + display.Audio(filename=path) + +class TestAudioDataWithNumpy(TestCase): + + @skipif_not_numpy + def test_audio_from_numpy_array(self): + test_tone = get_test_tone() + audio = display.Audio(test_tone, rate=44100) + assert len(read_wav(audio.data)) == len(test_tone) + + @skipif_not_numpy + def test_audio_from_list(self): + test_tone = get_test_tone() + audio = display.Audio(list(test_tone), rate=44100) + assert len(read_wav(audio.data)) == len(test_tone) + + @skipif_not_numpy + def test_audio_from_numpy_array_without_rate_raises(self): + self.assertRaises(ValueError, display.Audio, get_test_tone()) + + @skipif_not_numpy + def test_audio_data_normalization(self): + expected_max_value = numpy.iinfo(numpy.int16).max + for scale in [1, 0.5, 2]: + audio = display.Audio(get_test_tone(scale), rate=44100) + actual_max_value = numpy.max(numpy.abs(read_wav(audio.data))) + assert actual_max_value == expected_max_value + + @skipif_not_numpy + def test_audio_data_without_normalization(self): + max_int16 = numpy.iinfo(numpy.int16).max + for scale in [1, 0.5, 0.2]: + test_tone = get_test_tone(scale) + test_tone_max_abs = numpy.max(numpy.abs(test_tone)) + expected_max_value = int(max_int16 * test_tone_max_abs) + audio = display.Audio(test_tone, rate=44100, normalize=False) + actual_max_value = numpy.max(numpy.abs(read_wav(audio.data))) + assert actual_max_value == expected_max_value + + def test_audio_data_without_normalization_raises_for_invalid_data(self): + self.assertRaises( + ValueError, + lambda: display.Audio([1.001], rate=44100, normalize=False)) + self.assertRaises( + ValueError, + lambda: display.Audio([-1.001], rate=44100, normalize=False)) + +def simulate_numpy_not_installed(): + try: + import numpy + return mock.patch('numpy.array', mock.MagicMock(side_effect=ImportError)) + except ModuleNotFoundError: + return lambda x:x + +@simulate_numpy_not_installed() +class TestAudioDataWithoutNumpy(TestAudioDataWithNumpy): + # All tests from `TestAudioDataWithNumpy` are inherited. + + @skipif_not_numpy + def test_audio_raises_for_nested_list(self): + stereo_signal = [list(get_test_tone())] * 2 + self.assertRaises(TypeError, lambda: display.Audio(stereo_signal, rate=44100)) + + +@skipif_not_numpy +def get_test_tone(scale=1): + return numpy.sin(2 * numpy.pi * 440 * numpy.linspace(0, 1, 44100)) * scale + +def read_wav(data): + with wave.open(BytesIO(data)) as wave_file: + wave_data = wave_file.readframes(wave_file.getnframes()) + num_samples = wave_file.getnframes() * wave_file.getnchannels() + return struct.unpack('<%sh' % num_samples, wave_data) + +def test_code_from_file(): + c = display.Code(filename=__file__) + assert c._repr_html_().startswith('