Repository navigation
Conversation
Plotly 7.0.0 removed create_annotated_heatmap and create_distplot, so five tests raised AttributeError on any environment that resolved Plotly 7. Port the three heatmaps to go.Heatmap with native text/texttemplate, which renders the same array in the same orientation, and compute the two KDE curves with scipy.stats.gaussian_kde directly — the same 500-point estimate create_distplot made internally, so the curves are unchanged to floating point. TargetPredictionDistributionPlot was building two whole distplot figures only to read their x/y off them, so it loses more code than it gains. RegressionResidualsPlot gains the guarded scipy import the other statistical tests already use; it depended on scipy through create_distplot but let a bare ImportError escape. Keep the dependency at plotly (>=6.0.0) with no upper bound. The ported code runs on both majors, and texttemplate has been available on go.Heatmap since Plotly 5.5, so a cap would constrain users without protecting them. Add unit tests for ConfusionMatrix, RegressionResidualsPlot and TargetPredictionDistributionPlot, none of which had any — the reason only one of the five broken tests was identified from the report. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The Python 3.14 dependency leg resolves numpy>=2.3, where np.trapz no longer exists — it was renamed to np.trapezoid. Resolve the name once through getattr, which short-circuits on NumPy 2 before touching the missing attribute and still finds trapz on NumPy 1. GiniCoefficient is library code and had no test at all, so nothing caught that it raises AttributeError for anyone on Python 3.14. Add one, along with the same fallback in the residuals test added earlier on this branch. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
juanmleng
marked this pull request as draft
September 1, 2026 21:12
juanmleng
marked this pull request as ready for review
September 1, 2026 21:14
cachafla
approved these changes
Sep 1, 2026
juanmleng
deleted the
juanmleng/sc-18206/replace-removed-plotly-figure-factory-calls
branch
September 1, 2026 22:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Description
What and why?
Plotly 7.0.0 (released 2026-08-25) removed
create_annotated_heatmapandcreate_distplot. We allowplotly (>=6.0.0)with no upper bound, so any environment built since then gets Plotly 7 and five tests fail withAttributeError:ConfusionMatrix,RegressionResidualsPlot,TimeSeriesMissingValues,LaggedCorrelationHeatmapandTargetPredictionDistributionPlot. Older environments are unaffected, which is why this appeared with no change on our side.The three heatmaps now use
go.Heatmapwithtext/texttemplate. The two KDE plots callscipy.stats.gaussian_kdedirectly — the same thingcreate_distplotdid internally, so the curves are identical to floating point. The plots look the same as before.No version cap is added. The code runs on Plotly 6 and 7, and
texttemplatehas existed since Plotly 5.5, so a cap would restrict users without protecting them.Two smaller things came along:
RegressionResidualsPlotnow raisesMissingDependencyErrorfor scipy like the other statistical tests instead of a bareImportError, andGiniCoefficientusednp.trapz, which NumPy 2 removed — that broke it on Python 3.14, where we resolvenumpy>=2.3.How to test
The bug is invisible on Plotly 6, so run the suite on both:
Four new test files cover
ConfusionMatrix,RegressionResidualsPlot,TargetPredictionDistributionPlotandGiniCoefficient— none had any test, which is why only one of the five failures was spotted originally. Every figure was also rendered to PNG before and after and compared.What needs special review?
The confusion matrix orientation.
create_annotated_heatmapandpx.imshowdisagree about which corner is the origin, so porting viapx.imshowwould silently transpose the matrix — TN and TP swapped, no error. This usesgo.Heatmap, which keepszas given, and the new tests assert each quadrant's label.Also: the choice not to cap Plotly, and whether the NumPy fix belongs here — it is a different upstream and could be split out. It is included because it is one line and the same kind of failure.
Dependencies, breaking changes, and deployment notes
No dependency changes, no breaking changes. Until this ships, affected users can run
pip install "plotly<7"and restart their kernel.Release notes
Fixed five tests that failed with an
AttributeErroron Plotly 7.0.0 and later, which removed the helpers they used to draw heatmaps and distribution curves:ConfusionMatrix,RegressionResidualsPlot,TimeSeriesMissingValues,LaggedCorrelationHeatmapandTargetPredictionDistributionPlot. The plots are unchanged and now work on both Plotly 6 and 7, so no version pin is needed. Also fixedGiniCoefficient, which failed on Python 3.14 because of a renamed NumPy function.Checklist