Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readdlm does not support Complex #21935

Closed
dlfivefifty opened this issue May 18, 2017 · 8 comments · Fixed by #24713
Closed

readdlm does not support Complex #21935

dlfivefifty opened this issue May 18, 2017 · 8 comments · Fixed by #24713
Labels
complex Complex numbers io Involving the I/O subsystem: libuv, read, write, etc.

Comments

@dlfivefifty
Copy link
Contributor

This is in 0.6-rc1 (and earlier):

julia> writecsv("/tmp/comp.csv",[1+im])

julia> readcsv("/tmp/comp.csv")
1×1 Array{Any,2}:
 "1 + 1im"

I would expect it to return an Array{Complex{Int},2}.

PS A quick work around is eval.(parse.(readcsv("/tmp/comp.csv")))

@yuyichao yuyichao changed the title readcsv not inferring type for Complex readcsv does not support Complex May 18, 2017
@kshyatt kshyatt added complex Complex numbers io Involving the I/O subsystem: libuv, read, write, etc. labels May 18, 2017
@gasagna
Copy link
Contributor

gasagna commented Aug 22, 2017

Same for {read, write}dlm.

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.1-pre.0 (2017-06-19 13:06 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit dcf39a1 (64 days old release-0.6)
|__/                   |  x86_64-apple-darwin15.6.0

julia> writedlm("tmp", randn(2, 2) + randn(2, 2)*im)

shell> cat tmp
0.7743929262024812 - 0.3434835979330062im	0.33958454399005045 + 0.28680652862126105im
0.6928954470238671 + 1.597743784536779im	-0.04481314483176969 + 0.48528071828620334im

julia> readdlm("tmp")
2×6 Array{Any,2}:
 0.774393  "-"  "0.3434835979330062im"   0.339585   "+"  "0.28680652862126105im"
 0.692895  "+"  "1.597743784536779im"   -0.0448131  "+"  "0.48528071828620334im"

@fredrikekre fredrikekre changed the title readcsv does not support Complex readdlm does not support Complex Sep 28, 2017
@ViralBShah
Copy link
Member

readdlm is no longer in Base.

@KristofferC
Copy link
Member

It's in the stdlib which exists in this repo though?

@StefanKarpinski
Copy link
Member

Yeah, until we move things into separate repos, this is still the right place for these issues.

@ViralBShah
Copy link
Member

Fair enough. In this case, it isn't even clear if readdlm can or should deal with complex numbers given all the ways one could use whitespace. A CSV file could perhaps be easier to work with.

@gasagna
Copy link
Contributor

gasagna commented Oct 8, 2017

@ViralBShah IMO, if Base exposes the capability of writing a complex array to a file using 'writedlm', it should also expose some way to read it.

@ViralBShah
Copy link
Member

That is fair enough. I would argue that writedlm should not accept this. CSV.jl or JLD are better unambiguous ways to do this.

@stevengj
Copy link
Member

stevengj commented Nov 23, 2017

#24713 adds readdlm support for Complex{T} (actually requiring less code in DelimitedFiles.jl), though you have to explicitly specify the desired complex type (since the default in readdlm is Float64).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complex Complex numbers io Involving the I/O subsystem: libuv, read, write, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants