From 7b4e0e9036c544db73d7f887cc13d7fdd25c30fe Mon Sep 17 00:00:00 2001 From: algobytewise Date: Tue, 6 Apr 2021 16:27:15 +0530 Subject: [PATCH 1/8] fix type-hints arguments --- digital_image_processing/rotation/rotation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/digital_image_processing/rotation/rotation.py b/digital_image_processing/rotation/rotation.py index 2951f18fc0ec..7cf90917924f 100644 --- a/digital_image_processing/rotation/rotation.py +++ b/digital_image_processing/rotation/rotation.py @@ -4,8 +4,8 @@ def get_rotation( - img: np.array, pt1: np.float32, pt2: np.float32, rows: int, cols: int -) -> np.array: + img: np.ndarray, pt1: np.float32, pt2: np.float32, rows: int, cols: int +) -> np.ndarray: """ Get image rotation :param img: np.array From 7a575d6e83cf5959963faefb277defa543436dc4 Mon Sep 17 00:00:00 2001 From: algobytewise Date: Tue, 6 Apr 2021 16:42:05 +0530 Subject: [PATCH 2/8] fix matrices & image-path --- digital_image_processing/rotation/rotation.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/digital_image_processing/rotation/rotation.py b/digital_image_processing/rotation/rotation.py index 7cf90917924f..8d3fbf895dbf 100644 --- a/digital_image_processing/rotation/rotation.py +++ b/digital_image_processing/rotation/rotation.py @@ -1,10 +1,11 @@ import cv2 import numpy as np from matplotlib import pyplot as plt +import os.path def get_rotation( - img: np.ndarray, pt1: np.float32, pt2: np.float32, rows: int, cols: int + img: np.ndarray, pt1: np.ndarray, pt2: np.ndarray, rows: int, cols: int ) -> np.ndarray: """ Get image rotation @@ -21,17 +22,17 @@ def get_rotation( if __name__ == "__main__": # read original image - image = cv2.imread("lena.jpg") + image = cv2.imread(os.path.dirname(__file__) + "/../image_data/lena.jpg") # turn image in gray scale value gray_img = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # get image shape img_rows, img_cols = gray_img.shape # set different points to rotate image - pts1 = np.float32([[50, 50], [200, 50], [50, 200]]) - pts2 = np.float32([[10, 100], [200, 50], [100, 250]]) - pts3 = np.float32([[50, 50], [150, 50], [120, 200]]) - pts4 = np.float32([[10, 100], [80, 50], [180, 250]]) + pts1 = np.array([[50, 50], [200, 50], [50, 200]], np.float32) + pts2 = np.array([[10, 100], [200, 50], [100, 250]], np.float32) + pts3 = np.array([[50, 50], [150, 50], [120, 200]], np.float32) + pts4 = np.array([[10, 100], [80, 50], [180, 250]], np.float32) # add all rotated images in a list images = [ From c2d04aef65292af6b5f9ca9581c25ac8aadf4a50 Mon Sep 17 00:00:00 2001 From: algobytewise Date: Tue, 6 Apr 2021 16:43:22 +0530 Subject: [PATCH 3/8] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ca3e8092276e..6eb989e50425 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ jobs: python -m pip install mypy pytest-cov -r requirements.txt # FIXME: #4052 fix mypy errors in the exclude directories and remove them below - run: mypy --ignore-missing-imports - --exclude '(data_structures|digital_image_processing|dynamic_programming|graphs|maths|matrix|other|project_euler|scripts|searches|strings*)/$' . + --exclude '(data_structures|dynamic_programming|graphs|maths|matrix|other|project_euler|scripts|searches|strings*)/$' . - name: Run tests run: pytest --doctest-modules --ignore=project_euler/ --ignore=scripts/ --cov-report=term-missing:skip-covered --cov=. . - if: ${{ success() }} From 9ee8f9738f973d3f184ca61d46866ec4ca6dc1f3 Mon Sep 17 00:00:00 2001 From: algobytewise Date: Tue, 6 Apr 2021 16:50:50 +0530 Subject: [PATCH 4/8] Revert "Update build.yml" This reverts commit c2d04aef65292af6b5f9ca9581c25ac8aadf4a50. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6eb989e50425..ca3e8092276e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ jobs: python -m pip install mypy pytest-cov -r requirements.txt # FIXME: #4052 fix mypy errors in the exclude directories and remove them below - run: mypy --ignore-missing-imports - --exclude '(data_structures|dynamic_programming|graphs|maths|matrix|other|project_euler|scripts|searches|strings*)/$' . + --exclude '(data_structures|digital_image_processing|dynamic_programming|graphs|maths|matrix|other|project_euler|scripts|searches|strings*)/$' . - name: Run tests run: pytest --doctest-modules --ignore=project_euler/ --ignore=scripts/ --cov-report=term-missing:skip-covered --cov=. . - if: ${{ success() }} From 2d1c8b53b320545f8a7a73c58c507da9cad27fe6 Mon Sep 17 00:00:00 2001 From: algobytewise Date: Tue, 6 Apr 2021 18:07:55 +0530 Subject: [PATCH 5/8] use pathlib --- digital_image_processing/rotation/rotation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/digital_image_processing/rotation/rotation.py b/digital_image_processing/rotation/rotation.py index 8d3fbf895dbf..fca18d21273f 100644 --- a/digital_image_processing/rotation/rotation.py +++ b/digital_image_processing/rotation/rotation.py @@ -1,7 +1,7 @@ import cv2 import numpy as np from matplotlib import pyplot as plt -import os.path +from pathlib import Path def get_rotation( @@ -22,7 +22,7 @@ def get_rotation( if __name__ == "__main__": # read original image - image = cv2.imread(os.path.dirname(__file__) + "/../image_data/lena.jpg") + image = cv2.imread(str(Path(__file__).resolve().parent.parent / "image_data" / "lena.jpg")) # turn image in gray scale value gray_img = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # get image shape From b2b8cda409062927598a86aaff113b92d59cb898 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Tue, 6 Apr 2021 16:24:26 +0530 Subject: [PATCH 6/8] feat: Add mypy configuration file (#4315) * feat: Add mypy config file * refactor: Remove mypy options from build workflow * Remove linear_algebra Co-authored-by: Christian Clauss --- .github/workflows/build.yml | 4 +--- mypy.ini | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 mypy.ini diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ca3e8092276e..2ffc2aa293b0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,9 +21,7 @@ jobs: run: | python -m pip install --upgrade pip setuptools six wheel python -m pip install mypy pytest-cov -r requirements.txt - # FIXME: #4052 fix mypy errors in the exclude directories and remove them below - - run: mypy --ignore-missing-imports - --exclude '(data_structures|digital_image_processing|dynamic_programming|graphs|maths|matrix|other|project_euler|scripts|searches|strings*)/$' . + - run: mypy . - name: Run tests run: pytest --doctest-modules --ignore=project_euler/ --ignore=scripts/ --cov-report=term-missing:skip-covered --cov=. . - if: ${{ success() }} diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 000000000000..cf0ba26cfc82 --- /dev/null +++ b/mypy.ini @@ -0,0 +1,5 @@ +[mypy] +ignore_missing_imports = True + +; FIXME: #4052 fix mypy errors in the exclude directories and remove them below +exclude = (data_structures|digital_image_processing|dynamic_programming|graphs|maths|matrix|other|project_euler|scripts|searches|strings*)/$ From a3aeb1b5231b4bfa60a6754f03c2181b72c075d7 Mon Sep 17 00:00:00 2001 From: algobytewise Date: Tue, 6 Apr 2021 18:12:57 +0530 Subject: [PATCH 7/8] rebase & update mypy.ini --- mypy.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy.ini b/mypy.ini index cf0ba26cfc82..b6c4d6fe2785 100644 --- a/mypy.ini +++ b/mypy.ini @@ -2,4 +2,4 @@ ignore_missing_imports = True ; FIXME: #4052 fix mypy errors in the exclude directories and remove them below -exclude = (data_structures|digital_image_processing|dynamic_programming|graphs|maths|matrix|other|project_euler|scripts|searches|strings*)/$ +exclude = (data_structures|dynamic_programming|graphs|maths|matrix|other|project_euler|scripts|searches|strings*)/$ From 324187002be8a47adf7a632d29e9dc0f95d545ea Mon Sep 17 00:00:00 2001 From: algobytewise Date: Tue, 6 Apr 2021 18:21:01 +0530 Subject: [PATCH 8/8] fix pre-commit errors --- digital_image_processing/rotation/rotation.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/digital_image_processing/rotation/rotation.py b/digital_image_processing/rotation/rotation.py index fca18d21273f..958d16fafb91 100644 --- a/digital_image_processing/rotation/rotation.py +++ b/digital_image_processing/rotation/rotation.py @@ -1,7 +1,8 @@ +from pathlib import Path + import cv2 import numpy as np from matplotlib import pyplot as plt -from pathlib import Path def get_rotation( @@ -22,7 +23,9 @@ def get_rotation( if __name__ == "__main__": # read original image - image = cv2.imread(str(Path(__file__).resolve().parent.parent / "image_data" / "lena.jpg")) + image = cv2.imread( + str(Path(__file__).resolve().parent.parent / "image_data" / "lena.jpg") + ) # turn image in gray scale value gray_img = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # get image shape