Exceptions Module
Exceptions for arraybridge.
- exception MemoryConversionError(source_type, target_type, method, reason)[source]
Bases:
ExceptionException raised when memory conversion fails.
- source_type
The source memory type
- target_type
The target memory type
- method
The conversion method that was attempted
- reason
The reason for the failure
Exception Classes
MemoryConversionError
Examples
Catching Conversion Errors
from arraybridge import convert_memory
from arraybridge.exceptions import MemoryConversionError
import numpy as np
try:
data = np.array([1, 2, 3])
result = convert_memory(data, 'numpy', 'invalid_type', gpu_id=0)
except MemoryConversionError as e:
print(f"Conversion failed: {e}")
print(f"Source: {e.source_type}")
print(f"Target: {e.target_type}")
print(f"Method: {e.method}")
print(f"Reason: {e.reason}")