From 91254625d05a057dc4eeca8e730c17bc5581b8b6 Mon Sep 17 00:00:00 2001 From: Kyle Scully Date: Wed, 29 Nov 2023 21:17:54 -0800 Subject: [PATCH] chore: formatting and polish --- .../composite_recipe_results_sankey.ipynb | 2 +- .../dependency_usage_violin.ipynb | 79 +++++++++++-------- .../specs/dependency_usage_violin.yml | 2 +- 3 files changed, 46 insertions(+), 37 deletions(-) diff --git a/moderne_visualizations_misc/composite_recipe_results_sankey.ipynb b/moderne_visualizations_misc/composite_recipe_results_sankey.ipynb index 4989975..75598e7 100644 --- a/moderne_visualizations_misc/composite_recipe_results_sankey.ipynb +++ b/moderne_visualizations_misc/composite_recipe_results_sankey.ipynb @@ -123,7 +123,7 @@ "fig.update_layout(\n", " title_text=\"Recipes that made changes\",\n", " font_size=10,\n", - " height=max(len(all_nodes)*15, 400),\n", + " height=max(len(all_nodes) * 15, 400),\n", ")\n", "\n", "fig.show()" diff --git a/moderne_visualizations_misc/dependency_usage_violin.ipynb b/moderne_visualizations_misc/dependency_usage_violin.ipynb index 8d406b0..3f27500 100644 --- a/moderne_visualizations_misc/dependency_usage_violin.ipynb +++ b/moderne_visualizations_misc/dependency_usage_violin.ipynb @@ -17,7 +17,7 @@ "metadata": {}, "outputs": [], "source": [ - "df = df[['artifactId', 'version', 'depth']]" + "df = df[[\"artifactId\", \"version\", \"depth\"]]" ] }, { @@ -27,16 +27,20 @@ "outputs": [], "source": [ "from code_data_science.versions import index as index_versions\n", + "\n", "vmap = index_versions(df.version)\n", - "df['nVersion'] = list(map(lambda v: vmap[v], df.version))\n", + "df[\"nVersion\"] = list(map(lambda v: vmap[v], df.version))\n", + "\n", "\n", "def index_ga(groupartifacts):\n", " sorted_ga = sorted(list(set(groupartifacts)))\n", - " return { ga : sorted_ga.index(ga) for ga in sorted_ga }\n", + " return {ga: sorted_ga.index(ga) for ga in sorted_ga}\n", + "\n", + "\n", "gmap = index_ga(df.artifactId)\n", - "df['nArtifactId'] = list(map(lambda g: gmap[g], df.artifactId))\n", + "df[\"nArtifactId\"] = list(map(lambda g: gmap[g], df.artifactId))\n", "\n", - "df = df.sort_values(by=['nVersion', 'nArtifactId'])" + "df = df.sort_values(by=[\"nVersion\", \"nArtifactId\"])" ] }, { @@ -47,56 +51,61 @@ "source": [ "import plotly.graph_objects as go\n", "import code_data_science.palette as palette\n", + "\n", "colors = palette.colors_by_weight(500)\n", "\n", "fig = go.Figure()\n", "\n", "# Add a trace to the plot for each category\n", - "for i, category in enumerate(df['nArtifactId'].unique()):\n", - " category_data = df[df['nArtifactId'] == category]\n", + "for i, category in enumerate(df[\"nArtifactId\"].unique()):\n", + " category_data = df[df[\"nArtifactId\"] == category]\n", "\n", - " fig.add_trace(go.Scatter(\n", - " x=category_data['nArtifactId'],\n", - " y=category_data['nVersion'],\n", - " mode='markers',\n", - " marker=dict(color=colors[i % len(colors)], size=8),\n", - " showlegend=False,\n", - " name=\"\"\n", - " ))\n", - " \n", - " fig.add_trace(go.Violin(\n", - " x=category_data['nArtifactId'],\n", - " y=category_data['nVersion'],\n", - " fillcolor='black',\n", - " opacity=0.15,\n", - " line_color='black',\n", - " showlegend=False,\n", - " width=.7,\n", - " bandwidth=1.2\n", - " ))\n", + " fig.add_trace(\n", + " go.Scatter(\n", + " x=category_data[\"nArtifactId\"],\n", + " y=category_data[\"nVersion\"],\n", + " mode=\"markers\",\n", + " marker=dict(color=colors[i % len(colors)], size=8),\n", + " showlegend=False,\n", + " name=\"\",\n", + " )\n", + " )\n", + "\n", + " fig.add_trace(\n", + " go.Violin(\n", + " x=category_data[\"nArtifactId\"],\n", + " y=category_data[\"nVersion\"],\n", + " fillcolor=\"black\",\n", + " opacity=0.15,\n", + " line_color=\"black\",\n", + " showlegend=False,\n", + " width=0.7,\n", + " bandwidth=1.2,\n", + " )\n", + " )\n", "\n", - "num_versions = df['nVersion'].nunique()\n", + "num_versions = df[\"nVersion\"].nunique()\n", "height_per_version = 25\n", "fig_height = num_versions * height_per_version\n", - "tick_font_size=8\n", + "tick_font_size = 8\n", "# Customizing the layout\n", "fig.update_layout(\n", - " title='Artifact Versions in Use',\n", - " xaxis_title='Artifacts',\n", - " yaxis_title='Versions',\n", + " title=\"Artifact Versions in Use\",\n", + " xaxis_title=\"Artifacts\",\n", + " yaxis_title=\"Versions\",\n", " height=fig_height,\n", " xaxis=dict(\n", " tickfont=dict(size=tick_font_size),\n", - " tickmode='array',\n", + " tickmode=\"array\",\n", " tickvals=list(gmap.values()),\n", - " ticktext=list(gmap.keys())\n", + " ticktext=list(gmap.keys()),\n", " ),\n", " yaxis=dict(\n", " tickfont=dict(size=tick_font_size),\n", - " tickmode='array',\n", + " tickmode=\"array\",\n", " tickvals=list(vmap.values()),\n", " ticktext=list(vmap.keys()),\n", - " )\n", + " ),\n", ")\n", "\n", "fig.show()" diff --git a/moderne_visualizations_misc/specs/dependency_usage_violin.yml b/moderne_visualizations_misc/specs/dependency_usage_violin.yml index e86eb87..5c30ae4 100644 --- a/moderne_visualizations_misc/specs/dependency_usage_violin.yml +++ b/moderne_visualizations_misc/specs/dependency_usage_violin.yml @@ -3,6 +3,6 @@ type: specs.moderne.io/v1beta/visualization name: io.moderne.DependencyUsageViolin displayName: Dependency usage description: > - This notebook shows the distribution of dependencies by version. + See the distribution of dependencies by version. recipe: org.openrewrite.maven.search.DependencyInsight dataTable: org.openrewrite.maven.table.DependenciesInUse