Skip to content

tolist() fails on non-list quantity #185

@rgerkin

Description

@rgerkin

The .tolist() method does not work on a quantity derived from a single numpy value (rather than an array). The same method does work on all numpy values, regardless of whether they are lists. Other packages like jsonpickle depend on this behavior working.

import sys
sys.path.insert(0, '/home/rgerkin/Dropbox/dev/quantities')
import numpy as np
import quantities as pq

x = np.array([1.0, 2.0])
y = np.array(3.0)

x.tolist()  # Works fine
y.tolist() # Works fine

(x * pq.V).tolist() # Works fine
(y * pq.V).tolist() # Throws exception

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