Bug: uninformative error when hypotheses weights lose its names
A pull request for this has already been merged.
- #111 by @xidongdxi — merged
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 70/100
Research direction
Reproduce with the issue's snippet, then trace where graph_calculate_power -> test_input_val -> graph_generate_weights consumes hypotheses names (the failing line indexes with hyp_names). Look for the input-validation entry points in R/ that back these functions. Done means an unnamed graph$hypotheses either survives or fails with a message naming the missing names, covered by a new test under tests/testthat/.
Written by the indexing model from the issue text.
Description
What happened?
Assigning directly to graph$hypotheses (a natural way to tweak weights on an existing graph) drops the hypothesis names, because the replacement vector is unnamed. Every downstream function that relies on those names then fails with an error that gives the user no hint about the real cause:
Error in matrix_weights[i + 1, ] <- hypotheses[-del_index][hyp_names] :
replacement has length zero
Calls: graph_calculate_power -> test_input_val -> graph_generate_weights
Session Information
No response
Reproducible Example
library(graphicalMCP)
graph <- graph_create(
hypotheses = c(0.5, 0.5),
transitions = matrix(c(0, 1, 1, 0), nrow = 2)
)
# Changing the weights this way drops the names
graph$hypotheses <- c(0.6, 0.4)
names(graph$hypotheses)
#> NULL
graph_calculate_power(graph, alpha = 0.025, power_marginal = c(0.8, 0.7))
#> Error in matrix_weights[i + 1, ] <- hypotheses[-del_index][hyp_names] :
#> replacement has length zero
# Restoring the names fixes it
names(graph$hypotheses) <- c("H1", "H2")
graph_calculate_power(graph, alpha = 0.025, power_marginal = c(0.8, 0.7)) # works
- Dominant language
- R
- Stars
- 23
- Forks
- 1
- Avg merge
- 1h 42m
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openpharma/graphicalMCP
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
openpharma/graphicalMCP#114 ·
-
Ellipse layout OPTION for plot.May be free again @keaven claimed this 139 days ago, and no pull request is open. Openenhancement
openpharma/graphicalMCP#96 · 1 assignee ·
-
Add a function to customize deletion order for shortcut testingMay be free again @EeethB claimed this 1176 days ago, and no pull request is open. Openenhancement
openpharma/graphicalMCP#58 · 1 assignee ·
-
`plot.initial_graph` breaks when `pairs` curvature is implicit and a paired edge curve is adjustedOpen
Difficulty 3/5 1-2 days Newbie friendliness 48/100
openpharma/graphicalMCP#57 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
openpharma/graphicalMCP#56 ·
All issues in openpharma/graphicalMCP
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Huber-group-EMBL/Rarr#294 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
BGI-shenzhen/PopLDdecay#25 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Public-Environmental-Data-Partners/EJAM#699 ·
Maintainers usually reply within 1 day