Exemplo n.º 1
0
    def test_source_mismatch(self):
        # Metadata created from an artifact vs not shouldn't compare equal,
        # even if the data is the same.
        artifact = Artifact.import_data('Mapping', {'a': '1', 'b': '2'})
        md_from_artifact = artifact.view(Metadata)

        md_no_artifact = Metadata(md_from_artifact.to_dataframe())

        pdt.assert_frame_equal(md_from_artifact.to_dataframe(),
                               md_no_artifact.to_dataframe())
        self.assertReallyNotEqual(md_from_artifact, md_no_artifact)
Exemplo n.º 2
0
    def test_source_mismatch(self):
        # Metadata created from an artifact vs not shouldn't compare equal,
        # even if the data is the same.
        artifact = Artifact.import_data('Mapping', {'a': '1', 'b': '2'})
        md_from_artifact = Metadata.from_artifact(artifact)

        md_no_artifact = Metadata(md_from_artifact.to_dataframe())

        pdt.assert_frame_equal(md_from_artifact.to_dataframe(),
                               md_no_artifact.to_dataframe())
        self.assertReallyNotEqual(md_from_artifact, md_no_artifact)
Exemplo n.º 3
0
    def test_to_dataframe(self):
        index = pd.Index(['a', 'b', 'c'], name='id', dtype=object)
        df = pd.DataFrame({'col1': [2, 1, 3],
                           'col2': ['2', '1', '3'],
                           'col3': ['4.0', '5.2', '6.9'],
                           'col4': [4.0, 5.2, 6.9],
                           'col5': ['a', 'b', 'c']},
                          index=index)
        metadata = Metadata(df)

        obs_df = metadata.to_dataframe()

        self.assertEqual(dict(obs_df.dtypes),
                         {'col1': np.float, 'col2': object, 'col3': object,
                          'col4': np.float, 'col5': object})
Exemplo n.º 4
0
    def test_to_dataframe(self):
        index = pd.Index(['a', 'b', 'c'], name='id', dtype=object)
        df = pd.DataFrame({'col1': [2, 1, 3],
                           'col2': ['2', '1', '3'],
                           'col3': ['4.0', '5.2', '6.9'],
                           'col4': [4.0, 5.2, 6.9],
                           'col5': ['a', 'b', 'c']},
                          index=index)
        metadata = Metadata(df)

        obs_df = metadata.to_dataframe()

        self.assertEqual(dict(obs_df.dtypes),
                         {'col1': np.float, 'col2': object, 'col3': object,
                          'col4': np.float, 'col5': object})