Skip to content

Instantly share code, notes, and snippets.

@shoyer
Created August 28, 2019 16:20
Show Gist options
  • Save shoyer/7936a93843354299368145e8266c5d83 to your computer and use it in GitHub Desktop.
Save shoyer/7936a93843354299368145e8266c5d83 to your computer and use it in GitHub Desktop.
NumPY duck array ecosystem graph
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "NumPY duck array ecosystem graph",
"version": "0.3.2",
"provenance": [],
"collapsed_sections": [],
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/shoyer/7936a93843354299368145e8266c5d83/numpy-duck-array-ecosystem-graph.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"metadata": {
"id": "hoaizhyf8W3w",
"colab_type": "code",
"outputId": "47833502-aeb6-4b21-d91f-398cc49e00c4",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 560
}
},
"source": [
"from graphviz import Digraph\n",
"\n",
"# libraries that only interact with NumPy are not listed, e.g.,\n",
"# TensorFlow, PyTorch, scipy.sparse\n",
"g = Digraph(node_attr={'fontname': 'courier'})\n",
"g.edge('dask', 'numpy')\n",
"g.edge('dask', 'cupy')\n",
"g.edge('dask', 'sparse')\n",
"g.edge('dask', 'numpy.ma')\n",
"g.edge('dask', 'pandas')\n",
"g.edge('cupy', 'numpy')\n",
"g.edge('sparse', 'numpy')\n",
"g.edge('numpy.ma', 'numpy')\n",
"g.edge('pandas', 'numpy')\n",
"g.edge('pandas', 'numpy.ma')\n",
"g.edge('jax', 'numpy')\n",
"g.edge('pint', 'dask')\n",
"g.edge('pint', 'pandas')\n",
"g.edge('pint', 'numpy')\n",
"g.edge('xarray', 'dask')\n",
"g.edge('xarray', 'cupy')\n",
"g.edge('xarray', 'sparse')\n",
"g.edge('xarray', 'numpy')\n",
"g.edge('xarray', 'pandas')\n",
"g.edge('xarray', 'numpy.ma')\n",
"g.edge('xarray', 'pint')\n",
"g.edge('xarray', 'jax')\n",
"g\n"
],
"execution_count": 0,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"<graphviz.dot.Digraph at 0x7f962a7f2160>"
],
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<!-- Generated by graphviz version 2.40.1 (20161225.0304)\n -->\n<!-- Title: %3 Pages: 1 -->\n<svg width=\"515pt\" height=\"404pt\"\n viewBox=\"0.00 0.00 515.50 404.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 400)\">\n<title>%3</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"-4,4 -4,-400 511.4971,-400 511.4971,4 -4,4\"/>\n<!-- dask -->\n<g id=\"node1\" class=\"node\">\n<title>dask</title>\n<ellipse fill=\"none\" stroke=\"#000000\" cx=\"212.4971\" cy=\"-234\" rx=\"32.4942\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"212.4971\" y=\"-230.3\" font-family=\"Courier,monospace\" font-size=\"14.00\" fill=\"#000000\">dask</text>\n</g>\n<!-- numpy -->\n<g id=\"node2\" class=\"node\">\n<title>numpy</title>\n<ellipse fill=\"none\" stroke=\"#000000\" cx=\"319.4971\" cy=\"-18\" rx=\"37.8943\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"319.4971\" y=\"-14.3\" font-family=\"Courier,monospace\" font-size=\"14.00\" fill=\"#000000\">numpy</text>\n</g>\n<!-- dask&#45;&gt;numpy -->\n<g id=\"edge1\" class=\"edge\">\n<title>dask&#45;&gt;numpy</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M207.3112,-216.055C199.2553,-184.3018 187.3988,-117.2992 215.4971,-72 228.8086,-50.5396 253.6629,-37.1947 275.7364,-29.1408\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"276.9554,-32.4233 285.3067,-25.9037 274.7125,-25.7924 276.9554,-32.4233\"/>\n</g>\n<!-- cupy -->\n<g id=\"node3\" class=\"node\">\n<title>cupy</title>\n<ellipse fill=\"none\" stroke=\"#000000\" cx=\"32.4971\" cy=\"-162\" rx=\"32.4942\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"32.4971\" y=\"-158.3\" font-family=\"Courier,monospace\" font-size=\"14.00\" fill=\"#000000\">cupy</text>\n</g>\n<!-- dask&#45;&gt;cupy -->\n<g id=\"edge2\" class=\"edge\">\n<title>dask&#45;&gt;cupy</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M185.4531,-223.8892C157.3421,-213.2872 112.1345,-195.9778 73.4971,-180 71.4542,-179.1552 69.3593,-178.276 67.249,-177.3804\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"68.5824,-174.1439 58.0133,-173.4052 65.8149,-180.5736 68.5824,-174.1439\"/>\n</g>\n<!-- sparse -->\n<g id=\"node4\" class=\"node\">\n<title>sparse</title>\n<ellipse fill=\"none\" stroke=\"#000000\" cx=\"125.4971\" cy=\"-162\" rx=\"42.7926\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"125.4971\" y=\"-158.3\" font-family=\"Courier,monospace\" font-size=\"14.00\" fill=\"#000000\">sparse</text>\n</g>\n<!-- dask&#45;&gt;sparse -->\n<g id=\"edge3\" class=\"edge\">\n<title>dask&#45;&gt;sparse</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M194.0467,-218.7307C182.1505,-208.8856 166.4628,-195.9027 153.0973,-184.8415\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"155.0656,-181.9273 145.1301,-178.248 150.6026,-187.3201 155.0656,-181.9273\"/>\n</g>\n<!-- numpy.ma -->\n<g id=\"node5\" class=\"node\">\n<title>numpy.ma</title>\n<ellipse fill=\"none\" stroke=\"#000000\" cx=\"278.4971\" cy=\"-90\" rx=\"53.8905\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"278.4971\" y=\"-86.3\" font-family=\"Courier,monospace\" font-size=\"14.00\" fill=\"#000000\">numpy.ma</text>\n</g>\n<!-- dask&#45;&gt;numpy.ma -->\n<g id=\"edge4\" class=\"edge\">\n<title>dask&#45;&gt;numpy.ma</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M220.59,-216.3428C231.9707,-191.5122 252.8002,-146.066 266.1296,-116.9836\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"269.3532,-118.3506 270.338,-107.8017 262.9897,-115.434 269.3532,-118.3506\"/>\n</g>\n<!-- pandas -->\n<g id=\"node6\" class=\"node\">\n<title>pandas</title>\n<ellipse fill=\"none\" stroke=\"#000000\" cx=\"343.4971\" cy=\"-162\" rx=\"42.7926\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"343.4971\" y=\"-158.3\" font-family=\"Courier,monospace\" font-size=\"14.00\" fill=\"#000000\">pandas</text>\n</g>\n<!-- dask&#45;&gt;pandas -->\n<g id=\"edge5\" class=\"edge\">\n<title>dask&#45;&gt;pandas</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M235.6157,-221.2936C255.8472,-210.174 285.5325,-193.8584 308.6449,-181.1554\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"310.3863,-184.1922 317.464,-176.3083 307.0146,-178.0577 310.3863,-184.1922\"/>\n</g>\n<!-- cupy&#45;&gt;numpy -->\n<g id=\"edge6\" class=\"edge\">\n<title>cupy&#45;&gt;numpy</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M49.0279,-146.2292C70.5877,-126.4181 110.206,-92.5369 149.4971,-72 189.7126,-50.9799 239.5889,-36.3309 274.8897,-27.6465\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"275.9855,-30.983 284.8943,-25.2486 274.3539,-24.1758 275.9855,-30.983\"/>\n</g>\n<!-- sparse&#45;&gt;numpy -->\n<g id=\"edge7\" class=\"edge\">\n<title>sparse&#45;&gt;numpy</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M132.7433,-144.0661C141.6889,-123.984 158.6924,-91.6807 182.4971,-72 209.288,-49.8505 246.2673,-35.9962 275.0548,-27.8738\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"276.1175,-31.2124 284.8655,-25.2356 274.2997,-24.4526 276.1175,-31.2124\"/>\n</g>\n<!-- numpy.ma&#45;&gt;numpy -->\n<g id=\"edge8\" class=\"edge\">\n<title>numpy.ma&#45;&gt;numpy</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M288.632,-72.2022C293.3983,-63.832 299.1792,-53.6802 304.4435,-44.4356\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"307.5719,-46.0148 309.4789,-35.593 301.489,-42.5509 307.5719,-46.0148\"/>\n</g>\n<!-- pandas&#45;&gt;numpy -->\n<g id=\"edge9\" class=\"edge\">\n<title>pandas&#45;&gt;numpy</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M345.0072,-143.853C346.0879,-125.5199 346.5765,-96.4849 341.4971,-72 339.6054,-62.8808 336.232,-53.3419 332.6862,-44.8628\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"335.7794,-43.2042 328.5231,-35.4843 329.3815,-46.0444 335.7794,-43.2042\"/>\n</g>\n<!-- pandas&#45;&gt;numpy.ma -->\n<g id=\"edge10\" class=\"edge\">\n<title>pandas&#45;&gt;numpy.ma</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M328.093,-144.937C320.0356,-136.0119 310.0184,-124.9159 301.1003,-115.0373\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"303.5412,-112.518 294.2422,-107.4407 298.3453,-117.2088 303.5412,-112.518\"/>\n</g>\n<!-- jax -->\n<g id=\"node7\" class=\"node\">\n<title>jax</title>\n<ellipse fill=\"none\" stroke=\"#000000\" cx=\"452.4971\" cy=\"-234\" rx=\"27\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"452.4971\" y=\"-230.3\" font-family=\"Courier,monospace\" font-size=\"14.00\" fill=\"#000000\">jax</text>\n</g>\n<!-- jax&#45;&gt;numpy -->\n<g id=\"edge11\" class=\"edge\">\n<title>jax&#45;&gt;numpy</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M454.871,-215.9596C458.104,-183.7608 460.2774,-115.6836 428.4971,-72 412.8429,-50.4825 386.1932,-37.0648 363.1639,-28.9863\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"364.1511,-25.6268 353.5585,-25.843 361.9739,-32.2797 364.1511,-25.6268\"/>\n</g>\n<!-- pint -->\n<g id=\"node8\" class=\"node\">\n<title>pint</title>\n<ellipse fill=\"none\" stroke=\"#000000\" cx=\"332.4971\" cy=\"-306\" rx=\"32.4942\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"332.4971\" y=\"-302.3\" font-family=\"Courier,monospace\" font-size=\"14.00\" fill=\"#000000\">pint</text>\n</g>\n<!-- pint&#45;&gt;dask -->\n<g id=\"edge12\" class=\"edge\">\n<title>pint&#45;&gt;dask</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M310.2073,-292.6261C291.4318,-281.3608 264.3714,-265.1246 243.4867,-252.5937\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"245.0433,-249.4461 234.6676,-247.3023 241.4418,-255.4485 245.0433,-249.4461\"/>\n</g>\n<!-- pint&#45;&gt;numpy -->\n<g id=\"edge14\" class=\"edge\">\n<title>pint&#45;&gt;numpy</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M346.3581,-289.4381C368.7672,-260.6227 409.1374,-199.0684 395.4971,-144 385.882,-105.1823 359.6076,-66.7235 340.6435,-42.6996\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"343.2882,-40.4039 334.2798,-34.8272 337.8444,-44.8044 343.2882,-40.4039\"/>\n</g>\n<!-- pint&#45;&gt;pandas -->\n<g id=\"edge13\" class=\"edge\">\n<title>pint&#45;&gt;pandas</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M333.8903,-287.7623C335.7665,-263.201 339.1241,-219.2474 341.3312,-190.3541\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"344.8433,-190.3272 342.1153,-180.0896 337.8637,-189.794 344.8433,-190.3272\"/>\n</g>\n<!-- xarray -->\n<g id=\"node9\" class=\"node\">\n<title>xarray</title>\n<ellipse fill=\"none\" stroke=\"#000000\" cx=\"302.4971\" cy=\"-378\" rx=\"42.7926\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"302.4971\" y=\"-374.3\" font-family=\"Courier,monospace\" font-size=\"14.00\" fill=\"#000000\">xarray</text>\n</g>\n<!-- xarray&#45;&gt;dask -->\n<g id=\"edge15\" class=\"edge\">\n<title>xarray&#45;&gt;dask</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M286.8409,-360.7229C277.9555,-350.4638 266.9555,-336.9638 258.4971,-324 245.2487,-303.6946 232.9015,-279.091 224.3419,-260.7437\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"227.4612,-259.149 220.1106,-251.5188 221.0985,-262.0675 227.4612,-259.149\"/>\n</g>\n<!-- xarray&#45;&gt;numpy -->\n<g id=\"edge18\" class=\"edge\">\n<title>xarray&#45;&gt;numpy</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M340.5756,-369.6085C399.8601,-354.0455 507.4971,-314.6801 507.4971,-234 507.4971,-234 507.4971,-234 507.4971,-162 507.4971,-114.8889 487.4915,-102.3951 451.4971,-72 426.1403,-50.5876 391.1492,-36.794 363.5643,-28.511\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"364.3453,-25.094 353.768,-25.7047 362.4175,-31.8233 364.3453,-25.094\"/>\n</g>\n<!-- xarray&#45;&gt;cupy -->\n<g id=\"edge16\" class=\"edge\">\n<title>xarray&#45;&gt;cupy</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M271.5252,-365.4893C249.3355,-355.8011 219.2928,-341.1628 195.4971,-324 137.9233,-282.4745 81.6432,-220.4183 52.6687,-186.4277\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"55.0326,-183.8022 45.9064,-178.4203 49.6845,-188.3187 55.0326,-183.8022\"/>\n</g>\n<!-- xarray&#45;&gt;sparse -->\n<g id=\"edge17\" class=\"edge\">\n<title>xarray&#45;&gt;sparse</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M281.2256,-362.3062C267.668,-351.9579 249.9903,-337.8099 235.4971,-324 204.5008,-294.465 195.6568,-287.3468 171.4971,-252 157.8998,-232.1065 145.6542,-207.6591 137.2225,-189.2673\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"140.35,-187.6877 133.0603,-179.9993 133.9644,-190.5555 140.35,-187.6877\"/>\n</g>\n<!-- xarray&#45;&gt;numpy.ma -->\n<g id=\"edge20\" class=\"edge\">\n<title>xarray&#45;&gt;numpy.ma</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M298.0608,-359.6167C295.7275,-349.2244 293.0387,-335.9561 291.4971,-324 282.0001,-250.3421 279.437,-162.7596 278.7481,-118.5561\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"282.2443,-118.2395 278.6102,-108.2875 275.2449,-118.3336 282.2443,-118.2395\"/>\n</g>\n<!-- xarray&#45;&gt;pandas -->\n<g id=\"edge19\" class=\"edge\">\n<title>xarray&#45;&gt;pandas</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M331.0291,-364.5313C346.6639,-355.4703 364.623,-341.8984 373.4971,-324 395.3533,-279.9177 374.2913,-221.9317 358.1206,-188.6312\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"361.1547,-186.8751 353.5208,-179.5284 354.9071,-190.0322 361.1547,-186.8751\"/>\n</g>\n<!-- xarray&#45;&gt;jax -->\n<g id=\"edge22\" class=\"edge\">\n<title>xarray&#45;&gt;jax</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M337.7035,-367.5045C361.1366,-358.9957 391.2271,-344.9399 411.4971,-324 428.3009,-306.6409 439.019,-281.1742 445.2648,-261.757\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"448.6839,-262.5404 448.2083,-251.9563 441.9797,-260.5269 448.6839,-262.5404\"/>\n</g>\n<!-- xarray&#45;&gt;pint -->\n<g id=\"edge21\" class=\"edge\">\n<title>xarray&#45;&gt;pint</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M309.9128,-360.2022C313.3278,-352.0064 317.4545,-342.1024 321.2411,-333.0145\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"324.5512,-334.17 325.1667,-323.593 318.0897,-331.4776 324.5512,-334.17\"/>\n</g>\n</g>\n</svg>\n"
},
"metadata": {
"tags": []
},
"execution_count": 49
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "16iqjYR48hLz",
"colab_type": "code",
"colab": {}
},
"source": [
""
],
"execution_count": 0,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment