Convert from type Nullable in Julia - julia

The response from a call to the blpapi in Julia is type Array{Nullable,n}. I'd like to be able to work with the data (plot it, math operate on it). How can I get around each data point being type Nullable? Is there a way to convert to Float64?

Thanks to Dan Getz for this.
"Suppose v is the Nullable Array, then get.(v) should be a regular Array of the values (of course, there should not be #NULL values in v)."

Related

Create unique symbol in Julia, similar to Mathematica's `Unique[]`

I need to populate a column of a data frame with unique factors. I have been using sequential integers, but I don't want to consumer of my function to be confused and think that they can do arithmetic on these values. These values are categorical with no definition for order, distance, and scale. In R, I would have solved this problem with as.factor. I see that there is a CategoricalArrays.jl project, which I have never used, that might offer similar functionality.
Mathematica has a useful Unique function that can create a (as the name implies) unique symbol.
In[1]:= Unique[]
Out[1]= $10
Julia has a similar Symbol that generates a lightweight value that I think makes sense to treat as a factor, but I haven't found a built-in technique to automatically generate unique symbols. You cannot invoke Symbol() without a parameter. I suppose I could call Symbol(UUIDs.uuid1()), but these are very long.
julia> using UUIDs
julia> Symbol(UUIDs.uuid1())
Symbol("8a9452d0-2451-11ec-08b4-3bb7f56a346a")
Is there an idiomatic way to generate short and unique symbols in Julia?
The way to generate unique Symbol is to use the gensym function.
However, I assume you most likely want to use CategoricalArrays.jl as you have commented. This package allows you to create arrays of both ordered or unordered factors - just like in R. The difference from R is that the user will be able to clearly see that what is stored in an array is a factor even after extracting it from an array, e.g.:
julia> using CategoricalArrays
julia> x = categorical(1:3)
3-element CategoricalArray{Int64,1,UInt32}:
1
2
3
julia> x[1]
CategoricalValue{Int64, UInt32} 1
and as you can see the notion of being categorical is not lost which I guess is exactly what you want.

In Julia, how do I find out why Dict{String, Any} is Any?

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; and
unique 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.

In R what makes NULL atomical and therefore unable to exist in a vector?

In R for Everyone by Jared P. Lander on p. 54 it says "...NULL is atomical and cannot exist within a vector. If used inside a vector, it simply disappears."
I understand the concept of being atomic is being indivisible and that NULL represents "nothingness", used commonly to handle returns that are undefined.
Therefore, is NULL atomical b/c it has this one value always of "nothingness", meaning something simply does not exist and therefore R's way of handling that is to just not let it exist in a vector or on assignment in a list it will actually remove that element?
Trying to wrap my head around it and find a more intuitive and comprehensive answer.
In my opinion talking about vectors as being "atomic" is more confusing than helpful. Instead, consider that R has a series of data types built into the language. They are given by definition and are distinct from one another.
For example, one such data type is "integer vector", which represents a sequence of integer values. Note that R does not have a data type of "integer". If we are talking about integer 5 in R, it is actually an integer vector of length 1.
Another built-in data type is NULL. There is a single object of type NULL, which is also called NULL. Since NULL is a type and an object, but not an integer value, it cannot be part of an integer vector.
Missing data in an integer vector are represented by NA. In this context NA is considered an integer value. Note that NA can also be a numeric value, logical value, etc. NA is a not a data type, but a value.
A complete list of built-in data types can be found in the R source code and also in the documentation, e.g. https://cran.r-project.org/doc/manuals/r-release/R-ints.html#SEXPTYPEs

In CDS View select statement, how to convert type DEC to type INT?

In a CDS View select statement, given that I have a column of type DEC, how do I convert that to type INT?
Work done so far: According to the CAST_EXPR documentation, this is not possible with CAST_EXPR . According to the numeric functions documentation, math functions like FLOOR will return a value of the same type.
Update: the numeric functions documentation is correct.
The code floor(fieldname) will convert a DEC(X,Y) (where Y > 0) into a DEC(X,0). Essentially, floor strips the decimal places from the field without changing its type.
On the other hand, ceil(fieldname) will round up to the nearest integer and convert a DEC to an INT
If you want to get an integer from the floor function, then you must call ceil(floor(fieldname))
On a NetWeaver system, you should be able to find the CDS View demo_cds_sql_functions_num and program/report demo_cds_sql_functions_num that help demonstrate these concepts. You can use the debugger to view the report's variable result and confirm my findings.
ceil does it:
cast(ceil(fieldname) as abap.int4)
Note that floor won't.

What's the mean of "QVector<QVector<QVector<T>>> vector"?

This is the code:
QVector<QVector<QVector<T>>> vector
I've tried search from internet, nothing help
The mean QVector<QVector<QVector<T>>> vector is 3D - array storing objects of type T. If you need example for int, you can find it here:
Qt 3D-array with Qt-Objekts like QVector
Each dimension can be different.

Resources