From f8fec80c8ba4553e53867ab5921cdc6dfbb922b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=A4tz?= <61615369+martinschatz-cz@users.noreply.github.com> Date: Thu, 9 Feb 2023 15:22:48 +0100 Subject: [PATCH 01/19] install specifications --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index fd50faf..e908c7d 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,20 @@ also includes the line tension, a measure for the force transfer exclusively acr pyTFM includes an addon for the image annotation tool [clickpoints](https://clickpoints.readthedocs.io/en/latest/) allowing you to quickly analyze and vizualize large datasets. Please refer to the [Documentation](https://pytfm.readthedocs.io/en/latest/) of pyTFM for detailed instructions on installation and usage. + +## Conda enviroment creation +You need to create python 3.7 enviroment. +``` +conda create --name pyTFM python=3.7 +conda activate pyTFM +``` + +pyTFM package install +``` +pip install git+https://github.com/fabrylab/pyTFM.git +``` + +If you want to use jupyterlab with black packge +``` +conda install jupyterlab jupyterlab_code_formatter black isort -c conda-forge +``` From 1f86b7ae4db69fc3b6dccf2a5592e2be73ed190d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=A4tz?= <61615369+martinschatz-cz@users.noreply.github.com> Date: Thu, 9 Feb 2023 16:45:46 +0100 Subject: [PATCH 02/19] Create test_pyTFM.py --- testing/test_pyTFM.py | 104 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 testing/test_pyTFM.py diff --git a/testing/test_pyTFM.py b/testing/test_pyTFM.py new file mode 100644 index 0000000..0c47fdf --- /dev/null +++ b/testing/test_pyTFM.py @@ -0,0 +1,104 @@ +import numpy as np +import pytest +import matplotlib.pyplot as plt +import numpy as np +import openpiv.filters +import scipy.fft + +from openpiv.pyprocess import extended_search_area_piv +import openpiv.scaling +import openpiv.tools +import openpiv.validation +from matplotlib.colors import LinearSegmentedColormap +from mpl_toolkits.axes_grid1 import make_axes_locatable +from pyTFM.utilities_TFM import suppress_warnings +from scipy.ndimage.filters import median_filter, gaussian_filter +from scipy.ndimage.filters import uniform_filter +from pyTFM.TFM_functions import ffttc_traction +from pyTFM.TFM_functions import get_xy_for_quiver + +def test_ffttc_traction_output_shape(): + # create test inputs + u = np.zeros((10, 10)) + v = np.zeros((10, 10)) + pixelsize1 = 0.1 + pixelsize2 = 0.1 + young = 1e6 + + # call the function + tx_filter, ty_filter = ffttc_traction(u, v, pixelsize1, pixelsize2, young) + + # assert that the output shape is as expected + assert tx_filter.shape == (10, 10) + assert ty_filter.shape == (10, 10) + +def test_ffttc_traction_output_type(): + # create test inputs + u = np.zeros((10, 10)) + v = np.zeros((10, 10)) + pixelsize1 = 0.1 + pixelsize2 = 0.1 + young = 1e6 + + # call the function + tx_filter, ty_filter = ffttc_traction(u, v, pixelsize1, pixelsize2, young) + + # assert that the output is of the correct type + assert isinstance(tx_filter, np.ndarray) + assert isinstance(ty_filter, np.ndarray) + +def test_ffttc_traction_output_values(): + # create test inputs + u = np.zeros((10, 10)) + v = np.zeros((10, 10)) + pixelsize1 = 0.1 + pixelsize2 = 0.1 + young = 1e6 + + # call the function + tx_filter, ty_filter = ffttc_traction(u, v, pixelsize1, pixelsize2, young) + + # assert that the output is as expected + assert np.allclose(tx_filter, 0) + assert np.allclose(ty_filter, 0) + +def test_ffttc_traction_input_shape(): + # create test inputs with incorrect shape + u = np.zeros((10, 10, 10)) + v = np.zeros((10, 10)) + pixelsize1 = 0.1 + pixelsize2 = 0.1 + young = 1e6 + + # assert that a ValueError is raised for incorrect input shape + with pytest.raises(ValueError): + ffttc_traction(u, v, pixelsize1, pixelsize2, young) + +def test_ffttc_traction_input_type(): + # create test inputs with incorrect type + u = np.zeros((10, 10)) + v = "not an array" + pixelsize1 = 0.1 + pixelsize2 = 0.1 + young = 1e6 + + # assert that a TypeError is raised for incorrect input type + with pytest.raises(TypeError): + ffttc_traction(u, v, pixelsize1, pixelsize2, young) + +########get_xy_for_quiver +def test_get_xy_for_quiver(): + u = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) + xs, ys = get_xy_for_quiver(u) + + # Test the shape of xs and ys + assert np.shape(xs) == np.shape(u) + assert np.shape(ys) == np.shape(u) + + # Test the values of xs + for i in range(np.shape(u)[0]): + assert np.array_equal(xs[i, :], np.arange(0, np.shape(u)[1], 1)) + + # Test the values of ys + for j in range(np.shape(u)[1]): + assert np.array_equal(ys[:, j], np.arange(0, np.shape(u)[0], 1)) From 46cf963a07b2246ad87879378c7fc5497a17e297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=A4tz?= <61615369+martinschatz-cz@users.noreply.github.com> Date: Thu, 9 Feb 2023 16:51:10 +0100 Subject: [PATCH 03/19] Create python-package.yml --- .github/workflows/python-package.yml | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/python-package.yml diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..38c9a0c --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,40 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python package + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.6", "3.7", "3.8", "3.9"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest testing/test_pyTFM.py From 9120ecedb8a291167899f41ef78aa02e2a2ed317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=A4tz?= <61615369+martinschatz-cz@users.noreply.github.com> Date: Thu, 9 Feb 2023 16:53:01 +0100 Subject: [PATCH 04/19] Update python-package.yml --- .github/workflows/python-package.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 38c9a0c..51a29c8 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.6", "3.7", "3.8", "3.9"] + python-version: ["3.7", "3.8", "3.9"] steps: - uses: actions/checkout@v3 @@ -27,14 +27,8 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install flake8 pytest + python -m pip install pytest if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest run: | pytest testing/test_pyTFM.py From 58fe9d13bfcda30c2df5e6dba67316386b2dd4c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=A4tz?= <61615369+martinschatz-cz@users.noreply.github.com> Date: Thu, 9 Feb 2023 16:55:32 +0100 Subject: [PATCH 05/19] Create test_pyTFM.py --- pyTFM/test_pyTFM.py | 104 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 pyTFM/test_pyTFM.py diff --git a/pyTFM/test_pyTFM.py b/pyTFM/test_pyTFM.py new file mode 100644 index 0000000..0c47fdf --- /dev/null +++ b/pyTFM/test_pyTFM.py @@ -0,0 +1,104 @@ +import numpy as np +import pytest +import matplotlib.pyplot as plt +import numpy as np +import openpiv.filters +import scipy.fft + +from openpiv.pyprocess import extended_search_area_piv +import openpiv.scaling +import openpiv.tools +import openpiv.validation +from matplotlib.colors import LinearSegmentedColormap +from mpl_toolkits.axes_grid1 import make_axes_locatable +from pyTFM.utilities_TFM import suppress_warnings +from scipy.ndimage.filters import median_filter, gaussian_filter +from scipy.ndimage.filters import uniform_filter +from pyTFM.TFM_functions import ffttc_traction +from pyTFM.TFM_functions import get_xy_for_quiver + +def test_ffttc_traction_output_shape(): + # create test inputs + u = np.zeros((10, 10)) + v = np.zeros((10, 10)) + pixelsize1 = 0.1 + pixelsize2 = 0.1 + young = 1e6 + + # call the function + tx_filter, ty_filter = ffttc_traction(u, v, pixelsize1, pixelsize2, young) + + # assert that the output shape is as expected + assert tx_filter.shape == (10, 10) + assert ty_filter.shape == (10, 10) + +def test_ffttc_traction_output_type(): + # create test inputs + u = np.zeros((10, 10)) + v = np.zeros((10, 10)) + pixelsize1 = 0.1 + pixelsize2 = 0.1 + young = 1e6 + + # call the function + tx_filter, ty_filter = ffttc_traction(u, v, pixelsize1, pixelsize2, young) + + # assert that the output is of the correct type + assert isinstance(tx_filter, np.ndarray) + assert isinstance(ty_filter, np.ndarray) + +def test_ffttc_traction_output_values(): + # create test inputs + u = np.zeros((10, 10)) + v = np.zeros((10, 10)) + pixelsize1 = 0.1 + pixelsize2 = 0.1 + young = 1e6 + + # call the function + tx_filter, ty_filter = ffttc_traction(u, v, pixelsize1, pixelsize2, young) + + # assert that the output is as expected + assert np.allclose(tx_filter, 0) + assert np.allclose(ty_filter, 0) + +def test_ffttc_traction_input_shape(): + # create test inputs with incorrect shape + u = np.zeros((10, 10, 10)) + v = np.zeros((10, 10)) + pixelsize1 = 0.1 + pixelsize2 = 0.1 + young = 1e6 + + # assert that a ValueError is raised for incorrect input shape + with pytest.raises(ValueError): + ffttc_traction(u, v, pixelsize1, pixelsize2, young) + +def test_ffttc_traction_input_type(): + # create test inputs with incorrect type + u = np.zeros((10, 10)) + v = "not an array" + pixelsize1 = 0.1 + pixelsize2 = 0.1 + young = 1e6 + + # assert that a TypeError is raised for incorrect input type + with pytest.raises(TypeError): + ffttc_traction(u, v, pixelsize1, pixelsize2, young) + +########get_xy_for_quiver +def test_get_xy_for_quiver(): + u = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) + xs, ys = get_xy_for_quiver(u) + + # Test the shape of xs and ys + assert np.shape(xs) == np.shape(u) + assert np.shape(ys) == np.shape(u) + + # Test the values of xs + for i in range(np.shape(u)[0]): + assert np.array_equal(xs[i, :], np.arange(0, np.shape(u)[1], 1)) + + # Test the values of ys + for j in range(np.shape(u)[1]): + assert np.array_equal(ys[:, j], np.arange(0, np.shape(u)[0], 1)) From 879fbcbcccf1c69e7d52c091ce8374f3218ce014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=A4tz?= <61615369+martinschatz-cz@users.noreply.github.com> Date: Thu, 9 Feb 2023 16:55:47 +0100 Subject: [PATCH 06/19] Delete testing directory --- testing/test_pyTFM.py | 104 ------------------------------------------ 1 file changed, 104 deletions(-) delete mode 100644 testing/test_pyTFM.py diff --git a/testing/test_pyTFM.py b/testing/test_pyTFM.py deleted file mode 100644 index 0c47fdf..0000000 --- a/testing/test_pyTFM.py +++ /dev/null @@ -1,104 +0,0 @@ -import numpy as np -import pytest -import matplotlib.pyplot as plt -import numpy as np -import openpiv.filters -import scipy.fft - -from openpiv.pyprocess import extended_search_area_piv -import openpiv.scaling -import openpiv.tools -import openpiv.validation -from matplotlib.colors import LinearSegmentedColormap -from mpl_toolkits.axes_grid1 import make_axes_locatable -from pyTFM.utilities_TFM import suppress_warnings -from scipy.ndimage.filters import median_filter, gaussian_filter -from scipy.ndimage.filters import uniform_filter -from pyTFM.TFM_functions import ffttc_traction -from pyTFM.TFM_functions import get_xy_for_quiver - -def test_ffttc_traction_output_shape(): - # create test inputs - u = np.zeros((10, 10)) - v = np.zeros((10, 10)) - pixelsize1 = 0.1 - pixelsize2 = 0.1 - young = 1e6 - - # call the function - tx_filter, ty_filter = ffttc_traction(u, v, pixelsize1, pixelsize2, young) - - # assert that the output shape is as expected - assert tx_filter.shape == (10, 10) - assert ty_filter.shape == (10, 10) - -def test_ffttc_traction_output_type(): - # create test inputs - u = np.zeros((10, 10)) - v = np.zeros((10, 10)) - pixelsize1 = 0.1 - pixelsize2 = 0.1 - young = 1e6 - - # call the function - tx_filter, ty_filter = ffttc_traction(u, v, pixelsize1, pixelsize2, young) - - # assert that the output is of the correct type - assert isinstance(tx_filter, np.ndarray) - assert isinstance(ty_filter, np.ndarray) - -def test_ffttc_traction_output_values(): - # create test inputs - u = np.zeros((10, 10)) - v = np.zeros((10, 10)) - pixelsize1 = 0.1 - pixelsize2 = 0.1 - young = 1e6 - - # call the function - tx_filter, ty_filter = ffttc_traction(u, v, pixelsize1, pixelsize2, young) - - # assert that the output is as expected - assert np.allclose(tx_filter, 0) - assert np.allclose(ty_filter, 0) - -def test_ffttc_traction_input_shape(): - # create test inputs with incorrect shape - u = np.zeros((10, 10, 10)) - v = np.zeros((10, 10)) - pixelsize1 = 0.1 - pixelsize2 = 0.1 - young = 1e6 - - # assert that a ValueError is raised for incorrect input shape - with pytest.raises(ValueError): - ffttc_traction(u, v, pixelsize1, pixelsize2, young) - -def test_ffttc_traction_input_type(): - # create test inputs with incorrect type - u = np.zeros((10, 10)) - v = "not an array" - pixelsize1 = 0.1 - pixelsize2 = 0.1 - young = 1e6 - - # assert that a TypeError is raised for incorrect input type - with pytest.raises(TypeError): - ffttc_traction(u, v, pixelsize1, pixelsize2, young) - -########get_xy_for_quiver -def test_get_xy_for_quiver(): - u = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) - xs, ys = get_xy_for_quiver(u) - - # Test the shape of xs and ys - assert np.shape(xs) == np.shape(u) - assert np.shape(ys) == np.shape(u) - - # Test the values of xs - for i in range(np.shape(u)[0]): - assert np.array_equal(xs[i, :], np.arange(0, np.shape(u)[1], 1)) - - # Test the values of ys - for j in range(np.shape(u)[1]): - assert np.array_equal(ys[:, j], np.arange(0, np.shape(u)[0], 1)) From c518aa9e4b44e0f1b55acd58b9679f4c0e4ab445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=A4tz?= <61615369+martinschatz-cz@users.noreply.github.com> Date: Thu, 9 Feb 2023 16:56:05 +0100 Subject: [PATCH 07/19] Update python-package.yml --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 51a29c8..520d1e8 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -31,4 +31,4 @@ jobs: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Test with pytest run: | - pytest testing/test_pyTFM.py + pytest test_pyTFM.py From 7473e10f981048aa1451b1c3100f87d585bfaec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=A4tz?= <61615369+martinschatz-cz@users.noreply.github.com> Date: Thu, 9 Feb 2023 17:31:33 +0100 Subject: [PATCH 08/19] Update python-package.yml --- .github/workflows/python-package.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 520d1e8..b60c84e 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -29,6 +29,13 @@ jobs: python -m pip install --upgrade pip python -m pip install pytest if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + # Display the Python version being used + - name: Display Python version + run: python -c "import sys; print(sys.version)" + # Install the package using the setup.py + - name: Install package + run: python setup.py install + # Install pytest (you can use some other testing utility) - name: Test with pytest run: | - pytest test_pyTFM.py + pytest pyTFM/pyTFM/test_pyTFM.py From 4e29aec2adff6add788a7f5a04d96c42f2287fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=A4tz?= <61615369+martinschatz-cz@users.noreply.github.com> Date: Thu, 9 Feb 2023 17:35:00 +0100 Subject: [PATCH 09/19] Update python-package.yml --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index b60c84e..ec401c4 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -34,7 +34,7 @@ jobs: run: python -c "import sys; print(sys.version)" # Install the package using the setup.py - name: Install package - run: python setup.py install + run: pip install git+https://github.com/fabrylab/pyTFM.git # Install pytest (you can use some other testing utility) - name: Test with pytest run: | From c04447d90e9790af4a9b6620a812d82684dd2b79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=A4tz?= <61615369+martinschatz-cz@users.noreply.github.com> Date: Thu, 9 Feb 2023 17:41:13 +0100 Subject: [PATCH 10/19] Create test_pyTFM.py --- test_pyTFM.py | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 test_pyTFM.py diff --git a/test_pyTFM.py b/test_pyTFM.py new file mode 100644 index 0000000..0c47fdf --- /dev/null +++ b/test_pyTFM.py @@ -0,0 +1,104 @@ +import numpy as np +import pytest +import matplotlib.pyplot as plt +import numpy as np +import openpiv.filters +import scipy.fft + +from openpiv.pyprocess import extended_search_area_piv +import openpiv.scaling +import openpiv.tools +import openpiv.validation +from matplotlib.colors import LinearSegmentedColormap +from mpl_toolkits.axes_grid1 import make_axes_locatable +from pyTFM.utilities_TFM import suppress_warnings +from scipy.ndimage.filters import median_filter, gaussian_filter +from scipy.ndimage.filters import uniform_filter +from pyTFM.TFM_functions import ffttc_traction +from pyTFM.TFM_functions import get_xy_for_quiver + +def test_ffttc_traction_output_shape(): + # create test inputs + u = np.zeros((10, 10)) + v = np.zeros((10, 10)) + pixelsize1 = 0.1 + pixelsize2 = 0.1 + young = 1e6 + + # call the function + tx_filter, ty_filter = ffttc_traction(u, v, pixelsize1, pixelsize2, young) + + # assert that the output shape is as expected + assert tx_filter.shape == (10, 10) + assert ty_filter.shape == (10, 10) + +def test_ffttc_traction_output_type(): + # create test inputs + u = np.zeros((10, 10)) + v = np.zeros((10, 10)) + pixelsize1 = 0.1 + pixelsize2 = 0.1 + young = 1e6 + + # call the function + tx_filter, ty_filter = ffttc_traction(u, v, pixelsize1, pixelsize2, young) + + # assert that the output is of the correct type + assert isinstance(tx_filter, np.ndarray) + assert isinstance(ty_filter, np.ndarray) + +def test_ffttc_traction_output_values(): + # create test inputs + u = np.zeros((10, 10)) + v = np.zeros((10, 10)) + pixelsize1 = 0.1 + pixelsize2 = 0.1 + young = 1e6 + + # call the function + tx_filter, ty_filter = ffttc_traction(u, v, pixelsize1, pixelsize2, young) + + # assert that the output is as expected + assert np.allclose(tx_filter, 0) + assert np.allclose(ty_filter, 0) + +def test_ffttc_traction_input_shape(): + # create test inputs with incorrect shape + u = np.zeros((10, 10, 10)) + v = np.zeros((10, 10)) + pixelsize1 = 0.1 + pixelsize2 = 0.1 + young = 1e6 + + # assert that a ValueError is raised for incorrect input shape + with pytest.raises(ValueError): + ffttc_traction(u, v, pixelsize1, pixelsize2, young) + +def test_ffttc_traction_input_type(): + # create test inputs with incorrect type + u = np.zeros((10, 10)) + v = "not an array" + pixelsize1 = 0.1 + pixelsize2 = 0.1 + young = 1e6 + + # assert that a TypeError is raised for incorrect input type + with pytest.raises(TypeError): + ffttc_traction(u, v, pixelsize1, pixelsize2, young) + +########get_xy_for_quiver +def test_get_xy_for_quiver(): + u = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) + xs, ys = get_xy_for_quiver(u) + + # Test the shape of xs and ys + assert np.shape(xs) == np.shape(u) + assert np.shape(ys) == np.shape(u) + + # Test the values of xs + for i in range(np.shape(u)[0]): + assert np.array_equal(xs[i, :], np.arange(0, np.shape(u)[1], 1)) + + # Test the values of ys + for j in range(np.shape(u)[1]): + assert np.array_equal(ys[:, j], np.arange(0, np.shape(u)[0], 1)) From 8fb4c6f4de7815658a830d8ebe0917db0cf8504e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=A4tz?= <61615369+martinschatz-cz@users.noreply.github.com> Date: Thu, 9 Feb 2023 17:41:27 +0100 Subject: [PATCH 11/19] Delete test_pyTFM.py --- pyTFM/test_pyTFM.py | 104 -------------------------------------------- 1 file changed, 104 deletions(-) delete mode 100644 pyTFM/test_pyTFM.py diff --git a/pyTFM/test_pyTFM.py b/pyTFM/test_pyTFM.py deleted file mode 100644 index 0c47fdf..0000000 --- a/pyTFM/test_pyTFM.py +++ /dev/null @@ -1,104 +0,0 @@ -import numpy as np -import pytest -import matplotlib.pyplot as plt -import numpy as np -import openpiv.filters -import scipy.fft - -from openpiv.pyprocess import extended_search_area_piv -import openpiv.scaling -import openpiv.tools -import openpiv.validation -from matplotlib.colors import LinearSegmentedColormap -from mpl_toolkits.axes_grid1 import make_axes_locatable -from pyTFM.utilities_TFM import suppress_warnings -from scipy.ndimage.filters import median_filter, gaussian_filter -from scipy.ndimage.filters import uniform_filter -from pyTFM.TFM_functions import ffttc_traction -from pyTFM.TFM_functions import get_xy_for_quiver - -def test_ffttc_traction_output_shape(): - # create test inputs - u = np.zeros((10, 10)) - v = np.zeros((10, 10)) - pixelsize1 = 0.1 - pixelsize2 = 0.1 - young = 1e6 - - # call the function - tx_filter, ty_filter = ffttc_traction(u, v, pixelsize1, pixelsize2, young) - - # assert that the output shape is as expected - assert tx_filter.shape == (10, 10) - assert ty_filter.shape == (10, 10) - -def test_ffttc_traction_output_type(): - # create test inputs - u = np.zeros((10, 10)) - v = np.zeros((10, 10)) - pixelsize1 = 0.1 - pixelsize2 = 0.1 - young = 1e6 - - # call the function - tx_filter, ty_filter = ffttc_traction(u, v, pixelsize1, pixelsize2, young) - - # assert that the output is of the correct type - assert isinstance(tx_filter, np.ndarray) - assert isinstance(ty_filter, np.ndarray) - -def test_ffttc_traction_output_values(): - # create test inputs - u = np.zeros((10, 10)) - v = np.zeros((10, 10)) - pixelsize1 = 0.1 - pixelsize2 = 0.1 - young = 1e6 - - # call the function - tx_filter, ty_filter = ffttc_traction(u, v, pixelsize1, pixelsize2, young) - - # assert that the output is as expected - assert np.allclose(tx_filter, 0) - assert np.allclose(ty_filter, 0) - -def test_ffttc_traction_input_shape(): - # create test inputs with incorrect shape - u = np.zeros((10, 10, 10)) - v = np.zeros((10, 10)) - pixelsize1 = 0.1 - pixelsize2 = 0.1 - young = 1e6 - - # assert that a ValueError is raised for incorrect input shape - with pytest.raises(ValueError): - ffttc_traction(u, v, pixelsize1, pixelsize2, young) - -def test_ffttc_traction_input_type(): - # create test inputs with incorrect type - u = np.zeros((10, 10)) - v = "not an array" - pixelsize1 = 0.1 - pixelsize2 = 0.1 - young = 1e6 - - # assert that a TypeError is raised for incorrect input type - with pytest.raises(TypeError): - ffttc_traction(u, v, pixelsize1, pixelsize2, young) - -########get_xy_for_quiver -def test_get_xy_for_quiver(): - u = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) - xs, ys = get_xy_for_quiver(u) - - # Test the shape of xs and ys - assert np.shape(xs) == np.shape(u) - assert np.shape(ys) == np.shape(u) - - # Test the values of xs - for i in range(np.shape(u)[0]): - assert np.array_equal(xs[i, :], np.arange(0, np.shape(u)[1], 1)) - - # Test the values of ys - for j in range(np.shape(u)[1]): - assert np.array_equal(ys[:, j], np.arange(0, np.shape(u)[0], 1)) From 5663d0e886097c513475ccd22401d12e24421326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=A4tz?= <61615369+martinschatz-cz@users.noreply.github.com> Date: Thu, 9 Feb 2023 17:42:01 +0100 Subject: [PATCH 12/19] Update python-package.yml --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index ec401c4..890dd54 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -38,4 +38,4 @@ jobs: # Install pytest (you can use some other testing utility) - name: Test with pytest run: | - pytest pyTFM/pyTFM/test_pyTFM.py + pytest test_pyTFM.py From a835c83745a305003974683bca22940780c48380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=A4tz?= <61615369+martinschatz-cz@users.noreply.github.com> Date: Thu, 9 Feb 2023 17:50:32 +0100 Subject: [PATCH 13/19] Update python-package.yml --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 890dd54..40fa2fb 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.7", "3.8", "3.9"] + python-version: ["3.7"] #["3.7", "3.8", "3.9"] steps: - uses: actions/checkout@v3 From af6dcfd2b6c613685a62385f995b8917ea22a008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=A4tz?= <61615369+martinschatz-cz@users.noreply.github.com> Date: Thu, 9 Feb 2023 17:52:58 +0100 Subject: [PATCH 14/19] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index e908c7d..6a77932 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +[![Python package](https://github.com/martinschatz-cz/pyTFM/actions/workflows/python-package.yml/badge.svg?event=push)](https://github.com/martinschatz-cz/pyTFM/actions/workflows/python-package.yml) + +[![Python 3.7](https://img.shields.io/badge/python-3.7-green.svg)]() [![Python 3.8](https://img.shields.io/badge/python-3.8-red.svg)]() [![Python 3.9](https://img.shields.io/badge/python-3.9-red.svg)]() + ## Readme pyTFM is a python package that allows you to analyze force generation and stresses in cell colonies and confluent cell layers growing on a 2 dimensional surface. This package implements the procedures of [Traction Force Microscopy](https://www.ncbi.nlm.nih.gov/pubmed/11832345) and [Monolayer Stress Microscopy](https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0055172). In addition to the standard measures for stress and force generation, it From 235622a8dcd7aabcbc54ebe696a1f99410b2c48e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=A4tz?= <61615369+martinschatz-cz@users.noreply.github.com> Date: Fri, 10 Feb 2023 08:53:30 +0100 Subject: [PATCH 15/19] contractillity and strain_energy_points test --- test_pyTFM.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test_pyTFM.py b/test_pyTFM.py index 0c47fdf..7a0a459 100644 --- a/test_pyTFM.py +++ b/test_pyTFM.py @@ -16,6 +16,8 @@ from scipy.ndimage.filters import uniform_filter from pyTFM.TFM_functions import ffttc_traction from pyTFM.TFM_functions import get_xy_for_quiver +from pyTFM.TFM_functions import strain_energy_points +from pyTFM.TFM_functions import contractillity def test_ffttc_traction_output_shape(): # create test inputs @@ -102,3 +104,28 @@ def test_get_xy_for_quiver(): # Test the values of ys for j in range(np.shape(u)[1]): assert np.array_equal(ys[:, j], np.arange(0, np.shape(u)[0], 1)) + + +def test_contractility(): + tx = np.array([1, 2, 3, 4, 5]) + ty = np.array([1, 2, 3, 4, 5]) + pixelsize = 10 + mask = np.array([True, True, True, True, True]) + + expected_output = (30.0, np.array([5.5, 11.0, 16.5, 22.0, 27.5]), np.array([5.5, 11.0, 16.5, 22.0, 27.5]), np.array([2.5, 2.5])) + output = contractillity(tx, ty, pixelsize, mask) + + assert output == expected_output, f"Expected {expected_output}, but got {output}" + +def test_strain_energy_points(): + u = np.array([1, 2, 3, 4, 5]) + v = np.array([1, 2, 3, 4, 5]) + tx = np.array([1, 2, 3, 4, 5]) + ty = np.array([1, 2, 3, 4, 5]) + pixelsize1 = 10 + pixelsize2 = 10 + + expected_output = np.array([12.5, 25.0, 37.5, 50.0, 62.5]) + output = strain_energy_points(u, v, tx, ty, pixelsize1, pixelsize2) + + assert np.array_equal(output, expected_output), f"Expected {expected_output}, but got {output}" From b126fa8b9c1b84761d75b5bf598098a4402b4f48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=A4tz?= <61615369+martinschatz-cz@users.noreply.github.com> Date: Fri, 10 Feb 2023 08:57:52 +0100 Subject: [PATCH 16/19] clean --- test_pyTFM.py | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/test_pyTFM.py b/test_pyTFM.py index 7a0a459..9658d7d 100644 --- a/test_pyTFM.py +++ b/test_pyTFM.py @@ -104,28 +104,3 @@ def test_get_xy_for_quiver(): # Test the values of ys for j in range(np.shape(u)[1]): assert np.array_equal(ys[:, j], np.arange(0, np.shape(u)[0], 1)) - - -def test_contractility(): - tx = np.array([1, 2, 3, 4, 5]) - ty = np.array([1, 2, 3, 4, 5]) - pixelsize = 10 - mask = np.array([True, True, True, True, True]) - - expected_output = (30.0, np.array([5.5, 11.0, 16.5, 22.0, 27.5]), np.array([5.5, 11.0, 16.5, 22.0, 27.5]), np.array([2.5, 2.5])) - output = contractillity(tx, ty, pixelsize, mask) - - assert output == expected_output, f"Expected {expected_output}, but got {output}" - -def test_strain_energy_points(): - u = np.array([1, 2, 3, 4, 5]) - v = np.array([1, 2, 3, 4, 5]) - tx = np.array([1, 2, 3, 4, 5]) - ty = np.array([1, 2, 3, 4, 5]) - pixelsize1 = 10 - pixelsize2 = 10 - - expected_output = np.array([12.5, 25.0, 37.5, 50.0, 62.5]) - output = strain_energy_points(u, v, tx, ty, pixelsize1, pixelsize2) - - assert np.array_equal(output, expected_output), f"Expected {expected_output}, but got {output}" From efdcc02c597c73dc0f3bc273e06bac9934c63dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=A4tz?= <61615369+martinschatz-cz@users.noreply.github.com> Date: Thu, 23 Mar 2023 15:19:58 +0100 Subject: [PATCH 17/19] compatibility update --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6a77932..eda896e 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,9 @@ pyTFM package install pip install git+https://github.com/fabrylab/pyTFM.git ``` -If you want to use jupyterlab with black packge +If you want to use jupyterlab ``` -conda install jupyterlab jupyterlab_code_formatter black isort -c conda-forge +pip install jupyterlab +jupyter-lab ``` +Sometimes it is necessary to reinstall pyTFM again through the JupyterLab because of scikit-image package. From e1c17b3e30f658c4d860ad6be3ff66e5b30e3bc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=A4tz?= <61615369+martinschatz-cz@users.noreply.github.com> Date: Wed, 30 Aug 2023 15:32:11 +0200 Subject: [PATCH 18/19] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eda896e..ca247b1 100644 --- a/README.md +++ b/README.md @@ -11,12 +11,14 @@ pyTFM includes an addon for the image annotation tool [clickpoints](https://clic Please refer to the [Documentation](https://pytfm.readthedocs.io/en/latest/) of pyTFM for detailed instructions on installation and usage. ## Conda enviroment creation -You need to create python 3.7 enviroment. +You need to create python 3.6 enviroment. ``` -conda create --name pyTFM python=3.7 +conda create --name pyTFM python=3.6 conda activate pyTFM ``` +Note: python 3.7 works too, but clickpoints need python 3.6. + pyTFM package install ``` pip install git+https://github.com/fabrylab/pyTFM.git From 60e919eca1dbc98c86ae2ab7ff86c22f0e4876e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=A4tz?= <61615369+martinschatz-cz@users.noreply.github.com> Date: Wed, 30 Aug 2023 15:34:09 +0200 Subject: [PATCH 19/19] Update of python info --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ca247b1..4b8abce 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Python package](https://github.com/martinschatz-cz/pyTFM/actions/workflows/python-package.yml/badge.svg?event=push)](https://github.com/martinschatz-cz/pyTFM/actions/workflows/python-package.yml) -[![Python 3.7](https://img.shields.io/badge/python-3.7-green.svg)]() [![Python 3.8](https://img.shields.io/badge/python-3.8-red.svg)]() [![Python 3.9](https://img.shields.io/badge/python-3.9-red.svg)]() +[![Python 3.6](https://img.shields.io/badge/python-3.6-green.svg)]() [![Python 3.7](https://img.shields.io/badge/python-3.7-green.svg)]() [![Python 3.8](https://img.shields.io/badge/python-3.8-red.svg)]() [![Python 3.9](https://img.shields.io/badge/python-3.9-red.svg)]() ## Readme