dimod icon indicating copy to clipboard operation
dimod copied to clipboard

printing samplesets fails when one of the datafields is more than one dimension and has float biases

Open arcondello opened this issue 4 years ago • 0 comments

        rec = np.recarray(5, dtype=[('sample', '<f8', 2),
                                    ('energy', '<f8'),
                                    ('num_occurrences', 'int8'),
                                    ('violations', '<i1', 10),
                                    ])

        rec[:] = 1

        ss = dimod.SampleSet(rec, range(2), {}, 'SPIN')

        print(ss)

works fine, but

        rec = np.recarray(5, dtype=[('sample', '<f8', 2),
                                    ('energy', '<f8'),
                                    ('num_occurrences', 'int8'),
                                    ('violations', '<f8', 10),
                                    ])

        rec[:] = 1

        ss = dimod.SampleSet(rec, range(2), {}, 'SPIN')

        print(ss)

raises

TypeError: only size-1 arrays can be converted to Python scalars

arcondello avatar Jul 26 '21 23:07 arcondello