Jupyter dosen't return the MapBox map - jupyter-notebook

I am trying to test the jupyter version of mapbox gl js.
i copied the code of this example in my jupyter notebook , and attempted to return the map,
the result is an empty map !!:
what is wrong ?
please let me know if the map is returned in your devices

I solved my problem,the problem was with the token :
so instead of:
token=os.getenv(my_public_token)
(this function reads a system environment variable so i need ti set a MAPBOX_ACCESS_TOKEN environment variable if i want to use it)
the solution is directly :
token=my_public_token
Note: my_public_token is the public token of your mapbox account

Related

I get an error when using {future} and {furrr} functions within a Golem Shiny App, what does it come from?

I am currently working on a Golem Shiny App called "package_name" (which is a requirement for me) for which some functions I created need to use functions from the {furrr} and {future} packages.
However, whenever I try to run them, I get the following error :
Error : there is no package called 'package_name'
Please note that whenever any function that does not use either package works perfectly fine.
Does anyone know what the problem might be ?
Thanks !
While building the application with {golem}, the package with the app is not installed on your machine.
When you use {future}, the code is run inside another R session, meaning that the objects are transported and the libraries reloaded.
BUT if you try to use a function from inside your current app into your future, you need to make it "transportable", and using package_name::function() will not work because your package is not installed.
Let's say you need to use current_app_fun(), defined inside your package.
Technically, {future} will be able to transport this function, as it uses {globals} to identify the objects to transport to the new R session.
observeEvent( input$bla , {
# future() will identify that it needs to
# transport current_app_fun()
future({
current_app_fun()
})
})
You can also do an extra step just to be extra cautious:
observeEvent( input$bla , {
func_for_future <- current_app_fun
future({
func_for_future()
})
})
Cheers,
Colin

How to activate an active environment within a certain folder in Julia

After reading Pkg I can't figure out how to implement an active environment within a certain folder (something like Open Project in New Session by RStudio).
It's possible?
Is there any other document about it?
Please instruct me how to do it!
In julia you can use the question mark ? to access the help mode of the REPL. Then you can ask for help on using Pkg.activate if you do:
julia> using Pkg
and then you type
?Pkg.activate
(you will see some examples:)
Pkg.activate()
Pkg.activate("local/path")
Pkg.activate("MyDependency")
This works if you did the "using" step first.
But you can activate your environment from the Pkg mode in the REPL (accessed by typing ] from the REPL) as well by typing
] activate local/path/to/your/environment
Assuming that your environment is at the path "local/path/to/your/environment"
You can see this help by typing
julia> ]? activate
on your REPL
I use https://direnv.net and create a .envrc file with this in it:
export JULIA_PROJECT=#.
The first time you use it you have to do direnv allow and after that whenever you're in that directory your environment is modified so that Julia uses it as your active project. You can also add other useful environment variables in there.

In R how can I find in which file is a function defined

when I develop a package I find myself trying to find in which file is a function defined.
Say I some R file (of a package my_package) I see
fun <- myFun(...)
{
# some stuff
test <- someOtherFunction(...)
}
Is there an easy way to find in which file the function someOtherFunction is defined ?
Something like findFunction(name='someOtherFunction', package='my_package')
If you are looking to open the file in Rstudio in a quicker way.
You can use the Rstudio Go to file/function... to open a file that contains a function. This is useful when you have custom function written in a file or navigating around the modules.
Scroll to the tab Code
Code --> Go to file/function...
and enter the function name to locate the file with that function and open it.
You can use the default shortcut provided Ctrl+. or alternatively using the Tools tab Modify Keyboard Shortcuts and set up something it Ctrl O.

Creating a polygon with Point Cloud

I am trying to create a polygon with Point Cloud Library. It shows an error
that no matching argument list is found.
Here is my code :
pcl::visualization::PCLVisualizer::addPolygon(cloud);
Thank you for any suggestions...
Had same error, solved with .
pcl::visualization::PCLVisualizer::addPolygon(cloud);
to
pcl::visualization::PCLVisualizer::addPolygon<pcl::PointXYZ>(cloud);
Make sure you are using pcl::PointXYZ.
e.g. if you create your cloud data like this,
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud
then you need to use pcl::PointXYZRGB

Fix function in R for Ubuntu not working properly

I have been using R in the terminal window for Ubuntu. Recently I discovered the fix function in R, which I could use to edit my function. However, whenever I use the fix function, it opens up an editor (VIM) and I can use that to write my function. Then I type "wq" to save the work, however when I type the name of the function, it shows that there weren't any edits which were made to the function. Why does this happen?
In order to use the editing functionality, make sure you have either
the default editor installed (do eg grep EDITOR /etc/R/Renviron)
or set the EDITOR environment variable to a different editor you prefer,
or at runtime set options("editor"=....) to what you need.
Now, for the fix() function in particular, note this hint in its manual page:
‘fix’ invokes ‘edit’ on ‘x’ and then assigns the new (edited)
version of ‘x’ in the user's workspace.
So if the change "vanishes", maybe you were editing an object which is not yours. Start with something simple, edit it and see if that persists. Along the lines of
R> hw <- function() cat("Hello, world\n")
R> fix(hw) ## editing, adding 'new'
R> hw()
Hello, new world
R>

Resources