Skip to content

Conversation

krystophny
Copy link
Collaborator

@krystophny krystophny commented Oct 1, 2025

User description

Summary

  • use machine epsilon when detecting zero in tick formatting utilities
  • allow log tick labels to emit mathtext for arbitrarily small magnitudes

Testing

  • make test

PR Type

Bug fix


Description

  • Replace hardcoded epsilon with machine epsilon in tick formatting

  • Fix zero detection for logarithmic tick labels

  • Improve numerical precision for small magnitude values


Diagram Walkthrough

flowchart LR
  A["Hardcoded epsilon (1.0e-10)"] --> B["Machine epsilon function"]
  B --> C["Improved zero detection"]
  C --> D["Better log tick formatting"]
Loading

File Walkthrough

Relevant files
Bug fix
fortplot_tick_formatting.f90
Replace hardcoded epsilon with machine epsilon                     

src/utilities/ticks/fortplot_tick_formatting.f90

  • Replace hardcoded 1.0e-10_wp with epsilon(1.0_wp) in three functions
  • Update zero detection logic from < to <= comparison
  • Affects format_tick_value, format_tick_value_smart, and
    format_log_tick_value
+3/-3     

Copy link

qodo-merge-pro bot commented Oct 1, 2025

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

Copy link

qodo-merge-pro bot commented Oct 1, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Use a more appropriate zero-check tolerance

Revert the zero-check tolerance from epsilon(1.0_wp) to a more practical value
like the original 1.0e-10_wp. Using machine epsilon as an absolute tolerance is
inappropriate and can result in incorrect formatting for values that are
effectively zero.

src/utilities/ticks/fortplot_tick_formatting.f90 [29]

-if (abs_value <= epsilon(1.0_wp)) then
+if (abs_value < 1.0e-10_wp) then
  • Apply / Chat
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a significant logical flaw in using epsilon as an absolute tolerance for zero, which could lead to incorrect plot tick formatting and is a functional regression.

High
  • Update

@krystophny krystophny force-pushed the fix/log-tick-epsilon branch from bfd0e91 to 7ab8c8f Compare October 1, 2025 15:11
@krystophny krystophny merged commit 7fb493d into main Oct 1, 2025
2 checks passed
@krystophny krystophny deleted the fix/log-tick-epsilon branch October 1, 2025 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant