diff --git a/docs/source/examples/freeing_fixed_variables.py b/docs/source/examples/freeing_fixed_variables.py index 932cfc3ed..43944bec9 100644 --- a/docs/source/examples/freeing_fixed_variables.py +++ b/docs/source/examples/freeing_fixed_variables.py @@ -4,7 +4,7 @@ y = Variable("y", 3) # fix value to 3 m = Model(x, [x >= 1 + y, y >= 1]) # verbosity is 0 for testing's sake, no need to do that in your code! -sol = m.solve() # optimal cost is 4; y appears in sol["constants"] +sol = m.solve(verbosity=0) # optimal cost is 4; y appears in sol["constants"] assert abs(sol["cost"] - 4) <= 1e-4 assert y in sol["constants"] diff --git a/docs/source/figures/documentation sankeys.ipynb b/docs/source/figures/documentation sankeys.ipynb index 91ffc2704..92112de49 100644 --- a/docs/source/figures/documentation sankeys.ipynb +++ b/docs/source/figures/documentation sankeys.ipynb @@ -55,7 +55,12 @@ "Warning: skipped auto-differentiation of linked variable Aircraft.Empennage.HorizontalTail.Planform.cbarmac because NotImplementedError(\"Automatic differentiation not yet supported for .Quantity'> objects\") was raised. Set `gpkit.settings[\"ad_errors_raise\"] = True` to raise such Exceptions directly.\n", "\n", "Warning: skipped auto-differentiation of linked variable Aircraft.Empennage.VerticalTail.Planform.cbarmac because NotImplementedError(\"Automatic differentiation not yet supported for .Quantity'> objects\") was raised. Set `gpkit.settings[\"ad_errors_raise\"] = True` to raise such Exceptions directly.\n", - "\n" + "\n", + "Starting a sequence of GP solves\n", + " for 97 free variables\n", + " in 23 locally-GP constraints\n", + " and for 1032 free variables\n", + " in 1384 posynomial inequalities.\n" ] }, { @@ -70,12 +75,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Starting a sequence of GP solves\n", - " for 97 free variables\n", - " in 23 locally-GP constraints\n", - " and for 1032 free variables\n", - " in 1384 posynomial inequalities.\n", - "Solving took 1.28 seconds and 4 GP solves.\n", + "Solving took 1.3 seconds and 4 GP solves.\n", "Warning: Variable Mission.Climb.AircraftDrag.WingAero.CL[:] could cause inaccurate result because it is below lower bound. Solution is 1.0302 but bound is 0.9465\n", "Warning: Variable Mission.Climb.AircraftDrag.WingAero.Re[:] could cause inaccurate result because it is above upper bound. Solution is 1230806.2495 but bound is 600000.0000\n", "Warning: Variable Mission.Climb.AircraftDrag.TailAero1.Re[:] could cause inaccurate result because it is above upper bound. Solution is 1152795.0157 but bound is 1000000.0000\n" @@ -108,7 +108,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "e7b89175684c40a9847107e9be98ede6", + "model_id": "f7674899347547bcbe724d1f6bb2af10", "version_major": 2, "version_minor": 0 }, @@ -137,7 +137,31 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "f2e8bb63a12d4d5490f56d61cc51e84c", + "model_id": "14c3f385c3684b0286408f8d59d4a1eb", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "SankeyWidget(layout=Layout(height='400', width='1000'), links=[{'source': 'Mission.0001.0021', 'target': 'Miss…" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "Sankey(sol, M).diagram(minsenss=1, maxlinks=30, left=130, showconstraints=False)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "472bc4a9882641ad894031d6b1bdd6cf", "version_major": 2, "version_minor": 0 }, @@ -155,13 +179,13 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "6c7618d71dd349b4b130afa613d6f1a6", + "model_id": "8b9c2ec1fb5d44698a5079afdba5b703", "version_major": 2, "version_minor": 0 }, @@ -179,13 +203,13 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "3663b7ed2f014a4bbd5de4403548d091", + "model_id": "0027a5530f21403dab17842217089def", "version_major": 2, "version_minor": 0 }, @@ -203,13 +227,13 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "1f174e1129fd4997a86907f5852afa02", + "model_id": "12db93e8a7e44ae782133c8c29a859e8", "version_major": 2, "version_minor": 0 }, @@ -227,13 +251,13 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "81575a60603848a68073c6d90f96ad0b", + "model_id": "e26c56693b414d83ad57334447475cc4", "version_major": 2, "version_minor": 0 }, @@ -251,18 +275,18 @@ "reload(gpkit.interactive.sankey)\n", "Sankey = gpkit.interactive.sankey.Sankey\n", "\n", - "Sankey(sol, M, \"SolarMission\").diagram(maxlinks=30, showconstraints=False, height=700, left=100)" + "Sankey(sol, M, \"SolarMission\").diagram(maxlinks=30, showconstraints=False, height=700)" ] }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "96fc20dcc7434561b85a725420a58bdf", + "model_id": "3574d35d01464fe8a4bef3b16f1f16e8", "version_major": 2, "version_minor": 0 }, diff --git a/docs/source/figures/sankey_autosaves/Mission.png b/docs/source/figures/sankey_autosaves/Mission.png index ff2c0fc0d..2f2e294dd 100644 Binary files a/docs/source/figures/sankey_autosaves/Mission.png and b/docs/source/figures/sankey_autosaves/Mission.png differ diff --git a/docs/source/figures/sankey_autosaves/Mission2.png b/docs/source/figures/sankey_autosaves/Mission2.png deleted file mode 100644 index b229579c7..000000000 Binary files a/docs/source/figures/sankey_autosaves/Mission2.png and /dev/null differ diff --git a/docs/source/figures/sankey_autosaves/SolarMission.png b/docs/source/figures/sankey_autosaves/SolarMission.png index 0a7c62c3b..ade41b4f7 100644 Binary files a/docs/source/figures/sankey_autosaves/SolarMission.png and b/docs/source/figures/sankey_autosaves/SolarMission.png differ diff --git a/docs/source/figures/sankey_autosaves/SolarMission_Aircraft2.Wing.Planform.b.png b/docs/source/figures/sankey_autosaves/SolarMission_Aircraft2.Wing.Planform.b.png deleted file mode 100644 index 7c8ce7219..000000000 Binary files a/docs/source/figures/sankey_autosaves/SolarMission_Aircraft2.Wing.Planform.b.png and /dev/null differ diff --git a/docs/source/visint.rst b/docs/source/visint.rst index f03651cbb..af46d8b91 100644 --- a/docs/source/visint.rst +++ b/docs/source/visint.rst @@ -120,12 +120,11 @@ without any tight constraints or sensitive fixed variables. .. code:: python - Sankey(sol, M, "SolarMission").diagram(maxlinks=30, showconstraints=False, - height=700, left=100) + Sankey(sol, M, "SolarMission").diagram(maxlinks=30, showconstraints=False, height=700) .. figure:: figures/sankey_autosaves/SolarMission.png -Note that in addition to the ``left`` and ``showconstraints`` syntax introduced above, +Note that in addition to the ``showconstraints`` syntax introduced above, this uses two additional arguments you may find useful when visualizing large models: ``height`` sets the height of the diagram in pixels (similarly for ``width``), while ``maxlinks`` increases the maximum number of links (default 20), making diff --git a/gpkit/interactive/sankey.py b/gpkit/interactive/sankey.py index b9373571f..ff8dcd752 100644 --- a/gpkit/interactive/sankey.py +++ b/gpkit/interactive/sankey.py @@ -5,7 +5,7 @@ from collections.abc import Iterable import numpy as np from ipywidgets import Layout -from ipysankeywidget import SankeyWidget # pylint: disable=import-error +from ipysankeywidget import SankeyWidget from ..repr_conventions import lineagestr, unitstr from .. import Model, GPCOLORS from ..constraints.array import ArrayConstraint