diff --git a/README.md b/README.md index b165516..479d3c5 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Tris -[![Python Package tests status](https://github.com/three-body-analysis/codebase/actions/workflows/python-package.yml/badge.svg)](https://github.com/three-body-analysis/codebase/actions?query=workflow%3Apython-package) -[![Docs CI status](https://github.com/three-body-analysis/codebase/actions/workflows/docs.yml/badge.svg)](https://three-body-analysis.github.io/codebase/) +[![Python Package tests status](https://github.com/three-body-analysis/tris/actions/workflows/python-package.yml/badge.svg)](https://github.com/three-body-analysis/tris/actions?query=workflow%3Apython-package) +[![Docs CI status](https://github.com/three-body-analysis/tris/actions/workflows/docs.yml/badge.svg)](https://three-body-analysis.github.io/tris/) [![PyPI Latest Release](https://img.shields.io/pypi/v/tris.svg)](https://pypi.org/project/tris/) [![PyPI Downloads](https://static.pepy.tech/badge/tris)](https://pepy.tech/project/tris) -This repository comprises the codebase for our paper, "An Automated Screening System for Trinary Star System Candidates", -that has been submitted to _Physica Scripta_. +This repository comprises the codebase for our paper, "Tris: A Screening System for Trinary Star System Candidates", +that is in the process of being submitted to _The Astronomical Journal_. **Tris** (**Tri**nary **S**creener) is an open-source tool that offers a specialized method to determine "observed-minus-computed" (OC) diagrams from astronomical flux time series data (lightcurves) obtained from NASA's Kepler and K2 missions. @@ -38,7 +38,7 @@ files that contain the light curves for all objects classified as EBs. You can i Documentation ------------- -Read the documentation at [`https://three-body-analysis.github.io/codebase/`](https://three-body-analysis.github.io/codebase/). +Read the documentation at [`https://three-body-analysis.github.io/tris/`](https://three-body-analysis.github.io/tris/). Setup and Installation @@ -78,10 +78,10 @@ repository and store it on a local drive manually. To install Git, follow After you have successfully installed Git, you can run the following command in a terminal / Command Prompt etc: ```bash -$ git clone https://github.com/three-body-analysis/codebase.git +$ git clone https://github.com/three-body-analysis/tris.git ``` -This stores a copy in the folder `codebase`. You can then navigate into it using `cd codebase`. +This stores a copy in the folder `tris`. You can then navigate into it using `cd tris`. #### Poetry @@ -98,4 +98,9 @@ After this, you can use the following command to install this library: ```bash $ poetry install -``` \ No newline at end of file +``` + + +> [!WARNING] +> Note that this is part of a research work in the process of being published, hence this codebase will not be exceedingly updated. [Issues](https://github.com/three-body-analysis/tris/issues) and [Pull Requests](https://github.com/three-body-analysis/tris/pulls) are appreciated, so that we can work to make this library more usable by the larger astronomical community. + diff --git a/tests/test_io.py b/tests/test_io.py index b5c8903..7d7cce0 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -3,6 +3,7 @@ from glob import glob import pandas as pd import numpy as np +import os from tris.io import read_df, read_csv, read_excel, read_json @@ -10,11 +11,13 @@ warnings.filterwarnings("ignore") +# Set the file path to be relative to the directory the current file is in +os.chdir(os.path.dirname(os.path.abspath(__file__))) class DataReadTestCase(unittest.TestCase): def test_read_df(self): - df = pd.read_csv("tests/sample_data/processed.csv") - df_copy = pd.read_csv("tests/sample_data/processed.csv") + df = pd.read_csv("sample_data/processed.csv") + df_copy = pd.read_csv("sample_data/manipulated.csv") df_test_full_index = read_df(df, 0, 1) self.assertTrue(df.equals(df_test_full_index), "Full Index Read Test (identity) Failed") @@ -41,97 +44,98 @@ def test_read_df(self): self.assertTrue(df.equals(df_test_index_name), "Index, Name Read Test (manipulated) Failed") def test_csv(self): - df = pd.read_csv("tests/sample_data/processed.csv") + df = pd.read_csv("sample_data/processed.csv") - df_test_full_index = read_csv("tests/sample_data/processed.csv", 0, 1) + df_test_full_index = read_csv("sample_data/processed.csv", 0, 1) self.assertTrue(df.equals(df_test_full_index), "Full Index Read Test (identity) Failed") - df_test_full_name = read_csv("tests/sample_data/processed.csv", "time", "flux") + df_test_full_name = read_csv("sample_data/processed.csv", "time", "flux") self.assertTrue(df.equals(df_test_full_name), "Full Name Read Test (identity) Failed") - df_test_name_index = read_csv("tests/sample_data/processed.csv", "time", 1) + df_test_name_index = read_csv("sample_data/processed.csv", "time", 1) self.assertTrue(df.equals(df_test_name_index), "Name, Index Read Test (identity) Failed") - df_test_index_name = read_csv("tests/sample_data/processed.csv", 0, "flux") + df_test_index_name = read_csv("sample_data/processed.csv", 0, "flux") self.assertTrue(df.equals(df_test_index_name), "Index, Name Read Test (identity) Failed") - df_test_full_index = read_csv("tests/sample_data/manipulated.csv", 1, 3) + df_test_full_index = read_csv("sample_data/manipulated.csv", 1, 3) self.assertTrue(df.equals(df_test_full_index), "Full Index Read Test (manipulated) Failed") - df_test_full_name = read_csv("tests/sample_data/manipulated.csv", "time", "flux") + df_test_full_name = read_csv("sample_data/manipulated.csv", "time", "flux") self.assertTrue(df.equals(df_test_full_name), "Full Name Read Test (manipulated) Failed") - df_test_name_index = read_csv("tests/sample_data/manipulated.csv", "time", 3) + df_test_name_index = read_csv("sample_data/manipulated.csv", "time", 3) self.assertTrue(df.equals(df_test_name_index), "Name, Index Read Test (manipulated) Failed") - df_test_index_name = read_csv("tests/sample_data/manipulated.csv", 1, "flux") + df_test_index_name = read_csv("sample_data/manipulated.csv", 1, "flux") self.assertTrue(df.equals(df_test_index_name), "Index, Name Read Test (manipulated) Failed") def test_excel(self): - df = pd.read_csv("tests/sample_data/processed.csv") + df = pd.read_csv("sample_data/processed.csv") - df_test_index_index_index = read_excel("tests/sample_data/processed.xlsx", 0, 1, 0) - self.assertTrue(df.equals(df_test_index_index_index), "Index-Index-Index Read Test (identity) Failed") + df_test_index_index_index = read_excel("sample_data/processed.xlsx", 0, 1, 0) + self.assertTrue(np.isclose(df, df_test_index_index_index).all(), "Index-Index-Index Read Test (identity) Failed") - df_test_index_index_name = read_excel("tests/sample_data/processed.xlsx", 0, 1, "processed") - self.assertTrue(df.equals(df_test_index_index_name), "Index-Index-Name Read Test (identity) Failed") + df_test_index_index_name = read_excel("sample_data/processed.xlsx", 0, 1, "processed") + self.assertTrue(np.isclose(df, df_test_index_index_name).all(), "Index-Index-Name Read Test (identity) Failed") - df_test_index_name_index = read_excel("tests/sample_data/processed.xlsx", 0, "flux", 0) - self.assertTrue(df.equals(df_test_index_name_index), "Index-Name-Index Read Test (identity) Failed") + df_test_index_name_index = read_excel("sample_data/processed.xlsx", 0, "flux", 0) + self.assertTrue(np.isclose(df, df_test_index_name_index).all(), "Index-Name-Index Read Test (identity) Failed") - df_test_index_name_name = read_excel("tests/sample_data/processed.xlsx", 0, "flux", "processed") - self.assertTrue(df.equals(df_test_index_name_name), "Index-Name-Name Read Test (identity) Failed") + df_test_index_name_name = read_excel("sample_data/processed.xlsx", 0, "flux", "processed") + self.assertTrue(np.isclose(df, df_test_index_name_name).all(), "Index-Name-Name Read Test (identity) Failed") - df_test_name_index_index = read_excel("tests/sample_data/processed.xlsx", "time", 1, 0) - self.assertTrue(df.equals(df_test_name_index_index), "Name-Index-Index Read Test (identity) Failed") + df_test_name_index_index = read_excel("sample_data/processed.xlsx", "time", 1, 0) + self.assertTrue(np.isclose(df, df_test_name_index_index).all(), "Name-Index-Index Read Test (identity) Failed") - df_test_name_index_name = read_excel("tests/sample_data/processed.xlsx", "time", 1, "processed") - self.assertTrue(df.equals(df_test_name_index_name), "Name-Index-Name Read Test (identity) Failed") + df_test_name_index_name = read_excel("sample_data/processed.xlsx", "time", 1, "processed") + self.assertTrue(np.isclose(df, df_test_name_index_name).all(), "Name-Index-Name Read Test (identity) Failed") - df_test_name_name_index = read_excel("tests/sample_data/processed.xlsx", "time", "flux", 0) - self.assertTrue(df.equals(df_test_name_name_index), "Name-Name-Index Read Test (identity) Failed") + df_test_name_name_index = read_excel("sample_data/processed.xlsx", "time", "flux", 0) + self.assertTrue(np.isclose(df, df_test_name_name_index).all(), "Name-Name-Index Read Test (identity) Failed") - df_test_name_name_name = read_excel("tests/sample_data/processed.xlsx", "time", "flux", "processed") - self.assertTrue(df.equals(df_test_name_name_name), "Name-Name-Name Read Test (identity) Failed") + df_test_name_name_name = read_excel("sample_data/processed.xlsx", "time", "flux", "processed") + self.assertTrue(np.isclose(df, df_test_name_name_name).all(), "Name-Name-Name Read Test (identity) Failed") - df_test_index_index_index = read_excel("tests/sample_data/manipulated.xlsx", 1, 3, 0) - self.assertTrue(df.equals(df_test_index_index_index), "Index-Index-Index Read Test (manipulated) Failed") + df_test_index_index_index = read_excel("sample_data/manipulated.xlsx", 1, 3, 0) + self.assertTrue(np.isclose(df, df_test_index_index_index).all(), "Index-Index-Index Read Test (manipulated) Failed") - df_test_index_index_name = read_excel("tests/sample_data/manipulated.xlsx", 1, 3, "manipulated") - self.assertTrue(df.equals(df_test_index_index_name), "Index-Index-Name Read Test (manipulated) Failed") + df_test_index_index_name = read_excel("sample_data/manipulated.xlsx", 1, 3, "manipulated") + self.assertTrue(np.isclose(df, df_test_index_index_name).all(), "Index-Index-Name Read Test (manipulated) Failed") - df_test_index_name_index = read_excel("tests/sample_data/manipulated.xlsx", 1, "flux", 0) - self.assertTrue(df.equals(df_test_index_name_index), "Index-Name-Index Read Test (manipulated) Failed") + df_test_index_name_index = read_excel("sample_data/manipulated.xlsx", 1, "flux", 0) + self.assertTrue(np.isclose(df, df_test_index_name_index).all(), "Index-Name-Index Read Test (manipulated) Failed") - df_test_index_name_name = read_excel("tests/sample_data/manipulated.xlsx", 1, "flux", "manipulated") - self.assertTrue(df.equals(df_test_index_name_name), "Index-Name-Name Read Test (manipulated) Failed") + df_test_index_name_name = read_excel("sample_data/manipulated.xlsx", 1, "flux", "manipulated") + self.assertTrue(np.isclose(df, df_test_index_name_name).all(), "Index-Name-Name Read Test (manipulated) Failed") - df_test_name_index_index = read_excel("tests/sample_data/manipulated.xlsx", "time", 3, 0) - self.assertTrue(df.equals(df_test_name_index_index), "Name-Index-Index Read Test (manipulated) Failed") + df_test_name_index_index = read_excel("sample_data/manipulated.xlsx", "time", 3, 0) + self.assertTrue(np.isclose(df, df_test_name_index_index).all(), "Name-Index-Index Read Test (manipulated) Failed") - df_test_name_index_name = read_excel("tests/sample_data/manipulated.xlsx", "time", 3, "manipulated") - self.assertTrue(df.equals(df_test_name_index_name), "Name-Index-Name Read Test (manipulated) Failed") + df_test_name_index_name = read_excel("sample_data/manipulated.xlsx", "time", 3, "manipulated") + self.assertTrue(np.isclose(df, df_test_name_index_name).all(), "Name-Index-Name Read Test (manipulated) Failed") - df_test_name_name_index = read_excel("tests/sample_data/manipulated.xlsx", "time", "flux", 0) - self.assertTrue(df.equals(df_test_name_name_index), "Name-Name-Index Read Test (manipulated) Failed") + df_test_name_name_index = read_excel("sample_data/manipulated.xlsx", "time", "flux", 0) + self.assertTrue(np.isclose(df, df_test_name_name_index).all(), "Name-Name-Index Read Test (manipulated) Failed") - df_test_name_name_name = read_excel("tests/sample_data/manipulated.xlsx", "time", "flux", "manipulated") - self.assertTrue(df.equals(df_test_name_name_name), "Name-Name-Name Read Test (manipulated) Failed") + df_test_name_name_name = read_excel("sample_data/manipulated.xlsx", "time", "flux", "manipulated") + self.assertTrue(np.isclose(df, df_test_name_name_name).all(), "Name-Name-Name Read Test (manipulated) Failed") def test_json(self): - df = pd.read_csv("tests/sample_data/processed.csv") + df = pd.read_csv("sample_data/processed.csv") - df_test_full_index = read_json("tests/sample_data/processed.json", 0, 1) - self.assertTrue(df.equals(df_test_full_index), "Full Index Read Test (identity) Failed") + df_test_full_index = read_json("sample_data/processed.json", 0, 1) + print(df, df_test_full_index) + self.assertTrue(np.isclose(df, df_test_full_index).all(), "Full Index Read Test (identity) Failed") - df_test_full_name = read_json("tests/sample_data/processed.json", "time", "flux") - self.assertTrue(df.equals(df_test_full_name), "Full Name Read Test (identity) Failed") + df_test_full_name = read_json("sample_data/processed.json", "time", "flux") + self.assertTrue(np.isclose(df, df_test_full_name).all(), "Full Name Read Test (identity) Failed") - df_test_name_index = read_json("tests/sample_data/processed.json", "time", 1) - self.assertTrue(df.equals(df_test_name_index), "Name, Index Read Test (identity) Failed") + df_test_name_index = read_json("sample_data/processed.json", "time", 1) + self.assertTrue(np.isclose(df, df_test_name_index).all(), "Name, Index Read Test (identity) Failed") - df_test_index_name = read_json("tests/sample_data/processed.json", 0, "flux") - self.assertTrue(df.equals(df_test_index_name), "Index, Name Read Test (identity) Failed") + df_test_index_name = read_json("sample_data/processed.json", 0, "flux") + self.assertTrue(np.isclose(df, df_test_index_name).all(), "Index, Name Read Test (identity) Failed") if __name__ == '__main__':