-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest-gadget_likelihood_component.R
616 lines (563 loc) · 22.7 KB
/
test-gadget_likelihood_component.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
library(mfdb)
library(unittest, quietly = TRUE)
helpers <- c('utils/helpers.R', 'tests/utils/helpers.R') ; source(helpers[file.exists(helpers)])
all_components <- c(
"penalty",
"understocking",
"catchdistribution",
"catchstatistics",
"stockdistribution",
"surveydistribution",
"stomachcontent",
"migrationpenalty",
"catchinkilos",
NULL)
ok_group("Can generate gadget_likelihood_component objects", {
expect_error(
gadget_likelihood_component("aardvark"),
"aardvark")
expect_error(
gadget_likelihood_component("e12 ; bobby tables"),
"e12 ; bobby tables")
expect_equal(
class(gadget_likelihood_component("penalty")),
c("gadget_penalty_component", "gadget_likelihood_component"))
})
ok_group("Can use as.character on gadget_likelihood_components", {
comp <- gadget_likelihood_component("penalty", name = "wibble", weight = 0.5)
expect_equal(comp$name, "wibble")
expect_equal(comp$weight, 0.5)
expect_equal(comp$type, "penalty")
})
ok_group("Can nest data.frame in a list", {
df <- data.frame(year = 1, step = 1, area = 1, fleet = 1, total_weight = 1)
comp <- gadget_likelihood_component("catchinkilos", data = df)
ok(cmp(comp$datafile$data, df), "Data included with regular data.frame")
comp <- gadget_likelihood_component("catchinkilos", data = list(df))
ok(cmp(comp$datafile$data, df), "Data included with nested data.frame")
ok(cmp_error(
gadget_likelihood_component("catchinkilos", data = list(df, df)),
"list"), "More than one item causes an error")
})
for (type in all_components) {
if (type == "catchstatistics") {
default_opts <- list(type,
data = data.frame(), data_function = "customfunction")
} else if (type == "catchdistribution") {
default_opts <- list(type,
data = data.frame(year = 1, step = 1, area = 1, age = 1, length = 1, number = 1))
} else if (type == "stockdistribution") {
default_opts <- list(type,
data = data.frame(year = 1, step = 1, area = 1, aardvark = 1, age = 1, length = 1, number = 1))
} else if (type == "surveydistribution") {
default_opts <- list(type,
data = data.frame(year = 1, step = 1, area = 1, age = 1, length = 1, number = 1))
} else if (type == "stomachcontent") {
default_opts <- list(type,
data = data.frame(year = 1, step = 1, area = 1, predator_length = 'pred100', prey_length = 'prey10', ratio = 1),
predator_length = list('pred100' = 'pred100'),
prey_length = list('prey10' = 'prey10'),
prey_labels = list('prey10' = 'Prey 10'))
} else if (type == "catchinkilos") {
default_opts <- list(type,
data = data.frame(year = 1, step = 1, area = 1, fleet = 1, total_weight = 1))
} else {
default_opts <- list(type)
}
ok_group(paste("Name, type and weight for component", type), {
comp <- do.call(gadget_likelihood_component, default_opts)
# Class should match type
ok(cmp(class(comp), c(
paste0("gadget_", type, "_component"),
"gadget_likelihood_component")), "Has correct class")
# Type and name should match the name we gave
ok(cmp(comp$type, type), "Type set")
ok(cmp(comp$name, type), "Default name same as type")
ok(cmp(comp$weight, 0), "Weight defaults to 0")
# Can customise name & weight
comp <- do.call(gadget_likelihood_component, c(
default_opts,
list(name = "gerald", weight = 0.542),
NULL))
ok(cmp(comp$name, "gerald"), "Can set name")
ok(cmp(comp$weight, 0.542), "Can set weight")
})
ok_group(paste("Filenames for component", type), {
contains <- function(pattern, x) {
if(length(grep(pattern, x, value = FALSE)) > 0) {
TRUE
} else {
paste0(x, " does not contain ", pattern)
}
}
comp <- do.call(gadget_likelihood_component, c(
default_opts,
list(name = "gerald", weight = 0.542),
NULL))
for (key in names(comp)) {
if ("gadget_file" %in% class(comp[[key]]) && comp$type != "penalty") {
ok(contains(
paste0("^Data/", comp$type, "\\.", comp$name, "\\."),
comp$datafile$filename), "Filename starts with name and type")
}
}
})
}
ok_group("Can write likelihood components", {
# Create a temporary directory, starts off empty
dir <- tempfile()
gd <- gadget_directory(dir)
expect_equal(list.files(dir), character(0))
# Create some components
gadget_dir_write(gd, gadget_likelihood_component("understocking", name="head-bone", weight = 0.3))
expect_equal(list.files(dir), c("likelihood", "main"))
expect_equal(
gadget_dir_read(gd, "likelihood")$components,
list(
list(),
component = structure(list(name = "head-bone", weight = 0.3, type = "understocking"), preamble = list(""))))
ok(cmp_file(gd, "main",
ver_string,
"timefile\t",
"areafile\t",
"printfiles\t; Required comment",
"[stock]",
"[tagging]",
"[otherfood]",
"[fleet]",
"[likelihood]",
"likelihoodfiles\tlikelihood"))
gadget_dir_write(gd, gadget_likelihood_component("penalty", name="neck-bone", weight = 0.5))
ok(cmp(
list.files(dir, recursive = TRUE),
c("Data/neck-bone.penaltyfile", "likelihood", "main")), "Created penaltyfile")
expect_equal(
gadget_dir_read(gd, "likelihood")$components,
list(
list(),
component = structure(list(name = "head-bone", weight = 0.3, type = "understocking"), preamble = list("")),
component = structure(list(name = "neck-bone", weight = 0.5, type = "penalty", datafile = "Data/neck-bone.penaltyfile"), preamble = list(""))))
ok(cmp_file(gd, "main",
ver_string,
"timefile\t",
"areafile\t",
"printfiles\t; Required comment",
"[stock]",
"[tagging]",
"[otherfood]",
"[fleet]",
"[likelihood]",
"likelihoodfiles\tlikelihood"))
# Override one, add another
gadget_dir_write(gd, gadget_likelihood_component("understocking", name="head-bone", weight = 0.8))
gadget_dir_write(gd, gadget_likelihood_component("understocking", name="shoulder-bone", weight = 0.2))
expect_equal(
gadget_dir_read(gd, "likelihood")$components,
list(
list(),
component = structure(list(name = "head-bone", weight = 0.8, type = "understocking"), preamble = list("")),
component = structure(list(name = "neck-bone", weight = 0.5, type = "penalty", datafile = "Data/neck-bone.penaltyfile"), preamble = list("")),
component = structure(list(name = "shoulder-bone", weight = 0.2, type = "understocking"), preamble = list(""))))
ok(cmp_file(gd, "main",
ver_string,
"timefile\t",
"areafile\t",
"printfiles\t; Required comment",
"[stock]",
"[tagging]",
"[otherfood]",
"[fleet]",
"[likelihood]",
"likelihoodfiles\tlikelihood"))
# Add one to a new likelihood file
gadget_dir_write(gd, gadget_likelihood_component("understocking", likelihoodfile="dahood", name="bad-to-the-bone", weight = 0.8))
ok(cmp_file(gd, "main",
ver_string,
"timefile\t",
"areafile\t",
"printfiles\t; Required comment",
"[stock]",
"[tagging]",
"[otherfood]",
"[fleet]",
"[likelihood]",
"likelihoodfiles\tlikelihood\tdahood"))
ok(cmp_file(gd, "dahood",
ver_string,
"; ",
"[component]",
"name\tbad-to-the-bone",
"weight\t0.8",
"type\tunderstocking",
NULL))
})
###############################################################################
ok_group("Can generate an understocking component with default parameters", {
comp <- gadget_likelihood_component("understocking")
expect_equal(comp$name, "understocking")
expect_equal(comp$weight, 0)
expect_equal(comp$type, "understocking")
})
ok_group("Can customise it", {
comp <- gadget_likelihood_component("understocking", name = "alfred", weight = 0.3)
expect_equal(comp$name, "alfred")
expect_equal(comp$weight, 0.3)
expect_equal(comp$type, "understocking")
})
###############################################################################
ok_group("Function either provided explicitly or based on generator", {
expect_error(
gadget_likelihood_component("catchstatistics"),
"No data provided")
expect_error(
gadget_likelihood_component("catchstatistics", data = data.frame()),
"Cannot work out the required function, and data_function not provided")
expect_error(
gadget_likelihood_component("catchstatistics", data = structure(data.frame(), generator = "camel")),
"Unknown generator function camel")
expect_equal(
gadget_likelihood_component("catchstatistics",
data = data.frame(), data_function = "customfunction")[['function']],
"customfunction")
ok(cmp(
gadget_likelihood_component("catchstatistics", data = structure(
data.frame(year = 1990, step = 1, area = 1, age = 1, number = 1, mean = 1, stddev = 1),
generator = "mfdb_sample_meanlength_stddev"))[['function']],
"lengthgivenstddev"), "Guessed function given generator")
ok(cmp_error(
gadget_likelihood_component("catchstatistics", data = structure(
data.frame(),
generator = "mfdb_sample_meanlength_stddev")),
"data given to gadget_catchstatistics_component is empty"), "Noticed missing data")
ok(cmp_error(
gadget_likelihood_component("catchstatistics", data = structure(
data.frame(year = 1990, step = 1, area = 1, age = 1, number = 1, mean = 1),
generator = "mfdb_sample_meanlength_stddev")),
"stddev"), "Noticed missing column")
})
###############################################################################
ok_group("Aggregation files", {
cmp_agg <- function (agg_type, agg, ...) {
gd <- gadget_directory(tempfile())
agg_summ <- agg_summary(fake_mdb(), agg, 'c.col', 'col', data.frame(col = 1:5), 0)
gadget_dir_write(gd, gadget_likelihood_component(
"catchdistribution",
name="cd",
weight = 0.8,
data = structure(
data.frame(year = 1, step = 1, area = 1, age = 1, length = 1, number = 1),
area = if (agg_type == 'area') agg_summ else NULL,
age = if (agg_type == 'age') agg_summ else NULL,
length = if (agg_type == 'len') agg_summ else NULL,
generator = "mfdb_sample_meanlength")
))
do.call(cmp_file, c(
list(gd, paste0("Aggfiles/catchdistribution.cd.", agg_type, ".agg")),
list(...)))
}
ok(cmp_agg('area', list(divA = c('x', 't'), divB = c('s', 'r')),
ver_string,
"divA\t1",
"divB\t2",
NULL), "Area aggregation file has subdivisions hidden")
ok(cmp_agg('age', list(young = 1:4, old = 5:8),
ver_string,
"young\t1\t2\t3\t4",
"old\t5\t6\t7\t8",
NULL), "Age aggregation matches input")
ok(cmp_agg('age', 1:4,
ver_string,
"1\t1",
"2\t2",
"3\t3",
"4\t4",
NULL), "1:4 converted into 1 group for each")
ok(cmp_agg('age', mfdb_unaggregated(),
ver_string,
"1\t1",
"2\t2",
"3\t3",
"4\t4",
"5\t5",
NULL), "mfdb_unaggregated")
ok(cmp_agg('len', mfdb_interval("len", seq(0, 50, by = 10)),
ver_string,
"len0\t0\t10",
"len10\t10\t20",
"len20\t20\t30",
"len30\t30\t40",
"len40\t40\t50",
NULL), "mfdb_interval (with len, so min/max)")
ok(cmp_agg('len', mfdb_step_interval("len", to = 30, by = 5),
ver_string,
"len0\t0\t5",
"len5\t5\t10",
"len10\t10\t15",
"len15\t15\t20",
"len20\t20\t25",
"len25\t25\t30",
NULL), "mfdb_step_interval (with len, so min/max)")
ok(cmp_agg('age', mfdb_interval("age", seq(0, 20, by = 10)),
ver_string,
"age0\t0\t1\t2\t3\t4\t5\t6\t7\t8\t9",
"age10\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19",
NULL), "mfdb_interval (with age, so discrete numbers)")
ok(cmp_agg('age', mfdb_step_interval("age", to = 30, by = 5),
ver_string,
"age0\t0\t1\t2\t3\t4",
"age5\t5\t6\t7\t8\t9",
"age10\t10\t11\t12\t13\t14",
"age15\t15\t16\t17\t18\t19",
"age20\t20\t21\t22\t23\t24",
"age25\t25\t26\t27\t28\t29",
NULL), "mfdb_step_interval (with age, so discrete numbers)")
ok(cmp_agg('age', mfdb_step_interval("age", to = 5, by = 1),
ver_string,
"age0\t0",
"age1\t1",
"age2\t2",
"age3\t3",
"age4\t4",
NULL), "mfdb_step_interval (with age, so discrete numbers)")
})
###############################################################################
ok_group("surveyindices", {
cmp_component <- function (comp, ...) {
gd <- gadget_directory(tempfile())
gadget_dir_write(gd, comp)
cmp_file(gd, "likelihood", ...)
}
component <- gadget_likelihood_component('surveyindices', name = 'si', sitype = 'lengths', fittype = 'linearfit',
data = structure(
data.frame(year = 1998, step = 1:2, area = 101, length = c(100,200), number = c(2,4)),
area = list(all = 101),
length = list(len100 = c(100,500))))
ok(cmp(class(component)[[1]], 'gadget_surveyindices_component'), "Made lengths sitype")
ok(cmp_component(component,
ver_string,
"; ",
"[component]",
"name\tsi",
"weight\t0",
"type\tsurveyindices",
"datafile\tData/surveyindices.si.lengths",
"sitype\tlengths",
"biomass\t0",
"areaaggfile\tAggfiles/surveyindices.si.area.agg",
"lenaggfile\tAggfiles/surveyindices.si.len.agg",
"fittype\tlinearfit",
NULL), "Wrote component with lengths sitype")
component <- gadget_likelihood_component('surveyindices', name = 'si', sitype = 'ages', fittype = 'linearfit',
data = structure(
data.frame(year = 1998, step = 1:2, area = 101, age = c(100,200), number = c(2,4)),
area = list(all = 101),
age = list(age100 = c(100,500))))
ok(cmp(class(component)[[1]], 'gadget_surveyindices_component'), "Made ages sitype")
ok(cmp_component(component,
ver_string,
"; ",
"[component]",
"name\tsi",
"weight\t0",
"type\tsurveyindices",
"datafile\tData/surveyindices.si.ages",
"sitype\tages",
"biomass\t0",
"areaaggfile\tAggfiles/surveyindices.si.area.agg",
"ageaggfile\tAggfiles/surveyindices.si.age.agg",
"fittype\tlinearfit",
NULL), "Wrote component with ages sitype")
component <- gadget_likelihood_component('surveyindices', name = 'si', sitype = 'fleets', fittype = 'linearfit',
data = structure(
data.frame(year = 1998, step = 1:2, area = 101, length = c(100,200), number = c(2,4)),
area = list(all = 101),
length = list(len100 = c(100,500))),
fleetnames = c("cuthbert", "dibble"))
ok(cmp(class(component)[[1]], 'gadget_surveyindices_component'), "Made fleets sitype")
ok(cmp_component(component,
ver_string,
"; ",
"[component]",
"name\tsi",
"weight\t0",
"type\tsurveyindices",
"datafile\tData/surveyindices.si.fleets",
"sitype\tfleets",
"biomass\t0",
"areaaggfile\tAggfiles/surveyindices.si.area.agg",
"lenaggfile\tAggfiles/surveyindices.si.len.agg",
"fleetnames\tcuthbert\tdibble",
"fittype\tlinearfit",
NULL), "Wrote component with fleets sitype")
component <- gadget_likelihood_component('surveyindices', name = 'si', sitype = 'acoustic', fittype = 'linearfit',
data = structure(
data.frame(year = 1998, step = 1:2, area = 101, survey = c(100,200), acoustic = c(2,4)),
area = list(all = 101)),
surveynames = c("cuthbert", "dibble"))
ok(cmp(class(component)[[1]], 'gadget_surveyindices_component'), "Made acoustic sitype")
ok(cmp_component(component,
ver_string,
"; ",
"[component]",
"name\tsi",
"weight\t0",
"type\tsurveyindices",
"datafile\tData/surveyindices.si.acoustic",
"sitype\tacoustic",
"biomass\t0",
"areaaggfile\tAggfiles/surveyindices.si.area.agg",
"surveynames\tcuthbert\tdibble",
"fittype\tlinearfit",
NULL), "Wrote component with acoustic sitype")
component <- gadget_likelihood_component('surveyindices', name = 'si', sitype = 'effort', fittype = 'linearfit',
data = structure(
data.frame(year = 1998, step = 1:2, area = 101, fleet = c(100,200), effort = c(2,4)),
area = list(all = 101)),
fleetnames = c("cuthbert", "dibble"))
ok(cmp(class(component)[[1]], 'gadget_surveyindices_component'), "Made effort sitype")
ok(cmp_component(component,
ver_string,
"; ",
"[component]",
"name\tsi",
"weight\t0",
"type\tsurveyindices",
"datafile\tData/surveyindices.si.effort",
"sitype\teffort",
"biomass\t0",
"areaaggfile\tAggfiles/surveyindices.si.area.agg",
"fleetnames\tcuthbert\tdibble",
"fittype\tlinearfit",
NULL), "Wrote component with effort sitype")
})
###############################################################################
ok_group("surveydistribution", {
component <- gadget_likelihood_component('surveydistribution', name = 'sd',
data = structure(
data.frame(year = 1998, step = 1:2, area = 101, age = c(1,2), length = c(3,4), number = c(100,200)),
area = list(all = 101),
age = list(all = 1:20),
length = list(all = 1:10)),
stocknames = c('frank', 'barbara'),
fittype = 'linearfit',
parameters = c(2, 4),
suitability = "function woo",
epsilon = 10,
likelihoodtype = 'multinomial')
ok(cmp(class(component)[[1]], 'gadget_surveydistribution_component'), "Made effort sitype")
ok(cmp_component(component,
ver_string,
"; ",
"[component]",
"name\tsd",
"weight\t0",
"type\tsurveydistribution",
"datafile\tData/surveydistribution.sd.",
"areaaggfile\tAggfiles/surveydistribution.sd.area.agg",
"lenaggfile\tAggfiles/surveydistribution.sd.len.agg",
"ageaggfile\tAggfiles/surveydistribution.sd.age.agg",
"stocknames\tfrank\tbarbara",
"fittype\tlinearfit",
"parameters\t2\t4",
"function woo",
"epsilon\t10",
"likelihoodtype\tmultinomial",
NULL), "Wrote component with effort sitype")
})
###############################################################################
ok_group("stomachcontent - matching of prey to labels", {
# Create a temporary directory, starts off empty
dir <- tempfile()
gd <- gadget_directory(dir)
expect_equal(list.files(dir), character(0))
sample_data <- data.frame(year = 1, step = 1, area = 1:3, predator_length = 'pred100',
prey_length = c('cod', 'anacoda', 'cod.imm'),
ratio = 1)
# Default to get assigned eveywhere
gadget_dir_write(gd, gadget_likelihood_component(
'stomachcontent',
data = sample_data,
prey_length = list(cod = 10:20, anacoda = 1:5, "cod.imm" = 1:10),
prey_labels = 'Prey 10'))
ok(cmp_file(gd, gadget_dir_read(gd, "likelihood")$components[[2]]$preyaggfile,
ver_string,
"; ",
"cod\t",
"Prey 10\t",
"lengths\t10\t20",
"digestioncoefficients\t",
"; ",
"anacoda\t",
"Prey 10\t",
"lengths\t1\t5",
"digestioncoefficients\t",
"; ",
"cod.imm\t",
"Prey 10\t",
"lengths\t1\t10",
"digestioncoefficients\t",
NULL))
# The first match in the list wins, we match from the start
gadget_dir_write(gd, gadget_likelihood_component(
'stomachcontent',
data = sample_data,
prey_length = list(cod = 10:20, anacoda = 1:5, "cod.imm" = 1:10),
prey_labels = list("cod" = "all.cod", "cod.imm" = "immature.cod", "other"),
prey_digestion_coefficients = list("cod.imm" = c(1,1,1), "cod" = c(3,3,3), c(9,9,9))))
ok(cmp_file(gd, gadget_dir_read(gd, "likelihood")$components[[2]]$preyaggfile,
ver_string,
"; ",
"cod\t",
"all.cod\t",
"lengths\t10\t20",
"digestioncoefficients\t3\t3\t3",
"; ",
"anacoda\t",
"other\t",
"lengths\t1\t5",
"digestioncoefficients\t9\t9\t9",
"; ",
"cod.imm\t",
"all.cod\t",
"lengths\t1\t10",
"digestioncoefficients\t1\t1\t1",
NULL))
gadget_dir_write(gd, gadget_likelihood_component(
'stomachcontent',
data = sample_data,
prey_length = list(cod = 10:20, anacoda = 1:5, "cod.imm" = 1:10),
prey_labels = list("cod.imm" = "immature.cod", "cod" = "all.cod", "other"),
prey_digestion_coefficients = list("cod" = c(3,3,3), "cod.imm" = c(1,1,1), c(9,9,9))))
ok(cmp_file(gd, gadget_dir_read(gd, "likelihood")$components[[2]]$preyaggfile,
ver_string,
"; ",
"cod\t",
"all.cod\t",
"lengths\t10\t20",
"digestioncoefficients\t3\t3\t3",
"; ",
"anacoda\t",
"other\t",
"lengths\t1\t5",
"digestioncoefficients\t9\t9\t9",
"; ",
"cod.imm\t",
"immature.cod\t",
"lengths\t1\t10",
"digestioncoefficients\t3\t3\t3",
NULL))
})
###############################################################################
ok_group("catchinkilos", {
# aggregationlevel = 0
comp <- gadget_likelihood_component(
'catchinkilos',
data = data.frame(year = 1, step = 1:3, area = 1, fleet = 1, total_weight = 11:13))
ok(cmp(names(comp$datafile$data), c("year", "step", "area", "fleet", "total_weight")), "Has step column")
# aggregationlevel = 1
comp <- gadget_likelihood_component(
'catchinkilos',
data = structure(data.frame(year = 1, step = 1, area = 1, fleet = 1, total_weight = 11:13),
step = mfdb_timestep_yearly))
ok(cmp(names(comp$datafile$data), c("year", "area", "fleet", "total_weight")), "step column removed")
})