def test_float_random_start(self): fig=plt.figure() ax = fig.add_subplot('111') ax.plot([3,4], [8,6], markevery=4) ax.plot([3,5], [8,7], markevery=4) ax.plot([3,6], [8,8], markevery=4) apply_markevery_to_sequence_of_lines(ax.get_lines(), markevery=0.1, random_start=True, seed=1) try: from matplotlib.lines import _mark_every_path # the above import should fail for matplotlib <1.4. # However, since it was my addition to matplotlib I may have hardwired # all the markevery code it in to my own matplotlib.lines file. assert_allclose(ax.get_lines()[0].get_markevery(), (0.0134364244112, 0.1)) assert_allclose(ax.get_lines()[1].get_markevery(), (0.0847433736937, 0.1)) assert_allclose(ax.get_lines()[2].get_markevery(), (0.07637746189766, 0.1)) except ImportError: assert_equal(ax.get_lines()[0].get_markevery(), 4) assert_equal(ax.get_lines()[1].get_markevery(), 4) assert_equal(ax.get_lines()[2].get_markevery(), 4)
def test_float_random_start(self): fig = plt.figure() ax = fig.add_subplot('111') ax.plot([3, 4], [8, 6], markevery=4) ax.plot([3, 5], [8, 7], markevery=4) ax.plot([3, 6], [8, 8], markevery=4) apply_markevery_to_sequence_of_lines(ax.get_lines(), markevery=0.1, random_start=True, seed=1) try: from matplotlib.lines import _mark_every_path # the above import should fail for matplotlib <1.4. # However, since it was my addition to matplotlib I may have hardwired # all the markevery code it in to my own matplotlib.lines file. assert_allclose(ax.get_lines()[0].get_markevery(), (0.0134364244112, 0.1)) assert_allclose(ax.get_lines()[1].get_markevery(), (0.0847433736937, 0.1)) assert_allclose(ax.get_lines()[2].get_markevery(), (0.07637746189766, 0.1)) except ImportError: assert_equal(ax.get_lines()[0].get_markevery(), 4) assert_equal(ax.get_lines()[1].get_markevery(), 4) assert_equal(ax.get_lines()[2].get_markevery(), 4)
def test_int(self): fig=plt.figure() ax = fig.add_subplot('111') ax.plot([3,4], [8,6], markevery=4) ax.plot([3,5], [8,7], markevery=4) ax.plot([3,6], [8,8], markevery=4) apply_markevery_to_sequence_of_lines(ax.get_lines(), markevery=0.1, random_start=False, seed=None) try: from matplotlib.lines import _mark_every_path # the above import should fail for matplotlib <1.4. # However, since it was my addition to matplotlib I may have hardwired # all the markevery code it in to my own matplotlib.lines file. assert_equal(ax.get_lines()[0].get_markevery(), 0.1) assert_equal(ax.get_lines()[1].get_markevery(), 0.1) assert_equal(ax.get_lines()[2].get_markevery(), 0.1) except ImportError: assert_equal(ax.get_lines()[0].get_markevery(), 4) assert_equal(ax.get_lines()[1].get_markevery(), 4) assert_equal(ax.get_lines()[2].get_markevery(), 4)
def test_int(self): fig = plt.figure() ax = fig.add_subplot('111') ax.plot([3, 4], [8, 6], markevery=4) ax.plot([3, 5], [8, 7], markevery=4) ax.plot([3, 6], [8, 8], markevery=4) apply_markevery_to_sequence_of_lines(ax.get_lines(), markevery=0.1, random_start=False, seed=None) try: from matplotlib.lines import _mark_every_path # the above import should fail for matplotlib <1.4. # However, since it was my addition to matplotlib I may have hardwired # all the markevery code it in to my own matplotlib.lines file. assert_equal(ax.get_lines()[0].get_markevery(), 0.1) assert_equal(ax.get_lines()[1].get_markevery(), 0.1) assert_equal(ax.get_lines()[2].get_markevery(), 0.1) except ImportError: assert_equal(ax.get_lines()[0].get_markevery(), 4) assert_equal(ax.get_lines()[1].get_markevery(), 4) assert_equal(ax.get_lines()[2].get_markevery(), 4)
def test_defaults(self): fig=plt.figure() ax = fig.add_subplot('111') ax.plot([3,4], [8,6], markevery=4) ax.plot([3,5], [8,7], markevery=4) ax.plot([3,6], [8,8], markevery=4) apply_markevery_to_sequence_of_lines(ax.get_lines(), markevery=None , random_start=True, seed=None) assert_equal(ax.get_lines()[0].get_markevery(), None) assert_equal(ax.get_lines()[1].get_markevery(), None) assert_equal(ax.get_lines()[2].get_markevery(), None)
def test_int(self): fig=plt.figure() ax = fig.add_subplot('111') ax.plot([3,4], [8,6]) ax.plot([3,5], [8,7]) ax.plot([3,6], [8,8]) apply_markevery_to_sequence_of_lines(ax.get_lines(), markevery=8, random_start=False, seed=None) assert_equal(ax.get_lines()[0].get_markevery(), 8) assert_equal(ax.get_lines()[1].get_markevery(), 8) assert_equal(ax.get_lines()[2].get_markevery(), 8)
def test_int_random_start(self, mock_randint): mock_randint.return_value=2 fig=plt.figure() ax = fig.add_subplot('111') ax.plot([3,4], [8,6]) ax.plot([3,5], [8,7]) ax.plot([3,6], [8,8]) apply_markevery_to_sequence_of_lines(ax.get_lines(), markevery=8, random_start=True, seed=1) # using mock here is a bit of a cop out but randint, even # with the same seed, gives different answeres in # py34 vs py27 assert_equal(ax.get_lines()[0].get_markevery(), (2,8)) assert_equal(ax.get_lines()[1].get_markevery(), (2,8)) assert_equal(ax.get_lines()[2].get_markevery(), (2,8))