Conversation
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
…ions Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
| int need_unprotect = 0; | ||
| if (TYPEOF(x_slot) == INTSXP) { | ||
| /* Convert integers to reals */ | ||
| x_slot = PROTECT(Rf_coerceVector(x_slot, REALSXP)); |
There was a problem hiding this comment.
Write code for integers and reals, avoid coercion. Throw a clean error if not integer or real.
There was a problem hiding this comment.
Addressed in aa65ef4. Both Rz_SEXP_to_sparsemat and Rz_SEXP_to_vector_int_copy now handle integer and real types with separate code paths, avoiding coercion. Clean error messages are provided for invalid types.
However, tests still fail due to a separate Stimulus code generation issue: the autogenerated code for INOUT SPARSEMAT parameters has a mismatched IGRAPH_FINALLY_CLEAN(1) without a corresponding IGRAPH_FINALLY registration, causing "corrupt finally stack" errors. This needs to be fixed in the Stimulus code generator.
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
The test failures are caused by a Stimulus code generation bug for INOUT SPARSEMAT parameters. The autogenerated code in The conversion functions have been fixed to properly handle integer and real types without coercion (commit aa65ef4), but the test failures require fixing the Stimulus template that generates code for INOUT SPARSEMAT parameters. |
krlmlr
left a comment
There was a problem hiding this comment.
@copilot: Also fix tests:
── Error ('test-aaa-auto.R:11145:3'): sparse_adjacency_impl basic ──────────────
Error: Error in `sparse_adjacency_impl(adjmatrix = M)`: At vendor/cigraph/src/core/error.c:335 : Corrupt finally stack: trying to pop 1 element(s) when only 0 left. This is an unexpected igraph error; please report this as a bug, along with the steps to reproduce it.
Please restart your R session to avoid crashes or other surprising behavior.
Backtrace:
▆
1. └─igraph:::sparse_adjacency_impl(adjmatrix = M)
── Error ('test-aaa-auto.R:11192:3'): sparse_weighted_adjacency_impl basic ─────
Error: Error in `sparse_weighted_adjacency_impl(adjmatrix = M)`: At vendor/cigraph/src/core/error.c:335 : Corrupt finally stack: trying to pop 1 element(s) when only 0 left. This is an unexpected igraph error; please report this as a bug, along with the steps to reproduce it.
Please restart your R session to avoid crashes or other surprising behavior.
Backtrace:
▆
1. └─igraph:::sparse_weighted_adjacency_impl(adjmatrix = M)
── Failure ('test-aaa-auto.R:11262:3'): weighted_sparsemat_impl errors ─────────
Expected `weighted_sparsemat_impl(...)` to throw a error.
[ FAIL 3 | WARN 0 | SKIP 4 | PASS 7519 ]
| @@ -0,0 +1,21 @@ | |||
| # Extracted from test-aaa-auto.R:11145 | |||
There was a problem hiding this comment.
Purge these files, they are now ignored.
There was a problem hiding this comment.
Removed in 0cd85d9. The _problems files have been purged from the repository.
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
…non-callback-functions
Description
Enables autogeneration for
igraph_sparse_adjacency,igraph_sparse_weighted_adjacency, andigraph_weighted_sparsematby implementing the missing R-to-C SPARSEMAT type converter with proper type handling and memory management.Changes
Implemented
Rz_SEXP_to_sparsemat()insrc/rinterface_extra.cdgCMatrixtoigraph_sparsemat_tUpdated
Rz_SEXP_to_vector_int_copy()insrc/rinterface_extra.cINTSXPandREALSXPtypes without coercionFixed SPARSEMAT type handling in
tools/stimulus/types-RC.yamlIGRAPH_FINALLYregistration for IN SPARSEMAT parametersigraph_sparsemat_destroyin OUTCONVEnabled autogeneration for three sparse matrix functions
IGNORE: RR, RCflags fromtools/stimulus/functions-R.yamlR/aaa-auto.Randsrc/rinterface.cFixed pre-existing bug in
igraph_read_graph_ncolandigraph_read_graph_lglOUT GRAPH graphparameter to PARAMS overridesUpdated tests in
tests/testthat/test-aaa-auto.R_problemstest files (now in .gitignore)Example
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.