def test_prop_dict_styles(self): fig = plot_generic_loads( [[self.triple1], [self.triple2]], load_names=self.load_names, prop_dict={ 'styles': [{ 'markersize': 12, 'marker': '^' }, { 'markersize': 3, 'marker': 's' }] }) 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] assert_equal(line1.get_marker(), '^') assert_equal(line1.get_markersize(), 12) assert_equal(line2.get_marker(), '^') assert_equal(line2.get_markersize(), 12) assert_equal(line3.get_marker(), 's') assert_equal(line3.get_markersize(), 3) assert_equal(line4.get_marker(), 's') assert_equal(line4.get_markersize(), 3)
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')
def test_prop_dict_styles(self): fig = plot_generic_loads([[self.triple1], [self.triple2]], load_names=self.load_names, prop_dict={'styles':[{'markersize': 12, 'marker': '^'}, {'markersize': 3, 'marker': 's'}]}) 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] assert_equal(line1.get_marker(),'^') assert_equal(line1.get_markersize(),12) assert_equal(line2.get_marker(),'^') assert_equal(line2.get_markersize(),12) assert_equal(line3.get_marker(),'s') assert_equal(line3.get_markersize(),3) assert_equal(line4.get_marker(),'s') assert_equal(line4.get_markersize(),3)
def test_propdict_fig_prop_figsize(self): fig = plot_generic_loads([[self.triple1], [self.triple2]], load_names=self.load_names, prop_dict={'fig_prop': { 'figsize': (8, 9) }}) assert_allclose(fig.get_size_inches(), (8, 9))
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')
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')
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')
def test_defaults(self): fig = plot_generic_loads([[self.triple1], [self.triple2]], load_names=self.load_names) assert_equal(len(fig.get_axes()), 4) 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, 0])) 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, 0])) assert_allclose(line4.get_xydata()[-1], np.array([ 0.8, 1])) assert_equal(ax1.get_xlabel(), '') assert_equal(ax1.get_ylabel(), 'y0') assert_equal(ax2.get_xlabel(), '') assert_equal(ax2.get_ylabel(), 'Depth, z') assert_equal(ax3.get_xlabel(), 'Time') assert_equal(ax3.get_ylabel(), 'y1') assert_equal(ax4.get_xlabel(), 'Load factor') assert_equal(ax4.get_ylabel(), 'Depth, z') assert_equal(line1.get_label(), 'a0') assert_equal(line2.get_label(), 'a0') assert_equal(line3.get_label(), 'b0') assert_equal(line4.get_label(), 'b0') ok_(not ax1.get_legend() is None) ok_(not ax3.get_legend() is None)
def test_trange(self): fig = plot_generic_loads([[self.triple1], [self.triple2]], load_names=self.load_names, trange=(2, 3)) ax1 = fig.get_axes()[0] ax3 = fig.get_axes()[2] assert_allclose(ax1.get_xlim(), (2, 3)) assert_allclose(ax3.get_xlim(), (2, 3))
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')
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)
def test_trange(self): fig = plot_generic_loads([[self.triple1], [self.triple2]], load_names=self.load_names, trange = (2,3)) ax1 = fig.get_axes()[0] ax3 = fig.get_axes()[2] assert_allclose(ax1.get_xlim(), (2,3)) assert_allclose(ax3.get_xlim(), (2,3))
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')
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')
def test_propdict_fig_prop_figsize(self): fig = plot_generic_loads([[self.triple1], [self.triple2]], load_names=self.load_names, prop_dict={'fig_prop':{'figsize':(8,9)}}) assert_allclose(fig.get_size_inches(), (8,9))