diff --git a/week06/average-squares-example/average_squares/squares.py b/week06/average-squares-example/average_squares/squares.py index d7e454e..8e7fa07 100644 --- a/week06/average-squares-example/average_squares/squares.py +++ b/week06/average-squares-example/average_squares/squares.py @@ -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(list_of_numbers) def convert_numbers(list_of_strings): @@ -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 = [] diff --git a/week06/average-squares-example/docs/Makefile b/week06/average-squares-example/docs/Makefile new file mode 100644 index 0000000..d0c3cbf --- /dev/null +++ b/week06/average-squares-example/docs/Makefile @@ -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 = source +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) diff --git a/week06/average-squares-example/docs/content/average-squares-docs.rst b/week06/average-squares-example/docs/content/average-squares-docs.rst new file mode 100644 index 0000000..0834017 --- /dev/null +++ b/week06/average-squares-example/docs/content/average-squares-docs.rst @@ -0,0 +1,5 @@ +Average Squares Documentation +============================= + +.. automodule:: squares + :members: \ No newline at end of file diff --git a/week06/average-squares-example/docs/source/conf.py b/week06/average-squares-example/docs/source/conf.py new file mode 100644 index 0000000..1d38947 --- /dev/null +++ b/week06/average-squares-example/docs/source/conf.py @@ -0,0 +1,55 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +import os +import sys +sys.path.insert(0, os.path.abspath('..')) + + +# -- Project information ----------------------------------------------------- + +project = 'squares' +copyright = '2020, Danqing' +author = 'Danqing' + +# The full version, including alpha/beta/rc tags +release = '0.1' + + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = ['sphinx.ext.autodoc' +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = [] + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'alabaster' + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] \ No newline at end of file diff --git a/week06/average-squares-example/docs/source/index.rst b/week06/average-squares-example/docs/source/index.rst new file mode 100644 index 0000000..61f7d41 --- /dev/null +++ b/week06/average-squares-example/docs/source/index.rst @@ -0,0 +1,24 @@ +.. squares documentation master file, created by + sphinx-quickstart on Tue Nov 17 02:39:10 2020. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to squares's documentation! +=================================== + +This project is designed to calculate the weighted average of squares. + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + Average Squares Documentation + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` +