Skip to content

Commit bd1f04e

Browse files
committed
fix base data extraction
1 parent 6f05e4c commit bd1f04e

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

R/sits_classify.R

+14-6
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,14 @@ sits_classify.raster_cube <- function(data,
253253
.check_filter_fn(filter_fn)
254254
# Retrieve the samples from the model
255255
samples <- .ml_samples(ml_model)
256-
# Retrieve bands from the model
257-
base_bands <- intersect(
258-
.ml_bands(ml_model), .cube_bands(.cube_base_info(data))
259-
)
256+
# By default, base bands is null.
257+
base_bands <- NULL
258+
if (.cube_is_base(data)) {
259+
# Get base bands
260+
base_bands <- intersect(
261+
.ml_bands(ml_model), .cube_bands(.cube_base_info(data))
262+
)
263+
}
260264
# get non-base bands
261265
bands <- setdiff(.ml_bands(ml_model), base_bands)
262266
# Do the samples and tile match their timeline length?
@@ -270,8 +274,12 @@ sits_classify.raster_cube <- function(data,
270274
job_size = .block_size(block = block, overlap = 0),
271275
npaths = (
272276
length(.tile_paths(data, bands)) +
273-
length(.tile_paths(.cube_base_info(data), base_bands)) +
274-
length(.ml_labels(ml_model))
277+
length(.ml_labels(ml_model)) +
278+
ifelse(
279+
test = .cube_is_base(data),
280+
yes = length(.tile_paths(.cube_base_info(data), base_bands)),
281+
no = 0
282+
)
275283
),
276284
nbytes = 8,
277285
proc_bloat = proc_bloat

0 commit comments

Comments
 (0)