Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • julia: jl save not working

    Greetings,

    I have installed julia and have Julia 1.9.4 on my machine. When trying to run the basic command, jl save auto, I get a vague error message: r(999).

    Here is a fuller error:

    . set trace on

    . jl save auto
    ---------------------------------------------------------------------------------------------------------------------------------------- begin jl ---
    - version 14.1
    - if `"`0'"'=="version" {
    = if `"save auto"'=="version" {
    return local version 1.0.1
    exit
    }
    - cap _on_colon_parse `0'
    = cap _on_colon_parse save auto
    ------------------------------------------------------------------------------------------------------------------------- begin _on_colon_parse ---
    - version 8.2
    - sreturn local before ""
    - sreturn local after ""
    - gettoken before after : 0, parse(":") bind match(par) quotes
    - if "`par'" != "" {
    = if "" != "" {
    local before `"(`before')"'
    }
    - if `"`before'"' == ":" {
    = if `"save auto"' == ":" {
    sreturn local after `"`after'"'
    exit
    }
    - while `"`COLON'"' != ":" & `"`after'"' != "" {
    = while `""' != ":" & `""' != "" {
    gettoken COLON after : after, parse(":") bind match(par) quotes
    if "`par'" != "" {
    local before `before' (`COLON')
    local COLON
    }
    else if `"`COLON'"' != ":" {
    local before `"`before' `COLON'"'
    local COLON
    }
    }
    - if `"`COLON'"' != ":" {
    = if `""' != ":" {
    - di as err "'' found where ':' expected"
    - exit 198
    }
    --------------------------------------------------------------------------------------------------------------------------- end _on_colon_parse ---
    - if _rc & `"`0'"'!="" {
    = if _rc & `"save auto"'!="" {
    - tokenize `"`0'"', parse(" ,")
    = tokenize `"save auto"', parse(" ,")
    - local cmd `1'
    = local cmd save
    - macro shift
    - local 0 `*'
    = local 0 auto
    - if `"`cmd'"'=="stop" {
    = if `"save"'=="stop" {
    if 0$julia_loaded {
    plugin call _julia, stop
    global julia_loaded
    }
    exit
    }
    - if `"`cmd'"'=="start" {
    = if `"save"'=="start" {
    syntax, [Threads(passthru)]
    if 0$julia_loaded & `"`threads'"'!="" di as txt "threads() option ignored because Julia is already running."
    assure_julia_started, `threads'
    exit
    }
    - assure_julia_started
    ----------------------------------------------------------------------------------------------------------------- begin jl.assure_julia_started ---
    - version 14.1
    - if `"$julia_loaded"' == "" {
    = if `"0"' == "" {
    syntax, [threads(string)]
    if !inlist(`"`threads'"', "", "auto") {
    cap confirm integer number `threads'
    _assert !_rc & `threads'>0, msg(`"threads() option must be "auto" or a positive integer"') rc(198)
    }
    cap noi {
    cap wheresjulia
    cap if _rc & c(os)!="Windows" wheresjulia ~/.juliaup/bin/
    cap if _rc & c(os)=="MacOSX" {
    forvalues v=9/20 {
    cap wheresjulia /Applications/Julia-1.`v'.app/Contents/Resources/julia/bin/
    if !_rc continue, break
    }
    }
    error _rc
    di as txt `"Starting Julia `=cond(`"`threads'"'!="", "with threads=`threads'", "")'"'
    mata displayflush()
    plugin call _julia, start "`libpath'/`libname'" "`libpath'" `threads'
    }
    if _rc {
    di as err "Can't access Julia. {cmd:jl} requires that Julia be installed and that you are"
    di as err `"able to start it by typing "julia" in a terminal window (though you won't normally need to)."'
    di as err `"Installation via {browse "https://github.com/JuliaLang/juliaup#installation":juliaup} is recommended."'
    exit 198
    }
    plugin call _julia, eval `"Int(VERSION < v"1.9.4")"'
    if `__jlans' {
    di as err _n "jl requires that Julia 1.9.4 or higher be installed and accessible by default."
    di as err "See the Installation section of the {help jl##installation:jl help file}."
    global julia_loaded
    exit 198
    }
    cap noi {
    plugin call _julia, evalqui "using Pkg"
    AddPkg DataFrames, minver(1.6.1)
    AddPkg CategoricalArrays, minver(0.10.8)
    plugin call _julia, evalqui "using DataFrames, CategoricalArrays"
    qui findfile stataplugininterface.jl
    plugin call _julia, evalqui `"pushfirst!(LOAD_PATH, dirname(expanduser(raw"`r(fn)'")))"'
    plugin call _julia, evalqui "using stataplugininterface"
    qui findfile jl.plugin
    plugin call _julia, evalqui `"stataplugininterface.setdllpath(expanduser(raw"` r(fn)'"))"'
    }
    global julia_loaded = !_rc
    }
    ------------------------------------------------------------------------------------------------------------------- end jl.assure_julia_started ---
    - if inlist(`"`cmd'"',"SetEnv","GetEnv") {
    = if inlist(`"save"',"SetEnv","GetEnv") {
    if "`cmd'"=="SetEnv" {
    plugin call _julia, evalqui `"Pkg.activate(joinpath(dirname(Base.load_path_exp and("@v#.#")), "`1'"))"'
    AddPkg DataFrames
    AddPkg CategoricalArrays
    }
    return local env: subinstr local __jlans "\" "", all
    plugin call _julia, eval `"dirname(Base.active_project())"'
    local __jlans `__jlans'
    return local envdir: subinstr local __jlans "\" "", all
    plugin call _julia, eval `"dirname(Base.load_path_expand("@v#.#"))"'
    local __jlans: subinstr local __jlans "\" "", all
    if "`return(envdir)'" == `__jlans' return local env .
    else {
    plugin call _julia, eval `"splitpath(Base.active_project())[end-1]"'
    return local env `__jlans'
    }
    di as txt `"Current environment: `=cond("`return(env)'"==".","(default)","`return(e nv)'")', at `return(envdir)'"'
    }
    - else if `"`cmd'"'=="AddPkg" AddPkg `0'
    = else if `"save"'=="AddPkg" AddPkg auto
    - else if `"`cmd'"'=="use" {
    = else if `"save"'=="use" {
    syntax namelist [using/], [clear]
    if c(changed) & "`clear'"=="" error 4
    drop _all
    if `"`using'"'=="" {
    _assert `:word count `namelist''==1, msg("Just specify one source DataFrame.") rc(198)
    local source `namelist'
    plugin call _julia, eval `"join(names(`source'), " ")"'
    local cols `__jlans'
    }
    else {
    local source `using'
    local cols `namelist'
    }
    plugin call _julia, eval "size(`source',1)"
    qui set obs `__jlans'
    GetVarsFromDF `cols', source(`source')
    }
    - else if `"`cmd'"'=="PutVarsToDF" {
    = else if `"save"'=="PutVarsToDF" {
    PutVarsToDF `0'
    }
    - else if `"`cmd'"'=="save" {
    = else if `"save"'=="save" {
    - syntax [namelist(max=1)], [NOLABel DOUBLEonly NOMISSing]
    - if "`namelist'"=="" local namelist df
    = if "auto"=="" local namelist df
    - PutVarsToDF, dest(`namelist') `nolabel' `doubleonly' `nomissing'
    = PutVarsToDF, dest(auto)
    -------------------------------------------------------------------------------------------------------------------------- begin jl.PutVarsToDF ---
    - syntax [varlist] [if] [in], [DESTination(string) COLs(string) DOUBLEonly noMISSing noLABel]
    - if `"`destination'"'=="" local destination df
    = if `"auto"'=="" local destination df
    - local ncols = cond("`varlist'"=="",c(k),`:word count `varlist'')
    = local ncols = cond("make price mpg rep78 headroom trunk weight length turn displacement gear_ratio foreign"=="",c(k),12)
    - if `"`cols'"'=="" unab cols: `varlist'
    = if `""'=="" unab cols: make price mpg rep78 headroom trunk weight length turn displacement gear_ratio foreign
    ---------------------------------------------------------------------------------------------------------------------------------- begin unab ---
    - version 6
    - gettoken user 0: 0, parse(" :")
    - gettoken colon 0: 0, parse(" :")
    - if `"`colon'"' != ":" { error 198 }
    = if `":"' != ":" { error 198 }
    - syntax [varlist(default=empty)] [, MIN(integer 1) MAX(integer 120000) NAME(string)]
    - c_local `user' `varlist'
    = c_local cols make price mpg rep78 headroom trunk weight length turn displacement gear_ratio foreign
    - local n : word count `varlist'
    = local n : word count make price mpg rep78 headroom trunk weight length turn displacement gear_ratio foreign
    - if `n'>=`min' & `n'<=`max' { exit }
    = if 12>=1 & 12<=120000 { exit }
    ------------------------------------------------------------------------------------------------------------------------------------ end unab ---
    - else {
    confirm names `cols'
    _assert `:word count `cols''!=`ncols', msg("Source and destination variable lists different lengths.") rc(198)
    }
    - if "`doubleonly'"=="" {
    = if ""=="" {
    - foreach col in `cols' {
    = foreach col in make price mpg rep78 headroom trunk weight length turn displacement gear_ratio foreign {
    - local type: type `col'
    = local type: type make
    - local types `types' `=cond(substr("`type'",1,3)=="str", "str", "`type'")'
    = local types str
    - }
    - local type: type `col'
    = local type: type price
    - local types `types' `=cond(substr("`type'",1,3)=="str", "str", "`type'")'
    = local types str int
    - }
    - local type: type `col'
    = local type: type mpg
    - local types `types' `=cond(substr("`type'",1,3)=="str", "str", "`type'")'
    = local types str int int
    - }
    - local type: type `col'
    = local type: type rep78
    - local types `types' `=cond(substr("`type'",1,3)=="str", "str", "`type'")'
    = local types str int int int
    - }
    - local type: type `col'
    = local type: type headroom
    - local types `types' `=cond(substr("`type'",1,3)=="str", "str", "`type'")'
    = local types str int int int float
    - }
    - local type: type `col'
    = local type: type trunk
    - local types `types' `=cond(substr("`type'",1,3)=="str", "str", "`type'")'
    = local types str int int int float int
    - }
    - local type: type `col'
    = local type: type weight
    - local types `types' `=cond(substr("`type'",1,3)=="str", "str", "`type'")'
    = local types str int int int float int int
    - }
    - local type: type `col'
    = local type: type length
    - local types `types' `=cond(substr("`type'",1,3)=="str", "str", "`type'")'
    = local types str int int int float int int int
    - }
    - local type: type `col'
    = local type: type turn
    - local types `types' `=cond(substr("`type'",1,3)=="str", "str", "`type'")'
    = local types str int int int float int int int int
    - }
    - local type: type `col'
    = local type: type displacement
    - local types `types' `=cond(substr("`type'",1,3)=="str", "str", "`type'")'
    = local types str int int int float int int int int int
    - }
    - local type: type `col'
    = local type: type gear_ratio
    - local types `types' `=cond(substr("`type'",1,3)=="str", "str", "`type'")'
    = local types str int int int float int int int int int float
    - }
    - local type: type `col'
    = local type: type foreign
    - local types `types' `=cond(substr("`type'",1,3)=="str", "str", "`type'")'
    = local types str int int int float int int int int int float byte
    - }
    - }
    - else local types = "double " * `ncols'
    = else local types = "double " * 12
    - if "`doubleonly'"=="" local dfcmd `destination' = DataFrame([n=>Vector{stataplugininterface.S2Jtypedict[t]}(undef,%i) for (n,t) in zip(eachsplit(
    > "`cols'"), eachsplit("`types'"))])
    = if ""=="" local dfcmd auto = DataFrame([n=>Vector{stataplugininterface.S2Jtypedict[t]}(undef,%i) for (n,t) in zip(eachsplit("make price mpg rep78
    > headroom trunk weight length turn displacement gear_ratio foreign"), eachsplit("str int int int float int int int int int float byte"))])
    - plugin call _julia `varlist' `if' `in', PutVarsToDF`missing' `"`destination'"' `"`dfcmd'"' `"`if'`in'"'
    = plugin call _julia make price mpg rep78 headroom trunk weight length turn displacement gear_ratio foreign , PutVarsToDF `"auto"' `"auto = DataFr
    > ame([n=>Vector{stataplugininterface.S2Jtypedict[t]}(undef,%i) for (n,t) in zip(eachsplit("make price mpg rep78 headroom trunk weight length turn disp
    > lacement gear_ratio foreign"), eachsplit("str int int int float int int int int int float byte"))])"' `""'
    ---------------------------------------------------------------------------------------------------------------------------- end jl.PutVarsToDF ---
    di as txt "Data saved to DataFrame `namelist' in Julia"
    }
    else if `"`cmd'"'=="PutVarsToMat" {
    syntax [varlist] [if] [in], DESTination(string) [noMISSing]
    plugin call _julia `varlist' `if' `in', `cmd'`missing' `"`destination'"' `"`if'`in'"'
    }
    else if `"`cmd'"'=="GetVarsFromMat" {
    syntax namelist [if] [in], source(string asis) [replace]
    if "`replace'"=="" confirm new var `namelist'
    foreach var in `namelist' {
    cap gen double `var' = .
    }
    plugin call _julia `namelist' `if' `in', GetVarsFromMat `"`source'"' `"`if'`in'"'
    }
    else if `"`cmd'"'=="GetVarsFromDF" {
    GetVarsFromDF `0'
    }
    else if `"`cmd'"'=="GetMatFromMat" {
    syntax name, [source(string asis)]
    if `"`source'"'=="" local source `namelist'
    plugin call _julia, eval `"size(`source',1)"'
    local rows: copy local __jlans
    plugin call _julia, eval `"size(`source',2)"'
    mat `namelist' = J(`rows', `__jlans', .)
    plugin call _julia, GetMatFromMat `namelist' `"`source'"'
    }
    else if `"`cmd'"'=="PutMatToMat" {
    syntax name, [DESTination(string)]
    if `"`destination'"'=="" local destination `namelist'
    plugin call _julia, PutMatToMat `namelist' `destination'
    }
    else {
    di as err `"`cmd' is not a valid subcommand."'
    exit 198
    }
    }
    ------------------------------------------------------------------------------------------------------------------------------------------ end jl ---
    r(999);

    end of do-file

    You can learn more about what I am trying to do here: https://github.com/droodman/julia.ad.../doc/julia.pdf

    Am I missing something?
Working...
X