From 932dc0882b194906790a5b99a162e77318892b16 Mon Sep 17 00:00:00 2001 From: lokijuhy Date: Thu, 4 Mar 2021 22:05:37 +0100 Subject: [PATCH 1/2] wordsmithing --- docs/getting_started.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 613ab21..696b2dc 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -307,13 +307,14 @@ Here's a toy example of working with ``SelfAwareData``: View your `SelfAwareData` tree with the datatc web app! ''''''''''''''''''''''''''''''''''''''''''''''''''''''' -You can view the tree of how your SelfAwareData files are related in the datatc web app. -To start the web app, run the ``datatc_app`` command in your shell and provide the name of the data directory you'd like to view. -This data directory name must have been previously registered to datatc with ``DataDirectory.regiser_project()``. +You can view the tree of how your `SelfAwareData` files are related in the `datatc` web app. +To start the web app, run the ``datatc_app`` command in your shell +and provide the name of the project whose data directory you'd like to view. ->>> datatc_app +>>> datatc_app -If you need a reminder of what project hints you've registered with datatc, run ``datatc_list``. +This project must have been previously registered to datatc with ``DataDirectory.register_project()``. +If you need a reminder of what projects you've registered with `datatc`, run ``datatc_list``. .. note:: To use the web app, install datatc with the extra app dependencies: ``pip install datatc[app]``. From df038dad12931bb0e8bedbdd7c73080e126051a3 Mon Sep 17 00:00:00 2001 From: lokijuhy Date: Wed, 10 Mar 2021 14:01:13 +0100 Subject: [PATCH 2/2] fix and test --- datatc/self_aware_data.py | 4 ++-- tests/test_self_aware_data.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/datatc/self_aware_data.py b/datatc/self_aware_data.py index 75f07cf..0803d8a 100644 --- a/datatc/self_aware_data.py +++ b/datatc/self_aware_data.py @@ -358,7 +358,7 @@ def __init__(self, data: Any, metadata: TransformSequenceConvertible = None): self.transform_sequence = TransformSequence(metadata) @classmethod - def load_from_file(cls, file_path: str) -> 'SelfAwareData': + def load_from_file(cls, file_path: str, **kwargs) -> 'SelfAwareData': """ Create a SelfAwareData object with a initial SourceFileTransformStep @@ -368,7 +368,7 @@ def load_from_file(cls, file_path: str) -> 'SelfAwareData': Returns: SelfAwareData with a TransformSequence containing a SourceFileTransformStep pointing to file_path """ - data = MagicDataInterface.load(file_path) + data = MagicDataInterface.load(file_path, **kwargs) metadata = [{'file_path': file_path}] return cls(data, metadata) diff --git a/tests/test_self_aware_data.py b/tests/test_self_aware_data.py index 04edae3..f14398d 100644 --- a/tests/test_self_aware_data.py +++ b/tests/test_self_aware_data.py @@ -181,6 +181,16 @@ def test_load_SAD_from_file(self): self.raw_df.to_csv(raw_data_path, index=False) from_file_sad = SelfAwareData.load_from_file(raw_data_path) + pd.testing.assert_frame_equal(from_file_sad.data, self.raw_df) + self.assertEqual(len(from_file_sad.transform_sequence.sequence), 1) + self.assertTrue(type(from_file_sad.transform_sequence.sequence[0]), SourceFileTransformStep) + + def test_load_SAD_from_file_with_kwargs(self): + raw_data_path = Path(self.test_dir, 'raw_df.csv') + self.raw_df.to_csv(raw_data_path, index=False, sep='|') + from_file_sad = SelfAwareData.load_from_file(raw_data_path, sep='|') + + pd.testing.assert_frame_equal(from_file_sad.data, self.raw_df) self.assertEqual(len(from_file_sad.transform_sequence.sequence), 1) self.assertTrue(type(from_file_sad.transform_sequence.sequence[0]), SourceFileTransformStep)