Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewrite fixations_to_timepoints (fka binifyFixations) using join_by #44

Open
2 tasks
kalenkovich opened this issue May 7, 2024 · 2 comments
Open
2 tasks
Assignees

Comments

@kalenkovich
Copy link
Contributor

kalenkovich commented May 7, 2024

Note: fixations_to_timepoints isn't yet implemented at all.

t_series <- fixations %>%
  summarise(t_min = min(current_fix_start),
            t_max = max(current_fix_end)) %>%
  mutate(across(c(t_min, t_max),
                ~ floor(. / bin_size) * bin_size)) %>%
  mutate(t = list(seq(t_min, t_max, by = bin_size))) %>%
  select(t) %>%
  unnest(cols = t)

t_series %>%
  inner_join(
    fixations %>%
      mutate(across(c(current_fix_start, current_fix_end),
                    ~ floor(. / bin_size) * bin_size)),
    by = join_by(between(t, current_fix_start, current_fix_end))
  )

Update June 7 2024

The main part (speeding up by switching to a join) was done in a632aa0.

  • Check the stuff from the comment below
  • see a632aa0's message for how the function can be further sped up.
@kalenkovich kalenkovich self-assigned this May 7, 2024
@kalenkovich
Copy link
Contributor Author

Informal testing on ht_seedlings (possibly the largest dataset we have) and the join version takes less than 1 second while the orignal takes around a minute.

@kalenkovich
Copy link
Contributor Author

Not about the optimization but just to have this checklist somewhere:

  • enforce x, y, t_start, t_end, all numeric in the input,
  • output x, y, and t, nothing else (mainly, no timeBin).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant