Skip to content
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
7 changes: 5 additions & 2 deletions src/cheetahpy/cheetahpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import pandas as pd
import io

import logging

logger = logging.getLogger(__name__)

class URLs:
"""Class for retrieving GC AIP URL paths"""
Expand Down Expand Up @@ -73,7 +76,7 @@ def show_athletes(self):
try:
available_athletes = ', '.join(self.athletes)
except Exception as err:
print(f"{err}: Athletes undefinded, referencing API to load athletes")
logger.warning(f"{err}: Athletes undefinded, referencing API to load athletes")
self._get_athletes()
available_athletes = ', '.join(self.athletes)
print(available_athletes)
Expand All @@ -100,7 +103,7 @@ def _validate_athlete(self, athlete:str) -> bool:
try:
available_athletes = ', '.join(self.athletes)
except Exception as err:
print(f"{err}: Athletes undefinded, referencing API to load athletes")
logger.warning(f"{err}: Athletes undefinded, referencing API to load athletes")
self._get_athletes()
available_athletes = ', '.join(self.athletes)
assert athlete in self.athletes, f"Invalid athlete. Choose from:\n {available_athletes}"
Expand Down
7 changes: 5 additions & 2 deletions src/cheetahpy/local_opendata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import os
import json
import pandas as pd
import logging

logger = logging.getLogger(__name__)

class opendata_dataset(object):
def __init__(self, root_dir:str):
Expand Down Expand Up @@ -90,7 +92,7 @@ def _athlete_summary_path(self, athlete_id: str) -> str:
return ath_summary_path

@staticmethod
def _safe_convert(original_series:pd.Series, type_convert:type) -> pd.Series:
def _safe_convert(original_series:pd.Series, type_convert:type, warn_on_convert:bool=False) -> pd.Series:
try:
new_series = original_series.astype(type_convert)
return new_series
Expand All @@ -100,7 +102,8 @@ def _safe_convert(original_series:pd.Series, type_convert:type) -> pd.Series:
a_value_type = type(a_value[0])
else:
a_value_type = "UNKNOWN"
print(f'{err}: cannot convert {original_series.name} (of type: {a_value_type}) to type {type_convert}')
if warn_on_convert:
logger.warning(f'[{err}] cannot convert {original_series.name} (of type: {a_value_type}) to type {type_convert}')
return original_series

@staticmethod
Expand Down