diff --git a/README.md b/README.md index daac5a8..f40e833 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -# `scikit-project`: A Guide to Building Your Open-Source Science Project +# Make your code count +A Guide to building your open-source scientific computing project in Python. [![Unitary Fund](https://img.shields.io/badge/Supported%20By-UNITARY%20FUND-brightgreen.svg?style=for-the-badge)](http://unitary.fund) diff --git a/mylibrary/.gitignore b/mylibrary/.gitignore index 1644965..0e47979 100644 --- a/mylibrary/.gitignore +++ b/mylibrary/.gitignore @@ -1,4 +1,5 @@ mylibrary build dist -mylibrary.egg-info \ No newline at end of file +mylibrary.egg-info +.DS_Store diff --git a/mylibrary/LICENSE.md b/mylibrary/LICENSE.md index e69de29..1f73bba 100644 --- a/mylibrary/LICENSE.md +++ b/mylibrary/LICENSE.md @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2019, Nathan Shammah and Shahnawaz Ahmed +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/mylibrary/README.md b/mylibrary/README.md index 8d53209..68800d8 100644 --- a/mylibrary/README.md +++ b/mylibrary/README.md @@ -2,3 +2,5 @@ This simply library prints a hello world message from a python package and tests its functionality. + +We add the basic elements that you need to get a working python package - a setup file that lets you install your library locally, tests and documentation with sphinx. diff --git a/mylibrary/docs/Makefile b/mylibrary/docs/Makefile new file mode 100644 index 0000000..d0c3cbf --- /dev/null +++ b/mylibrary/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/mylibrary/docs/make.bat b/mylibrary/docs/make.bat new file mode 100644 index 0000000..6247f7e --- /dev/null +++ b/mylibrary/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/mylibrary/docs/source/conf.py b/mylibrary/docs/source/conf.py new file mode 100644 index 0000000..4ca727a --- /dev/null +++ b/mylibrary/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 = 'mylibrary' +copyright = '2020, Nathan Shammah, Shahnawaz Ahmed' +author = 'Nathan Shammah, Shahnawaz Ahmed' + +# The full version, including alpha/beta/rc tags +release = '0.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 = [ +] + +# 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 = 'sphinx_rtd_theme' + +# 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'] diff --git a/mylibrary/docs/source/index.rst b/mylibrary/docs/source/index.rst new file mode 100644 index 0000000..1d4464a --- /dev/null +++ b/mylibrary/docs/source/index.rst @@ -0,0 +1,20 @@ +.. mylibrary documentation master file, created by + sphinx-quickstart on Tue Oct 20 08:22:04 2020. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to mylibrary's documentation! +===================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/mylibrary/mylibrary-notebooks/.ipynb_checkpoints/0-introduction-checkpoint.ipynb b/mylibrary/examples/.ipynb_checkpoints/0-introduction-checkpoint.ipynb similarity index 100% rename from mylibrary/mylibrary-notebooks/.ipynb_checkpoints/0-introduction-checkpoint.ipynb rename to mylibrary/examples/.ipynb_checkpoints/0-introduction-checkpoint.ipynb diff --git a/mylibrary/mylibrary-notebooks/0-introduction.ipynb b/mylibrary/examples/0-introduction.ipynb similarity index 100% rename from mylibrary/mylibrary-notebooks/0-introduction.ipynb rename to mylibrary/examples/0-introduction.ipynb diff --git a/mylibrary/mylibrary-notebooks/apt.txt b/mylibrary/examples/apt.txt similarity index 100% rename from mylibrary/mylibrary-notebooks/apt.txt rename to mylibrary/examples/apt.txt diff --git a/mylibrary/mylibrary-notebooks/environment.yml b/mylibrary/examples/environment.yml similarity index 100% rename from mylibrary/mylibrary-notebooks/environment.yml rename to mylibrary/examples/environment.yml diff --git a/mylibrary/mylibrary/hello.py b/mylibrary/mylibrary/hello.py index 75281b5..8baeb05 100644 --- a/mylibrary/mylibrary/hello.py +++ b/mylibrary/mylibrary/hello.py @@ -2,10 +2,63 @@ A simple hello world """ -class HelloWorld(): - """ - """ - def print_message(self, message): - """ - """ - print(message) + +def hello(name): + """ + Simple function that prints "Hello X" for + an input `name`. + + Parameters + ---------- + name : str + The name of the person. + + Returns + ------- + greeting: str + The message - Hello `name`. + """ + if type(name) != str: + raise ValueError("Name should be a string") + greeting = "Hello " + name + return greeting + + +class ChatBot(object): + """ + Simple class that acts as a bot. + + Parameters + —————————- + name : str + The name of the person. + """ + + def __init__(self, name): + self.name = name + if type(name) != str: + raise ValueError("Name should be a string") + + def hello(self): + """ + Simple function that prints Hello `name` + an input `name`. + + Returns + ——————- + str + The message - Hello `name`. + """ + return "Hello " + self.name + + def goodbye(self): + """ + Simple function that prints Bye `name` + an input `name`. + + Returns + ——————- + str + The message - Bye `name`. + """ + return "Bye " + self.name diff --git a/mylibrary/requirements.txt b/mylibrary/requirements.txt new file mode 100644 index 0000000..296d654 --- /dev/null +++ b/mylibrary/requirements.txt @@ -0,0 +1 @@ +numpy \ No newline at end of file diff --git a/mylibrary/setup.py b/mylibrary/setup.py index f9c0835..b5cff3a 100644 --- a/mylibrary/setup.py +++ b/mylibrary/setup.py @@ -1,12 +1,12 @@ #!/usr/bin/env python """ -Setup file created +Setup file """ -from setuptools import setup +from setuptools import setup, find_packages setup(name='mylibrary', - version='0.1', - description='Test', + version='0.0.1', + description='Test library', author='Shahnawaz Ahmed, Nathan Shammah', - packages = ['mylibrary'] + packages = find_packages(include=['mylibrary', 'mylibrary.*']) ) diff --git a/mylibrary/tests/__pycache__/test_hello.cpython-37-pytest-5.4.1.pyc b/mylibrary/tests/__pycache__/test_hello.cpython-37-pytest-5.4.1.pyc new file mode 100644 index 0000000..cf845a9 Binary files /dev/null and b/mylibrary/tests/__pycache__/test_hello.cpython-37-pytest-5.4.1.pyc differ diff --git a/mylibrary/tests/test_hello.py b/mylibrary/tests/test_hello.py new file mode 100644 index 0000000..c45df42 --- /dev/null +++ b/mylibrary/tests/test_hello.py @@ -0,0 +1,16 @@ +""" +Tests for the hello module +""" +from mylibrary.hello import hello + +import pytest + + +def test_hello(): + """ + Tests the hello function. + """ + assert(hello("John") == "Hello John") + assert(hello("Mary") == "Hello Mary") + + pytest.raises(ValueError, hello, [5])