Error syntax: Extra token 'oftype' after end of expression


#1

Sorry guys, I’m a newbie in Julia and I’m trying hard to execute some bitbucket .jl script files on ATOM 1.29. I think the code is a kind of outdated and I got many errors during execution. I solved some, but when trying to execute the code extract below, I got a Syntax error. Could somebody tell me what is the new syntax to replace dataobject oftype Array{Int64,1}. I tried to remove and let only Array {Int64,1} but it doesn’t work either and returns me the different error below:
Systemerror: opening file./NewFSAM_PT/Dist1Iter1.csv: No such file or directory
in anonymous abase/
in macro expansion at PlotData.jl:56
in readcsv at base/datafmt.jl:618
in #readcsv #14 at base/datafmt.jl:618
in readdlm at base/datafmt.jl:73
in #readdlm#6 at base/datafmt.jl:73
in readdlm at base/datafmt.jl:81
in #readdlm#7 at base/datafmt.jl:81
in #readdlm_auto#11 at base/datafmt.jl:134
in open at base/iostream.jl:150
in open at base/iostream.jl:104
in systemerror at base/ero.jl:64
in#systemerror#44 at base/error.jl:64

My Julia version is 0.6.4
Atom 1.29

The code was originally written in Julia 0.45 and is detached below:

==============

for k=1:NumIter
for i=1:3
filename = DirName*“Dist"string(i)“Iter"string(k)”.csv”

    data = readcsv(filename)

    if i==1
        Distributions1[:,:,k] = data
    elseif i==2
        Distributions2[:,:,k] = data
    elseif i==3
        Distributions3[:,:,k] = data
    end
end

filename = DirName*"RobustnessIter"*string(k)*".csv"
data = readcsv(filename)

robustness[:,k] = dataobject oftype Array{Int64,1}

end


#2

So, this might not be what you want, but I think the last line there should be

robustness[:,k] = data

That is, the oftype Array{Int64,1} is probably a comment or something that got appended incorrectly.


#3

It will be easier to read your code (and also easier for us to help you) if you quote your code: PSA: how to quote code with backticks


#4

Do you mean the whole code?


#5

"
#====================================================================
This file plots the distribution from the cross-entropy
simulations, the average robustness across all cross-entropy trials,
and a sample monte carlo runs from the selected distributions
Use ReqIter to select the required cross-entropy trial from which
you would like to view distributions and run monte carlo simulations
====================================================================#

include(“MonteCarlo.jl”)
include(“PlotMCSim.jl”)

Specify directory from which to read data files

DirName = “./NewFSAM_PT/”

trials = 1000 # Number of trials in each cross-entropy simulation
NumIter = 7 # Number of cross-entropy trials to be read from file
ReqIter = 7 # Required cross-entropy trial to visualize

Setup variables required

xlabel1 = Array(Array{Float64,1},5)
xlabel2 = Array(Array{Float64,1},5)
xlabel3 = Array(Array{Float64,1},3)

Distributions1 = zeros(Nsegments,Nbehavior1,NumIter)
Distributions2 = zeros(Nsegments,Nbehavior2,NumIter)
Distributions3 = zeros(Nsegments,Nbehavior3,NumIter)

x1 = collect(1:Nbehavior1)
x2 = collect(1:Nbehavior2)
x3 = collect(1:Nbehavior3)

robustness = zeros(trials,NumIter)
stdrobustness = zeros(NumIter)

Var = zeros(NumIter)
std = zeros(NumIter)
AvgRobustness = zeros(NumIter)

#Create labels for bar plots
for i=1:5
xlabel1[i] = Array{Float64,1}(Behavior1[i])
xlabel2[i] = Array{Float64,1}(Behavior2[i])

if(i<=3)
 xlabel3[i] = Array{Float64,1}(Behavior3[i])

end end

Read all distributions and robustness values

for k=1:NumIter
for i=1:3
filename = DirName*“Dist"string(i)“Iter"string(k)”.csv”

    data = readcsv(filename)

    if i==1
        Distributions1[:,:,k] = data
    elseif i==2
        Distributions2[:,:,k] = data
    elseif i==3
        Distributions3[:,:,k] = data
    end
end

filename = DirName*"RobustnessIter"*string(k)*".csv"
data = readcsv(filename)

robustness[:,k] =  Data

end

Plot distributions for required iteration (bar plots)

figure(4)
for i = 1:Nsegments
subplot(Nsegments,1,i)
bar(x1,Distributions1[i,:,ReqIter][:],width=1,align=“center”,
alpha=0.6,linewidth=2.0,edgecolor=“k”)
xticks(x1,xlabel1)
axis(“tight”)

end

figure(5)
for i = 1:Nsegments
subplot(Nsegments,1,i)
bar(x3,Distributions3[i,:,ReqIter][:],width=1.0,align=“center”,
alpha=0.6,linewidth=2.0,edgecolor=“k”)
xticks(x3,xlabel3)
end

#=
figure(3)
for i = 1:Nsegments
subplot(Nsegments,1,i)
bar(x2,Distributions2[i,:,ReqIter][:],align=“center”,
alpha=0.6,linewidth=2.0,edgecolor=“k”)
xticks(x2,xlabel2)
end
=#

Compute average robustness and standard deviation for all trials

and plot a graph with errror bars

figure(6)
for k=1:NumIter

AvgRobustness[k] = sum(robustness[:,k])/trials

for i=1:trials
    Var[k] = Var[k] + (robustness[i,k] - AvgRobustness[k])^2
end

Var[k] = Var[k]/trials
std[k] = sqrt(Var[k])

end

x = collect(1:NumIter)
lerror = std
uerror = std
errs = vcat(lerror’,uerror’)

plot(x,AvgRobustness)
errorbar(x,AvgRobustness,yerr=errs,fmt=“ro”)
ylabel(“Average Robustness”)
xlabel(“Iterations”)

Pitch guidance

Distribution1 = Distributions1[:,:,ReqIter]

Yaw guidance

Distribution2 = Distributions2[:,:,ReqIter]

Thrust guidance

Distribution3 = Distributions3[:,:,ReqIter]

#trials = 50
#RunMCSim()
#PlotSim()
"


#6

hile loading /Users/marcelord12/Documents/phd2018/mppo/thesis/Falsification/PlotData.jl, in expression starting on line 52

#systemerror#44 at error.jl:64 [inlined]

systemerror(::String, ::Bool) at error.jl:64

open(::String, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at iostream.jl:104

open(::Base.#readstring, ::String) at iostream.jl:150

#readdlm_auto#11(::Array{Any,1}, ::Function, ::String, ::Char, ::Type{T} where T, ::Char, ::Bool) at datafmt.jl:134

#readdlm#7 at datafmt.jl:81 [inlined]

readdlm(::String, ::Char, ::Char) at datafmt.jl:81

#readdlm#6 at datafmt.jl:73 [inlined]

readdlm(::String, ::Char) at datafmt.jl:73

#readcsv#14 at datafmt.jl:618 [inlined]

readcsv(::String) at datafmt.jl:618

macro expansion at PlotData.jl:56 [inlined]

anonymous at <missing>:?

include_string(::String, ::String) at loading.jl:522

include_string(::Module, ::String, ::String) at Compat.jl:88

(::Atom.##112#116{String,String})() at eval.jl:109

withpath(::Atom.##112#116{String,String}, ::String) at utils.jl:30

withpath(::Function, ::String) at eval.jl:38

hideprompt(::Atom.##111#115{String,String}) at repl.jl:67

macro expansion at eval.jl:106 [inlined]

(::Atom.##110#114{Dict{String,Any}})() at task.jl:80