| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Agent-Logs-Url: https://github.com/sdpython/teachpyx/sessions/e6e8e7c7-c0a1-47b3-9763-5ebb04affcb9 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Agent-Logs-Url: https://github.com/sdpython/teachpyx/sessions/e6e8e7c7-c0a1-47b3-9763-5ebb04affcb9 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Agent-Logs-Url: https://github.com/sdpython/teachpyx/sessions/e6e8e7c7-c0a1-47b3-9763-5ebb04affcb9 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Agent-Logs-Url: https://github.com/sdpython/teachpyx/sessions/e6e8e7c7-c0a1-47b3-9763-5ebb04affcb9 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Agent-Logs-Url: https://github.com/sdpython/teachpyx/sessions/e6e8e7c7-c0a1-47b3-9763-5ebb04affcb9 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
| if len(colors) != 3: | ||
| raise ValueError(f"colors must contain 3 values, not {len(colors)}.") | ||
|
|
||
| try: |
There was a problem hiding this comment.
@copilot enleve moi ça (try catch)
Sorry, something went wrong.
There was a problem hiding this comment.
Fait dans le commit 90a5382 : le try/except autour de pandas.to_numeric a été supprimé dans plot_waterfall.
Sorry, something went wrong.
Agent-Logs-Url: https://github.com/sdpython/teachpyx/sessions/51a3850a-5547-4962-a7d6-829066c3c6ff Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
|
@copilot ajoute un vrai exemple dans la documentation |
Sorry, something went wrong.
Agent-Logs-Url: https://github.com/sdpython/teachpyx/sessions/242bb04a-1d52-4f54-a254-e242a90f9ed5 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Agent-Logs-Url: https://github.com/sdpython/teachpyx/sessions/242bb04a-1d52-4f54-a254-e242a90f9ed5 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
C’est fait dans c22383e : j’ai ajouté un vrai exemple rendu dans la doc (_doc/api/tools/pandas.rst) avec un bloc .. plot:: qui montre l’usage complet de plot_waterfall et le graphique produit. |
Sorry, something went wrong.
There was a problem hiding this comment.
Adds a new dataframe-based helper for producing waterfall charts in teachpyx.tools.pandas, along with documentation and unit tests to validate both computation and error handling.
Changes:
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| teachpyx/tools/pandas.py | Introduces plot_waterfall with input validation, geometry computation, and Matplotlib plotting. |
| _unittests/ut_tools/test_pandas.py | Adds tests for waterfall computation and validation branches. |
| _doc/api/tools/pandas.rst | Documents plot_waterfall via a Sphinx plot example and includes it in module API output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
| @@ -14,6 +16,39 @@ def test_read_csv_cached(self): | |||
| self.assertEqual(df.shape, df2.shape) | |||
| self.assertEqual(list(df.columns), list(df2.columns)) | |||
|
|
|||
| def test_plot_waterfall(self): | |||
| df = pandas.DataFrame( | |||
| { | |||
| "name": ["A", "B", "C"], | |||
| "delta": [10, -3, 5], | |||
| } | |||
| ) | |||
| ax, plot_df = plot_waterfall(df, "delta", "name", total_label="TOTAL") | |||
| self.assertIsInstance(ax, Axes) | |||
| self.assertEqual(list(plot_df["label"]), ["A", "B", "C", "TOTAL"]) | |||
| self.assertEqual(list(plot_df["start"]), [0.0, 10.0, 7.0, 0.0]) | |||
| self.assertEqual(list(plot_df["end"]), [10.0, 7.0, 12.0, 12.0]) | |||
There was a problem hiding this comment.
plot_waterfall creates a new Matplotlib figure when ax is None, and this unit test will exercise that path. In headless CI environments, importing/using matplotlib.pyplot can fail or pick an interactive backend unless a non-interactive backend (e.g., Agg) is forced by the test runner/environment. Consider explicitly forcing a non-interactive backend for this test suite (or in this test) and closing the created figure to avoid accumulating open figures across tests.
Sorry, something went wrong.
| :param colors: positive, negative, total colors | ||
| :return: axis, computed dataframe used to draw the chart | ||
|
|
||
| .. versionadded:: 0.6.1 |
There was a problem hiding this comment.
The docstring marks this helper as .. versionadded:: 0.6.1, but the project version in pyproject.toml is currently 0.6.0. Please align the versionadded tag with the release version that will actually contain this function (either bump the package version as part of this change, or adjust the tag) to avoid misleading API docs.
| .. versionadded:: 0.6.1 | |
| .. versionadded:: 0.6.0 |
Sorry, something went wrong.
…github.com/sdpython/teachpyx into copilot/implement-waterfall-graph-function
| Back | FazBrowse Home | New Git URL |
This issue asked for a function to generate a waterfall graph.
This PR adds a reusable plotting helper in teachpyx.tools with focused input validation and test coverage.
New plotting API (teachpyx.tools.pandas)
Input validation
Unit tests (_unittests/ut_tools/test_pandas.py)
Example usage: