Skip to content

Saving of complex variables in dd.json. #68

@jmcclena

Description

@jmcclena

json save/read fails for complex values Example below.

dd = IMAS.dd()
resize!(dd.gyrokinetics_local.linear.wavevector,1)
resize!(dd.gyrokinetics_local.linear.wavevector[1].eigenmode,1)
dd.gyrokinetics_local.linear.wavevector[1].eigenmode[1].angle_pol = 0:2π/11:2π
dd.gyrokinetics_local.linear.wavevector[1].eigenmode[1].time_norm = [1.0]
dd.gyrokinetics_local.linear.wavevector[1].eigenmode[1].fields.a_field_parallel_perturbed_norm = (1.0+1.0im)*ones(10,2)

IMAS.imas2json(dd,"dd.json")
dd1 = IMAS.json2imas("dd.json")

gives the following error.

MethodError: Cannot `convert` an object of type Dict{String, Any} to an object of type ComplexF64
The function `convert` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  (::Type{Complex{T}} where T<:Real)(::Any, ::Any)
   @ Base complex.jl:14
  convert(::Type{T}, ::Polynomials.AbstractPolynomial{T, X}) where {T<:Number, X}
   @ Polynomials [~/.julia/packages/Polynomials/13Ozz/src/common.jl:557](http://localhost:8889/lab/tree/~/.julia/packages/Polynomials/13Ozz/src/common.jl#line=556)
  convert(::Type{S}, ::PQ) where {S<:Number, PQ<:Polynomials.AbstractRationalFunction}
   @ Polynomials [~/.julia/packages/Polynomials/13Ozz/src/rational-functions/common.jl:68](http://localhost:8889/lab/tree/~/.julia/packages/Polynomials/13Ozz/src/rational-functions/common.jl#line=67)
  ...

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions