Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 1, 2025

Change constructors to use explicit arguments

  • Identify all constructor functions that need to be updated
  • Update constructors in R/make.R
  • Update constructors in R/conversion.R
  • Update constructors in R/adjacency.R
  • Update constructors in R/games.R
  • Verify tests pass after changes
  • Update documentation
  • Run linters and formatters
  • Final test run
  • Apply code review feedback
  • Fix devtools::check() errors
  • Merge main branch
  • Use named arguments for all forwarding

Summary

Updated constructor functions to accept explicit arguments instead of just ..., matching their corresponding make_* and sample_* function signatures. This improves IDE autocomplete and makes the API clearer.

Latest changes

  1. Merged main branch - includes version bump to 2.2.1.9004 and modularity fix
  2. Added check_dots_empty() to sample_growing() - ensures consistency with the constructor
  3. All constructors now use named arguments for forwarding to constructor_spec():
    • Example: constructor_spec(make_wheel, n = n, mode = mode, center = center) instead of constructor_spec(make_wheel, n, mode = mode, center = center)
    • This makes the code more explicit and maintainable

Testing

✅ All tests pass: 7,418 passed, 2 skipped (unrelated), 0 failures
devtools::check() passes: 0 errors, 0 warnings, 0 notes

Original prompt

This section details on the original issue you should resolve

<issue_title>Change constructors to use explicit arguments</issue_title>
<issue_description>Example: wheel() should accept n, ..., mode and center and pass on these arguments, just like make_wheel() . Apply this to all constructors.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 1, 2025 19:23
Update constructor functions to accept explicit arguments instead of just `...`,
matching their corresponding `make_*` and `sample_*` function signatures.
This improves IDE autocomplete and makes the API clearer.

Exceptions:
- `directed_graph()` and `undirected_graph()` kept as `...` since they
  work with `make_()` where arguments can be passed in various orders
- `tree()` and `from_literal()` kept as `...` with .lazy = TRUE due to
  their special lazy evaluation behavior

Co-authored-by: krlmlr <[email protected]>
Copilot AI changed the title [WIP] Change constructors to use explicit arguments feat: change constructors to use explicit arguments Nov 1, 2025
Copilot AI requested a review from krlmlr November 1, 2025 19:31
Copilot finished work on behalf of krlmlr November 1, 2025 19:31
@krlmlr krlmlr requested a review from schochastics November 1, 2025 19:38
R/make.R Outdated
mode = c("in", "out", "mutual", "undirected"),
center = 1
) {
constructor_spec(make_wheel, n, ..., mode = mode, center = center)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
constructor_spec(make_wheel, n, ..., mode = mode, center = center)
check_dots_empty()
constructor_spec(make_wheel, n, mode = mode, center = center)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied in c246631. Added check_dots_empty() to wheel() and other constructors with ... parameter (growing, bipartite_gnm, bipartite_gnp).

@krlmlr
Copy link
Contributor

krlmlr commented Nov 1, 2025

@copilot: Apply feedback, fix errors seen with devtools::check() .

- Add check_dots_empty() to constructors with ... parameter (wheel, growing, bipartite_gnm, bipartite_gnp)
- Revert from_edgelist() and from_data_frame() to use ... for flexibility with graph_()
- Fix documentation warnings by adding @inheritParams rlang::args_dots_empty
- Remove @param ... from constructors that no longer have ... parameter
- Update sample_() example to remove pattern that no longer works

Co-authored-by: krlmlr <[email protected]>
Copy link
Contributor Author

Copilot AI commented Nov 1, 2025

@copilot: Apply feedback, fix errors seen with devtools::check() .

Fixed in c246631. All devtools::check() errors and warnings resolved:

  • Added check_dots_empty() to constructors with ...
  • Reverted from_edgelist() and from_data_frame() to use ... for graph_() compatibility
  • Fixed documentation warnings by adding @inheritParams rlang::args_dots_empty and removing incorrect @param ...
  • Updated sample_() example to remove incompatible pattern

Status: 0 errors ✔ | 0 warnings ✔ | 0 notes ✔

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cran.rstudio.com
    • Triggering command: /opt/R/4.5.2/lib/R/bin/exec/R --no-restore --no-echo --args nextArgigraph_2.2.1.9003.tar.gznextArg--as-crannextArg--timingsnextArg--no-manual (dns block)
  • packagemanager.posit.co
    • Triggering command: /opt/R/4.5.2/lib/R/bin/exec/R --no-restore --no-echo --args nextArgigraph_2.2.1.9003.tar.gznextArg--as-crannextArg--timingsnextArg--no-manual (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from krlmlr November 1, 2025 22:33
Copilot finished work on behalf of krlmlr November 1, 2025 22:33
Copy link
Contributor

@krlmlr krlmlr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot: Merge main, adhere to feedback. Always use named arguments for forwarding.

#' @export
growing <- function(...) constructor_spec(sample_growing, ...)
growing <- function(n, m = 1, ..., directed = TRUE, citation = FALSE) {
check_dots_empty()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the check to the sampler as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 269d1bb. Added check_dots_empty() to sample_growing().

Copilot AI and others added 2 commits November 2, 2025 10:42
- Merge main branch (includes version bump and modularity fix)
- Add check_dots_empty() to sample_growing() as requested
- Change all constructor_spec calls to use named arguments for consistency and clarity
- This ensures better code readability and makes argument forwarding explicit

All constructors now use named arguments when calling constructor_spec:
- R/make.R: star, full_graph, ring, atlas, chordal_ring, circulant, line_graph,
  de_bruijn_graph, kautz_graph, from_prufer, bipartite_graph, full_bipartite_graph,
  full_multipartite, turan, full_citation_graph
- R/games.R: gnp, gnm, growing, grg, smallworld, last_cit, cit_types, cit_cit_types,
  bipartite_gnm, bipartite_gnp, sbm, hierarchical_sbm, dot_product
- R/adjacency.R: from_adjacency

Co-authored-by: krlmlr <[email protected]>
Copy link
Contributor Author

Copilot AI commented Nov 2, 2025

@copilot: Merge main, adhere to feedback. Always use named arguments for forwarding.

Completed in 269d1bb:

  • Merged main branch (includes version bump and modularity fix)
  • Changed all constructor_spec calls to use named arguments
  • Added check_dots_empty() to sample_growing()

All 40+ constructors now explicitly name all forwarded arguments for clarity and maintainability.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cran.rstudio.com
    • Triggering command: /opt/R/4.5.2/lib/R/bin/exec/R --no-restore --no-echo --args nextArgigraph_2.2.1.9004.tar.gznextArg--as-crannextArg--timingsnextArg--no-manual (dns block)
  • packagemanager.posit.co
    • Triggering command: /opt/R/4.5.2/lib/R/bin/exec/R --no-restore --no-echo --args nextArgigraph_2.2.1.9004.tar.gznextArg--as-crannextArg--timingsnextArg--no-manual (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from krlmlr November 2, 2025 10:58
Copilot finished work on behalf of krlmlr November 2, 2025 10:58
@krlmlr krlmlr marked this pull request as ready for review November 2, 2025 14:48
@krlmlr krlmlr removed their assignment Nov 2, 2025
@krlmlr
Copy link
Contributor

krlmlr commented Nov 16, 2025

@schochastics: Good to merge?

@krlmlr
Copy link
Contributor

krlmlr commented Nov 16, 2025

Do we even need to export the constructors? In #2500, there is a collision with circulant() exported from elsewhere.

Copy link
Contributor

@schochastics schochastics left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@schochastics
Copy link
Contributor

Do we even need to export the constructors? In #2500, there is a collision with circulant() exported from elsewhere.

I assume we cannot simple remove them since they were available before? I might have to think more about it but I currently dont see where these could be more handy than the corresponding make functions?

@krlmlr krlmlr merged commit a4419cf into main Nov 17, 2025
6 checks passed
@krlmlr krlmlr deleted the copilot/change-constructors-to-use-explicit-arguments branch November 17, 2025 19:21
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

Successfully merging this pull request may close these issues.

Change constructors to use explicit arguments

3 participants