In Python 3, convert np.array object type to float type, with variable number of object element
Date : March 29 2020, 07:55 AM
Hope that helps I have a np.array with dtype as object. Each element here is a np.array with dtype as float and shape as (2,2)  in maths, it is a 2by2 matrix. My aim is to obtain one 2dimenional matrix by converting all the objecttype element into floattype element. This can be better presented by the following example. , Here's a quick way. Your A: In [137]: A
Out[137]:
array([[array([[1, 1],
[1, 1]]), array([[2, 2],
[2, 2]])],
[array([[3, 3],
[3, 3]]), array([[4, 4],
[4, 4]])]], dtype=object)
In [138]: B = np.bmat(A.tolist())
In [139]: B
Out[139]:
matrix([[1, 1, 2, 2],
[1, 1, 2, 2],
[3, 3, 4, 4],
[3, 3, 4, 4]])
In [140]: B = np.bmat(A.tolist()).A
In [141]: B
Out[141]:
array([[1, 1, 2, 2],
[1, 1, 2, 2],
[3, 3, 4, 4],
[3, 3, 4, 4]])
In [164]: np.swapaxes(A.tolist(), 1, 2).reshape(4, 4)
Out[164]:
array([[1, 1, 2, 2],
[1, 1, 2, 2],
[3, 3, 4, 4],
[3, 3, 4, 4]])
In [165]: np.swapaxes(A.tolist(), 1, 2).reshape(A.shape[0]*dA, A.shape[1]*dA)
Out[165]:
array([[1, 1, 2, 2],
[1, 1, 2, 2],
[3, 3, 4, 4],
[3, 3, 4, 4]])

Android/Firebase  Can't convert object of type java.util.ArrayList to type **my object**
Date : March 29 2020, 07:55 AM
I wish this helpful for you Just remembered this post. Have found the answer. When you're working with maps in Firebase, if you have an int as a string (1 vs "1"), Firebase reads that as an int. Whether you inputted it as a string or not. So what I did was add "_key" to the numbers ("1_key") which forced Firebase to read it as a string and not an int. This fixed things right up

com.google.firebase.database.DatabaseException: Can't convert object of type java.lang.String to type class object
Date : March 29 2020, 07:55 AM
this one helps. There was a problem with the authentication and database synchronisation of Firebase, the user which was accessing the database was not registered in the auth section, also there were a few minor glitches, the code is working fine now and I'm getting the child nodes correctly.

Julia: Cannot `convert` an object of type Array{Number,1} to an object of type GLM.LmResp
Tag : julia , By : firebasket
Date : March 29 2020, 07:55 AM
seems to work fine After a few hours, I realized that GLM requires concrete types and Number is an abstract type (even though the documentation for GLM.LmResp says little about this at the time of this writing, only "Encapsulates the response for a linear model"). The solution is to change the declaration to a concrete type, such as Float64: using DataFrames
using GLM
df = DataFrame(response = Float64[])
for i in 1:10
df = vcat(df, DataFrame(response = rand()))
end
fit(LinearModel, @formula(response ~ 1), df)
StatsModels.DataFrameRegressionModel{GLM.LinearModel{GLM.LmResp{Array{Float64,1}},GLM.DensePredChol{Float64,Base.LinAlg.Cholesky{Float64,Array{Float64,2}}}},Array{Float64,2}}
Formula: response ~ +1
Coefficients:
Estimate Std.Error t value Pr(>t)
(Intercept) 0.408856 0.0969961 4.21518 0.0023
ERROR: LoadError: `float` not defined on abstractlytyped arrays; please convert to a more specific type
using DataFrames
using GLM
df = DataFrame(response = Number[])
for i in 1:10
df = vcat(df, DataFrame(response = rand()))
end
df2 = DataFrame(response = map(Real, df[:response]))
fit(LinearModel, @formula(response ~ 1), df2)
julia> typeof(df2[:response])
Array{Float64,1}

Julia append!() Cannot `convert` an object of type Char to an object of type String
Tag : julia , By : John R
Date : March 29 2020, 07:55 AM
it helps some times I cannot see your answer, but here is a typical pattern. You can push! a single element or append! a collection: julia> arry = String[]
0element Array{String,1}
julia> push!(arry, "test")
1element Array{String,1}:
"test"
julia> append!(arry, ("test",))
2element Array{String,1}:
"test"
"test"
julia> append!(arry, ["test"])
3element Array{String,1}:
"test"
"test"
"test"
julia> append!(arry, Ref("test"))
4element Array{String,1}:
"test"
"test"
"test"
"test"

