Installing Flux.jl on Linux: NNlibCUDA fails to precompile - julia

While trying to install Flux I run into an error where it fails to precompile the NNlibCUDA library.
Running ] test NNlibCUDA results in LoadError: UndefVarError: upsample_linear_wcn! not defined:
(#v1.7) pkg> test NNlibCUDA
Testing NNlibCUDA
Status `/tmp/jl_1psy2E/Project.toml`
[052768ef] CUDA v3.10.1
[f6369f11] ForwardDiff v0.10.30
[872c559c] NNlib v0.8.6
[a00861dc] NNlibCUDA v0.2.3
[e88e6eb3] Zygote v0.6.40
[37e2e46d] LinearAlgebra `#stdlib/LinearAlgebra`
[9a3f8284] Random `#stdlib/Random`
[10745b16] Statistics `#stdlib/Statistics`
[8dfed614] Test `#stdlib/Test`
Status `/tmp/jl_1psy2E/Manifest.toml`
[621f4979] AbstractFFTs v1.1.0
[79e6a3ab] Adapt v3.3.3
[ab4f0b2a] BFloat16s v0.2.0
[fa961155] CEnum v0.4.2
[052768ef] CUDA v3.10.1
[082447d4] ChainRules v1.35.1
[d360d2e6] ChainRulesCore v1.15.0
[9e997f8a] ChangesOfVariables v0.1.3
[bbf7d656] CommonSubexpressions v0.3.0
[34da2185] Compat v3.44.0
[163ba53b] DiffResults v1.0.3
[b552c78f] DiffRules v1.11.0
[ffbed154] DocStringExtensions v0.8.6
[e2ba6199] ExprTools v0.1.8
[1a297f60] FillArrays v0.13.2
[f6369f11] ForwardDiff v0.10.30
[0c68f7d7] GPUArrays v8.3.2
[61eb1bfa] GPUCompiler v0.15.2
[7869d1d1] IRTools v0.4.6
[3587e190] InverseFunctions v0.1.4
[92d709cd] IrrationalConstants v0.1.1
[692b3bcd] JLLWrappers v1.4.1
[929cbde3] LLVM v4.13.0
[2ab3a3ac] LogExpFunctions v0.3.15
[1914dd2f] MacroTools v0.5.9
[872c559c] NNlib v0.8.6
[a00861dc] NNlibCUDA v0.2.3
[77ba4419] NaNMath v1.0.0
[21216c6a] Preferences v1.3.0
[74087812] Random123 v1.5.0
[e6cf234a] RandomNumbers v1.5.3
[c1ae055f] RealDot v0.1.0
[189a3867] Reexport v1.2.2
[ae029012] Requires v1.3.0
[276daf66] SpecialFunctions v2.1.5
[90137ffa] StaticArrays v1.4.4
[a759f4b9] TimerOutputs v0.5.19
[e88e6eb3] Zygote v0.6.40
[700de1a5] ZygoteRules v0.2.2
[dad2f222] LLVMExtra_jll v0.0.16+0
[efe28fd5] OpenSpecFun_jll v0.5.5+0
[0dad84c5] ArgTools `#stdlib/ArgTools`
[56f22d72] Artifacts `#stdlib/Artifacts`
[2a0f44e3] Base64 `#stdlib/Base64`
[ade2ca70] Dates `#stdlib/Dates`
[8bb1440f] DelimitedFiles `#stdlib/DelimitedFiles`
[8ba89e20] Distributed `#stdlib/Distributed`
[f43a241f] Downloads `#stdlib/Downloads`
[7b1f6079] FileWatching `#stdlib/FileWatching`
[b77e0a4c] InteractiveUtils `#stdlib/InteractiveUtils`
[4af54fe1] LazyArtifacts `#stdlib/LazyArtifacts`
[b27032c2] LibCURL `#stdlib/LibCURL`
[76f85450] LibGit2 `#stdlib/LibGit2`
[8f399da3] Libdl `#stdlib/Libdl`
[37e2e46d] LinearAlgebra `#stdlib/LinearAlgebra`
[56ddb016] Logging `#stdlib/Logging`
[d6f4376e] Markdown `#stdlib/Markdown`
[a63ad114] Mmap `#stdlib/Mmap`
[ca575930] NetworkOptions `#stdlib/NetworkOptions`
[44cfe95a] Pkg `#stdlib/Pkg`
[de0858da] Printf `#stdlib/Printf`
[3fa0cd96] REPL `#stdlib/REPL`
[9a3f8284] Random `#stdlib/Random`
[ea8e919c] SHA `#stdlib/SHA`
[9e88b42a] Serialization `#stdlib/Serialization`
[1a1011a3] SharedArrays `#stdlib/SharedArrays`
[6462fe0b] Sockets `#stdlib/Sockets`
[2f01184e] SparseArrays `#stdlib/SparseArrays`
[10745b16] Statistics `#stdlib/Statistics`
[fa267f1f] TOML `#stdlib/TOML`
[a4e569a6] Tar `#stdlib/Tar`
[8dfed614] Test `#stdlib/Test`
[cf7118a7] UUIDs `#stdlib/UUIDs`
[4ec0a83e] Unicode `#stdlib/Unicode`
[e66e0078] CompilerSupportLibraries_jll `#stdlib/CompilerSupportLibraries_jll`
[deac9b47] LibCURL_jll `#stdlib/LibCURL_jll`
[29816b5a] LibSSH2_jll `#stdlib/LibSSH2_jll`
[c8ffd9c3] MbedTLS_jll `#stdlib/MbedTLS_jll`
[14a3606d] MozillaCACerts_jll `#stdlib/MozillaCACerts_jll`
[4536629a] OpenBLAS_jll `#stdlib/OpenBLAS_jll`
[05823500] OpenLibm_jll `#stdlib/OpenLibm_jll`
[83775a58] Zlib_jll `#stdlib/Zlib_jll`
[8e850b90] libblastrampoline_jll `#stdlib/libblastrampoline_jll`
[8e850ede] nghttp2_jll `#stdlib/nghttp2_jll`
[3f19e933] p7zip_jll `#stdlib/p7zip_jll`
Precompiling project...
✗ NNlibCUDA
0 dependencies successfully precompiled in 4 seconds (47 already precompiled)
1 dependency errored. To see a full report either run `import Pkg; Pkg.precompile()` or load the package
Testing Running tests...
ERROR: LoadError: UndefVarError: upsample_linear_wcn! not defined
Stacktrace:
[1] getproperty(x::Module, f::Symbol)
# Base ./Base.jl:35
[2] top-level scope
# ~/.julia/packages/NNlibCUDA/vECff/src/upsample.jl:118
[3] include(mod::Module, _path::String)
# Base ./Base.jl:418
[4] include(x::String)
# NNlibCUDA ~/.julia/packages/NNlibCUDA/vECff/src/NNlibCUDA.jl:1
[5] top-level scope
# ~/.julia/packages/NNlibCUDA/vECff/src/NNlibCUDA.jl:9
[6] include
# ./Base.jl:418 [inlined]
[7] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
# Base ./loading.jl:1318
[8] top-level scope
# none:1
[9] eval
# ./boot.jl:373 [inlined]
[10] eval(x::Expr)
# Base.MainInclude ./client.jl:453
[11] top-level scope
# none:1
in expression starting at /home/manman/.julia/packages/NNlibCUDA/vECff/src/upsample.jl:118
in expression starting at /home/manman/.julia/packages/NNlibCUDA/vECff/src/NNlibCUDA.jl:1
ERROR: LoadError: Failed to precompile NNlibCUDA [a00861dc-f156-4864-bf3c-e6376f28a68d] to /home/manman/.julia/compiled/v1.7/NNlibCUDA/jl_kwzmLD.
Stacktrace:
[1] error(s::String)
# Base ./error.jl:33
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, ignore_loaded_modules::Bool)
# Base ./loading.jl:1466
[3] compilecache(pkg::Base.PkgId, path::String)
# Base ./loading.jl:1410
[4] _require(pkg::Base.PkgId)
# Base ./loading.jl:1120
[5] require(uuidkey::Base.PkgId)
# Base ./loading.jl:1013
[6] require(into::Module, mod::Symbol)
# Base ./loading.jl:997
[7] include(fname::String)
# Base.MainInclude ./client.jl:451
[8] top-level scope
# none:6
in expression starting at /home/manman/.julia/packages/NNlibCUDA/vECff/test/runtests.jl:4
ERROR: Package NNlibCUDA errored during testing
I am running Julia 1.7.3 on Pop!_OS 22.04 with a GTX 1050Ti Mobile.

I just had this issue. I found that running ] update fixed it.

Related

Cannot install JuliaSymbolics / SymbolicUtils.jl

I'm using Ubuntu 20.04.3 LTS (GNU/Linux 5.4.0-100-generic x86_64), julia v1.7.
] add SymbolicUtils failed to install this package.
The output of Pkg.precompile() is:
Precompiling project...
✗ Groebner
✗ Symbolics
0 dependencies successfully precompiled in 8 seconds (327 already precompiled)
ERROR: The following 2 direct dependencies failed to precompile:
SymbolicUtils [d1185830-fcd6-423d-90d6-eec64667417b]
Error: Missing source file for SymbolicUtils [d1185830-fcd6-423d-90d6-eec64667417b]
Symbolics [0c5d862f-8b57-4792-8d23-62f2024744c7]
Failed to precompile Symbolics [0c5d862f-8b57-4792-8d23-62f2024744c7] to ~/.julia/compiled/v1.7/Symbolics/jl_VPYpQf.
ERROR: LoadError: ArgumentError: Package SymbolicUtils [d1185830-fcd6-423d-90d6-eec64667417b] is required but does not seem to be installed:
- Run `Pkg.instantiate()` to install all recorded dependencies.
Stacktrace:
[1] _require(pkg::Base.PkgId)
# Base ./loading.jl:1089
[2] require(uuidkey::Base.PkgId)
# Base ./loading.jl:1013
[3] require(into::Module, mod::Symbol)
# Base ./loading.jl:997
[4] include
# ./Base.jl:418 [inlined]
[5] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
# Base ./loading.jl:1318
[6] top-level scope
# none:1
[7] eval
# ./boot.jl:373 [inlined]
[8] eval(x::Expr)
# Base.MainInclude ./client.jl:453
[9] top-level scope
# none:1
in expression starting at ~/.julia/packages/Symbolics/kG5bl/src/Symbolics.jl:1
Stacktrace:
[1] pkgerror(msg::String)
# Pkg.Types ~/software/julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/Types.jl:68
[2] precompile(ctx::Pkg.Types.Context; internal_call::Bool, strict::Bool, warn_loaded::Bool, already_instantiated::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
# Pkg.API ~/software/julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/API.jl:1362
[3] precompile
# ~/software/julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/API.jl:1013 [inlined]
[4] #precompile#220
# ~/software/julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/API.jl:1011 [inlined]
[5] precompile()
# Pkg.API ~/software/julia-1.7.3/share/julia/stdlib/v1.7/Pkg/src/API.jl:1011
[6] top-level scope
# REPL[1]:1
Why can't I install it? I'm happy to provide more info if needed.
If I remove them by Pkg.rm("SymbolicUtils"); Pkg.rm("Symbolics"), Pkg.precomile() does work. Then ] add SymbolicUtils yields:
Resolving package versions...2.3
Updating `~/.julia/environments/v1.7/Project.toml`
[d1185830] + SymbolicUtils v0.19.11
Updating `~/.julia/environments/v1.7/Manifest.toml`
[1520ce14] + AbstractTrees v0.4.2
[dce04be8] + ArgCheck v2.3.0
[15f4f7f2] + AutoHashEquals v0.2.0
[198e06fe] + BangBang v0.3.36
[9718e550] + Baselet v0.1.1
[e2ed5e7c] + Bijections v0.1.4
[861a8166] + Combinatorics v1.0.2
[a33af91c] + CompositionsBase v0.1.1
[244e2a9f] + DefineSingletons v0.1.2
[7c1d4256] + DynamicPolynomials v0.4.5
[22cec73e] + InitialValues v0.3.1
[2ee39098] + LabelledArrays v1.11.1
[e9d8d322] + Metatheory v1.3.4
[128add7d] + MicroCollections v0.1.2
[102ac46a] + MultivariatePolynomials v0.4.6
[42d2dcc6] + Referenceables v0.1.2
[171d559e] + SplittablesBase v0.1.14
[d1185830] + SymbolicUtils v0.19.11
[8ea1fca8] + TermInterface v0.2.3
[ac1d9e8a] + ThreadsX v0.1.10
[28d57a85] + Transducers v0.4.73
0 dependencies successfully precompiled in 2 seconds (319 already precompiled)
1 dependency errored. To see a full report either run `import Pkg; Pkg.precompile()` or load the package
precompile yields:
ERROR: The following 1 direct dependency failed to precompile:
SymbolicUtils [d1185830-fcd6-423d-90d6-eec64667417b]
Error: Missing source file for SymbolicUtils [d1185830-fcd6-423d-90d6-eec64667417b```

Julia Roots find_zero with ForwardDiff.Dual type?

I'm trying to apply automatic differentiation (ForwardDiff) to a function that contains an instance of find_zero (Roots) and am encountering an error that seems to relate to find_zero not accepting the ForwardDiff.Dual type.
Here's a (contrived) minimal working example that illustrates the issue:
using Distributions
using Roots
using StatsFuns
using ForwardDiff
function test_fun(θ::AbstractVector{T}) where T
μ,σ,p = θ;
z_star = find_zero(z -> logistic(z) - p, 0.0)
return pdf(Normal(μ,σ),z_star)
end
test_fun([0.0,1.0,0.75])
ForwardDiff.gradient(test_fun,[0.0,1.0,0.75])
This results in the following error:
ERROR: MethodError: no method matching Float64(::ForwardDiff.Dual{ForwardDiff.Tag{typeof(test_fun),Float64},Float64,3})
Closest candidates are:
Float64(::Real, ::RoundingMode) where T<:AbstractFloat at rounding.jl:200
Float64(::T) where T<:Number at boot.jl:716
Float64(::Irrational{:invsqrt2}) at irrationals.jl:189
...
Stacktrace:
[1] convert(::Type{Float64}, ::ForwardDiff.Dual{ForwardDiff.Tag{typeof(test_fun),Float64},Float64,3}) at ./number.jl:7
[2] setproperty!(::Roots.UnivariateZeroState{Float64,ForwardDiff.Dual{ForwardDiff.Tag{typeof(test_fun),Float64},Float64,3}}, ::Symbol, ::ForwardDiff.Dual{ForwardDiff.Tag{typeof(test_fun),Float64},Float64,3}) at ./Base.jl:34
[3] update_state(::Roots.Secant, ::Roots.DerivativeFree{Roots.DerivativeFree{var"#5#6"{ForwardDiff.Dual{ForwardDiff.Tag{typeof(test_fun),Float64},Float64,3}}}}, ::Roots.UnivariateZeroState{Float64,ForwardDiff.Dual{ForwardDiff.Tag{typeof(test_fun),Float64},Float64,3}}, ::Roots.UnivariateZeroOptions{Float64,Float64,ForwardDiff.Dual{ForwardDiff.Tag{typeof(test_fun),Float64},Float64,3},ForwardDiff.Dual{ForwardDiff.Tag{typeof(test_fun),Float64},Float64,3}}) at /bbkinghome/asharris/.julia/packages/Roots/TZpjF/src/derivative_free.jl:163
[4] find_zero(::Roots.Secant, ::Roots.AlefeldPotraShi, ::Roots.DerivativeFree{Roots.DerivativeFree{var"#5#6"{ForwardDiff.Dual{ForwardDiff.Tag{typeof(test_fun),Float64},Float64,3}}}}, ::Roots.UnivariateZeroState{Float64,ForwardDiff.Dual{ForwardDiff.Tag{typeof(test_fun),Float64},Float64,3}}, ::Roots.UnivariateZeroOptions{Float64,Float64,ForwardDiff.Dual{ForwardDiff.Tag{typeof(test_fun),Float64},Float64,3},ForwardDiff.Dual{ForwardDiff.Tag{typeof(test_fun),Float64},Float64,3}}, ::Roots.NullTracks) at /bbkinghome/asharris/.julia/packages/Roots/TZpjF/src/find_zero.jl:868
[5] find_zero(::Roots.DerivativeFree{var"#5#6"{ForwardDiff.Dual{ForwardDiff.Tag{typeof(test_fun),Float64},Float64,3}}}, ::Float64, ::Roots.Secant, ::Roots.AlefeldPotraShi; tracks::Roots.NullTracks, verbose::Bool, p::Nothing, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /bbkinghome/asharris/.julia/packages/Roots/TZpjF/src/find_zero.jl:689
[6] #find_zero#36 at /bbkinghome/asharris/.julia/packages/Roots/TZpjF/src/derivative_free.jl:123 [inlined]
[7] find_zero at /bbkinghome/asharris/.julia/packages/Roots/TZpjF/src/derivative_free.jl:120 [inlined]
[8] #find_zero#5 at /bbkinghome/asharris/.julia/packages/Roots/TZpjF/src/find_zero.jl:707 [inlined]
[9] find_zero at /bbkinghome/asharris/.julia/packages/Roots/TZpjF/src/find_zero.jl:707 [inlined]
[10] test_fun at ./REPL[7856]:3 [inlined]
[11] vector_mode_dual_eval at /bbkinghome/asharris/.julia/packages/ForwardDiff/QOqCN/src/apiutils.jl:37 [inlined]
[12] vector_mode_gradient(::typeof(test_fun), ::Array{Float64,1}, ::ForwardDiff.GradientConfig{ForwardDiff.Tag{typeof(test_fun),Float64},Float64,3,Array{ForwardDiff.Dual{ForwardDiff.Tag{typeof(test_fun),Float64},Float64,3},1}}) at /bbkinghome/asharris/.julia/packages/ForwardDiff/QOqCN/src/gradient.jl:106
[13] gradient(::Function, ::Array{Float64,1}, ::ForwardDiff.GradientConfig{ForwardDiff.Tag{typeof(test_fun),Float64},Float64,3,Array{ForwardDiff.Dual{ForwardDiff.Tag{typeof(test_fun),Float64},Float64,3},1}}, ::Val{true}) at /bbkinghome/asharris/.julia/packages/ForwardDiff/QOqCN/src/gradient.jl:19
[14] gradient(::Function, ::Array{Float64,1}, ::ForwardDiff.GradientConfig{ForwardDiff.Tag{typeof(test_fun),Float64},Float64,3,Array{ForwardDiff.Dual{ForwardDiff.Tag{typeof(test_fun),Float64},Float64,3},1}}) at /bbkinghome/asharris/.julia/packages/ForwardDiff/QOqCN/src/gradient.jl:17 (repeats 2 times)
[15] top-level scope at REPL[7858]:1
[16] run_repl(::REPL.AbstractREPL, ::Any) at /builddir/build/BUILD/julia/build/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:288
I have limited experience using the FowardDiff package and am probably misunderstanding how the Dual type works, so I would really appreciate if someone knows how to solve this issue. Thanks so much!
z_star = find_zero(z -> logistic(z) - p, 0.0)
You have a fixed initial condition which is non-dual. Make it dual.
z_star = find_zero(z -> logistic(z) - p, zero(eltype(θ))

Interact.jl error: WebIOServer not defined

I am getting this error when using the Interact.jl #manipulate macro in Juno:
UndefVarError: WebIOServer not defined
enter code here
setup_server() at webio.jl:76
show(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::MIME{Symbol("application/prs.juno.plotpane+html")}, ::Widget{:manipulate,Any}) at webio.jl:68
show(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::String, ::Widget{:manipulate,Any}) at multimedia.jl:109
displayinplotpane(::Widget{:manipulate,Any}) at showdisplay.jl:51
displayandrender(::Widget{:manipulate,Any}) at showdisplay.jl:131
(::Atom.var"#208#213"{String})() at eval.jl:136
#invokelatest#1 at essentials.jl:712 [inlined]
invokelatest at essentials.jl:711 [inlined]
macro expansion at dynamic.jl:24 [inlined]
eval(::String, ::Int64, ::String, ::String, ::Bool) at eval.jl:113
invokelatest(::Any, ::Any, ::Vararg{Any,N} where N; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}}) at essentials.jl:712
invokelatest(::Any, ::Any, ::Vararg{Any,N} where N) at essentials.jl:711
macro expansion at eval.jl:41 [inlined]
(::Atom.var"#188#189")() at task.jl:358
Piece of code (the function generatePlot is defined previously for generating Makie plots):
#manipulate for variable = Dict(string(vars[i])=>vars[i] for i=1:16),
labl = Dict(string(label[i])=>label[i] for i=1:length(label))
generatePlot(variable, labl)
end
Env:
[c601a237] Interact v0.10.3
[ee78f7c6] Makie v0.11.0
[85f8d34a] NCDatasets v0.10.2
[2913bbd2] StatsBase v0.33.0
[0f1e0344] WebIO v0.8.14
Any thoughts on what can be the problem?

LoadError:PyCall.PyError ("\$(Expr(:escape, :(ccall(#= /home/omkar/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:44 =# #pysym(:PyObject_Call)

I am getting the following Error for PyCall and am on Julia v 1.2.0
ERROR: LoadError: PyCall.PyError("\$(Expr(:escape, :(ccall(#= /home/omkar/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:44 =# #pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))", PyCall.PyObject(Ptr{PyCall.PyObject_struct} #0x00007f9ea56a2520), PyCall.PyObject(Ptr{PyCall.PyObject_struct} #0x00007f9db65dcca8), PyCall.PyObject(Ptr{PyCall.PyObject_struct} #0x00007f9d004f9f08))
Stacktrace:
[1] pyerr_check at /home/omkar/.julia/packages/PyCall/ttONZ/src/exception.jl:60 [inlined]
[2] pyerr_check at /home/omkar/.julia/packages/PyCall/ttONZ/src/exception.jl:64 [inlined]
[3] macro expansion at /home/omkar/.julia/packages/PyCall/ttONZ/src/exception.jl:84 [inlined]
[4] __pycall!(::PyCall.PyObject, ::Ptr{PyCall.PyObject_struct}, ::PyCall.PyObject, ::Ptr{Nothing}) at /home/omkar/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:44
[5] _pycall!(::PyCall.PyObject, ::PyCall.PyObject, ::Tuple{String,String,String,String,String,Float64,String,Float64}, ::Int64, ::Ptr{Nothing}) at /home/omkar/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:29
[6] _pycall!(::PyCall.PyObject, ::PyCall.PyObject, ::Tuple{String,String,String,String,String,Float64,String,Float64}, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/omkar/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:11
[7] #call#111(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::PyCall.PyObject, ::String, ::Vararg{Any,N} where N) at /home/omkar/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:89
[8] (::PyCall.PyObject)(::String, ::Vararg{Any,N} where N) at /home/omkar/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:89
I have already tried update and below is the setup for the build file
ENV["PYTHON"] = " "
Pkg.build("PyCall")
using PyCall, Conda
pyexec = pyimport("sys").executable

julia provide wrong numerical result

When I tried to calculate
julia> -2.3^-7.6
-0.0017818389423254909
But the result given by my calculator is
0.0005506 + 0.001694 i
Just to be safe I tried it again and this time it complains. Why does it not complain when I tried it the first time?
julia> a = -2.3; b = -7.6; a^b
ERROR: DomainError with -2.6:
Exponentiation yielding a complex result requires a complex argument.
Replace x^y with (x+0im)^y, Complex(x)^y, or similar.
Stacktrace:
[1] throw_exp_domainerror(::Float64) at ./math.jl:35
[2] ^(::Float64, ::Float64) at ./math.jl:769
[3] top-level scope at none:0
[4] eval at ./boot.jl:319 [inlined]
[5] #85 at /Users/ssiew/.julia/packages/Atom/jodeb/src/repl.jl:129 [inlined]
[6] with_logstate(::getfield(Main, Symbol("##85#87")),::Base.CoreLogging.LogState) at ./logging.jl:397
[7] with_logger(::Function, ::Atom.Progress.JunoProgressLogger) at ./logging.jl:493
[8] top-level scope at /Users/ssiew/.julia/packages/Atom/jodeb/src/repl.jl:128
This is an order of operations issue. You can see how Julia's parsing that expression:
julia> parse("-2.3^-7.6")
:(-(2.3 ^ -7.6))
and so the reason you don't have any problems is because you're actually taking 2.3 ^ (-7.6), which is 0.0017818389423254909, and then flipping the sign.
Your second approach is equivalent to making sure that the "x" in "x^y" is really negative, or:
julia> parse("(-2.3)^-7.6")
:(-2.3 ^ -7.6)
julia> eval(parse("(-2.3)^-7.6"))
ERROR: DomainError:
Exponentiation yielding a complex result requires a complex argument.
Replace x^y with (x+0im)^y, Complex(x)^y, or similar.
Stacktrace:
[1] nan_dom_err at ./math.jl:300 [inlined]
[2] ^(::Float64, ::Float64) at ./math.jl:699
[3] eval(::Module, ::Any) at ./boot.jl:235
[4] eval(::Any) at ./boot.jl:234
And if we follow that instruction, we get what you expect:
julia> Complex(-2.3)^-7.6
0.0005506185144176565 + 0.0016946295370871215im

Resources