Skip to content

Migrate internal dat$run$nw references to use get_network()/set_network() accessors #977

@smjenness

Description

@smjenness

Summary

EpiModel provides get_network() and set_network() S3 methods for netsim_dat objects (defined in R/get.R), which correctly abstract over the tergmLite vs. full-mode network storage. However, 31 occurrences across 9 internal R files still access dat$run$nw directly, bypassing these accessors.

Motivation

  • Consistency: Extension module authors read internal code to learn patterns. Direct dat$run$nw access teaches the wrong pattern and may break if the internal structure changes.
  • Abstraction: The accessors handle tergmLite/full-mode differences internally. Direct access requires each call site to handle this distinction, which is error-prone.
  • Maintainability: If the internal storage structure changes, only the accessor implementations need updating rather than 31 call sites.

Scope

Files with direct dat$run$nw access (31 occurrences total):

File Count
R/net.mod.init.R 7
R/saveout.R 4
R/update.R 4
R/net.fn.utils.R 3
R/net.mod.nwupdate.R 2
R/edgelists.R 1

Also 6 occurrences in inst/JSS/ and tests/testthat/ (lower priority).

Similarly, dat$run$el is accessed directly in several files and could benefit from the same treatment, though get_edgelist() already exists for read access.

Notes

  • The vignettes have already been updated to use get_network()/set_network() exclusively (PR Updates to Package Vignettes #976).
  • Some internal call sites (e.g., net.mod.init.R initializing dat$run$nw <- nws) may need a dedicated initialization path rather than set_network(), since the object may not be fully constructed yet. These should be evaluated case by case.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions