Skip to content

Test failures with test_transform on NixOS #20

Closed
@doronbehar

Description

@doronbehar

As part of my packaging effort, here are 2 small failures we experience in NixOS in NixOS/nixpkgs#327446 :

=================================== FAILURES ===================================
__________________________ test_transform[False-500] ___________________________

N = 500, assemble_images = False

    @pytest.mark.parametrize("N", [500])
    @pytest.mark.parametrize("assemble_images", [False, True])
    def test_transform(N: int, assemble_images: bool) -> None:
        """Test image transforms
    
        Args:
            N: Image size (N x N)
            assemble_images: If True, assemble images (default: False)
        """
        with qt_app_context(exec_loop=True):
>           items = make_items(N)

lib/python3.12/site-packages/plotpy/tests/items/test_transform.py:205: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
lib/python3.12/site-packages/plotpy/tests/items/test_transform.py:122: in make_items
    write_text_on_array(img, 0, 0, int(N / 15.0), str(dtype))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

data = array([[148, 157, 160, ...,  91, 114, 134],
       [150, 157, 157, ...,  98, 120, 138],
       [149, 154, 152, ..., 10...,  53,  80, 105],
       [136, 150, 159, ...,  67,  94, 117],
       [144, 155, 161, ...,  80, 105, 127]], dtype=uint8)
x = 0, y = 0, sz = 33, txt = "<class 'numpy.uint8'>", range = None

    def write_text_on_array(
        data: np.ndarray,
        x: int,
        y: int,
        sz: int,
        txt: str,
        range: tuple[int, int] | None = None,
    ) -> None:
        """Write text in image (in-place)
    
        Args:
            data: Image data
            x: X-coordinate of top-left corner
            y: Y-coordinate of top-left corner
            sz: Font size
            txt: Text to write
            range: Range of values to map to 0-255 (default: None)
        """
        arr = get_font_array(sz, txt)
        if arr is None:
            return
        if range is None:
            m, M = data.min(), data.max()
        else:
            m, M = range
        z = (float(M) - float(m)) * np.array(arr, float) / 255.0 + m
        arr = np.array(z, data.dtype)
        dy, dx = arr.shape
>       data[y : y + dy, x : x + dx] = arr
E       ValueError: could not broadcast input array from shape (33,693) into shape (33,500)

lib/python3.12/site-packages/plotpy/tests/items/test_transform.py:101: ValueError
----------------------------- Captured stdout call -----------------------------
(40, 40)
___________________________ test_transform[True-500] ___________________________

N = 500, assemble_images = True

    @pytest.mark.parametrize("N", [500])
    @pytest.mark.parametrize("assemble_images", [False, True])
    def test_transform(N: int, assemble_images: bool) -> None:
        """Test image transforms
    
        Args:
            N: Image size (N x N)
            assemble_images: If True, assemble images (default: False)
        """
        with qt_app_context(exec_loop=True):
>           items = make_items(N)

lib/python3.12/site-packages/plotpy/tests/items/test_transform.py:205: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
lib/python3.12/site-packages/plotpy/tests/items/test_transform.py:122: in make_items
    write_text_on_array(img, 0, 0, int(N / 15.0), str(dtype))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

data = array([[ 1, 13, 26, ..., 21, 15,  8],
       [ 6, 16, 29, ..., 13,  9,  4],
       [12, 21, 32, ...,  7,  6,  7],
    ...15, 11, 18, ..., 40, 32, 23],
       [10, 10, 20, ..., 34, 27, 19],
       [ 4, 10, 23, ..., 28, 22, 13]], dtype=uint8)
x = 0, y = 0, sz = 33, txt = "<class 'numpy.uint8'>", range = None

    def write_text_on_array(
        data: np.ndarray,
        x: int,
        y: int,
        sz: int,
        txt: str,
        range: tuple[int, int] | None = None,
    ) -> None:
        """Write text in image (in-place)
    
        Args:
            data: Image data
            x: X-coordinate of top-left corner
            y: Y-coordinate of top-left corner
            sz: Font size
            txt: Text to write
            range: Range of values to map to 0-255 (default: None)
        """
        arr = get_font_array(sz, txt)
        if arr is None:
            return
        if range is None:
            m, M = data.min(), data.max()
        else:
            m, M = range
        z = (float(M) - float(m)) * np.array(arr, float) / 255.0 + m
        arr = np.array(z, data.dtype)
        dy, dx = arr.shape
>       data[y : y + dy, x : x + dx] = arr
E       ValueError: could not broadcast input array from shape (33,693) into shape (33,500)

lib/python3.12/site-packages/plotpy/tests/items/test_transform.py:101: ValueError
----------------------------- Captured stdout call -----------------------------
(40, 40)
=============================== warnings summary ===============================
lib/python3.12/site-packages/plotpy/tests/widgets/test_theme.py:26
  /nix/store/lyx1hxrv16ll7p8n3x045sdq6jxli33d-python3.12-plotpy-2.6.2/lib/python3.12/site-packages/plotpy/tests/widgets/test_theme.py:26: PytestCollectionWarning: cannot collect test class 'TestWidget' because it has a __init__ constructor (from: lib/python3.12/site-packages/plotpy/tests/widgets/test_theme.py)
    class TestWidget(GuidataTestWidget):

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED lib/python3.12/site-packages/plotpy/tests/items/test_transform.py::test_transform[False-500] - ValueError: could not broadcast input array from shape (33,693) into shape ...
FAILED lib/python3.12/site-packages/plotpy/tests/items/test_transform.py::test_transform[True-500] - ValueError: could not broadcast input array from shape (33,693) into shape ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions