-
Notifications
You must be signed in to change notification settings - Fork 0
Add implementation of standard deviation on data #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sl6391
wants to merge
3
commits into
main
Choose a base branch
from
feature-std-dev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import math | ||
|
|
||
| class Circle: | ||
| def __init__(self, radius): | ||
| self.radius = radius | ||
|
|
||
| def get_area(self): | ||
| return math.pi * self.radius * self.radius | ||
|
|
||
| class Rectangle: | ||
| def __init__(self,width,height): | ||
| self.width = width | ||
| self.height = height | ||
|
|
||
| def get_area(self): | ||
| return self.width * self.height | ||
|
|
||
| my_circle = Circle(10) | ||
| your_rectangle = Rectangle(20,30) | ||
|
|
||
| shapes = [my_circle, your_rectangle] | ||
|
|
||
| for shape in shapes: | ||
| print(shape.get_area()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| #! /usr/bin/env python | ||
|
|
||
| from pathlib import Path | ||
| import numpy.testing as npt | ||
| import pytest | ||
| from unittest.mock import Mock | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "data,expected_output", | ||
| [ | ||
| ([[[0, 1, 0],[0, 2, 0]]], [0, 0, 0]), | ||
| ], | ||
| ids=['Two patients in same file']) | ||
|
|
||
| def test_compute_standard_deviation_by_day(data,expected_output): | ||
| from inflammation.compute_data import compute_standard_deviation_by_day | ||
|
|
||
| result = compute_standard_deviation_by_day(data) | ||
| npt.assert_almost_equal(result,expected_output) | ||
|
|
||
|
|
||
| def test_analyse_data(): | ||
| from inflammation.compute_data import analyse_data, CSVDataSource | ||
| path = "data" | ||
| data_source = CSVDataSource(path) | ||
| result = analyse_data(data_source) | ||
|
|
||
| npt.assert_almost_equal(result, [0. , 0.22510286, 0.18157299, 0.1264423 , 0.9495481 , | ||
| 0.27118211, 0.25104719, 0.22330897, 0.89680503, 0.21573875, | ||
| 1.24235548, 0.63042094, 1.57511696, 2.18850242, 0.3729574 , | ||
| 0.69395538, 2.52365162, 0.3179312 , 1.22850657, 1.63149639, | ||
| 2.45861227, 1.55556052, 2.8214853 , 0.92117578, 0.76176979, | ||
| 2.18346188, 0.55368435, 1.78441632, 0.26549221, 1.43938417, | ||
| 0.78959769, 0.64913879, 1.16078544, 0.42417995, 0.36019114, | ||
| 0.80801707, 0.50323031, 0.47574665, 0.45197398, 0.22070227]) | ||
|
|
||
|
|
||
| def test_with_mocks(): | ||
| print('Hello') | ||
| mock_shape1 = Mock() | ||
| mock_shape1.get_area.return_value = 10 | ||
|
|
||
| mock_shape2 = Mock() | ||
| mock_shape2.get_area.return_value = 20 | ||
|
|
||
| shapes = [mock_shape1,mock_shape2] | ||
|
|
||
| for shape in shapes: | ||
| print(shape.get_area()) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # This file must be used with "source bin/activate" *from bash* | ||
| # you cannot run it directly | ||
|
|
||
| deactivate () { | ||
| # reset old environment variables | ||
| if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then | ||
| PATH="${_OLD_VIRTUAL_PATH:-}" | ||
| export PATH | ||
| unset _OLD_VIRTUAL_PATH | ||
| fi | ||
| if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then | ||
| PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}" | ||
| export PYTHONHOME | ||
| unset _OLD_VIRTUAL_PYTHONHOME | ||
| fi | ||
|
|
||
| # This should detect bash and zsh, which have a hash command that must | ||
| # be called to get it to forget past commands. Without forgetting | ||
| # past commands the $PATH changes we made may not be respected | ||
| if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then | ||
| hash -r | ||
| fi | ||
|
|
||
| if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then | ||
| PS1="${_OLD_VIRTUAL_PS1:-}" | ||
| export PS1 | ||
| unset _OLD_VIRTUAL_PS1 | ||
| fi | ||
|
|
||
| unset VIRTUAL_ENV | ||
| if [ ! "$1" = "nondestructive" ] ; then | ||
| # Self destruct! | ||
| unset -f deactivate | ||
| fi | ||
| } | ||
|
|
||
| # unset irrelevant variables | ||
| deactivate nondestructive | ||
|
|
||
| VIRTUAL_ENV="/home/sl6391/python-intermediate-inflammation/venv" | ||
| export VIRTUAL_ENV | ||
|
|
||
| _OLD_VIRTUAL_PATH="$PATH" | ||
| PATH="$VIRTUAL_ENV/bin:$PATH" | ||
| export PATH | ||
|
|
||
| # unset PYTHONHOME if set | ||
| # this will fail if PYTHONHOME is set to the empty string (which is bad anyway) | ||
| # could use `if (set -u; : $PYTHONHOME) ;` in bash | ||
| if [ -n "${PYTHONHOME:-}" ] ; then | ||
| _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}" | ||
| unset PYTHONHOME | ||
| fi | ||
|
|
||
| if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then | ||
| _OLD_VIRTUAL_PS1="${PS1:-}" | ||
| if [ "x(venv) " != x ] ; then | ||
| PS1="(venv) ${PS1:-}" | ||
| else | ||
| if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then | ||
| # special case for Aspen magic directories | ||
| # see http://www.zetadev.com/software/aspen/ | ||
| PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1" | ||
| else | ||
| PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1" | ||
| fi | ||
| fi | ||
| export PS1 | ||
| fi | ||
|
|
||
| # This should detect bash and zsh, which have a hash command that must | ||
| # be called to get it to forget past commands. Without forgetting | ||
| # past commands the $PATH changes we made may not be respected | ||
| if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then | ||
| hash -r | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # This file must be used with "source bin/activate.csh" *from csh*. | ||
| # You cannot run it directly. | ||
| # Created by Davide Di Blasi <davidedb@gmail.com>. | ||
| # Ported to Python 3.3 venv by Andrew Svetlov <andrew.svetlov@gmail.com> | ||
|
|
||
| alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate' | ||
|
|
||
| # Unset irrelevant variables. | ||
| deactivate nondestructive | ||
|
|
||
| setenv VIRTUAL_ENV "/home/sl6391/python-intermediate-inflammation/venv" | ||
|
|
||
| set _OLD_VIRTUAL_PATH="$PATH" | ||
| setenv PATH "$VIRTUAL_ENV/bin:$PATH" | ||
|
|
||
|
|
||
| set _OLD_VIRTUAL_PROMPT="$prompt" | ||
|
|
||
| if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then | ||
| if ("venv" != "") then | ||
| set env_name = "venv" | ||
| else | ||
| if (`basename "VIRTUAL_ENV"` == "__") then | ||
| # special case for Aspen magic directories | ||
| # see http://www.zetadev.com/software/aspen/ | ||
| set env_name = `basename \`dirname "$VIRTUAL_ENV"\`` | ||
| else | ||
| set env_name = `basename "$VIRTUAL_ENV"` | ||
| endif | ||
| endif | ||
| set prompt = "[$env_name] $prompt" | ||
| unset env_name | ||
| endif | ||
|
|
||
| alias pydoc python -m pydoc | ||
|
|
||
| rehash |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.