Skip to content

test: add comprehensive test suite for main interface functions - #7

Closed
thorwhalen wants to merge 4 commits into
masterfrom
claude/improve-repository-comprehensive-011CV2gNPpkRH5X9crvt9Um3
Closed

thorwhalen wants to merge 4 commits into
masterfrom
claude/improve-repository-comprehensive-011CV2gNPpkRH5X9crvt9Um3

Conversation

@thorwhalen

Copy link
Copy Markdown
Member

This commit adds 74 tests covering the main interface functions exported
by oplot.init.py:

  • test_matrix.py: Tests for heatmap, xy_boxplot, vlines_ranges, vlines_of_matrix
  • test_plot_data_set.py: Tests for density_distribution, scatter_and_color_according_to_y, side_by_side_bar
  • test_plot_stats.py: Tests for plot_confusion_matrix, make_tables_tn_fp_fn_tp, make_normal_outlier_timeline, render_mpl_table
  • test_distributions.py: Tests for kdeplot_w_boundary_condition
  • test_multiplots.py: Tests for ax_func_to_plot
  • test_outlier_scores.py: Tests for plot_scores_and_zones and related functions
  • test_plot_mappings.py: Tests for dict_bar_plot

All tests pass successfully (74/74). This provides a safety net for future
changes and validates current functionality.

This commit adds 74 tests covering the main interface functions exported
by oplot.__init__.py:

- test_matrix.py: Tests for heatmap, xy_boxplot, vlines_ranges, vlines_of_matrix
- test_plot_data_set.py: Tests for density_distribution, scatter_and_color_according_to_y, side_by_side_bar
- test_plot_stats.py: Tests for plot_confusion_matrix, make_tables_tn_fp_fn_tp, make_normal_outlier_timeline, render_mpl_table
- test_distributions.py: Tests for kdeplot_w_boundary_condition
- test_multiplots.py: Tests for ax_func_to_plot
- test_outlier_scores.py: Tests for plot_scores_and_zones and related functions
- test_plot_mappings.py: Tests for dict_bar_plot

All tests pass successfully (74/74). This provides a safety net for future
changes and validates current functionality.
…o_y (#1)

Fixed AttributeError: 'AxesSubplot' object has no attribute 'colorbar'
that occurred when plotting with continuous y values (floats).

The issue was on lines 298 and 324 where ax.colorbar() was incorrectly
called. Axes objects don't have a colorbar() method in matplotlib.

Changed to:
- Capture the scatter plot object in variable 'sc'
- Call fig.colorbar(sc, ax=ax) instead of ax.colorbar()

This fix applies to both 1D and 2D projection modes when using
continuous color mapping.

Fixes #1
Fixed issue where make_normal_outlier_timeline didn't respect the order
of class labels when y_order parameter was None.

Previously, the function used np.unique(y) which returns sorted unique
values, discarding the original order of appearance in the data.

Changed line 399 from:
    y_order = np.unique(y)

To:
    y_order = list(dict.fromkeys(y))

This preserves insertion order (order of first appearance) using
dict.fromkeys(), which maintains insertion order as of Python 3.7+.

For example, if y = ['C', 'A', 'B', 'C', 'A', 'B'], the order will now
be ['C', 'A', 'B'] instead of the alphabetically sorted ['A', 'B', 'C'].

Fixes #6
Added comprehensive analysis document covering:
- Main functionality overview (20+ exported functions)
- Test coverage assessment (was 0%, now has 74 tests)
- Documentation quality evaluation (excellent README)
- Detailed analysis of all 4 open issues:
  * #1: Fixed - colorbar AttributeError
  * #3: Enhancement request - needs user clarification
  * #5: Bug report - needs reproduction steps
  * #6: Fixed - class ordering not preserved
- Resolution strategy and commit plan
- Testing approach and priorities
- Recommendations for future work

This document provides a complete record of the comprehensive repository
improvement effort and serves as reference for maintainers.
@thorwhalen

Copy link
Copy Markdown
Member Author

Closing: fully superseded, and merging as-is would now be a regression.

This branch's substantive content (the test suite, the colorbar AttributeError fix, the insertion-order fix, ISSUE_ANALYSIS.md) was already cherry-picked into master back on 2025-11-21 (commit ccb7324, "Incorporate changes from claude/improve-repository-comprehensive-011CV2gNPpkRH5X9crvt9Um3"). Master has since moved further ahead independently of this branch:

  • Typing was modernized (PEP 604/585: X | Y, tuple[int, int], collections.abc imports) — this branch still has the older Union/Tuple/typing.Iterable style.
  • scatter_and_color_according_to_y was just fixed in Use plt.get_cmap instead of removed-in-3.11 plt.cm.get_cmap #9 to use plt.get_cmap instead of the matplotlib-3.11-removed plt.cm.get_cmap — this branch still has the deprecated call, and is missing the regression test (test_scatter_with_float_y_emits_no_deprecation_warning) that Use plt.get_cmap instead of removed-in-3.11 plt.cm.get_cmap #9 added to guard it.
  • render_mpl_table now iterates mpl_table._cells.items() directly instead of six.iteritems(...).

Diffing this branch against current master (git diff origin/master pr7-branch) confirms the remaining diff is entirely this backward drift, spread across oplot/matrix.py, oplot/plot_data_set.py, oplot/plot_stats.py, oplot/sequences.py, oplot/util.py, and .github/workflows/ci.yml (a generate-documentation step master already dropped, see 142d248). Nothing left to land.

Co-Authored-By: Claude Opus 5 noreply@anthropic.com

@thorwhalen thorwhalen closed this Sep 22, 2026
@thorwhalen
thorwhalen deleted the claude/improve-repository-comprehensive-011CV2gNPpkRH5X9crvt9Um3 branch September 22, 2026 13:03
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