Skip to content

Disable Numba looplift on _extract_pairs to suppress warning#24

Open
maxanier wants to merge 1 commit intoRohde-Schwarz:mainfrom
maxanier:patch-1
Open

Disable Numba looplift on _extract_pairs to suppress warning#24
maxanier wants to merge 1 commit intoRohde-Schwarz:mainfrom
maxanier:patch-1

Conversation

@maxanier
Copy link
Copy Markdown

@maxanier maxanier commented Sep 5, 2024

When numba is installed, every time I run a script that imports RsWaveform a warning is printed to console:

xxx/venv/lib/python3.10/site-packages/RsWaveform/iqw/load.py:68: NumbaWarning: 
Compilation is falling back to object mode WITHOUT looplifting enabled because Function "_extract_pairs" failed type inference due to: Unknown attribute 'extend' of type bytearray(uint8, 1d, C)

File "../../../../venv/lib/python3.10/site-packages/RsWaveform/iqw/load.py", line 75:
    def _extract_pairs(buf: bytes, start: int = 0) -> bytes:
        <source elided>
        for idx in np.arange(start * 4, length, 8):
            single_pair.extend(buf[idx : idx + 4])
            ^

During: typing of get attribute at xxx/venv/lib/python3.10/site-packages/RsWaveform/iqw/load.py (75)

File "../../../../venv/lib/python3.10/site-packages/RsWaveform/iqw/load.py", line 75:
    def _extract_pairs(buf: bytes, start: int = 0) -> bytes:
        <source elided>
        for idx in np.arange(start * 4, length, 8):
            single_pair.extend(buf[idx : idx + 4])
            ^

  @staticmethod

Maybe it is possible to somehow help Numba to looplift this function by giving it some information about the extend method, but I don't know how.
My proposed solution is to just specifically disabling looplifting on that function. It is not applied anyway due to above error and by disabling it no warning is printed.

Feel free to manually implement this without merging this PR or implementing a different solution

Numby fails to looplift this function due to Unknown attribute 'extend' of type bytearray(uint8, 1d, C).
To avoid printing a warning when running, just disable this right away
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant