How to manage Unfold precompiling error: _iszero not defined? - julia

On a new computer I was trying to run Unfold and UnfoldMakie. See this error in both cases.
Like something wrong with the MutableArithmetics library.
Any idea how to manage it?
Also get this after update of MakieCore package:
Versions:
Julia 1.8.0.
Unfold v0.3.11
UnfoldMakie v0.1.4

It seems as a solution:
These packages work in the julia envv1.7, but do not work in v1.8.
In VScode you can change it here:

Finally figured out the problem:
First, I created a new environment/project.
https://pkgdocs.julialang.org/v1/environments/
Second, activated it in the notebook.
Third, installed problematic libraries through this code:
import Pkg
p = "Unfold"
Pkg.add(p)
Pkg.build(p)

Related

Python - Bokeh Interactive Legend - Attribute Error

I am trying to make an interactive legend.
Even when I run the code in this link https://docs.bokeh.org/en/latest/docs/user_guide/interaction/legends.html
I get the error:
AttributeError: unexpected attribute 'legend_label' to Line, possible attributes are js_event_callbacks, js_property_callbacks, line_alpha, line_cap, line_color, line_dash, line_dash_offset, line_join, line_width, name, subscribed_events, tags, x or y
Any ideas why? I have the latest version of Bokeh, as far I know.
Use legend instead of legend_field or legend_label.
legend_label was added in version 1.4. You will have to update to that or later, or else refer to the docs specific to your version:
https://docs.bokeh.org/en/1.3.4/docs/user_guide/interaction/legends.html
I got a similar error when installing bokeh through the shell first and through the conda later. This got me with two versions and the old one was preferred.
I think what solved it for me: uninstalling previous versions, installing only conda (I have done it in Jupyter Notebook) and restarting the computer afterwards. Hope it helps.

XRJulia and findJulia in MacOSX

I'm having problem in MacOSX when trying to use XRJulia package.
When I run FindJulia, I get the error:
"Error in findJulia() :
No julia executable in search path and JULIA_BIN environment variable not set"
There seems to be an answer here but I don't really understand it,
How do I add a "key" in MacOSX and how do I add Julia to the path? A step by step explanation would be very much appreciated,
Thanks
EDIT: I resolved the problem and here is the piece of code I used for setup:
julia_setup(JULIA_HOME="/Applications/Julia-1.0.app/Contents/Resources/julia/bin")

Julia doesn't find packages in depot_path anymore

I have a problem with using packages in Julia. It has worked before, and I'm not really sure why this has changed or how to troubleshoot.
I have a folder
/my_path/julia/packages
with Julia packages. For example, there is a folder
/my_path/julia/packages/FFTW/
with the FFTW package.
Further, I have changed the depot path to point at this directory by assigning JULIA_DEPOT_PATH before starting julia, so that
Base.DEPOT_PATH = ["/my_path/julia/"]
However, if I run
julia> using FFTW
I get the following error message:
ERROR: ArgumentError: Package FFTW not found in current path:
- Run `import Pkg; Pkg.add("FFTW")` to install the FFTW package.
Any idea how I can troubleshoot or fix this?
Manipulating Base.DEPOT_PATH does not seem like a good idea.
The code proposed by #cmc will does not work (at least on Julia 1.3.1):
julia> Base.DEPOT_PATH = ["/some/path"]
ERROR: cannot assign variables in other modules
There is a workaround:
Base.DEPOT_PATH[1] = "/some/path"
However, the correct way is to assign the JULIA_DEPOT_PATH system variable before starting Julia, Windows:
set JULIA_DEPOT_PATH=c:\some\path
or
set JULIA_DEPOT_PATH=c:\some\path1;c:\some\path2
Linux/OSX:
export JULIA_DEPOT_PATH=/some/path
or
export JULIA_DEPOT_PATH=/some/path1:/some/path2
Unless you have a specific reason to do so (and if this is the case I'd be interested to hear it!), you don't need to fiddle with the DEPOT_PATH or LOAD_PATH variables: using Julia's package manager should be enough to cover your needs most of the time.
In this specific instance, have you tried to do what the error message suggests?
julia> import Pkg
julia> Pkg.add("FFTW")
LOAD_PATH, not DEPOT_PATH, will modify code loading.
You want to do something like push!(LOAD_PATH, /my_path/julia/packages).
I will echo #ffevotte and strongly suggest to not modify LOAD_PATH unless necessary. The benefits of organizing dependencies into Pkg environments far outweigh the small overhead of declaring them explicitly through Pkg.add.

Installing / Using R Packages in Sublime Text 3

I am trying to use the R function dmvnorm (found in the mvtnorm package) in Sublime Text 3. I installed it and ran my code in RStudio, so I know the code is fine. In sublime, I entered:
install.packages('mvtnorm',repos='http://cran.us.r-project.org')
library(mvtnorm)
It looked as though it worked, but when I ran my code it said:
Error: could not find function "dmvnorm"
I'm using a Mac and my hunch is this is somehow related to specifying the path in Preferences -> Package Settings -> Sublime REPL -> Settings - User. The current path displayed as part of the error reads:
[path: /usr/bin:/bin:/usr/sbin:/sbin]
Thanks!
I had a hard time with this recently as well. I'm very new to R so I'm not sure this is the best answer, but to hold you off until someone gives a better one, did you include library('package.name') in the file (in sublime)? require('package.name') also works, but this appears not to be best practice for reasons described, e.g., here.
I hope this helps!

How can I tell which packages I am not using in my R script?

As my code evolves from version to version, I'm aware that there are some packages for which I've found better/more appropriate packages for the task at hand or whose purpose was limited to a section of code which I've now phased out.
Is there any easy way to tell which of the loaded packages are actually used in a given script? My header is beginning to get cluttered.
Update 2020-04-13
I've now updated the referenced function to use the abstract syntax tree (AST) instead of using regular expressions as before. This is a much more robust way of approaching the problem (it's still not completely ironclad). This is available from version 0.2.0 of funchir, now on CRAN.
I've just got around to writing a quick-and-dirty function to handle this which I call stale_package_check, and I've added it to my package (funchir).
e.g., if we save the following script as test.R:
library(data.table)
library(iotools)
DT = data.table(a = 1:3)
Then (from the directory with that script) run funchir::stale_package_check('test.R'), we'll get:
Functions matched from package data.table: data.table
**No exported functions matched from iotools**
Have you considered using packrat?
packrat::clean() would remove unused packages, for example.
I've written a command-line script to accomplish this task. You can find it in this Github gist. I'm sure there are edge cases that it misses, but it works pretty well, on both R scripts and Rmd files.
My approach always is to close my R script or IDE (i.e. RStudio) and then start it again.
After this I run my function without loading any dependecies/packages beforehand.
This should result in various warning and error messages telling you which functions couldn't be found and executed. This again will give you hints on what packages are necessary to load beforehand and which one you can leave out.

Resources