Skip to content

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

Open
@MeaningOfLights

Description

@MeaningOfLights

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions