I am very new to Julia and mostly code in Python these days. I am using Julia to work with and manipulate HDF5 files.
So when I get to writing out (h5write
), I get an error because the data argument is of mixed type and I need to find out why.
The error message says Array{Dict{String,Any},4}
is what I am trying to pass in, but when I look at the values (and it is a huge structure), I see a lot of 0xff
and values like this. How do I quickly find why the Any and not a single type?
Just to make this an answer:
If my_dicts
is an Array{Dict{String, Any}, 4}
, then one way of working out what types are hiding in the Any
part of the dict is:
unique(typeof.(values(my_dicts[1])))
To explain:
my_dicts[1]
picks out the first element of your Array, i.e. one of your Dict{String, Any}
values
then extracts the values, which is the Any
part of the dictionary,typeof.
(notice the dot) broadcasts the typeof
function over all elements returned by values
, returning the types of all of these elements; andunique
takes the list of all these types and reduces it to its unique elements, so you'll end up with a list of each separate type contained in the Any
partof your dictionary.