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

Week07 group5 #4

Closed
wants to merge 3 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
199 changes: 199 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
1 change: 0 additions & 1 deletion brain_average.csv

This file was deleted.

20 changes: 0 additions & 20 deletions brain_sample.csv

This file was deleted.

Empty file added sagital/__init__.py
Empty file.
1 change: 1 addition & 0 deletions sagital/brain_average.csv
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions sagital/brain_sample.csv
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions sagital/command.py
Original file line number Diff line number Diff line change
@@ -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()
11 changes: 1 addition & 10 deletions sagital_brain.py → sagital/sagital_brain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Empty file added sagital/tests/__init__.py
Empty file.
53 changes: 53 additions & 0 deletions sagital/tests/test_sagital_history.py
Original file line number Diff line number Diff line change
@@ -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

'''
9 changes: 9 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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']}
)