Skip to content

Commit

Permalink
format files
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilHvitfeldt committed Dec 21, 2024
1 parent 70cd797 commit 07b4328
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions R/json.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ orbital_json_write <- function(x, path) {
actions <- as.list(unclass(x))

res <- list(
actions = actions,
actions = actions,
pred_names = attr(x, "pred_names"),
version = 2
)
Expand Down Expand Up @@ -93,14 +93,13 @@ orbital_json_read <- function(path) {
json <- jsonlite::read_json(path)

version <- json$version

if (version == 1) {
res <- unlist(json$actions)
attr(res, "pred_names") <- utils::tail(names(res), 1)
} else if (version == 2) {
res <- unlist(json$actions)
attr(res, "pred_names") <- json$pred_names

}

new_orbital_class(res)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-json.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test_that("read and write json works - backwards from version 1", {
orbital_obj <- orbital(wf_fit)

tmp_file <- tempfile()

orbital_json_write(orbital_obj, tmp_file)

# Fake version 1
Expand Down

0 comments on commit 07b4328

Please sign in to comment.