Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_UFuncNoLoopError: ufunc 'subtract' did not contain a loop with signature matching types (dtype('S8'), dtype('int64')) -> None #33

Open
MeaningOfLights opened this issue Jun 16, 2024 · 0 comments

Comments

@MeaningOfLights
Copy link

I'm running using Python 3.9 and I get this error:

numpy.core._exceptions._UFuncNoLoopError: ufunc 'subtract' did not contain a loop with signature matching types (dtype('S8'), dtype('int64')) -> None

With this line of code:

yield sid, offset - mapper[audio_hash]

To get around it I added a Try/Catch however I'm losing a lot of information and want to know the correct way to handle this?

        for hash, sid, offset in x:
            try:
                if isinstance(mapper[hash], bytes):
                    db_offset = int(mapper[hash].decode('utf-8'))
                elif isinstance(mapper[hash], (int, np.integer)):
                    db_offset = int(mapper[hash])
                else:
                    raise ValueError(f"Unsupported type for mapper[{hash}]: {type(mapper[hash])}")
                
                if isinstance(offset, bytes):
                    offset = int(offset.decode('utf-8'))
                elif not isinstance(offset, (int, np.integer)):
                    raise ValueError(f"Unsupported type for offset: {type(offset)}")
    
                yield (sid, offset - db_offset)
            except ValueError:
                print(f"Invalid value for mapper[{hash}]: {mapper[hash]} - Offset {offset}")    # Heaps are invalid
                continue
            except KeyError:
                print(f"Key {hash} not found in mapper")
                continue
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

No branches or pull requests

1 participant