flatten icon indicating copy to clipboard operation
flatten copied to clipboard

Regression 0.1.6 -> 0.1.7 for numpy arrays

Open jtlz2 opened this issue 5 years ago • 2 comments

Such a useful module - thank you.

I've noticed that when a numpy array is present as a dictionary value, flatten() throws the following:

  File "myfile.py", line 452, in myfunc
    flattened = flatten(x)
  File "/anaconda2/lib/python2.7/site-packages/flatten_json.py", line 82, in flatten
    _flatten(nested_dict, None)
  File "/anaconda2/lib/python2.7/site-packages/flatten_json.py", line 74, in _flatten
    object_key))
  File "/anaconda2/lib/python2.7/site-packages/flatten_json.py", line 66, in _flatten
    if not object_:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

This worked in 0.1.6. Any ideas what happened? Has some default changed? Is there a workaround? Thanks

jtlz2 avatar Sep 27 '19 15:09 jtlz2

Any update on this?

jtlz2 avatar Jan 23 '20 09:01 jtlz2

@jtlz2 do you mind sharing an example? I haven't looked at it myself yet, maybe someone else has?!

We don't have any tests with numpy arrays and a recent change must've broken things.

amirziai avatar Jan 23 '20 22:01 amirziai