Skip to content
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

Update python version #17

Merged
merged 2 commits into from
Oct 25, 2023
Merged
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
9 changes: 5 additions & 4 deletions phykit/helpers/boolean_argument_parsing.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import argparse


def str2bool(v):
if isinstance(v, bool):
return v
if v.lower() in ('true', 't', '1'):
return v
if v.lower() in ("true", "t", "1"):
return True
elif v.lower() in ('false', 'f', '0'):
elif v.lower() in ("false", "f", "0"):
return False
else:
raise argparse.ArgumentTypeError('Boolean value expected.')
raise argparse.ArgumentTypeError("Boolean value expected.")
4 changes: 2 additions & 2 deletions phykit/helpers/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ def get_alignment_and_format(alignment_file_path: str):
print("Please check file name and pathing")
sys.exit()


def read_single_column_file_to_list(single_col_file_path: str) -> list:
try:
with open(single_col_file_path) as f:
return [line.rstrip('\n').strip() for line in f]
return [line.rstrip("\n").strip() for line in f]
except FileNotFoundError:
print(f"{single_col_file_path} corresponds to no such file or directory.")
print("Please check file name and pathing")
sys.exit()

36 changes: 15 additions & 21 deletions phykit/helpers/stats_summary.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
import statistics as stat
import sys

import numpy as np


def calculate_summary_statistics_from_arr(
arr
):
def calculate_summary_statistics_from_arr(arr):
"""
calcuate summary statistics for an input list
"""
stats = dict(
mean = stat.mean(arr),
median = stat.median(arr),
twenty_fifth = np.percentile(arr, 25),
seventy_fifth = np.percentile(arr, 75),
minimum = np.min(arr),
maximum = np.max(arr),
standard_deviation = stat.stdev(arr),
variance = stat.variance(arr)
mean=stat.mean(arr),
median=stat.median(arr),
twenty_fifth=np.percentile(arr, 25),
seventy_fifth=np.percentile(arr, 75),
minimum=np.min(arr),
maximum=np.max(arr),
standard_deviation=stat.stdev(arr),
variance=stat.variance(arr),
)

return stats

def calculate_summary_statistics_from_dict(
dat: dict
):

def calculate_summary_statistics_from_dict(dat: dict):
"""
calcuate summary statistics for a dictionary
"""
Expand All @@ -37,16 +33,14 @@ def calculate_summary_statistics_from_dict(
minimum=np.min([*dat.values()]),
maximum=np.max([*dat.values()]),
standard_deviation=stat.stdev([*dat.values()]),
variance=stat.variance([*dat.values()])
variance=stat.variance([*dat.values()]),
)

return stats

def print_summary_statistics(
stats: list
):
"""
"""

def print_summary_statistics(stats: list):
""" """
try:
print(f"mean: {round(stats['mean'], 4)}")
print(f"median: {round(stats['median'], 4)}")
Expand Down
Loading
Loading