ERROR: MethodError: no method matching adjoint(::DateTime)

Hello,

I am struggling with Julia’s less than MATLAB capability for transposing matrices (row data).

I parse a file into a temporary vector. I transpose the vector and append to the matrix. Neither before nor after the transposing can I succeed at having the element a native DateTime type.

[DateTime(0) 0]'  # fails

while this succeeds to create and append a row as desired:

julia> x = [DateTime(0) 0]
1×2 Matrix{Any}:
 0000-01-01T00:00:00  0
julia> [x; x]
2×2 Matrix{Any}:
 0000-01-01T00:00:00  0
 0000-01-01T00:00:00  0

Currently I take a vector with the unix timestamp, transpose it, then try to convert the first element back to DateTime. This does not work because I create a 1x2 adjoint vector rather than a 1x2 matrix as desired.

How do I avoid the Adjoint mess and insert this element into my data stream?

Cheers,
Joe

Solved using reshape() to specify the 1x15 Matrix rather than adjoint type.

This feature of the language certainly violated the principle of least surprise here, so any commentary is welcome.

Cheers,
Joe

' postfix is the syntax for adjoint which is applied recursively and is a linear algebra concept. The adjoint of a date doesn’t make sense which is why it errors.

1 Like

While I agree it’s slightly surprising, the recommended function for arrays of various objects is permutedims. (Which, on a vector, is precisely reshape.)

help?> adjoint
search: adjoint adjoint! Adjoint

  A'
  adjoint(A)

  Lazy adjoint (conjugate transposition). Note that adjoint is applied recursively to elements.

  For number types, adjoint returns the complex conjugate, and therefore it is equivalent to the
  identity function for real numbers.

  This operation is intended for linear algebra usage - for general data manipulation see
  permutedims.
2 Likes