Commit cfb0eedf authored by christian.foerster's avatar christian.foerster

final docstring tweaks

parent 7e7c3be8
......@@ -239,7 +239,7 @@
<span class="sd"> Example</span>
<span class="sd"> -------</span>
<span class="sd"> </span>
<span class="sd"> # define network structure</span>
<span class="sd"> # define network structure </span>
<span class="sd"> # tank4 &amp; tank5 flow into tank6, tank1 &amp; tank2 flow into tank4, ... </span>
<span class="sd"> &gt;&gt;&gt; network_structure = {&quot;tank_6&quot;:[&quot;tank_4&quot;,&quot;tank_5&quot;],</span>
<span class="sd"> &quot;tank_4&quot;:[&quot;tank_1&quot;,&quot;tank_2&quot;],</span>
......
......@@ -11,7 +11,10 @@ Leave some example code like ...
from tanks.tanks import Tank, initiate_tanks, get_levels
## define network and attributes
network_structure = {"tank_6":["tank_4","tank_5"],"tank_4":["tank_1","tank_2"],"tank_5":["tank_3"]}
network_structure = {"tank_6":["tank_4","tank_5"],
"tank_4":["tank_1","tank_2"],
"tank_5":["tank_3"]}
attributes = {"tank_1":(10, 0.0),
"tank_2":(20, 0.06),
"tank_3":(15, 0.9),
......@@ -27,13 +30,12 @@ Leave some example code like ...
levels = {"tank_{}".format(k):[] for k in range(7)[1:]} # init dict for our level values
for dt in range(100):
tank_levels = get_levels(all_tanks) # retrieve levels for every iteration
for tank_id, level in tank_levels.items(): # save the levels!
levels[tank_id].append(level) #
for tank_id, level in tank_levels.items(): # iterate over all tank levels
levels[tank_id].append(level) # save the levels!
final_tank.fill_tank() # open valves and let the water through to our last tank!
# checking results
# visualizing results
fig, axis = plt.subplots(6,1,figsize = (12,8))
for idx, ax in enumerate(axis):
ax.plot(levels["tank_{}".format(idx+1)])
......
Search.setIndex({docnames:["index","source/description","source/example","source/installation","source/issues","source/modules","source/tanks"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["index.rst","source/description.rst","source/example.rst","source/installation.rst","source/issues.rst","source/modules.rst","source/tanks.rst"],objects:{"tanks.tanks":{Tank:[6,1,1,""],get_levels:[6,4,1,""],initiate_tanks:[6,4,1,""]},"tanks.tanks.Tank":{Q:[6,2,1,""],fill_tank:[6,3,1,""]},tanks:{tanks:[6,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","attribute","Python attribute"],"3":["py","method","Python method"],"4":["py","function","Python function"]},objtypes:{"0":"py:module","1":"py:class","2":"py:attribute","3":"py:method","4":"py:function"},terms:{"15m":6,"class":6,"function":6,"import":2,"return":6,"switch":3,all:[1,6],all_tank:[2,6],ani:4,append:2,attribut:[2,6],axi:2,base:6,basic:[1,2],can:[0,1],check:2,code:2,connect:6,contain:6,content:0,creat:[0,6],defin:[2,6],describ:6,descript:0,dict:[2,6],dictionari:6,directli:3,discharg:6,downstream:6,dream:1,each:6,entir:2,entri:6,enumer:2,equal:6,everi:2,exampl:[0,6],extract:6,fig:2,figsiz:2,fill_tank:[2,6],final_tank:2,flow:6,footprint:6,format:[0,2],from:[2,3,6],gener:[2,6],get:3,get_level:[2,6],git:3,gitlab:[3,4],has:6,have:6,here:6,how:0,http:3,id_0:6,id_1:6,idx:2,index:0,init:2,initiate_tank:[2,6],instal:0,instanc:6,interact:1,issu:0,item:2,iter:2,its:6,kei:6,last:2,latest:3,leav:[2,4],let:2,level:[2,6],like:2,manag:1,matplotlib:2,mention:6,minim:0,modul:[0,5],more:6,must:6,necessari:2,nerd:1,network:[2,6],network_structur:[2,6],networt:6,none:6,note:0,object:6,one:6,onli:2,open:2,our:2,own:0,packag:[0,1,4,5],page:0,paramet:6,pip3:3,pip:3,plot:2,plt:2,product:6,propag:6,provid:6,pyplot:2,python:0,rang:2,rate:6,represent:6,result:2,retriev:2,run:2,save:2,search:0,set_titl:2,shape:6,show:2,simul:2,simulaten:1,some:2,sourc:6,specifi:6,structur:6,subplot:2,sww:3,system:6,tank1:6,tank2:6,tank4:6,tank5:6,tank6:6,tank:[1,2,3],tank_1:[2,6],tank_2:[2,6],tank_3:[2,6],tank_4:[2,6],tank_5:[2,6],tank_6:[2,6],tank_:2,tank_id:[2,6],tank_id_downstream:6,tank_id_upstream_n:6,tank_id_upstream_np1:6,tank_level:2,thi:[0,1,6],through:[2,6],tight_layout:2,troubl:4,type:6,upstream:6,upstream_tank:6,using:3,valu:2,valv:2,version:3,want:6,water:[1,2,6],you:[0,1,6],your:0},titles:["Welcome to tanks\u2019s documentation!","Description","Examples","Installation","Issues","tanks","tanks package"],titleterms:{descript:1,document:0,exampl:2,indic:0,instal:3,issu:4,modul:6,packag:6,tabl:0,tank:[0,5,6],welcom:0}})
\ No newline at end of file
Search.setIndex({docnames:["index","source/description","source/example","source/installation","source/issues","source/modules","source/tanks"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["index.rst","source/description.rst","source/example.rst","source/installation.rst","source/issues.rst","source/modules.rst","source/tanks.rst"],objects:{"tanks.tanks":{Tank:[6,1,1,""],get_levels:[6,4,1,""],initiate_tanks:[6,4,1,""]},"tanks.tanks.Tank":{Q:[6,2,1,""],fill_tank:[6,3,1,""]},tanks:{tanks:[6,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","attribute","Python attribute"],"3":["py","method","Python method"],"4":["py","function","Python function"]},objtypes:{"0":"py:module","1":"py:class","2":"py:attribute","3":"py:method","4":"py:function"},terms:{"15m":6,"class":6,"function":6,"import":2,"return":6,"switch":3,all:[1,2,6],all_tank:[2,6],ani:4,append:2,attribut:[2,6],axi:2,base:6,basic:[1,2],can:[0,1],check:[],code:2,connect:6,contain:6,content:0,creat:[0,6],defin:[2,6],describ:6,descript:0,dict:[2,6],dictionari:6,directli:3,discharg:6,downstream:6,dream:1,each:6,entir:2,entri:6,enumer:2,equal:6,everi:2,exampl:[0,6],extract:6,fig:2,figsiz:2,fill_tank:[2,6],final_tank:2,flow:6,footprint:6,format:[0,2],from:[2,3,6],gener:[2,6],get:3,get_level:[2,6],git:3,gitlab:[3,4],has:6,have:6,here:6,how:0,http:3,id_0:6,id_1:6,idx:2,index:0,init:2,initiate_tank:[2,6],instal:0,instanc:6,interact:1,issu:0,item:2,iter:2,its:6,kei:6,last:2,latest:3,leav:[2,4],let:2,level:[2,6],like:2,manag:1,matplotlib:2,mention:6,minim:0,modul:[0,5],more:6,must:6,necessari:2,nerd:1,network:[2,6],network_structur:[2,6],networt:6,none:6,note:0,object:6,one:6,onli:2,open:2,our:2,over:2,own:0,packag:[0,1,4,5],page:0,paramet:6,pip3:3,pip:3,plot:2,plt:2,product:6,propag:6,provid:6,pyplot:2,python:0,rang:2,rate:6,represent:6,result:2,retriev:2,run:2,save:2,search:0,set_titl:2,shape:6,show:2,simul:2,simulaten:1,some:2,sourc:6,specifi:6,structur:6,subplot:2,sww:3,system:6,tank1:6,tank2:6,tank4:6,tank5:6,tank6:6,tank:[1,2,3],tank_1:[2,6],tank_2:[2,6],tank_3:[2,6],tank_4:[2,6],tank_5:[2,6],tank_6:[2,6],tank_:2,tank_id:[2,6],tank_id_downstream:6,tank_id_upstream_n:6,tank_id_upstream_np1:6,tank_level:2,thi:[0,1,6],through:[2,6],tight_layout:2,troubl:4,type:6,upstream:6,upstream_tank:6,using:3,valu:2,valv:2,version:3,visual:2,want:6,water:[1,2,6],you:[0,1,6],your:0},titles:["Welcome to tanks\u2019s documentation!","Description","Examples","Installation","Issues","tanks","tanks package"],titleterms:{descript:1,document:0,exampl:2,indic:0,instal:3,issu:4,modul:6,packag:6,tabl:0,tank:[0,5,6],welcom:0}})
\ No newline at end of file
......@@ -159,7 +159,10 @@
<span class="kn">from</span> <span class="nn">tanks.tanks</span> <span class="kn">import</span> <span class="n">Tank</span><span class="p">,</span> <span class="n">initiate_tanks</span><span class="p">,</span> <span class="n">get_levels</span>
<span class="c1">## define network and attributes</span>
<span class="n">network_structure</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;tank_6&quot;</span><span class="p">:[</span><span class="s2">&quot;tank_4&quot;</span><span class="p">,</span><span class="s2">&quot;tank_5&quot;</span><span class="p">],</span><span class="s2">&quot;tank_4&quot;</span><span class="p">:[</span><span class="s2">&quot;tank_1&quot;</span><span class="p">,</span><span class="s2">&quot;tank_2&quot;</span><span class="p">],</span><span class="s2">&quot;tank_5&quot;</span><span class="p">:[</span><span class="s2">&quot;tank_3&quot;</span><span class="p">]}</span>
<span class="n">network_structure</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;tank_6&quot;</span><span class="p">:[</span><span class="s2">&quot;tank_4&quot;</span><span class="p">,</span><span class="s2">&quot;tank_5&quot;</span><span class="p">],</span>
<span class="s2">&quot;tank_4&quot;</span><span class="p">:[</span><span class="s2">&quot;tank_1&quot;</span><span class="p">,</span><span class="s2">&quot;tank_2&quot;</span><span class="p">],</span>
<span class="s2">&quot;tank_5&quot;</span><span class="p">:[</span><span class="s2">&quot;tank_3&quot;</span><span class="p">]}</span>
<span class="n">attributes</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;tank_1&quot;</span><span class="p">:(</span><span class="mi">10</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">),</span>
<span class="s2">&quot;tank_2&quot;</span><span class="p">:(</span><span class="mi">20</span><span class="p">,</span> <span class="mf">0.06</span><span class="p">),</span>
<span class="s2">&quot;tank_3&quot;</span><span class="p">:(</span><span class="mi">15</span><span class="p">,</span> <span class="mf">0.9</span><span class="p">),</span>
......@@ -175,13 +178,12 @@
<span class="n">levels</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;tank_{}&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">k</span><span class="p">):[]</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">7</span><span class="p">)[</span><span class="mi">1</span><span class="p">:]}</span> <span class="c1"># init dict for our level values</span>
<span class="k">for</span> <span class="n">dt</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">100</span><span class="p">):</span>
<span class="n">tank_levels</span> <span class="o">=</span> <span class="n">get_levels</span><span class="p">(</span><span class="n">all_tanks</span><span class="p">)</span> <span class="c1"># retrieve levels for every iteration</span>
<span class="k">for</span> <span class="n">tank_id</span><span class="p">,</span> <span class="n">level</span> <span class="ow">in</span> <span class="n">tank_levels</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> <span class="c1"># save the levels!</span>
<span class="n">levels</span><span class="p">[</span><span class="n">tank_id</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">level</span><span class="p">)</span> <span class="c1">#</span>
<span class="k">for</span> <span class="n">tank_id</span><span class="p">,</span> <span class="n">level</span> <span class="ow">in</span> <span class="n">tank_levels</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> <span class="c1"># iterate over all tank levels</span>
<span class="n">levels</span><span class="p">[</span><span class="n">tank_id</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">level</span><span class="p">)</span> <span class="c1"># save the levels!</span>
<span class="n">final_tank</span><span class="o">.</span><span class="n">fill_tank</span><span class="p">()</span> <span class="c1"># open valves and let the water through to our last tank!</span>
<span class="c1"># checking results</span>
<span class="c1"># visualizing results</span>
<span class="n">fig</span><span class="p">,</span> <span class="n">axis</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="mi">6</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="n">figsize</span> <span class="o">=</span> <span class="p">(</span><span class="mi">12</span><span class="p">,</span><span class="mi">8</span><span class="p">))</span>
<span class="k">for</span> <span class="n">idx</span><span class="p">,</span> <span class="n">ax</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">axis</span><span class="p">):</span>
<span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">levels</span><span class="p">[</span><span class="s2">&quot;tank_{}&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">idx</span><span class="o">+</span><span class="mi">1</span><span class="p">)])</span>
......
......@@ -11,7 +11,10 @@ Leave some example code like ...
from tanks.tanks import Tank, initiate_tanks, get_levels
## define network and attributes
network_structure = {"tank_6":["tank_4","tank_5"],"tank_4":["tank_1","tank_2"],"tank_5":["tank_3"]}
network_structure = {"tank_6":["tank_4","tank_5"],
"tank_4":["tank_1","tank_2"],
"tank_5":["tank_3"]}
attributes = {"tank_1":(10, 0.0),
"tank_2":(20, 0.06),
"tank_3":(15, 0.9),
......@@ -27,13 +30,12 @@ Leave some example code like ...
levels = {"tank_{}".format(k):[] for k in range(7)[1:]} # init dict for our level values
for dt in range(100):
tank_levels = get_levels(all_tanks) # retrieve levels for every iteration
for tank_id, level in tank_levels.items(): # save the levels!
levels[tank_id].append(level) #
for tank_id, level in tank_levels.items(): # iterate over all tank levels
levels[tank_id].append(level) # save the levels!
final_tank.fill_tank() # open valves and let the water through to our last tank!
# checking results
# visualizing results
fig, axis = plt.subplots(6,1,figsize = (12,8))
for idx, ax in enumerate(axis):
ax.plot(levels["tank_{}".format(idx+1)])
......
......@@ -89,7 +89,7 @@ def initiate_tanks(network_structure, attributes):
Example
-------
# define network structure
# define network structure
# tank4 & tank5 flow into tank6, tank1 & tank2 flow into tank4, ...
>>> network_structure = {"tank_6":["tank_4","tank_5"],
"tank_4":["tank_1","tank_2"],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment