示例#1
0
    def test_prop_dict_ylabel(self):
        fig = plot_single_material_vs_depth((self.a, self.b),
                                            self.xlabels,
                                            prop_dict={'ylabel': 'hello'})
        ax1 = fig.get_axes()[0]

        assert_equal(ax1.get_ylabel(), 'hello')
示例#2
0
def test_to_dict_recursive_circular():

    class Brother(TInterface):

        _dict_attrs = (
            'name',
            'siblings'
        )

        def __init__(self, name):
            self.name = name
            self.siblings = []

        def __repr__(self):
            return 'Brother: %s' % (self.name)

    tom = Brother('tom')
    jerry = Brother('jerry')
    tom.siblings.append(jerry)
    jerry.siblings.append(tom)

    result = to_dict_recursive(tom)
    result2 = to_dict_recursive(jerry)

    assert_equal(
        result,
        {'name': 'tom', 'siblings': [{'name': 'jerry', 'siblings': []}]}
    )

    assert_equal(
        result2,
        {'name': 'jerry', 'siblings': [{'name': 'tom', 'siblings': []}]}
    )
示例#3
0
    def test_area(self):

        assert_equal(integrate_f_over_polygon_code(1).splitlines(),
                     'def ifxy(pts):\n    "Integrate f = 1 over '
                     'polygon"\n\n    x, y, z = xyz_from_pts(pts, True)'
                     '\n\n    return np.sum((x[:-1]/2 + x[1:]/2)*(-y[:-1] '
                     '+ y[1:]))'.splitlines())
示例#4
0
    def test_prop_dict_ylabel(self):
        fig = plot_single_material_vs_depth((self.a, self.b),
                                            self.xlabels,
                                            prop_dict={'ylabel': 'hello'})
        ax1 = fig.get_axes()[0]

        assert_equal(ax1.get_ylabel(), 'hello')
示例#5
0
    def test_defaults(self):
        fig = plot_single_material_vs_depth((self.a, self.b), self.xlabels)

        assert_equal(len(fig.get_axes()), 2)
        ax1 = fig.get_axes()[0]
        line1= ax1.get_lines()[0]

        ax2 = fig.get_axes()[1]
        line2 = ax2.get_lines()[0]

        assert_allclose(line1.get_xydata()[0],
                     np.array([ 1., 0.]))
        assert_allclose(line1.get_xydata()[-1],
                     np.array([ 2., 1]))

        assert_allclose(line2.get_xydata()[0],
                     np.array([ 2., 0.]))
        assert_allclose(line2.get_xydata()[-1],
                     np.array([ 3., 1]))

        assert_equal(ax1.get_xlabel(), 'a')
        assert_equal(ax2.get_xlabel(), 'b')

        assert_equal(ax1.get_ylabel(), 'Depth, z')
        assert_equal(ax2.get_ylabel(), '')
示例#6
0
def test_initialize_objects_attributes():
    """test for initialize_objects_attributes function"""
    #initialize_objects_attributes(obj, attributes=[], defaults = dict(),  not_found_value = None):

    a = EmptyClass()
    initialize_objects_attributes(a,attributes=['a','b'], defaults={'a': 6})
    assert_equal([a.a,a.b],[6,None])
示例#7
0
def test_to_dict_recursive_circular():
    class Brother(TInterface):

        _dict_attrs = ('name', 'siblings')

        def __init__(self, name):
            self.name = name
            self.siblings = []

        def __repr__(self):
            return 'Brother: %s' % (self.name)

    tom = Brother('tom')
    jerry = Brother('jerry')
    tom.siblings.append(jerry)
    jerry.siblings.append(tom)

    result = to_dict_recursive(tom)
    result2 = to_dict_recursive(jerry)

    assert_equal(result, {
        'name': 'tom',
        'siblings': [{
            'name': 'jerry',
            'siblings': []
        }]
    })

    assert_equal(result2, {
        'name': 'jerry',
        'siblings': [{
            'name': 'tom',
            'siblings': []
        }]
    })
示例#8
0
    def test_defaults(self):
        fig = plot_single_material_vs_depth((self.a, self.b), self.xlabels)

        assert_equal(len(fig.get_axes()), 2)
        ax1 = fig.get_axes()[0]
        line1= ax1.get_lines()[0]

        ax2 = fig.get_axes()[1]
        line2 = ax2.get_lines()[0]

        assert_allclose(line1.get_xydata()[0],
                     np.array([ 1., 0.]))
        assert_allclose(line1.get_xydata()[-1],
                     np.array([ 2., 1]))

        assert_allclose(line2.get_xydata()[0],
                     np.array([ 2., 0.]))
        assert_allclose(line2.get_xydata()[-1],
                     np.array([ 3., 1]))

        assert_equal(ax1.get_xlabel(), 'a')
        assert_equal(ax2.get_xlabel(), 'b')

        assert_equal(ax1.get_ylabel(), 'Depth, z')
        assert_equal(ax2.get_ylabel(), '')
示例#9
0
def test_check_attribute_pairs_have_equal_length():
    """test for check_attribute_pairs_have_equal_length function"""
    #check_attribute_pairs_have_equal_length(obj, attributes=[])

    a = EmptyClass()

    a.a = None
    a.b = [7, 8]
    a.c = [8]
    a.d = [6, 7]
    a.e = 8

    #    assert_raises(ValueError, check_attribute_pairs_have_equal_length, a,
    #                  attributes=[['a','b']])
    assert_raises(ValueError,
                  check_attribute_pairs_have_equal_length,
                  a,
                  attributes=[['b', 'c']])
    assert_raises(TypeError,
                  check_attribute_pairs_have_equal_length,
                  a,
                  attributes=[['b', 'e']])

    assert_equal(
        check_attribute_pairs_have_equal_length(a, attributes=[['b', 'd']]),
        None)
示例#10
0
def test_initialize_objects_attributes():
    """test for initialize_objects_attributes function"""
    #initialize_objects_attributes(obj, attributes=[], defaults = dict(),  not_found_value = None):

    a = EmptyClass()
    initialize_objects_attributes(a, attributes=['a', 'b'], defaults={'a': 6})
    assert_equal([a.a, a.b], [6, None])
示例#11
0
    def test_RLzero(self):

        fig = plot_generic_loads([[self.triple1], [self.triple2]],
                                 load_names=self.load_names,
                                 H=2.0,
                                 RLzero=1)

        ax1 = fig.get_axes()[0]
        line1 = ax1.get_lines()[0]
        ax2 = fig.get_axes()[1]
        line2 = ax2.get_lines()[0]
        ax3 = fig.get_axes()[2]
        line3 = ax3.get_lines()[0]
        ax4 = fig.get_axes()[3]
        line4 = ax4.get_lines()[0]

        #first row of charts
        assert_allclose(line1.get_xydata()[0], np.array([0, 0]))
        assert_allclose(line1.get_xydata()[-1],
                        np.array([10, 1 * np.cos(0.5 * 10 + 0.3)]))

        assert_allclose(line2.get_xydata()[0], np.array([1, 1]))
        assert_allclose(line2.get_xydata()[-1], np.array([0.5, -1]))

        #2nd row of charts
        assert_allclose(line3.get_xydata()[0], np.array([0, 0]))
        assert_allclose(line3.get_xydata()[-1], np.array([9, 2]))

        assert_allclose(line4.get_xydata()[0], np.array([1, 1]))
        assert_allclose(line4.get_xydata()[-1], np.array([0.8, -1]))

        assert_equal(ax2.get_ylabel(), 'RL')
        assert_equal(ax4.get_ylabel(), 'RL')
示例#12
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())
示例#13
0
 def test_propdict_legend_prop_title(self):
     fig = plot_generic_loads([[self.triple1], [self.triple2]],
                               load_names=self.load_names,
                        prop_dict={'legend_prop':{'title':'abc'}})
     ax1 = fig.get_axes()[0]
     ax3 = fig.get_axes()[2]
     assert_equal(ax1.get_legend().get_title().get_text(), 'abc')
     assert_equal(ax3.get_legend().get_title().get_text(), 'abc')
示例#14
0
 def test_propdict_legend_prop_title(self):
     fig = plot_generic_loads([[self.triple1], [self.triple2]],
                               load_names=self.load_names,
                        prop_dict={'legend_prop':{'title':'abc'}})
     ax1 = fig.get_axes()[0]
     ax3 = fig.get_axes()[2]
     assert_equal(ax1.get_legend().get_title().get_text(), 'abc')
     assert_equal(ax3.get_legend().get_title().get_text(), 'abc')
示例#15
0
    def test_area(self):

        assert_equal(
            integrate_f_over_polygon_code(1).splitlines(),
            'def ifxy(pts):\n    "Integrate f = 1 over '
            'polygon"\n\n    x, y, z = xyz_from_pts(pts, True)'
            '\n\n    return np.sum((x[:-1]/2 + x[1:]/2)*(-y[:-1] '
            '+ y[1:]))'.splitlines())
示例#16
0
 def test_save_data_input_text(self):
     a = InputFileLoaderCheckerSaver()
     a._input_text= "hello"
     a.save_data_to_file=True
     a._save_data()
     assert_equal(self.tempdir.read(
             ('out0002','out0002_input_original.py'), 'utf-8').strip().splitlines(),
                  'hello'.splitlines())
示例#17
0
    def test_check_attributes_to_force_same_len(self):
        a = InputFileLoaderCheckerSaver()
        a.a = [4,5]
        a.c=None
        a._attributes_to_force_same_len = ['a c'.split()]
        a.check_input_attributes()

        assert_equal(a.c, [None, None])
示例#18
0
    def test_determine_output_stem_directory(self):
        a = InputFileLoaderCheckerSaver()
        a.directory = os.path.join(self.tempdir.path, 'what')
        a._determine_output_stem()

        assert_equal(
            a._file_stem,
            os.path.join(self.tempdir.path, 'what', 'out0002', 'out0002'))
示例#19
0
    def test_check_attributes_to_force_same_len(self):
        a = InputFileLoaderCheckerSaver()
        a.a = [4, 5]
        a.c = None
        a._attributes_to_force_same_len = ['a c'.split()]
        a.check_input_attributes()

        assert_equal(a.c, [None, None])
示例#20
0
 def test_propdict_legend_prop_title(self):
     fig = plot_vs_depth(self.x,
                         self.z, ['a', 'b', 'c'],
                         prop_dict={'legend_prop': {
                             'title': 'abc'
                         }})
     ax = fig.get_axes()[0]
     assert_equal(ax.get_legend().get_title().get_text(), 'abc')
示例#21
0
    def test_propdict_has_legend(self):

        fig = plot_vs_depth(self.x,
                            self.z, ['a', 'b', 'c'],
                            prop_dict={'has_legend': False})
        ax = fig.get_axes()[0]

        assert_equal(ax.get_legend(), None)
示例#22
0
 def test_save_data_input_text(self):
     a = InputFileLoaderCheckerSaver()
     a._input_text= "hello"
     a.save_data_to_file=True
     a._save_data()
     assert_equal(self.tempdir.read(
             ('out0002','out0002_input_original.py'), 'utf-8').strip().splitlines(),
                  'hello'.splitlines())
示例#23
0
    def test_propdict_has_legend(self):


        fig = plot_vs_depth(self.x, self.z, ['a', 'b', 'c'],
                           prop_dict={'has_legend': False})
        ax = fig.get_axes()[0]

        assert_equal(ax.get_legend(), None)
示例#24
0
    def test_prop_dict_depth_axis_label(self):
        fig = plot_generic_loads([[self.triple1], [self.triple2]],
                                 load_names=self.load_names,
                                 prop_dict={'depth_axis_label': 'hello'})

        ax2 = fig.get_axes()[1]
        ax4 = fig.get_axes()[3]
        assert_equal(ax2.get_xlabel(), '')
        assert_equal(ax4.get_xlabel(), 'hello')
示例#25
0
    def test_prop_dict_time_axis_label(self):
        fig = plot_generic_loads([[self.triple1], [self.triple2]],
                                  load_names=self.load_names,
                           prop_dict={'time_axis_label': 'hello'})

        ax1 = fig.get_axes()[0]
        ax3 = fig.get_axes()[2]
        assert_equal(ax1.get_xlabel(), '')
        assert_equal(ax3.get_xlabel(), 'hello')
示例#26
0
def test_split_sequence_into_dict_and_nondicts():
    """test for split_sequence_into_dict_and_nondicts"""
    #split_sequence_into_dict_and_nondicts(*args)

    assert_equal(split_sequence_into_dict_and_nondicts({'a': 2, 'b': 3},
                                   4,
                                   {'a':8, 'c':5},
                                   5),
                                   ([4,5], {'a': 8, 'b': 3, 'c':5}))
示例#27
0
def test_copy_dict():
    """test for copy_dict"""
    #copy_dict(source_dict, diffs)
#    ok_(copy_dict({'a':7, 'b':12}, {'c':13})=={'a':7, 'b':12, 'c':13})
    assert_equal(copy_dict({'a':7, 'b':12}, {'c':13}),
                 {'a':7, 'b':12, 'c':13})
#    ok_(copy_dict({'a':7, 'b':12}, {'a':21, 'c':13})=={'a':21, 'b':12, 'c':13})
    assert_equal(copy_dict({'a':7, 'b':12}, {'a':21, 'c':13}),
                 {'a':21, 'b':12, 'c':13})
示例#28
0
    def test_prop_dict_time_axis_label(self):
        fig = plot_generic_loads([[self.triple1], [self.triple2]],
                                 load_names=self.load_names,
                                 prop_dict={'time_axis_label': 'hello'})

        ax1 = fig.get_axes()[0]
        ax3 = fig.get_axes()[2]
        assert_equal(ax1.get_xlabel(), '')
        assert_equal(ax3.get_xlabel(), 'hello')
示例#29
0
    def test_check_attributes_that_should_be_lists(self):
        a = InputFileLoaderCheckerSaver()
        a.a=4
        a.b=6
        a._attributes_that_should_be_lists = ['b']
        a.check_input_attributes()

        assert_equal(a.a, 4)
        assert_equal(a.b, [6])
示例#30
0
    def test_prop_dict_depth_axis_label(self):
        fig = plot_generic_loads([[self.triple1], [self.triple2]],
                                  load_names=self.load_names,
                           prop_dict={'depth_axis_label': 'hello'})

        ax2 = fig.get_axes()[1]
        ax4 = fig.get_axes()[3]
        assert_equal(ax2.get_xlabel(), '')
        assert_equal(ax4.get_xlabel(), 'hello')
示例#31
0
    def test_check_attributes_that_should_be_lists(self):
        a = InputFileLoaderCheckerSaver()
        a.a = 4
        a.b = 6
        a._attributes_that_should_be_lists = ['b']
        a.check_input_attributes()

        assert_equal(a.a, 4)
        assert_equal(a.b, [6])
示例#32
0
    def test_propdict_xylabels(self):


        fig = plot_vs_depth(self.x, self.z, ['a', 'b', 'c'],
                           prop_dict={'xlabel':'xxx', 'ylabel':'yyy'})
        ax = fig.get_axes()[0]

        assert_equal(ax.get_xlabel(), 'xxx')
        assert_equal(ax.get_ylabel(), 'yyy')
示例#33
0
def test_split_sequence_into_dict_and_nondicts():
    """test for split_sequence_into_dict_and_nondicts"""
    #split_sequence_into_dict_and_nondicts(*args)

    assert_equal(split_sequence_into_dict_and_nondicts({'a': 2, 'b': 3},
                                   4,
                                   {'a':8, 'c':5},
                                   5),
                                   ([4,5], {'a': 8, 'b': 3, 'c':5}))
示例#34
0
    def test_propdict_xylabels(self):


        fig = plot_vs_depth(self.x, self.z, ['a', 'b', 'c'],
                           prop_dict={'xlabel':'xxx', 'ylabel':'yyy'})
        ax = fig.get_axes()[0]

        assert_equal(ax.get_xlabel(), 'xxx')
        assert_equal(ax.get_ylabel(), 'yyy')
示例#35
0
def test_copy_dict():
    """test for copy_dict"""
    #copy_dict(source_dict, diffs)
#    ok_(copy_dict({'a':7, 'b':12}, {'c':13})=={'a':7, 'b':12, 'c':13})
    assert_equal(copy_dict({'a':7, 'b':12}, {'c':13}),
                 {'a':7, 'b':12, 'c':13})
#    ok_(copy_dict({'a':7, 'b':12}, {'a':21, 'c':13})=={'a':21, 'b':12, 'c':13})
    assert_equal(copy_dict({'a':7, 'b':12}, {'a':21, 'c':13}),
                 {'a':21, 'b':12, 'c':13})
示例#36
0
    def test_propdict_has_legend(self):

        fig = plot_generic_loads([[self.triple1], [self.triple2]],
                                 load_names=self.load_names,
                                 prop_dict={'has_legend': False})
        ax1 = fig.get_axes()[0]
        ax3 = fig.get_axes()[2]

        assert_equal(ax1.get_legend(), None)
        assert_equal(ax3.get_legend(), None)
示例#37
0
def test_copy_attributes_from_text_to_object():
    """test for copy_attributes_from_text_to_object function"""
    #copy_attributes_from_text_to_object(reader,*args, **kwargs)
    reader = textwrap.dedent("""\
        a = 2
        b = 3
        """)
    a = EmptyClass()
    copy_attributes_from_text_to_object(reader,a,['a','b', 'aa', 'bb'], {'bb': 27})
    assert_equal([a.a, a.b, a.aa, a.bb], [2, 3, None, 27])
示例#38
0
def test_default():
	default_validator = konval.Default(konval.types.IsType(str), 'NOT A STRING!')

	string_value = '1234'

	assert_equal(default_validator(string_value), string_value)

	numerical_value = 1234

	assert_equal(default_validator(numerical_value), 'NOT A STRING!')
示例#39
0
    def test_ylabels(self):
        fig = plot_generic_loads([[self.triple1], [self.triple2]],
                                 load_names=self.load_names,
                                 ylabels=['one', 'two'])

        ax1 = fig.get_axes()[0]
        ax3 = fig.get_axes()[2]

        assert_equal(ax1.get_ylabel(), 'one')
        assert_equal(ax3.get_ylabel(), 'two')
示例#40
0
def test_if():
	if_validator = konval.If(True, konval.types.ToType(int))

	numerical_string = '1234'

	assert_equal(if_validator(numerical_string), 1234)

	if_validator = konval.If(False, konval.types.ToType(int))

	assert_equal(if_validator(numerical_string), numerical_string)
示例#41
0
def test_if_else():
	if_else_validator = konval.IfElse(konval.types.IsType(str), konval.types.ToType(str))

	string_value = '1234'

	assert_equal(if_else_validator(string_value), string_value)

	numerical_value = 1234

	assert_equal(if_else_validator(numerical_value), string_value)
示例#42
0
def test_copy_attributes_from_text_to_object():
    """test for copy_attributes_from_text_to_object function"""
    #copy_attributes_from_text_to_object(reader,*args, **kwargs)
    reader = textwrap.dedent("""\
        a = 2
        b = 3
        """)
    a = EmptyClass()
    copy_attributes_from_text_to_object(reader,a,['a','b', 'aa', 'bb'], {'bb': 27})
    assert_equal([a.a, a.b, a.aa, a.bb], [2, 3, None, 27])
示例#43
0
    def test_plot_args_marker(self):
        fig = plt.figure()
        data = [([self.xa1, self.ya1,{'marker': 's'}], [self.xa2, self.ya2]),
                ([self.xb1, self.yb1],)]

        plot_data_in_grid(fig, data, self.gs)

        assert_equal(len(fig.get_axes()), 2)
        ax1 = fig.get_axes()[0]
        line1 = ax1.get_lines()[0]
        assert_equal(line1.get_marker(), 's')
示例#44
0
    def test_pattern_with_fobj(self):

        a = GenericInputFileArgParser(self._abc_fobj, True)
        args = '-d {0} -p *.txt'.format(self.tempdir.path).split()
#        print(args)
        a.main(argv=args)

        assert_equal(self.tempdir.read(('out.zebra'), 'utf-8').splitlines(),
                            textwrap.dedent("""\
                            b1
                            b2""").splitlines())
示例#45
0
    def test_directory_with_path(self):

        a = GenericInputFileArgParser(self._abc_path, False)
        args = '-d {0} -p'.format(self.tempdir.path).split()
        print(args)
        a.main(argv=args)

        assert_equal(self.tempdir.read(('out.zebra'), 'utf-8').splitlines(),
                            textwrap.dedent("""\
                            a1.py
                            a2.py""").splitlines())
示例#46
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())
示例#47
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())
示例#48
0
    def test_propdict_has_legend(self):


        fig = plot_generic_loads([[self.triple1], [self.triple2]],
                                  load_names=self.load_names,
                           prop_dict={'has_legend': False})
        ax1 = fig.get_axes()[0]
        ax3 = fig.get_axes()[2]

        assert_equal(ax1.get_legend(), None)
        assert_equal(ax3.get_legend(), None)
示例#49
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())
示例#50
0
    def test_directory_with_path(self):

        a = GenericInputFileArgParser(self._abc_path, False)
        args = '-d {0} -p'.format(self.tempdir.path).split()
        print(args)
        a.main(argv=args)

        assert_equal(self.tempdir.read(('out.zebra'), 'utf-8').splitlines(),
                            textwrap.dedent("""\
                            a1.py
                            a2.py""").splitlines())
示例#51
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())
示例#52
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())
示例#53
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())
示例#54
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())
示例#55
0
    def test_pattern_with_fobj(self):

        a = GenericInputFileArgParser(self._abc_fobj, True)
        args = '-d {0} -p *.txt'.format(self.tempdir.path).split()
#        print(args)
        a.main(argv=args)

        assert_equal(self.tempdir.read(('out.zebra'), 'utf-8').splitlines(),
                            textwrap.dedent("""\
                            b1
                            b2""").splitlines())
示例#56
0
    def test_plot_args_marker(self):
        fig = plt.figure()
        data = [([self.xa1, self.ya1,{'marker': 's'}], [self.xa2, self.ya2]),
                ([self.xb1, self.yb1],)]

        plot_data_in_grid(fig, data, self.gs)

        assert_equal(len(fig.get_axes()), 2)
        ax1 = fig.get_axes()[0]
        line1 = ax1.get_lines()[0]
        assert_equal(line1.get_marker(), 's')
示例#57
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())
示例#58
0
    def test_ylabels(self):
        fig = plot_generic_loads([[self.triple1], [self.triple2]],
                                  load_names=self.load_names,
                                  ylabels = ['one', 'two'])


        ax1 = fig.get_axes()[0]
        ax3 = fig.get_axes()[2]

        assert_equal(ax1.get_ylabel(), 'one')
        assert_equal(ax3.get_ylabel(), 'two')
示例#59
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())
示例#60
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())