Skip to content

Commit

Permalink
Merge pull request #17 from JLSteenwyk/update_python_version
Browse files Browse the repository at this point in the history
Update python version
  • Loading branch information
JLSteenwyk authored Oct 25, 2023
2 parents ac0b0f7 + e9c1595 commit f3fdcb1
Show file tree
Hide file tree
Showing 51 changed files with 836 additions and 1,035 deletions.
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

0 comments on commit f3fdcb1

Please sign in to comment.