-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from WenjieDu/dev
Simplify API names, add the config file for ReadTheDocs
- Loading branch information
Showing
7 changed files
with
293 additions
and
162 deletions.
There are no files selected for viewing
This file contains 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,29 @@ | ||
# This is file is used to help customize TSDB documentation building process on ReadTheDocs. | ||
|
||
version: 2 | ||
|
||
formats: | ||
- htmlzip | ||
- epub | ||
|
||
sphinx: | ||
configuration: docs/conf.py | ||
fail_on_warning: false | ||
|
||
build: | ||
os: ubuntu-22.04 | ||
|
||
tools: | ||
python: "3.10" | ||
|
||
jobs: | ||
pre_install: | ||
- python -m pip install --upgrade pip | ||
- pip install pandas numpy scipy scikit-learn | ||
- pip install sphinx==6.2.1 docutils==0.19 sphinxcontrib-bibtex==2.1.4 sphinxcontrib-gtagjs sphinx-autodoc-typehints furo==2023.07.26 | ||
|
||
post_install: | ||
- pip install docutils==0.20 | ||
# this version fixes issue#102, put it in post_install to avoid being | ||
# overwritten by other versions (like 0.19) while installing other packages |
This file contains 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 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 |
---|---|---|
@@ -1,13 +1,16 @@ | ||
""" | ||
TSDB test cases | ||
TSDB unit testing cases. | ||
""" | ||
|
||
# Created by Wenjie Du <[email protected]> | ||
# License: GLP-v3 | ||
|
||
import os | ||
import unittest | ||
|
||
import tsdb | ||
from tsdb.database import DATABASE | ||
from tsdb.utils.logging import Logger | ||
|
||
DATASETS_TO_TEST = [ | ||
"physionet_2012", | ||
|
@@ -19,28 +22,60 @@ | |
|
||
|
||
class TestTSDB(unittest.TestCase): | ||
logger_creator = Logger(name="testing log", logging_level="debug") | ||
logger = logger_creator.logger | ||
|
||
def test_0_available_datasets(self): | ||
all_datasets_in_database = tsdb.list_database() | ||
available_datasets = tsdb.list_available_datasets() | ||
available_datasets = tsdb.list() | ||
assert len(available_datasets) > 0 | ||
assert len(all_datasets_in_database) == len(available_datasets) | ||
assert len(DATABASE) == len(available_datasets) | ||
|
||
def test_1_downloading_only(self): | ||
tsdb.download_and_extract("ucr_uea_Wine", "./save_it_here") | ||
file_list = os.listdir() | ||
assert len(file_list) > 0 | ||
tsdb.purge_given_path("save_it_here") | ||
tsdb.purge_path("save_it_here") | ||
|
||
def test_2_dataset_loading(self): | ||
for d_ in DATASETS_TO_TEST: | ||
data = tsdb.load_dataset(d_) | ||
data = tsdb.load(d_) | ||
assert isinstance(data, dict), f"Loaded dataset {d_} is not a dict." | ||
|
||
def test_3_dataset_purging(self): | ||
cached_datasets = tsdb.list_cached_data() | ||
cached_datasets = tsdb.list_cache() | ||
assert isinstance(cached_datasets, list) | ||
tsdb.delete_cached_data("physionet_2012") # delete single | ||
tsdb.delete_cached_data() # delete all | ||
tsdb.delete_cache("physionet_2012") # delete single | ||
tsdb.delete_cache() # delete all | ||
|
||
def test_4_logging(self): | ||
# different level logging | ||
self.logger.debug("debug") | ||
self.logger.info("info") | ||
self.logger.warning("warning") | ||
self.logger.error("error") | ||
|
||
# change logging level | ||
self.logger_creator.set_level("info") | ||
assert ( | ||
self.logger.level == 20 | ||
), f"the level of logger is {self.logger.level}, not INFO" | ||
self.logger_creator.set_level("warning") | ||
assert ( | ||
self.logger.level == 30 | ||
), f"the level of logger is {self.logger.level}, not WARNING" | ||
self.logger_creator.set_level("error") | ||
assert ( | ||
self.logger.level == 40 | ||
), f"the level of logger is {self.logger.level}, not ERROR" | ||
self.logger_creator.set_level("debug") | ||
assert ( | ||
self.logger.level == 10 | ||
), f"the level of logger is {self.logger.level}, not DEBUG" | ||
|
||
# save log into file | ||
self.logger_creator.set_saving_path("test_log", "testing.log") | ||
assert os.path.exists("test_log/testing.log") | ||
tsdb.purge_path("test_log/testing.log", ignore_errors=True) | ||
|
||
|
||
if __name__ == "__main__": | ||
|
This file contains 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
""" | ||
tsdb package | ||
TSDB (Time Series Data Beans): a Python toolbox to ease loading public time-series datasets. | ||
""" | ||
|
||
# Created by Wenjie Du <[email protected]> | ||
|
@@ -21,38 +21,42 @@ | |
# | ||
# Dev branch marker is: 'X.Y.dev' or 'X.Y.devN' where N is an integer. | ||
# 'X.Y.dev0' is the canonical version of 'X.Y.dev' | ||
__version__ = "0.1" | ||
__version__ = "0.1.1" | ||
|
||
|
||
try: | ||
from tsdb.data_processing import ( | ||
list_database, | ||
list_available_datasets, | ||
window_truncate, | ||
download_and_extract, | ||
load_dataset, | ||
delete_cached_data, | ||
purge_given_path, | ||
list_cached_data, | ||
CACHED_DATASET_DIR, | ||
pickle_dump, | ||
pickle_load, | ||
) | ||
|
||
except Exception as e: | ||
print(e) | ||
from tsdb.data_processing import ( | ||
list, | ||
load, | ||
download_and_extract, | ||
list_cache, | ||
delete_cache, | ||
purge_path, | ||
CACHED_DATASET_DIR, | ||
pickle_dump, | ||
pickle_load, | ||
# below are deprecated functions, import for now, will be removed in v0.2 | ||
list_database, | ||
list_available_datasets, | ||
list_cached_data, | ||
load_dataset, | ||
delete_cached_data, | ||
) | ||
|
||
__all__ = [ | ||
"__version__", | ||
"list_database", | ||
"list_available_datasets", | ||
"window_truncate", | ||
"list", | ||
"load", | ||
"download_and_extract", | ||
"load_dataset", | ||
"delete_cached_data", | ||
"purge_given_path", | ||
"list_cached_data", | ||
"list_cache", | ||
"delete_cache", | ||
"purge_path", | ||
"CACHED_DATASET_DIR", | ||
"pickle_dump", | ||
"pickle_load", | ||
# below are deprecated functions, import for now, will be removed in v0.2 | ||
"list_database", | ||
"list_available_datasets", | ||
"list_cached_data", | ||
"load_dataset", | ||
"delete_cached_data", | ||
] |
Oops, something went wrong.