Skip to content

Large Matrices Result in Integer Overflow #285

@danielsclint

Description

@danielsclint

I thought this problem was eradicated with PR #265. Unfortunately, with really large numbers, the issue still occurs.

omx_shape = skim_info['omx_shape']
skim_dtype = skim_info['dtype']
blocks = skim_info['blocks']
skim_data = []
for block_name, block_size in iteritems(blocks):
skims_shape = omx_shape + (block_size,)
block_buffer = skim_buffers[block_name]
assert len(block_buffer) == int(np.prod(skims_shape))

The issue is in the Numpy library np.prod() method. According to the documentation:

Arithmetic is modular when using integer types, and no error is raised on overflow.

>>> x = np.array([536870910, 536870910, 536870910, 536870910])
>>> np.prod(x)
16 # may vary

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions