Exemple #1
0
 def test_index_out_of_length(self):
     s = ''
     i = 1
     self.assertEqual(
         bracket.bracket(s, i),
         'Passed index is out of string length',
         'Asserting that index is on range')
Exemple #2
0
 def test_iter(self):
     composers = ["Ludwig", "Copland", "Bernstein", "Britten", "Schubert", "Chopin"]
 
     b1 = rankedElement(composers[0])
     b2 = rankedElement(composers[1])
     b3 = rankedElement(composers[2])
     b4 = rankedElement(composers[3])
     b5 = rankedElement(composers[4])
     b6 = rankedElement(composers[5])
     b7 = branchedElement(b1, b2)
     b8 = branchedElement(b3, b4)
     
     b9 = branchedElement(b5, b7)
     b10 = branchedElement(b6, b8)
     
     top = branchedElement(b9, b10)
     
     br = bracket.bracket(top)
     
     elements = [b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, top]
     
     for e in br:
         if e in elements:
             elements.remove(e)
         else:
             raise ValueError("Found element " + str(e) + " in this tree for some reason!")
             
     self.assertEqual(len(elements), 0)
Exemple #3
0
 def test_expected_user_outputs(self):
     s = '[ABC[23]][89]'
     i = 4
     self.assertEqual(
         bracket.bracket(s, i),
         'The opening bracket at index: 4, closes at index: 7',
         'Asserting that the correct message is displayed'
     )
Exemple #4
0
xhigh = -6 + xmin
xplot.set_xlim(xlow, xhigh)
zplot.set_xlim(x_to_z(xlow), x_to_z(xhigh))

xticks = [6, 4, 2]
zticks = [1, 3, 5, 7]

plotticks = xticks + [z_to_x(z) for z in zticks]
xplot.set_xticks(xticks)
zplot.set_xticks(zticks)
xplot.set_xticks(plotticks)
xplot.set_xticklabels(['$%i$' % tick for tick in xticks] +
                      ['$%i$' % tick for tick in zticks])
zplot.set_xticks([])

bracket.bracket(xplot, -.01, (xlow - 2) / (xlow - xhigh) + 0.007, -.06, .06,
                r'$x/R$')
bracket.bracket(xplot, (xlow - xmin) / (xlow - xhigh) - 0.013, 1.01, -.06, .06,
                r'$z/R$')

twod_plot.set_xlim(zmin, zmax)
twod_plot.set_ylim(-rmax, rmax)

#fig.subplots_adjust(hspace=0.001)

twod_plot.set_aspect('equal')
g3mc = read_triplet(ff, 'mc')[:, int(center / dx):-1]
rpoints = len(g3mc[:, 0])
zpoints = len(g3mc[0, :])
r = arange(0, rpoints * dx, dx)
z = arange(center, center + zpoints * dx, dx)
Z, R = meshgrid(z, r)
Exemple #5
0

def x_to_z(x):
    return 2 - x


zmax_lineplot = 6.
xmax_lineplot = 4.
xplot.set_xlim(zmax_lineplot, -xmax_lineplot)
xplot.set_xticks([6, 4, 2, 0, -2, -4])
xplot.set_xticklabels(["$6$", "$4$", "$2~~0$", "$2$", "$4$", "$6$"])
zplot.set_xlim(x_to_z(xplot.get_xlim()[0]), x_to_z(xplot.get_xlim()[1]))
zplot.set_xticks([])
#xplot.set_ylim(0)

bracket.bracket(xplot, -.01, xmax_lineplot / (xmax_lineplot + zmax_lineplot),
                -.06, .06, r'$x/R$')
bracket.bracket(zplot, xmax_lineplot / (xmax_lineplot + zmax_lineplot), 1.01,
                -.06, .06, r'$z/R$')

twod_plot.set_xlim(-1, 6)
twod_plot.set_ylim(-ymax, ymax)
sphere = Circle((0, 0), 1, color='slategray')
twod_plot.add_artist(sphere)

#fig.subplots_adjust(hspace=0.001)

twod_plot.set_aspect('equal')
g2mc = read_walls_mc(ff)
rbins = int(round(rmax / dx))
zposbins = int(round(zmax / dx))
znegbins = int(round(-zmin / dx))
Exemple #6
0
def z_to_x(z):
  return 2 - z
def x_to_z(x):
  return 2 - x

zmax_lineplot = 6.
xmax_lineplot = 4.
xplot.set_xlim(zmax_lineplot, -xmax_lineplot)
xplot.set_xticks([6, 4, 2, 0, -2, -4])
xplot.set_xticklabels(["$6$", "$4$", "$2~~0$", "$2$", "$4$", "$6$"])
zplot.set_xlim(x_to_z(xplot.get_xlim()[0]), x_to_z(xplot.get_xlim()[1]))
zplot.set_xticks([])
#xplot.set_ylim(0)

bracket.bracket(xplot, -.01, xmax_lineplot/(xmax_lineplot+zmax_lineplot), -.06, .06, r'$x/R$')
bracket.bracket(zplot, xmax_lineplot/(xmax_lineplot+zmax_lineplot), 1.01, -.06, .06, r'$z/R$')

twod_plot.set_xlim(-1, 6)
twod_plot.set_ylim(-ymax, ymax)
sphere = Circle((0, 0), 1, color='slategray')
twod_plot.add_artist(sphere)

#fig.subplots_adjust(hspace=0.001)


twod_plot.set_aspect('equal')
g2mc = read_walls_mc(ff)
rbins = round(rmax/dx)
zposbins = round(zmax/dx)
znegbins = round(-zmin/dx)
Exemple #7
0

def x_to_z(x):
    return 2 - x


zmax_lineplot = 6.0
xmax_lineplot = 4.0
xplot.set_xlim(zmax_lineplot, -xmax_lineplot)
xplot.set_xticks([6, 4, 2, 0, -2, -4])
xplot.set_xticklabels(["$6$", "$4$", "$2~~0$", "$2$", "$4$", "$6$"])
zplot.set_xlim(x_to_z(xplot.get_xlim()[0]), x_to_z(xplot.get_xlim()[1]))
zplot.set_xticks([])
# xplot.set_ylim(0)

bracket.bracket(xplot, -0.01, xmax_lineplot / (xmax_lineplot + zmax_lineplot), -0.06, 0.06, r"$x/R$")
bracket.bracket(zplot, xmax_lineplot / (xmax_lineplot + zmax_lineplot), 1.01, -0.06, 0.06, r"$z/R$")

twod_plot.set_xlim(-1, 6)
twod_plot.set_ylim(-ymax, ymax)
sphere = Circle((0, 0), 1, color="slategray")
twod_plot.add_artist(sphere)

# fig.subplots_adjust(hspace=0.001)


twod_plot.set_aspect("equal")
g2mc = read_walls_mc(ff)
rbins = round(rmax / dx)
zposbins = round(zmax / dx)
znegbins = round(-zmin / dx)
xhigh = -6+xmin
xplot.set_xlim(xlow, xhigh)
zplot.set_xlim(x_to_z(xlow), x_to_z(xhigh))

xticks = [6, 4, 2]
zticks = [1, 3, 5, 7]

plotticks = xticks + [z_to_x(z) for z in zticks]
xplot.set_xticks(xticks)
zplot.set_xticks(zticks)
xplot.set_xticks(plotticks)
xplot.set_xticklabels(['$%i$' %tick for tick in xticks] +
                       ['$%i$' %tick for tick in zticks])
zplot.set_xticks([])

bracket.bracket(xplot, -.01, (xlow - 2)/(xlow - xhigh) + 0.007, -.06, .06, r'$x/R$')
bracket.bracket(xplot, (xlow - xmin)/(xlow - xhigh) - 0.013, 1.01, -.06, .06, r'$z/R$')

twod_plot.set_xlim(zmin, zmax)
twod_plot.set_ylim(-rmax, rmax)

#fig.subplots_adjust(hspace=0.001)

twod_plot.set_aspect('equal')
g3mc = read_triplet(ff, 'mc')[:, center/dx:-1]
rpoints = len(g3mc[:,0])
zpoints = len(g3mc[0,:])
r = arange(0, rpoints*dx, dx)
z = arange(center, center+zpoints*dx, dx)
Z, R = meshgrid(z, r)
gmax = g3mc.max()
xplot.set_xlim(xlow, xhigh)
zplot.set_xlim(x_to_z(xlow), x_to_z(xhigh))

xticks = [-6, -4, -2, 0]
zticks = [4, 6, 8, 10]

plotticks = xticks + [z_to_x(z) for z in zticks]
xplot.set_xticks(plotticks)
xplot.set_xticklabels(['$%i$' %tick for tick in xticks[:-1]] + ['$0$ $2$'] +
                      ['$%i$' %tick for tick in zticks])
zplot.set_xticks([])

zplot.axvline(x=rpath, color='k')
zplot.axvline(x=3*rpath, color='k')

bracket.bracket(xplot, -0.01, -xlow/(xhigh - xlow), -.06, .06, r'$x/R$')
bracket.bracket(xplot, -xlow/(xhigh - xlow), 1.01, -.06, .06, r'$z/R$')

xmin = 1.0
xmax = 9.0
ymax = 6.0

twod_plot.set_xlim(zmin, zmax)
twod_plot.set_ylim(-rmax, rmax)

#fig.subplots_adjust(hspace=0.001)

twod_plot.set_aspect('equal')
g3mc = read_triplet(ff, 'mc')[:, center/dx:-1]
rpoints = len(g3mc[:,0])
zpoints = len(g3mc[0,:])
Exemple #10
0
xplot.set_xlim(xlow, xhigh)
zplot.set_xlim(x_to_z(xlow), x_to_z(xhigh))

xticks = [-6, -4, -2, 0]
zticks = [4, 6, 8, 10]

plotticks = xticks + [z_to_x(z) for z in zticks]
xplot.set_xticks(plotticks)
xplot.set_xticklabels(['$%i$' % tick for tick in xticks[:-1]] + ['$0$ $2$'] +
                      ['$%i$' % tick for tick in zticks])
zplot.set_xticks([])

zplot.axvline(x=rpath, color='k')
zplot.axvline(x=3 * rpath, color='k')

bracket.bracket(xplot, -0.01, -xlow / (xhigh - xlow), -.06, .06, r'$x/R$')
bracket.bracket(xplot, -xlow / (xhigh - xlow), 1.01, -.06, .06, r'$z/R$')

xmin = 1.0
xmax = 9.0
ymax = 6.0

twod_plot.set_xlim(zmin, zmax)
twod_plot.set_ylim(-rmax, rmax)

#fig.subplots_adjust(hspace=0.001)

twod_plot.set_aspect('equal')
g3mc = read_triplet(ff, 'mc')[:, int(center / dx):-1]
rpoints = len(g3mc[:, 0])
zpoints = len(g3mc[0, :])