performance icon indicating copy to clipboard operation
performance copied to clipboard

test: add failing tests for check_model() theme argument bug (#851)

Open ANAMASGARD opened this issue 2 months ago • 8 comments

  • Tests document expected behavior of theme argument
  • Tests currently FAIL due to bugs in see package
  • Covers: standard themes, custom themes, string themes, attribute storage
  • Bug is in see/R/plot.check_model.R (hardcoded args issue)
Screenshot From 2025-10-24 19-52-00

Relates to #851

ANAMASGARD avatar Oct 24 '25 14:10 ANAMASGARD

Summary of Changes

Hello @ANAMASGARD, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request adds a comprehensive set of failing tests to pinpoint and document a critical bug in the check_model() function's theme argument. The tests cover various scenarios, including standard ggplot2 themes, string-based theme references, and custom theme functions, all of which currently fail due to issues within the see package's plotting mechanism. The primary goal is to provide clear, reproducible examples of the bug, facilitating its eventual fix.

Highlights

  • New Failing Tests: Introduced a new test file test-check_model_theme.R containing six test cases that currently fail, specifically designed to expose a bug in the check_model() function's theme argument within the see package.
  • Theme Argument Issues: The tests demonstrate problems with check_model()'s theme argument, including failures when applying standard ggplot2 themes (due to 'unused arguments' errors), issues with themes passed as strings, and an inability to access custom user-defined theme functions.
  • Attribute Storage and Override: The new tests also verify that the theme attribute is correctly stored and retrieved by check_model(), and that the style argument in the plot() method can successfully override the theme set during the initial check_model() call.
  • Bug Location Identified: The pull request explicitly points out that the underlying bug is located in the see package's R/plot.check_model.R file, specifically around lines 64-67, related to hardcoded arguments.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

[^1]: Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

gemini-code-assist[bot] avatar Oct 24 '25 14:10 gemini-code-assist[bot]

Current Status

This PR adds comprehensive failing tests that document the expected behavior of the theme argument in check_model(). These tests are intentionally failing as part of a Test-Driven Development (TDD) approach.

Root Cause Location

The actual bug is not in the performance package - it's in the see package's plotting mechanism:

Bug Location: easystats/seeR/plot.check_model.R (approximately lines 64-67)

Problem: The plot.see_check_model() method tries to call theme functions with hardcoded arguments like plot.title.space and axis.title.space that don't exist in standard ggplot2 themes, causing "unused arguments" errors.

What This PR Provides

✅ Comprehensive test coverage documenting three bug scenarios:

  1. Standard ggplot2 themes (theme_dark, theme_minimal, theme_bw)
  2. Themes passed as strings (backward compatibility)
  3. Custom user-defined theme functions

✅ Tests validate:

  • Theme attribute storage and retrieval
  • Default theme behavior
  • Style argument override functionality

Related Links

  • Original Issue: #851
  • See Package: https://github.com/easystats/see
  • Target File: https://github.com/easystats/see/blob/main/R/plot.check_model.R

ANAMASGARD avatar Oct 24 '25 14:10 ANAMASGARD

@ANAMASGARD Thanks a lot for this support! I'm currently busy with teaching, but I'll get back to this early November. Just to inform you and to let you know your PRs are recognized :-)

strengejacke avatar Oct 29 '25 10:10 strengejacke

@strengejacke Thank you so much sir , please review it and give your feedback and let me know if any further changes I should make .

ANAMASGARD avatar Oct 31 '25 09:10 ANAMASGARD

@strengejacke Also Sir can you recommend me some blogs or resources so that i can understand easystats better , so that I can contribute better . Thank You !

ANAMASGARD avatar Oct 31 '25 09:10 ANAMASGARD

@strengejacke Also Sir can you recommend me some blogs or resources so that i can understand easystats better , so that I can contribute better . Thank You !

I'm not sure we have that many resources. We wrote down some code-conventions, see https://easystats.github.io/easystats/articles/conventions.html

@easystats/core-team any other ideas?

strengejacke avatar Nov 13 '25 07:11 strengejacke

All packages have a small "Contributing" page that is basically the same everywhere but not very detailed, e.g. https://easystats.github.io/datawizard/CONTRIBUTING.html. We use S3 generics and methods in all packages so if you're not familiar with it, I would recommend reading this chapter of Advanced R: https://adv-r.hadley.nz/s3.html

Apart from that, I don't know other resources to contribute better to easystats. We don't have a file that explains the structure of each package.


About this PR in particular, apparently the root cause is in see so I would focus on fixing the issue there and once it's done then add a couple of tests in performance (and add a link to the related PR in see). Note that you don't need so many comments to explain the issue. Usually, the test_that() descriptions and potentially a couple of comments are enough, e.g.

test_that("ggplot2 theme is correctly applied, #851", {
  ...
})

etiennebacher avatar Nov 13 '25 07:11 etiennebacher

@ANAMASGARD Can you tell me why tests fail? Do they require a certain minimum version of the see package?

strengejacke avatar Nov 26 '25 19:11 strengejacke