diff --git a/draugr/__init__.py b/draugr/__init__.py index 8d76233a..37b22506 100644 --- a/draugr/__init__.py +++ b/draugr/__init__.py @@ -4,7 +4,7 @@ __project__ = "Draugr" __author__ = "Christian Heider Nielsen" -__version__ = "1.1.1" +__version__ = "1.1.2" __doc__ = r""" Created on 27/04/2019 diff --git a/draugr/numpy_utilities/__init__.py b/draugr/numpy_utilities/__init__.py index 193471ff..73d60aaa 100644 --- a/draugr/numpy_utilities/__init__.py +++ b/draugr/numpy_utilities/__init__.py @@ -16,7 +16,6 @@ try: from .channel_transform import * from .manipulation import * - from .resize import * from .datasets import * from .sampling import * from .powers import * diff --git a/draugr/visualisation/pillow_utilities/__init__.py b/draugr/visualisation/pillow_utilities/__init__.py new file mode 100644 index 00000000..799d8f6e --- /dev/null +++ b/draugr/visualisation/pillow_utilities/__init__.py @@ -0,0 +1,3 @@ +from .resize import * +from .conversion import * +from .enums import * diff --git a/draugr/visualisation/pillow_utilities.py b/draugr/visualisation/pillow_utilities/conversion.py similarity index 83% rename from draugr/visualisation/pillow_utilities.py rename to draugr/visualisation/pillow_utilities/conversion.py index d347adff..4b2fb4a0 100644 --- a/draugr/visualisation/pillow_utilities.py +++ b/draugr/visualisation/pillow_utilities/conversion.py @@ -7,7 +7,6 @@ Created on 17/07/2020 """ -from enum import Enum from typing import Tuple, Union import numpy @@ -23,28 +22,6 @@ import io from PIL import Image -from sorcery import assigned_names - - -class PilModesEnum(Enum): - """ - PIL pixel formats: - - RGB 24bits per pixel, 8-bit-per-channel RGB), 3 channels - RGBA (8-bit-per-channel RGBA), 4 channels - RGBa (8-bit-per-channel RGBA, remultiplied alpha), 4 channels - 1 - 1bpp, often for masks, 1 channel - L - 8bpp, grayscale, 1 channel - P - 8bpp, paletted, 1 channel - I - 32-bit integers, grayscale, 1 channel - F - 32-bit floats, grayscale, 1 channel - CMYK - 8 bits per channel, 4 channels - YCbCr - 8 bits per channel, 3 channels - """ - - OneBpp = "1" - CMYK, F, HSV, I, L, LAB, P, RGB, RGBA, RGBX, YCbCr = assigned_names() - """ 1 (1-bit pixels, black and white, stored with one pixel per byte) diff --git a/draugr/visualisation/pillow_utilities/enums.py b/draugr/visualisation/pillow_utilities/enums.py new file mode 100644 index 00000000..5e32b39f --- /dev/null +++ b/draugr/visualisation/pillow_utilities/enums.py @@ -0,0 +1,27 @@ +from enum import Enum + +from sorcery import assigned_names + +__all__ = [ + "PilModesEnum", +] + + +class PilModesEnum(Enum): + """ + PIL pixel formats: + + RGB 24bits per pixel, 8-bit-per-channel RGB), 3 channels + RGBA (8-bit-per-channel RGBA), 4 channels + RGBa (8-bit-per-channel RGBA, remultiplied alpha), 4 channels + 1 - 1bpp, often for masks, 1 channel + L - 8bpp, grayscale, 1 channel + P - 8bpp, paletted, 1 channel + I - 32-bit integers, grayscale, 1 channel + F - 32-bit floats, grayscale, 1 channel + CMYK - 8 bits per channel, 4 channels + YCbCr - 8 bits per channel, 3 channels + """ + + OneBpp = "1" + CMYK, F, HSV, I, L, LAB, P, RGB, RGBA, RGBX, YCbCr = assigned_names() diff --git a/draugr/numpy_utilities/resize.py b/draugr/visualisation/pillow_utilities/resize.py similarity index 94% rename from draugr/numpy_utilities/resize.py rename to draugr/visualisation/pillow_utilities/resize.py index bab5adf4..c4589dfb 100644 --- a/draugr/numpy_utilities/resize.py +++ b/draugr/visualisation/pillow_utilities/resize.py @@ -11,7 +11,7 @@ import PIL.Image import numpy -from draugr.visualisation.pillow_utilities import np_array_to_pil_img +from .conversion import np_array_to_pil_img __all__ = ["resize_array"] diff --git a/requirements/requirements_dev.txt b/requirements/requirements_dev.txt index a8c54cfe..e792146d 100644 --- a/requirements/requirements_dev.txt +++ b/requirements/requirements_dev.txt @@ -18,6 +18,7 @@ doc8>=0.11.2 flake8>=4.0.1 bandit>=1.7.4 matplotlib>=3.5.2 +types-six>=1.1.1 -r ../requirements.txt -r requirements_docs.txt @@ -35,6 +36,8 @@ matplotlib>=3.5.2 -r requirements_extensions.txt -r requirements_multiprocessing.txt -r requirements_pygame.txt + # full install setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability -numpy>=1.22.2 # not directly required, pinned by Snyk to avoid a vulnerability \ No newline at end of file +numpy>=1.22.2 # not directly required, pinned by Snyk to avoid a vulnerability +pillow>=10.0.1 # not directly required, pinned by Snyk to avoid a vulnerability \ No newline at end of file diff --git a/requirements/requirements_opencv.txt b/requirements/requirements_opencv.txt index 0dd006bb..fa4932a0 100644 --- a/requirements/requirements_opencv.txt +++ b/requirements/requirements_opencv.txt @@ -1 +1,2 @@ opencv-python +numpy>=1.22.2 # not directly required, pinned by Snyk to avoid a vulnerability diff --git a/requirements/requirements_torch.txt b/requirements/requirements_torch.txt index c629e715..a14e3998 100644 --- a/requirements/requirements_torch.txt +++ b/requirements/requirements_torch.txt @@ -4,3 +4,4 @@ torch>=1.12.0 tensorboard torchvision>=0.13.0 wheel>=0.38.0 # not directly required, pinned by Snyk to avoid a vulnerability +pillow>=10.0.1 # not directly required, pinned by Snyk to avoid a vulnerability diff --git a/requirements/requirements_visualisation.txt b/requirements/requirements_visualisation.txt index bb10b208..2d2c3cf2 100644 --- a/requirements/requirements_visualisation.txt +++ b/requirements/requirements_visualisation.txt @@ -1,7 +1,8 @@ -matplotlib -pandas -scikit-learn -numpy -seaborn +matplotlib>=3.8.0 +pandas>=2.1.1 +scikit-learn>=1.3.1 +numpy>=1.26.0 +seaborn>=0.13.0 progress # remove this shit -setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability \ No newline at end of file +setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability +pillow>=10.0.1 # not directly required, pinned by Snyk to avoid a vulnerability \ No newline at end of file diff --git a/requirements/requirements_writers.txt b/requirements/requirements_writers.txt index bbf429b2..599b20ee 100644 --- a/requirements/requirements_writers.txt +++ b/requirements/requirements_writers.txt @@ -4,4 +4,5 @@ scikit-learn numpy visdom sorcery -tornado>=6.3.2 # not directly required, pinned by Snyk to avoid a vulnerability \ No newline at end of file +tornado>=6.3.2 # not directly required, pinned by Snyk to avoid a vulnerability +pillow>=10.0.1 # not directly required, pinned by Snyk to avoid a vulnerability \ No newline at end of file diff --git a/samples/python_tools/logging_filter.py b/samples/python_tools/logging_filter.py new file mode 100644 index 00000000..dac7d657 --- /dev/null +++ b/samples/python_tools/logging_filter.py @@ -0,0 +1,21 @@ +import logging + + +class ContextFilterWorstLevel(logging.Filter): + def __init__(self): + self.worst_level = logging.INFO + + def filter(self, record): + if record.levelno > self.worst_level: + self.worst_level = record.levelno + return True + + +# Create a logger object and add the filter +logger = logging.getLogger() +logger.addFilter(ContextFilterWorstLevel()) + +# Check the worst log level called later +for filter in logger.filters: + if isinstance(filter, ContextFilterWorstLevel): + print(filter.worst_level)