Пример #1
0
    def test_two_files(self):

        data = np.arange(6).reshape(3, 2)
        save_grid_data_to_file([{
            'data': data,
            'name': 1
        }, {
            'data': 2 * data,
            'name': 2
        }],
                               directory=self.tempdir.path,
                               file_stem="qqq")
        assert_equal(
            self.tempdir.read(('qqq', 'qqq1.csv'), 'utf-8').splitlines(),
            textwrap.dedent("""\
                            idex,0,1
                            0,0,1
                            1,2,3
                            2,4,5""").splitlines())
        assert_equal(
            self.tempdir.read(('qqq', 'qqq2.csv'), 'utf-8').splitlines(),
            textwrap.dedent("""\
                            idex,0,1
                            0,0,2
                            1,4,6
                            2,8,10""").splitlines())
Пример #2
0
    def test_data_dict_row_labels(self):

        data = np.arange(6).reshape(3,2)
        save_grid_data_to_file({'data': data, 'row_labels':[8,12,6]},
                               directory=self.tempdir.path)
        assert_equal(self.tempdir.read(('out_000','out_000.csv'), 'utf-8').splitlines(),
                            textwrap.dedent("""\
                            idex,item,0,1
                            0,8,0,1
                            1,12,2,3
                            2,6,4,5""").splitlines())
Пример #3
0
    def test_data_dict_column_labels(self):

        data = np.arange(6).reshape(3,2)
        save_grid_data_to_file({'data': data, 'column_labels':['a', 'b']},
                               directory=self.tempdir.path)
        assert_equal(self.tempdir.read(('out_000','out_000.csv'), 'utf-8').splitlines(),
                            textwrap.dedent("""\
                            idex,a,b
                            0,0,1
                            1,2,3
                            2,4,5""").splitlines())
Пример #4
0
    def test_directory(self):

        data = np.arange(6).reshape(3,2)
        save_grid_data_to_file({'data': data},
                               directory=os.path.join(self.tempdir.path,'g'))
        assert_equal(self.tempdir.read(('g','out_000','out_000.csv'), 'utf-8').splitlines(),
                            textwrap.dedent("""\
                            idex,0,1
                            0,0,1
                            1,2,3
                            2,4,5""").splitlines())
Пример #5
0
    def test_data_dict_name(self):

        data = np.arange(6).reshape(3,2)
        save_grid_data_to_file({'data': data, 'name':'xx'},
                               directory=self.tempdir.path)
        assert_equal(self.tempdir.read(('out_000','out_000xx.csv'), 'utf-8').splitlines(),
                            textwrap.dedent("""\
                            idex,0,1
                            0,0,1
                            1,2,3
                            2,4,5""").splitlines())
Пример #6
0
    def test_data_dict_column_labels(self):

        data = np.arange(6).reshape(3,2)
        save_grid_data_to_file({'data': data, 'column_labels':['a', 'b']},
                               directory=self.tempdir.path)
        assert_equal(self.tempdir.read(('out_000','out_000.csv'), 'utf-8').splitlines(),
                            textwrap.dedent("""\
                            idex,a,b
                            0,0,1
                            1,2,3
                            2,4,5""").splitlines())
Пример #7
0
    def test_data_dict_row_labels(self):

        data = np.arange(6).reshape(3,2)
        save_grid_data_to_file({'data': data, 'row_labels':[8,12,6]},
                               directory=self.tempdir.path)
        assert_equal(self.tempdir.read(('out_000','out_000.csv'), 'utf-8').splitlines(),
                            textwrap.dedent("""\
                            idex,item,0,1
                            0,8,0,1
                            1,12,2,3
                            2,6,4,5""").splitlines())
Пример #8
0
    def test_data_dict_name(self):

        data = np.arange(6).reshape(3,2)
        save_grid_data_to_file({'data': data, 'name':'xx'},
                               directory=self.tempdir.path)
        assert_equal(self.tempdir.read(('out_000','out_000xx.csv'), 'utf-8').splitlines(),
                            textwrap.dedent("""\
                            idex,0,1
                            0,0,1
                            1,2,3
                            2,4,5""").splitlines())
Пример #9
0
    def test_directory(self):

        data = np.arange(6).reshape(3,2)
        save_grid_data_to_file({'data': data},
                               directory=os.path.join(self.tempdir.path,'g'))
        assert_equal(self.tempdir.read(('g','out_000','out_000.csv'), 'utf-8').splitlines(),
                            textwrap.dedent("""\
                            idex,0,1
                            0,0,1
                            1,2,3
                            2,4,5""").splitlines())
Пример #10
0
    def test_create_directory(self):

        data = np.arange(6).reshape(3,2)
        save_grid_data_to_file({'data': data},
                               directory=self.tempdir.path,
                               create_directory=False)
        assert_equal(self.tempdir.read('out_000.csv', 'utf-8').splitlines(),
                            textwrap.dedent("""\
                            idex,0,1
                            0,0,1
                            1,2,3
                            2,4,5""").splitlines())
Пример #11
0
    def test_file_stem(self):

        data = np.arange(6).reshape(3,2)
        save_grid_data_to_file({'data': data},
                               directory=self.tempdir.path,
                               file_stem="ppp")
        assert_equal(self.tempdir.read(('ppp','ppp.csv'), 'utf-8').splitlines(),
                            textwrap.dedent("""\
                            idex,0,1
                            0,0,1
                            1,2,3
                            2,4,5""").splitlines())
Пример #12
0
    def test_ext(self):

        data = np.arange(6).reshape(3,2)
        save_grid_data_to_file({'data': data},
                               directory=self.tempdir.path,
                               ext=".out")
        assert_equal(self.tempdir.read(('out_000','out_000.out'), 'utf-8').splitlines(),
                            textwrap.dedent("""\
                            ,0,1
                            0,0,1
                            1,2,3
                            2,4,5""").splitlines())
Пример #13
0
    def test_create_directory(self):

        data = np.arange(6).reshape(3,2)
        save_grid_data_to_file({'data': data},
                               directory=self.tempdir.path,
                               create_directory=False)
        assert_equal(self.tempdir.read('out_000.csv', 'utf-8').splitlines(),
                            textwrap.dedent("""\
                            idex,0,1
                            0,0,1
                            1,2,3
                            2,4,5""").splitlines())
Пример #14
0
    def test_file_stem(self):

        data = np.arange(6).reshape(3,2)
        save_grid_data_to_file({'data': data},
                               directory=self.tempdir.path,
                               file_stem="ppp")
        assert_equal(self.tempdir.read(('ppp','ppp.csv'), 'utf-8').splitlines(),
                            textwrap.dedent("""\
                            idex,0,1
                            0,0,1
                            1,2,3
                            2,4,5""").splitlines())
Пример #15
0
    def test_two_files(self):

        data = np.arange(6).reshape(3,2)
        save_grid_data_to_file([{'data': data, 'name':1},
                                {'data': 2*data, 'name':2}],
                               directory=self.tempdir.path,
                               file_stem="qqq")
        assert_equal(self.tempdir.read(('qqq','qqq1.csv'), 'utf-8').splitlines(),
                            textwrap.dedent("""\
                            idex,0,1
                            0,0,1
                            1,2,3
                            2,4,5""").splitlines())
        assert_equal(self.tempdir.read(('qqq','qqq2.csv'), 'utf-8').splitlines(),
                            textwrap.dedent("""\
                            idex,0,1
                            0,0,2
                            1,4,6
                            2,8,10""").splitlines())