Skip to content

Commit

Permalink
Merge pull request #41 from quantshah/master
Browse files Browse the repository at this point in the history
Added some basic functionality to the library and tests
  • Loading branch information
nathanshammah authored Jun 22, 2021
2 parents 563b2eb + fd23c0f commit 7915c31
Show file tree
Hide file tree
Showing 17 changed files with 247 additions and 14 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
3 changes: 2 additions & 1 deletion mylibrary/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mylibrary
build
dist
mylibrary.egg-info
mylibrary.egg-info
.DS_Store
29 changes: 29 additions & 0 deletions mylibrary/LICENSE.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions mylibrary/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
20 changes: 20 additions & 0 deletions mylibrary/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 = 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)
35 changes: 35 additions & 0 deletions mylibrary/docs/make.bat
Original file line number Diff line number Diff line change
@@ -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
55 changes: 55 additions & 0 deletions mylibrary/docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -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']
20 changes: 20 additions & 0 deletions mylibrary/docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -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`
File renamed without changes.
File renamed without changes.
File renamed without changes.
67 changes: 60 additions & 7 deletions mylibrary/mylibrary/hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions mylibrary/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
numpy
10 changes: 5 additions & 5 deletions mylibrary/setup.py
Original file line number Diff line number Diff line change
@@ -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.*'])
)
Binary file not shown.
16 changes: 16 additions & 0 deletions mylibrary/tests/test_hello.py
Original file line number Diff line number Diff line change
@@ -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])

0 comments on commit 7915c31

Please sign in to comment.