Skip to contents

A CallablePythonCode class of objects

A CallablePythonCode class of objects

Super classes

teal.data::Callable -> teal.data::CallableFunction -> CallablePythonCode

Methods

Inherited methods


Method new()

Create a new CallablePythonCode object

Usage

CallablePythonCode$new(fun, env = new.env(parent = parent.env(globalenv())))

Arguments

fun

(function)
function to be evaluated in class. Function should be named

env

(environment)
environment where the result of python code evaluation are stored

Returns

new CallablePythonCode object


Method set_object()

For scripts and code that contain multiple objects, save the name of the object that corresponds to the final dataset of interest. This is required for running python scripts with reticulate.

Usage

CallablePythonCode$set_object(x)

Arguments

x

(character) the name of the object produced by the code or script.

Returns

(self) invisibly for chaining.


Method run()

Execute Callable python code.

Usage

CallablePythonCode$run(args = NULL, try = FALSE)

Arguments

args

(NULL or named list)
supplied for callable functions only, these are dynamic arguments passed to reticulate::py_run_string or reticulate::py_run_file. Dynamic arguments are executed in this call and are not saved which means that self$get_call() won't include them later.

try

(logical value)
whether perform function evaluation inside try clause

Returns

nothing or output from function depending on return argument. If run fails it will return object of class simple-error error when try = TRUE or will stop if try = FALSE.


Method clone()

The objects of this class are cloneable with this method.

Usage

CallablePythonCode$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.