julia UndefVarError : unshift ! non défini

Aug 20 2020

J'utilise julia 1.4 et j'exécute le code suivant :

using PyCall
using JLD
using ArgParse
using Pandas
@pyimport networkx as nx
@pyimport scipy.sparse.csgraph as csg
@pyimport numpy as np

unshift!(PyVector(pyimport("sys")["path"]), "")
# unshift!(PyVector(pyimport("sys")["path"]), "..")
unshift!(PyVector(pyimport("sys")["path"]), "combinatorial")
@pyimport utils.load_graph as lg
@pyimport utils.distortions as dis
@pyimport graph_util as gu
....

lorsque j'exécute ce code, j'obtiens l'erreur suivante :

 ERROR: LoadError: UndefVarError: unshift! not defined
Stacktrace:
 [1] top-level scope at /root/hyperbolics/combinatorial/comb.jl:9
 [2] include(::Module, ::String) at ./Base.jl:377
 [3] exec_options(::Base.JLOptions) at ./client.jl:288
 [4] _start() at ./client.jl:484
in expression starting at /root/hyperbolics/combinatorial/comb.jl:9

Quand j'ai cherché des documents, unshift ! est une fonction existante dans julia 1.4, donc je ne comprends pas pourquoi cette erreur se produit. Je suis nouveau sur Julia, aidez-moi s'il vous plaît.

Réponses

6 fredrikekre Aug 19 2020 at 22:55

débrayage ! est une fonction existante dans julia 1.4

Où avez-vous vu cela? Il a été renommé pour Julia 1.0 il y a deux ans en pushfirst!:

julia> pushfirst!([1, 2, 3], 4)
4-element Array{Int64,1}:
 4
 1
 2
 3