Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Week 7 Class Work #152

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions week06/average-squares-example/average_squares/squares.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Computation of weighted average of squares."""

from argparse import ArgumentParser

def average_of_squares(list_of_numbers, list_of_weights=None):
""" Return the weighted average of a list of values.
Expand Down Expand Up @@ -29,7 +29,7 @@ def average_of_squares(list_of_numbers, list_of_weights=None):
for number, weight
in zip(list_of_numbers, effective_weights)
]
return sum(squares)
return sum(squares)/len(squares)


def convert_numbers(list_of_strings):
Expand All @@ -38,7 +38,7 @@ def convert_numbers(list_of_strings):
Example:
--------
>>> convert_numbers(["4", " 8 ", "15 16", " 23 42 "])
[4, 8, 15, 16]
[4.0, 8.0, 15.0, 16.0, 23.0, 42.0]

"""
all_numbers = []
Expand All @@ -51,12 +51,14 @@ def convert_numbers(list_of_strings):


if __name__ == "__main__":
numbers_strings = ["1","2","4"]
weight_strings = ["1","1","1"]

numbers = convert_numbers(numbers_strings)
weights = convert_numbers(weight_strings)

parser = ArgumentParser(description="Return weighted average of squares")

parser.add_argument('numbers', nargs='+', type=float)
parser.add_argument('--weights', '-w', nargs='+', type=float)

arguments = parser.parse_args()

result = average_of_squares(numbers, weights)
result = average_of_squares(arguments.numbers, arguments.weights)

print(result)
20 changes: 20 additions & 0 deletions week06/average-squares-example/docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Binary file not shown.
Binary file not shown.
Binary file not shown.
121 changes: 121 additions & 0 deletions week06/average-squares-example/docs/_build/html/#index.html#
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@

<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Welcome to project_name’s documentation! &#8212; project_name documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/language_data.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Average Squares Documentation" href="content/average-squares-docs.html" />

<link rel="stylesheet" href="_static/custom.css" type="text/css" />


<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

</head><body>


<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">


<div class="body" role="main">

<div class="section" id="welcome-to-project-name-s-documentation">
<h1>Welcome to project_name’s documentation!<a class="headerlink" href="#welcome-to-project-name-s-documentation" title="Permalink to this headline">¶</a></h1>
<div class="toctree-wrapper compound">
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="content/average-squares-docs.html">Average Squares Documentation</a></li>
</ul>
</div>
</div>
<div class="section" id="indices-and-tables">
<h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline">¶</a></h1>
<ul class="simple">
<li><p><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></p></li>
<li><p><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></p></li>
<li><p><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></p></li>
</ul>
</div>


</div>

</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="#">project_name</a></h1>








<h3>Navigation</h3>
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="content/average-squares-docs.html">Average Squares Documentation</a></li>
</ul>

<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="#">Documentation overview</a><ul>
<li>Next: <a href="content/average-squares-docs.html" title="next chapter">Average Squares Documentation</a></li>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>








</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2020, alex.

|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.3.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>

|
<a href="_sources/index.rst.txt"
rel="nofollow">Page source</a>
</div>




</body>
</html>
4 changes: 4 additions & 0 deletions week06/average-squares-example/docs/_build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: e44231bc8ad9dbabb8c6cfd21309a5c2
tags: 645f666f9bcd5a90fca523b33c5a78b7
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Average Squares Documentation
=============================

.. automodule:: squares
:members:
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.. project_name documentation master file, created by
sphinx-quickstart on Tue Nov 17 17:08:45 2020.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

Welcome to project_name's documentation!
========================================

Im dumb

.. toctree::
:maxdepth: 2
:caption: Contents:

content/average-squares-docs.rst

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
Loading