Skip to content

Commit

Permalink
Merge pull request #324 from andreranza/f-default-free-dataformat
Browse files Browse the repository at this point in the history
The default data format for X-13 is "free"
  • Loading branch information
christophsax authored Jun 14, 2024
2 parents 50763b3 + 07ae6c4 commit 7a2876c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
8 changes: 5 additions & 3 deletions R/import.spc.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ print.import.spc <- function(x, ...){

ext_ser_call <- function(spc, vname){
if (is.null(spc)) return(NULL)

# the default data format for X-13 is "free"
fformat <- ifelse(is.null(spc$format), "free", spc$format)
frm <- rem_quotes(fformat)

# analyze series spec
if ("data" %in% names(spc)){
Expand All @@ -190,9 +194,7 @@ ext_ser_call <- function(spc, vname){
", start = ", deparse(start), ", frequency = ", f, ")")

} else if ("file" %in% names(spc)){

frm <- rem_quotes(spc$format)


# fragment for name, for fortran and x11 series
if (!is.null(spc$name)) {
nm <- rem_quotes(spc$name)
Expand Down
14 changes: 14 additions & 0 deletions tests/testthat/_snaps/ext_ser_call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# ext_ser_call()

Code
ext_ser_call(pp, "x")
Output
[1] "x <- import.ts(file.dat)"

# ext_ser_call() defaults to format "free"

Code
ext_ser_call(pp, "x")
Output
[1] "x <- import.ts(file.dat, format = \"free\", start = c(2014, 1), frequency = 12, name = \"xyz\")"

32 changes: 32 additions & 0 deletions tests/testthat/test-ext_ser_call.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
test_that("ext_ser_call()", {

pp <- list(
title = "abc",
start = 2014.01,
period = 12,
save = c("a1", "b1"),
print = "brief",
format = "datevalue",
name = "xyz",
file = "file.dat"
)

expect_snapshot(ext_ser_call(pp, "x"))

})

test_that("ext_ser_call() defaults to format \"free\"", {

pp <- list(
title = "abc",
start = 2014.01,
period = 12,
save = c("a1", "b1"),
print = "brief",
name = "xyz",
file = "file.dat"
)

expect_snapshot(ext_ser_call(pp, "x"))

})

0 comments on commit 7a2876c

Please sign in to comment.