save_MAFs | R Documentation |
Infusion fit results created using the mafR package contain (pointers to) Python objects, which are lost (their pointers being reduced to null pointers) when the fit object is saved on file and reloaded. The functions described here circumvent this issue.
save_MAFs
will save the Python objects in distinct files. load_MAFs
will load them back into the fit object, not overriding anyone pre-existing into the target fit object.
The Python objects are saved under, and read from, files whose names are made of "jointdens"
, "pardens"
... and the given prefix
and ext
ension.
save_MAFs(object, ext="_MAF.pkl", prefix="")
load_MAFs(object, ext="_MAF.pkl", prefix="", set_path_only=FALSE)
object |
An object of class |
prefix , ext |
Character: Prefix and extension for the filename of each saved MAF object. |
set_path_only |
Boolean: if TRUE, checks the presence of the saved MAF files, but do not load them, and (re)set the path information in the |
Both functions can write file path information into the input object
's load_MAFs_info
element (an environment), where it can be read afterwards. save_MAFs
will do so in all cases, and load_MAFs
will do so when called with argument set_path_only=TRUE
. When a bootstrap is run using parallelisation, the child processes can thus load files using their location information stored in this way. When the files have been moved after the save_MAFs
call, their location information must then be updated using load_MAFs(., set_path_onlTRUE)
.
Both functions return the updated input object
.
reticulate::py_save_object
is used to save the Python objects.
## Given object 'slik_j' of class SLik_j
# save_MAFs(slik_j, prefix = "2024Feb30_")
## => '2024Feb30_jointdens_MAF.pkl', etc.
# save(slik_j, file="slik_j.rda")
## => Objects from Python environments are not saved in the RData file.
# and later:
# load(file="slik_j.rda")
# slik_j <- load_MAFs(slik_j, prefix = "2024Feb30_")
## Objects from pkl files are put back at the right place in 'slik_j'.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.