-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UndefVarError: .+ not defined #24
Comments
Hi Valerii, Can you please provide me with a minimal code sample with which I can replicate this error. |
I don't have problem on my computer. It works perfectly. But on server, I have these errors. |
If it works on your computer, but not on your server, then it may have to do with the Linux distribution of Julia. If I'm not able to replicate the error on my computer, then it may be difficult or impossible for me to fix. Have you tried upgrading Julia to the latest version, to see if that fixes it? |
Yes, I understand it. But do you know your code in the lines? What can cause the error? |
So that line is modified by an internal macro. The code is, @positive model.phi[1] = model.beta_old[:,terms] .* exp.(model.Elogtheta_old[d]) Which should result in the following expression at compile time, model.phi[1] = EPSILON .+ model.beta_old[:,terms] .* exp.(model.Elogtheta_old[d]) |
Are you able to to perform coordinate-wise addition of a scalar with an array on your server's version of Julia? |
Maybe it can be useful
|
this is a simple exercise, with the same problem
|
c= Corpus([Document([1,2,3]),Document([1,2,3]),Document([1,2,3]),Document([1,2,3]),
Document([4,5,6]),Document([4,5,6]),Document([4,5,6]),Document([4,5,6]),
Document([7,7,7]),Document([7,7,7]),Document([7,7,7]),Document([7,7,7])],
vocab = split("1 2 3 4 5 6 7"))
model = LDA(c, 2) This code works fine for me on the MacOS distribution of Julia 1.4.2. |
it works on Julia 1.3 on my PC. So is the problem of Julia 1.1.1? Can I do something to patch it? |
If you unable to upgrade your server's version of Julia (which may or may not fix the problem), then patching your copy of TopicModelsVB.jl will be difficult if the problem is the element-wise addition operator, since that operator is used in many places in the source code. So even if you manually fix this particular line, the error will just then pop up somewhere else. Can you please run the following code on your server, and let me know if it works: 3 .+ [1 2; 3 4] |
Thank you for your help. it works perfectly. |
Ok, now can you please try this code: EPSILON = 1
macro positive(expr::Expr)
"Add EPSILON to a numerical variable or array during variable assignment."
if (expr.head == :.) || (expr.head == :ref)
expr_out = :(:($($expr)) .+= EPSILON)
elseif expr.head == :(=)
expr_out = :(:($($(expr.args[1]))) = EPSILON .+ :($($(expr.args[2]))))
end
return expr_out
end
@positive x = 3 The result should be And then if that works, try this: @positive x = [1 2; 3 4] |
the same error
|
Which gave you the error, |
The first, I can't even define the macro |
Ok, so this is something I will need to discuss with the Julia Dev team, and then I can get back to you hopefully with a solution at a future date. In the mean time, my only suggestion is to try upgrading Julia to the latest version (if you can), as that may fix the issue. |
Thank. Thank you for your help. |
This code works on Julia ver 1.1.1 |
Could you try out the following code on your command line: macro positive(expr::Expr)
"Add EPSILON to a numerical variable or array during variable assignment."
if (expr.head == :.) || (expr.head == :ref)
expr_out = :($expr .+= EPSILON)
elseif expr.head == :(=)
expr_out = :($(expr.args[1]) = EPSILON .+ $(expr.args[2]))
end
return expr_out
end If it works, then you could try patching the macros.jl file by replacing the It appears to be working for my preliminary tests, but I'll need to test it further before I open a PR. |
Unfortunately, it doesn't work.
|
Ok so I did find this related dicussion concerning unresolved issues in Julia's metaprogramming functionality. If escaping the return value is what's fixing the problem for you, then a potential patch would be to go into macros.jl and replace macro juliadots(str::String)
macro juliadots(expr::Expr)
macro boink(expr::Expr)
macro positive(expr::Expr)
macro finite(expr::Expr) |
Ok, so I've modified the offending macros. You can see the changes made here fcd6f8d. Could you let me know if this fixes the problem for you? |
thank you. Shall I replace only macro.jl file, or should I update the whole package? P.S. right now, I am working with my hand fixing macro. jl |
The changes have been committed to the master branch. So if you just run, pkg> add https://github.com/ericproffitt/TopicModelsVB.jl Then you should be good to go, no need to modify the macros.jl file yourself. |
Thank you, I will check a lit bit later. Thank you so much |
I'm going to close this issue, if you're still having problems with the macro functionality, please feel free to reopen. |
julia ver. 1.1.1
The text was updated successfully, but these errors were encountered: