Class ArrayMemoryError
- Namespace
- NumSharp
- Assembly
- NumSharp.dll
NumPy's _ArrayMemoryError: an array of a given shape and dtype could not be allocated. Its text is NumPy's
Unable to allocate 7.45 GiB for an array with shape (1000000000,) and data type float64, the size in binary
units from the shape and the dtype's item size.
public class ArrayMemoryError : MemoryError, ISerializable, INumSharpException
- Inheritance
-
ArrayMemoryError
- Implements
- Inherited Members
Remarks
A subclass of MemoryError (and so of .NET's OutOfMemoryException), as NumPy's is a
subclass of Python's MemoryError; catch MemoryError, as NumPy advises (_ArrayMemoryError
is private to NumPy and its traceback shows it as MemoryError). NumSharp drops NumPy's leading underscore:
a C# type name cannot hide behind _display_as_base.
It reports a request NumPy's size checks accept (a byte count that fits intp) but the memory cannot hold; a
byte count past intp is NumPy's ValueError array is too big; … instead.
Constructors
ArrayMemoryError(long[], DType)
NumPy's _ArrayMemoryError(shape, dtype): the message is NumPy's str of the two values.
public ArrayMemoryError(long[] shape, DType dtype)
Parameters
shapelong[]The dimensions of the array that could not be allocated (a 0-d array: empty).
dtypeDTypeIts dtype; the item size times the dimensions is the byte count reported.
Exceptions
- ArgumentNullException
shapeordtypeis null (NumPy fails only when the text is formatted; NumSharp formats it here).
ArrayMemoryError(long[], DType, Exception)
NumPy's _ArrayMemoryError(shape, dtype) with the exception that caused it: NumSharp's translation of a
.NET allocation failure keeps the .NET exception in InnerException.
public ArrayMemoryError(long[] shape, DType dtype, Exception innerException)
Parameters
shapelong[]The dimensions of the array that could not be allocated (a 0-d array: empty).
dtypeDTypeIts dtype.
innerExceptionExceptionThe exception that led to this one (the allocator's OutOfMemoryException), or null for none.
Exceptions
- ArgumentNullException
shapeordtypeis null.
ArrayMemoryError(string, Exception)
Creates the error from a message and the exception that caused it, .NET's standard constructor every NumSharp exception has: the message is kept verbatim and shape / dtype are null.
public ArrayMemoryError(string message, Exception innerException)
Parameters
messagestringThe verbatim message.
innerExceptionExceptionThe exception that led to this one, or null for none.
Remarks
Python has no such constructor (NumPy's _ArrayMemoryError takes the shape and the dtype). NumSharp's
raise sites always use the shape-and-dtype form, so a caught error carries both; this form is for code that
holds a text only. Footgun: new ArrayMemoryError(null, null) does not compile (both two-argument
constructors accept two nulls); cast the arguments to pick one.
Properties
dtype
The dtype of the array that could not be allocated (NumPy's dtype attribute); null when the error
was built from a message alone.
public DType dtype { get; }
Property Value
shape
The dimensions of the array that could not be allocated (NumPy's shape attribute), as a fresh copy on
every read: NumPy's is an immutable tuple, so a caller that changes the copy cannot change the error. Null
when the error was built from a message alone.
public long[] shape { get; }
Property Value
- long[]