Skip to content

Commit 9c968f9

Browse files
committed
tidy
1 parent 0e7a6ca commit 9c968f9

File tree

6 files changed

+14
-30
lines changed

6 files changed

+14
-30
lines changed

R/layers-preprocessing.R

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2360,15 +2360,6 @@ set_vocabulary <- function(object, vocabulary, idf_weights=NULL, ...) {
23602360
}
23612361

23622362

2363-
## TODO: TextVectorization has a compile() method. investigate if this is
2364-
## actually useful to export
2365-
#compile.keras.engine.base_preprocessing_layer.PreprocessingLayer <-
2366-
function(object, run_eagerly = NULL, steps_per_execution = NULL, ...) {
2367-
args <- capture_args(ignore="object")
2368-
do.call(object$compile, args)
2369-
}
2370-
2371-
23722363
#' A preprocessing layer to convert raw audio signals to Mel spectrograms.
23732364
#'
23742365
#' @description
@@ -2585,11 +2576,12 @@ function (object, fft_length = 2048L, sequence_stride = 512L,
25852576
adapt <- function(object, data, ..., batch_size=NULL, steps=NULL) {
25862577
if (!is_py_object(data))
25872578
data <- keras_array(data)
2588-
# TODO: use as_tensor() here
25892579

2590-
args <- capture_args(list(batch_size = as_nullable_integer,
2591-
step = as_nullable_integer),
2592-
ignore = c("object", "data"))
2580+
args <- capture_args(
2581+
list(batch_size = as_nullable_integer,
2582+
step = as_nullable_integer),
2583+
ignore = c("object", "data")
2584+
)
25932585
# `data` named to `dataset` in keras3 keras.utils.FeatureSpace
25942586
# pass it as a positional arg
25952587
args <- c(list(data), args)

R/metrics.R

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3673,11 +3673,3 @@ py_to_r_wrapper.keras.src.metrics.metric.Metric <- py_to_r_wrapper.keras.src.los
36733673
custom_metric <- function(name, metric_fn) {
36743674
py_func2(metric_fn, convert = TRUE, name = name)
36753675
}
3676-
3677-
# TODO: export ??
3678-
# can be used w/ activations, regularizers, metrics, loss, anything else
3679-
# where it helps to have a name
3680-
custom_fn <- function(name, fn) {
3681-
py_func2(fn, TRUE, name)
3682-
}
3683-

R/model-training.R

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,6 @@ function (object, x, y = NULL, sample_weight = NULL, class_weight = NULL)
913913
#' @export
914914
summary.keras.src.models.model.Model <- function(object, ...) {
915915
writeLines(f <- format.keras.src.models.model.Model(object, ...))
916-
# TODO: knit_print...?
917916
invisible(f)
918917
}
919918

@@ -927,6 +926,7 @@ function(x,
927926
expand_nested = FALSE,
928927
show_trainable = NA,
929928
...,
929+
# TODO: add force_ascii arg
930930
# force_ascii ... (impl in man/roxygen/meta.R)
931931
# width = getOption("width"),
932932
# rich = TRUE, ??
@@ -945,9 +945,6 @@ function(x,
945945
args$show_trainable <- built && as.logical(length(x$non_trainable_weights))
946946
}
947947

948-
# args$print_fn <- function(x, ...) {browser(); x}
949-
950-
# Do we need to check for model$built before calling summary?
951948
with_rich_config(
952949
out <- trimws(py_capture_output(do.call(x$summary, args)))
953950
)

R/package.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ keras <- NULL
5151

5252
.onLoad <- function(libname, pkgname) {
5353

54-
# TODO: remove this requireNamespace()
5554
# tensorflow:::.onLoad() registers some reticulate class filter hooks
5655
# we need to identify tensors reliably.
5756
requireNamespace("tensorflow", quietly = TRUE)

R/py-classes.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,14 @@ def wrap_fn(r_fn):
458458
}
459459

460460

461+
# Export this if the API calls for a bare named function somewhere
462+
custom_fn <- function(name, fn) {
463+
py_func2(fn, TRUE, name)
464+
}
465+
466+
467+
468+
461469
# TODO: (maybe?) factor out a py_class() function,
462470
# funnel r_to_py.R6ClassGenerator() and %py_class%() to go through py_class()
463471
# export py_class()

R/r-utils.R

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,6 @@ as_py_function <- function(fn, default_name = "r_func") {
464464
attr(fn, "name", TRUE) %||%
465465
default_name
466466

467-
# TODO: try to generate a pretty name using deparse(substitute(x)) would need
468-
# to update capture_args() to construct calls to transformers so that
469-
# substitute will work here.
470-
# if(is.null(name)) { name <- as_py_name(deparse1(substitute(x)))}
471467
py_func2(fn, convert = TRUE, name = name)
472468
}
473469

0 commit comments

Comments
 (0)