How to get the explicit path of a Julia function?
I try to use @which
but it leads me to a page on GitHub with the code, however I want to know the explicit path in my computer i.e. the file that is used when I call the function. for example broadcast(+, A, A)
where A
is an Array, I thought the path was:
C:UsersuserAppDataLocalJulia-0.6.3sharejuliabasebroadcast.jl
but when I edited it, changing some value return, and then use the function, there is not any change, Which makes me think that it is not the desired file.
function path julia-lang
|
show 1 more comment
I try to use @which
but it leads me to a page on GitHub with the code, however I want to know the explicit path in my computer i.e. the file that is used when I call the function. for example broadcast(+, A, A)
where A
is an Array, I thought the path was:
C:UsersuserAppDataLocalJulia-0.6.3sharejuliabasebroadcast.jl
but when I edited it, changing some value return, and then use the function, there is not any change, Which makes me think that it is not the desired file.
function path julia-lang
1
use Revise.jl if you wanna edit a base function.
– Gnimuc
Nov 13 '18 at 5:47
1
@edit broadcast(+, A, A)
will open the correct file in an editor.
– DNF
Nov 13 '18 at 7:03
1
@DNF is right. If it doesn't then set the environmental variableJULIA_EDITOR
.
– crstnbr
Nov 13 '18 at 8:08
1
Just to add a comment to all the comments above - I would not recommend you to change Base like this. The way it is best to do it is to change a specific method after starting Julia. If you want it to be changed every time you start Julia put the relevant code in startup.jl file.
– Bogumił Kamiński
Nov 13 '18 at 8:50
1
Don't you have to rebuild the system image if you modify base functions? (docs.julialang.org/en/v1/devdocs/sysimg/…)
– daycaster
Nov 13 '18 at 9:23
|
show 1 more comment
I try to use @which
but it leads me to a page on GitHub with the code, however I want to know the explicit path in my computer i.e. the file that is used when I call the function. for example broadcast(+, A, A)
where A
is an Array, I thought the path was:
C:UsersuserAppDataLocalJulia-0.6.3sharejuliabasebroadcast.jl
but when I edited it, changing some value return, and then use the function, there is not any change, Which makes me think that it is not the desired file.
function path julia-lang
I try to use @which
but it leads me to a page on GitHub with the code, however I want to know the explicit path in my computer i.e. the file that is used when I call the function. for example broadcast(+, A, A)
where A
is an Array, I thought the path was:
C:UsersuserAppDataLocalJulia-0.6.3sharejuliabasebroadcast.jl
but when I edited it, changing some value return, and then use the function, there is not any change, Which makes me think that it is not the desired file.
function path julia-lang
function path julia-lang
asked Nov 13 '18 at 5:03
4lrdyD4lrdyD
345
345
1
use Revise.jl if you wanna edit a base function.
– Gnimuc
Nov 13 '18 at 5:47
1
@edit broadcast(+, A, A)
will open the correct file in an editor.
– DNF
Nov 13 '18 at 7:03
1
@DNF is right. If it doesn't then set the environmental variableJULIA_EDITOR
.
– crstnbr
Nov 13 '18 at 8:08
1
Just to add a comment to all the comments above - I would not recommend you to change Base like this. The way it is best to do it is to change a specific method after starting Julia. If you want it to be changed every time you start Julia put the relevant code in startup.jl file.
– Bogumił Kamiński
Nov 13 '18 at 8:50
1
Don't you have to rebuild the system image if you modify base functions? (docs.julialang.org/en/v1/devdocs/sysimg/…)
– daycaster
Nov 13 '18 at 9:23
|
show 1 more comment
1
use Revise.jl if you wanna edit a base function.
– Gnimuc
Nov 13 '18 at 5:47
1
@edit broadcast(+, A, A)
will open the correct file in an editor.
– DNF
Nov 13 '18 at 7:03
1
@DNF is right. If it doesn't then set the environmental variableJULIA_EDITOR
.
– crstnbr
Nov 13 '18 at 8:08
1
Just to add a comment to all the comments above - I would not recommend you to change Base like this. The way it is best to do it is to change a specific method after starting Julia. If you want it to be changed every time you start Julia put the relevant code in startup.jl file.
– Bogumił Kamiński
Nov 13 '18 at 8:50
1
Don't you have to rebuild the system image if you modify base functions? (docs.julialang.org/en/v1/devdocs/sysimg/…)
– daycaster
Nov 13 '18 at 9:23
1
1
use Revise.jl if you wanna edit a base function.
– Gnimuc
Nov 13 '18 at 5:47
use Revise.jl if you wanna edit a base function.
– Gnimuc
Nov 13 '18 at 5:47
1
1
@edit broadcast(+, A, A)
will open the correct file in an editor.– DNF
Nov 13 '18 at 7:03
@edit broadcast(+, A, A)
will open the correct file in an editor.– DNF
Nov 13 '18 at 7:03
1
1
@DNF is right. If it doesn't then set the environmental variable
JULIA_EDITOR
.– crstnbr
Nov 13 '18 at 8:08
@DNF is right. If it doesn't then set the environmental variable
JULIA_EDITOR
.– crstnbr
Nov 13 '18 at 8:08
1
1
Just to add a comment to all the comments above - I would not recommend you to change Base like this. The way it is best to do it is to change a specific method after starting Julia. If you want it to be changed every time you start Julia put the relevant code in startup.jl file.
– Bogumił Kamiński
Nov 13 '18 at 8:50
Just to add a comment to all the comments above - I would not recommend you to change Base like this. The way it is best to do it is to change a specific method after starting Julia. If you want it to be changed every time you start Julia put the relevant code in startup.jl file.
– Bogumił Kamiński
Nov 13 '18 at 8:50
1
1
Don't you have to rebuild the system image if you modify base functions? (docs.julialang.org/en/v1/devdocs/sysimg/…)
– daycaster
Nov 13 '18 at 9:23
Don't you have to rebuild the system image if you modify base functions? (docs.julialang.org/en/v1/devdocs/sysimg/…)
– daycaster
Nov 13 '18 at 9:23
|
show 1 more comment
1 Answer
1
active
oldest
votes
This is an attempt to (sort of) summarize what has been written in the comments already.
Before anything, as @daycaster mentioned correctly, changes to Base source files won't take effect until you recompile your system image. So, the path you gave is actually correct.
In the REPL, using @which
will tell you where the function is defined (name of the Base file and line number):
julia> @which 3+3
+(x::T, y::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8} in Base at int.jl:53
Integer addition is defined in line 53 of int.jl in the base
folder of your local julia installation. In Jupyter (maybe also in Juno?) this is automatically made clickable and will bring you to the respective line on github.
If you told Julia what you favorite editor is, by setting JULIA_EDITOR
to e.g. vim
, you can use @edit 3+3
to get an editor instance at the right file and line locally.
(Note that there is a URL bug on Windows which leads to incorrect URLs for methods living in standard libraries.)
In any case, as @BogumiłKamiński mentioned, you probably shouldn't modify the julia source in the first place. Just "overwrite" the relevant method in an open Julia session (you can do it in your startup.jl
if you want this to be locally permanent):
julia> inv(3)
0.3333333333333333
julia> Base.inv(x::Integer) = begin println("JUHU!"); float(one(x)) / float(x) end
julia> inv(3)
JUHU!
0.3333333333333333
If (for some mysterious reasons) you really want to make the change in a Base source file, you can use Revise.jl, as mentioned by @Gnimuc. This would look like this:
julia> using Revise
julia> Revise.track(Base)
julia> inv(3)
0.3333333333333333
julia> @edit inv(3) # make a change
julia> inv(3)
JUHU!
0.3333333333333333
However, this isn't much different from just overwriting the method yourself. It also won't be permanent.
UPDATE:
I just realized that you're still on 0.6. In that case the file isn't called startup.jl
but juliarc.jl
. Also the Windows URL bug doesn't effect you then.
Thank you very much, this will help me a lot.
– 4lrdyD
Nov 14 '18 at 1:40
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53274123%2fhow-to-get-the-explicit-path-of-a-julia-function%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is an attempt to (sort of) summarize what has been written in the comments already.
Before anything, as @daycaster mentioned correctly, changes to Base source files won't take effect until you recompile your system image. So, the path you gave is actually correct.
In the REPL, using @which
will tell you where the function is defined (name of the Base file and line number):
julia> @which 3+3
+(x::T, y::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8} in Base at int.jl:53
Integer addition is defined in line 53 of int.jl in the base
folder of your local julia installation. In Jupyter (maybe also in Juno?) this is automatically made clickable and will bring you to the respective line on github.
If you told Julia what you favorite editor is, by setting JULIA_EDITOR
to e.g. vim
, you can use @edit 3+3
to get an editor instance at the right file and line locally.
(Note that there is a URL bug on Windows which leads to incorrect URLs for methods living in standard libraries.)
In any case, as @BogumiłKamiński mentioned, you probably shouldn't modify the julia source in the first place. Just "overwrite" the relevant method in an open Julia session (you can do it in your startup.jl
if you want this to be locally permanent):
julia> inv(3)
0.3333333333333333
julia> Base.inv(x::Integer) = begin println("JUHU!"); float(one(x)) / float(x) end
julia> inv(3)
JUHU!
0.3333333333333333
If (for some mysterious reasons) you really want to make the change in a Base source file, you can use Revise.jl, as mentioned by @Gnimuc. This would look like this:
julia> using Revise
julia> Revise.track(Base)
julia> inv(3)
0.3333333333333333
julia> @edit inv(3) # make a change
julia> inv(3)
JUHU!
0.3333333333333333
However, this isn't much different from just overwriting the method yourself. It also won't be permanent.
UPDATE:
I just realized that you're still on 0.6. In that case the file isn't called startup.jl
but juliarc.jl
. Also the Windows URL bug doesn't effect you then.
Thank you very much, this will help me a lot.
– 4lrdyD
Nov 14 '18 at 1:40
add a comment |
This is an attempt to (sort of) summarize what has been written in the comments already.
Before anything, as @daycaster mentioned correctly, changes to Base source files won't take effect until you recompile your system image. So, the path you gave is actually correct.
In the REPL, using @which
will tell you where the function is defined (name of the Base file and line number):
julia> @which 3+3
+(x::T, y::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8} in Base at int.jl:53
Integer addition is defined in line 53 of int.jl in the base
folder of your local julia installation. In Jupyter (maybe also in Juno?) this is automatically made clickable and will bring you to the respective line on github.
If you told Julia what you favorite editor is, by setting JULIA_EDITOR
to e.g. vim
, you can use @edit 3+3
to get an editor instance at the right file and line locally.
(Note that there is a URL bug on Windows which leads to incorrect URLs for methods living in standard libraries.)
In any case, as @BogumiłKamiński mentioned, you probably shouldn't modify the julia source in the first place. Just "overwrite" the relevant method in an open Julia session (you can do it in your startup.jl
if you want this to be locally permanent):
julia> inv(3)
0.3333333333333333
julia> Base.inv(x::Integer) = begin println("JUHU!"); float(one(x)) / float(x) end
julia> inv(3)
JUHU!
0.3333333333333333
If (for some mysterious reasons) you really want to make the change in a Base source file, you can use Revise.jl, as mentioned by @Gnimuc. This would look like this:
julia> using Revise
julia> Revise.track(Base)
julia> inv(3)
0.3333333333333333
julia> @edit inv(3) # make a change
julia> inv(3)
JUHU!
0.3333333333333333
However, this isn't much different from just overwriting the method yourself. It also won't be permanent.
UPDATE:
I just realized that you're still on 0.6. In that case the file isn't called startup.jl
but juliarc.jl
. Also the Windows URL bug doesn't effect you then.
Thank you very much, this will help me a lot.
– 4lrdyD
Nov 14 '18 at 1:40
add a comment |
This is an attempt to (sort of) summarize what has been written in the comments already.
Before anything, as @daycaster mentioned correctly, changes to Base source files won't take effect until you recompile your system image. So, the path you gave is actually correct.
In the REPL, using @which
will tell you where the function is defined (name of the Base file and line number):
julia> @which 3+3
+(x::T, y::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8} in Base at int.jl:53
Integer addition is defined in line 53 of int.jl in the base
folder of your local julia installation. In Jupyter (maybe also in Juno?) this is automatically made clickable and will bring you to the respective line on github.
If you told Julia what you favorite editor is, by setting JULIA_EDITOR
to e.g. vim
, you can use @edit 3+3
to get an editor instance at the right file and line locally.
(Note that there is a URL bug on Windows which leads to incorrect URLs for methods living in standard libraries.)
In any case, as @BogumiłKamiński mentioned, you probably shouldn't modify the julia source in the first place. Just "overwrite" the relevant method in an open Julia session (you can do it in your startup.jl
if you want this to be locally permanent):
julia> inv(3)
0.3333333333333333
julia> Base.inv(x::Integer) = begin println("JUHU!"); float(one(x)) / float(x) end
julia> inv(3)
JUHU!
0.3333333333333333
If (for some mysterious reasons) you really want to make the change in a Base source file, you can use Revise.jl, as mentioned by @Gnimuc. This would look like this:
julia> using Revise
julia> Revise.track(Base)
julia> inv(3)
0.3333333333333333
julia> @edit inv(3) # make a change
julia> inv(3)
JUHU!
0.3333333333333333
However, this isn't much different from just overwriting the method yourself. It also won't be permanent.
UPDATE:
I just realized that you're still on 0.6. In that case the file isn't called startup.jl
but juliarc.jl
. Also the Windows URL bug doesn't effect you then.
This is an attempt to (sort of) summarize what has been written in the comments already.
Before anything, as @daycaster mentioned correctly, changes to Base source files won't take effect until you recompile your system image. So, the path you gave is actually correct.
In the REPL, using @which
will tell you where the function is defined (name of the Base file and line number):
julia> @which 3+3
+(x::T, y::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8} in Base at int.jl:53
Integer addition is defined in line 53 of int.jl in the base
folder of your local julia installation. In Jupyter (maybe also in Juno?) this is automatically made clickable and will bring you to the respective line on github.
If you told Julia what you favorite editor is, by setting JULIA_EDITOR
to e.g. vim
, you can use @edit 3+3
to get an editor instance at the right file and line locally.
(Note that there is a URL bug on Windows which leads to incorrect URLs for methods living in standard libraries.)
In any case, as @BogumiłKamiński mentioned, you probably shouldn't modify the julia source in the first place. Just "overwrite" the relevant method in an open Julia session (you can do it in your startup.jl
if you want this to be locally permanent):
julia> inv(3)
0.3333333333333333
julia> Base.inv(x::Integer) = begin println("JUHU!"); float(one(x)) / float(x) end
julia> inv(3)
JUHU!
0.3333333333333333
If (for some mysterious reasons) you really want to make the change in a Base source file, you can use Revise.jl, as mentioned by @Gnimuc. This would look like this:
julia> using Revise
julia> Revise.track(Base)
julia> inv(3)
0.3333333333333333
julia> @edit inv(3) # make a change
julia> inv(3)
JUHU!
0.3333333333333333
However, this isn't much different from just overwriting the method yourself. It also won't be permanent.
UPDATE:
I just realized that you're still on 0.6. In that case the file isn't called startup.jl
but juliarc.jl
. Also the Windows URL bug doesn't effect you then.
edited Nov 13 '18 at 13:48
answered Nov 13 '18 at 13:43
crstnbrcrstnbr
3,91911022
3,91911022
Thank you very much, this will help me a lot.
– 4lrdyD
Nov 14 '18 at 1:40
add a comment |
Thank you very much, this will help me a lot.
– 4lrdyD
Nov 14 '18 at 1:40
Thank you very much, this will help me a lot.
– 4lrdyD
Nov 14 '18 at 1:40
Thank you very much, this will help me a lot.
– 4lrdyD
Nov 14 '18 at 1:40
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53274123%2fhow-to-get-the-explicit-path-of-a-julia-function%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
use Revise.jl if you wanna edit a base function.
– Gnimuc
Nov 13 '18 at 5:47
1
@edit broadcast(+, A, A)
will open the correct file in an editor.– DNF
Nov 13 '18 at 7:03
1
@DNF is right. If it doesn't then set the environmental variable
JULIA_EDITOR
.– crstnbr
Nov 13 '18 at 8:08
1
Just to add a comment to all the comments above - I would not recommend you to change Base like this. The way it is best to do it is to change a specific method after starting Julia. If you want it to be changed every time you start Julia put the relevant code in startup.jl file.
– Bogumił Kamiński
Nov 13 '18 at 8:50
1
Don't you have to rebuild the system image if you modify base functions? (docs.julialang.org/en/v1/devdocs/sysimg/…)
– daycaster
Nov 13 '18 at 9:23