diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a73bf5b --- /dev/null +++ b/.gitignore @@ -0,0 +1,199 @@ +# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig + +# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,macos,jupyternotebooks,python +# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,macos,jupyternotebooks,python + +### JupyterNotebooks ### +# gitignore template for Jupyter Notebooks +# website: http://jupyter.org/ + +.ipynb_checkpoints +*/.ipynb_checkpoints/* + +# IPython +profile_default/ +ipython_config.py + +# Remove previous ipynb_checkpoints +# git rm -r .ipynb_checkpoints/ + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +pytestdebug.log + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ +doc/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook + +# IPython + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ +pythonenv* + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# profiling data +.prof + +### VisualStudioCode ### +.vscode/* +!.vscode/tasks.json +!.vscode/launch.json +*.code-workspace + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,macos,jupyternotebooks,python + +# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option) + diff --git a/brain_average.csv b/brain_average.csv deleted file mode 100644 index d30573e..0000000 --- a/brain_average.csv +++ /dev/null @@ -1 +0,0 @@ -10.5,11.5,12.5,13.5,14.5,15.5,16.5,17.5,18.5,19.5,20.5,21.5,22.5,23.5,24.5,25.5,26.5,27.5,28.5,29.5 diff --git a/brain_sample.csv b/brain_sample.csv deleted file mode 100644 index 7b809c6..0000000 --- a/brain_sample.csv +++ /dev/null @@ -1,20 +0,0 @@ -1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 -2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21 -3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 -4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 -5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24 -6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25 -7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26 -8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27 -9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28 -10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29 -11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30 -12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 -13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32 -14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33 -15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34 -16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35 -17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36 -18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37 -19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38 -20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39 diff --git a/sagital/__init__.py b/sagital/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sagital/brain_average.csv b/sagital/brain_average.csv new file mode 100644 index 0000000..af02e18 --- /dev/null +++ b/sagital/brain_average.csv @@ -0,0 +1 @@ +0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0 diff --git a/sagital/brain_sample.csv b/sagital/brain_sample.csv new file mode 100644 index 0000000..d0b9035 --- /dev/null +++ b/sagital/brain_sample.csv @@ -0,0 +1,20 @@ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 diff --git a/sagital/command.py b/sagital/command.py new file mode 100644 index 0000000..18d38ff --- /dev/null +++ b/sagital/command.py @@ -0,0 +1,24 @@ +from argparse import ArgumentParser +from .sagital_brain import run_averages +import sys + + +def process(): + + parser = ArgumentParser(description="Weighted mean of squared numbers") + # parser.add_argument("numbers", nargs='+', help="the list of numbers") + parser.add_argument("numbers", type=int, nargs='+', help="the list of numbers") + parser.add_argument("--weights", "-w", type=int, nargs='+', help="the list of weights") + arguments = parser.parse_args() + + # numbers = convert_numbers(arguments.numbers) + numbers = arguments.numbers + if arguments.weights: + weights = arguments.weights + else: + weights = [1] * len(numbers) + + run_averages(numbers, weights) + +if __name__ == "__main__": + process() \ No newline at end of file diff --git a/sagital_brain.py b/sagital/sagital_brain.py similarity index 80% rename from sagital_brain.py rename to sagital/sagital_brain.py index 292d76c..d610dc7 100644 --- a/sagital_brain.py +++ b/sagital/sagital_brain.py @@ -31,13 +31,4 @@ def run_averages(file_input, file_output): with open(file_output, 'w') as myoutput: myoutput.write(','.join(sagital_averages) + '\n') -if __name__ == "__main__": - import sys - argumens = sys.argv - file_input = None - file_output = None - if len(argumens) > 1: - file_input = sys.argv[1] - if len(argumens) > 2: - file_output = sys.argv[2] - run_averages(file_input, file_output) + diff --git a/sagital/tests/__init__.py b/sagital/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sagital/tests/test_sagital_history.py b/sagital/tests/test_sagital_history.py new file mode 100644 index 0000000..c4a6413 --- /dev/null +++ b/sagital/tests/test_sagital_history.py @@ -0,0 +1,53 @@ + +import numpy as np + +def test_basic(): + # Make new output file + data_input = np.zeros((20, 20)) + data_input[-1, :] = 1 + np.savetxt("brain_sample.csv", data_input, fmt='%d', delimiter=',') + + # Run sagital brain file to generate output + exec(open("sagital_brain.py").read()) + + # Load output + loaded = np.loadtxt('brain_average.csv', delimiter=',') + + # Expected output + expected = np.array([0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0]) + + # Check the values are identical + np.testing.assert_array_equal(loaded, expected) + + +def test_better(): + data_input = np.zeros((20, 20)) + data_input[-1, :] = 1 + np.savetxt("brain_sample.csv", data_input, fmt='%d', delimiter=',') + + + +''' + +import subprocess +import numpy as np + +# generated data +data_input = np.zeros((20, 20)) +data_input[-1, :] = 1 +np.savetxt("brain_sample.csv", data_input, fmt='%d', delimiter=',') + +# run +subprocess.run(["python", "sagital_brain.py"]) + +# read output to then compare +result = np.loadtxt('brain_average.csv', delimiter=',') + +# Generate an expected result + +expected = np.zeros(20) +expected[-1] = 1 + +np.testing.assert_array_equal(result, expected) # error if it fails + +''' \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..879312c --- /dev/null +++ b/setup.py @@ -0,0 +1,9 @@ +from setuptools import setup, find_packages + +setup( + name="sagital", + version="0.1.0", + packages=find_packages(), + entry_points={'console_scripts': [ + 'run_averages= sagital.command:process']} +)