Skip to content

Implement r2_exact function for R package#56

Merged
MLopez-Ibanez merged 6 commits intomainfrom
copilot/implement-r2-exact-function
Feb 8, 2026
Merged

Implement r2_exact function for R package#56
MLopez-Ibanez merged 6 commits intomainfrom
copilot/implement-r2-exact-function

Conversation

Copy link
Contributor

Copilot AI commented Feb 8, 2026

  • Add r2_exact.c to MOOCORE_SRC_FILES in r/src/Makevars so it gets compiled
  • Add C wrapper function r2_exact_C in r/src/Rmoocore.c that bridges R to the C r2_exact() function
  • Register the C wrapper in r/src/init.h
  • Create r/R/r2.R with the r2_exact() R function, roxygen2 docs, and doctest examples
  • Create r/man/r2_exact.Rd manual page
  • Update r/NAMESPACE to export r2_exact
  • Create r/tests/testthat/test_r2.R with tests converted from Python
  • Create r/tests/testthat/test-doctest-r2_exact.R with doctest examples
  • Use example1_dat instead of ALG_1_dat.xz in doctest examples, with explanatory comments from Python docstring
  • Add detailed R2 indicator documentation translated from Python RST to roxygen2 @details
  • Pass R CMD check (all tests pass, examples run correctly)
Original prompt

Analyse commit e13933d and implement the r2_exact function for the R package under the r/ folder. The function should be implemented in a new file r/R/r2.R Add documentation using roxygen2 taking the text from the Python implementation in the commit. Similar to python, the new R r2_exact function must call the C r2_exact function. For the implementation of an R function that calls a C function. you should study how the hypervolume() function is implemented in R and follow a similar pattern. Also add r/tests/testthat/test_r2.R with tests from the commit converted from Python to R. Doctests from the Python r2_exact() function should be converted into examples in R using the doctest R package. For en example about using doctest in R, see the R function epsilon_additive(). The implementation should pass R CMD check and R CMD check --as-cran. All changes should be contained within the r/ folder of the repository.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits February 8, 2026 08:33
- Add r2_exact.c to Makevars compilation
- Add C wrapper r2_exact_C in Rmoocore.c
- Register r2_exact_C in init.h
- Create r/R/r2.R with roxygen2 documentation and doctest examples
- Create r/man/r2_exact.Rd manual page
- Update NAMESPACE to export r2_exact
- Add r/tests/testthat/test_r2.R with tests from Python
- Add r/tests/testthat/test-doctest-r2_exact.R with doctest examples

Co-authored-by: MLopez-Ibanez <2620021+MLopez-Ibanez@users.noreply.github.com>
Co-authored-by: MLopez-Ibanez <2620021+MLopez-Ibanez@users.noreply.github.com>
Co-authored-by: MLopez-Ibanez <2620021+MLopez-Ibanez@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement r2_exact function for R package Implement r2_exact function for R package Feb 8, 2026
Copilot AI requested a review from MLopez-Ibanez February 8, 2026 08:35
@codecov
Copy link

codecov bot commented Feb 8, 2026

Codecov Report

❌ Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.15%. Comparing base (e13933d) to head (aadf696).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #56      +/-   ##
==========================================
+ Coverage   78.06%   78.15%   +0.08%     
==========================================
  Files          63       64       +1     
  Lines        5949     5973      +24     
  Branches      913      913              
==========================================
+ Hits         4644     4668      +24     
- Misses       1102     1105       +3     
+ Partials      203      200       -3     
Flag Coverage Δ
R 70.04% <87.50%> (+0.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
tests 100.00% <ø> (ø)
src 87.56% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MLopez-Ibanez
Copy link
Contributor

@copilot Use example1_dat instead of ALG_1 for the R doctest to implement the python doctest that uses input1.dat, and do not omit it. To keep the explanatory text within the Python examples you can use comments in R.

@MLopez-Ibanez
Copy link
Contributor

@copilot Also, translate the documentation about "(Exact) R2 Indicator" found in https://github.com/multi-objective/moocore/blob/main/python/doc/source/reference/functions.metrics.rst to roxygen2 and include it in the details section of the documentation of the r2_exact function in R.

Replace ALG_1_dat.xz with example1_dat (R equivalent of Python's
input1.dat) and remove @omit so all examples are tested. Add
explanatory comments matching the Python docstring text.

Co-authored-by: MLopez-Ibanez <2620021+MLopez-Ibanez@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 8, 2026

@copilot Use example1_dat instead of ALG_1 for the R doctest to implement the python doctest that uses input1.dat, and do not omit it. To keep the explanatory text within the Python examples you can u...

Done in 31f32bd. Replaced ALG_1_dat.xz with example1_dat, removed @omit so all examples are now tested via doctest, and added explanatory comments matching the Python docstring text (minimisation default, merge sets, dominated points ignored).

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:

  • cloud.r-project.org
    • Triggering command: /usr/lib/R/bin/exec/R /usr/lib/R/bin/exec/R --no-restore --no-echo --args nextArg--no-manualnextArgmoocore_0.2.0.900.tar.gz elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z -o lude cmdline.o ndor/bin/bash eaf.o eaf_main.o eaf3d.o ntrib.o (dns block)

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

Translate the (Exact) R2 Indicator documentation from
python/doc/source/reference/functions.metrics.rst to roxygen2 format
in the @details section, including mathematical definition, properties,
and citations (HanJas1998, SchKer2025r2v2).

Co-authored-by: MLopez-Ibanez <2620021+MLopez-Ibanez@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 8, 2026

@copilot Also, translate the documentation about "(Exact) R2 Indicator" found in https://github.com/multi-objective/moocore/blob/main/python/doc/source/reference/functions.metrics.rst to roxygen2 and...

Done in aadf696. Added the full R2 indicator documentation from the Python RST to the @details section, including the mathematical definition of R2, the weight distribution, optimality properties (strongly Pareto-compliant), scale-dependency note, and citations to HanJas1998 and SchKer2025r2v2.

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:

  • cloud.r-project.org
    • Triggering command: /usr/lib/R/bin/exec/R /usr/lib/R/bin/exec/R --no-restore --no-echo --args nextArg--no-manualnextArgmoocore_0.2.0.900.tar.gz elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z --in�� lude liblapack.so.3-x86_64-linux-gnu ndor/bin/bash 10 .10.27-1_amd64.d-f eb .o (dns block)

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

@MLopez-Ibanez MLopez-Ibanez marked this pull request as ready for review February 8, 2026 10:53
@MLopez-Ibanez MLopez-Ibanez merged commit 9b72f1b into main Feb 8, 2026
16 checks passed
@MLopez-Ibanez MLopez-Ibanez deleted the copilot/implement-r2-exact-function branch February 8, 2026 10:54
MLopez-Ibanez added a commit that referenced this pull request Feb 8, 2026
Co-authored-by: MLopez-Ibanez <2620021+MLopez-Ibanez@users.noreply.github.com>
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.

2 participants