pypulseq icon indicating copy to clipboard operation
pypulseq copied to clipboard

make_label raises ValueError for numpy.int

Open felixlandmeyer opened this issue 9 months ago • 0 comments

Describe the bug The make_label function raises an ValueError if the input is a numpy integer type.

To Reproduce

import pypulseq as pp
pp.make_label(label='PAR', value=np.int64(2), type='SET')   

Expected behavior Should accept the value as other int.

Desktop (please complete the following information):

  • numpy version: 2.1.3
  • pypulseq version: 1.4.2

Additional context Error raised in: https://github.com/imr-framework/pypulseq/blob/0398b12bc1d86c1997ed5ad34242a22cc95003bd/src/pypulseq/make_label.py#L42-L43 Can be resolved either by adding np.integer to the accepted values

import numpy
if not isinstance(value, (bool, float, int, np.integer)):
    raise ValueError('Must supply a valid numerical or logical value.')

Or by import numbers

import numbers
if not isinstance(value, numbers.Number):
    raise ValueError('Must supply a valid numerical or logical value.')

felixlandmeyer avatar Feb 25 '25 12:02 felixlandmeyer