Search code examples
matrixtime-seriestypeerrordolphindb

Error “Not allowed to create a matrix with type ANY” when using byRow in DolphinDB


I am currently using the byRow function to calculate row by row, and it resulted in 'Not allowed to create a matrix with type ANY'.

What may be the reason for this error?

Environment Details:

  • DolphinDB Version: 2.00.10 (server)
  • Client: DolphinDB Python API 1.30.22.2
  • Data Structure: 10x10 floating-point matrix p

My code:

code = """  
// linearTimeTrend(p, 12)  
byRow(linearTimeTrend{,4},  
transpose(p[1:10,1:10]))  
"""  
s.run(code)

Error: Not allowed to create a matrix with type ANY

I had verified matrix slice type:

s.run("transpose(p[1:10,1:10]).xtype()") # Returns FLOATING

And I try to Simplify the function call but still fails:

s.run("byRow(linearTimeTrend{,4}, transpose(p[1:10,1:10]))")


Solution

  • The linearTimeTrend function returns a tuple, but the byRow function can only return a vector of equal length or a scalar.

    According to your code requirements, there is no need to transpose; you can directly iterate over the columns using a loop function for processing.

    loop(linearTimeTrend{,4}, p[1:10,1:10])