title: strange behavior of scipy.interpolate.bisplrep
body: <p>I have a very strange behavior of bisplrep.</p>
  
  <p>reproduced the problem in the following example.
  first a create sample data
  then select scattered data on te fine grid, and try to apply bisplrep with different number of knots (tx,ty).
  At that point, there is already a problem for me. Some of the plots are not representing the data at all.</p>
  
  <pre><code>from scipy.interpolate import bisplrep,bisplev
  from numpy import arange
  import numpy as np
  from matplotlib import pyplot as mpl
  
  #create data
  x,y = np.mgrid[slice(0, 100, 0.1),
                  slice(0,50,0.1)]
  
  z = cos(x/10)*sin(y/5)**2
  
  
  # random selection of scattered data
  select = np.random.randint(2, size=x.shape)
  for i in range(8):
      select *= np.random.randint(2, size=x.shape)
  sx = x.flatten().compress(select.flatten() == 1)
  sy = y.flatten().compress(select.flatten() == 1)
  sz = z.flatten().compress(select.flatten() == 1)
  print len(sx)
  
  #plot original data
  fig,axs = subplots(nrows = 4,ncols = 3)
  axs[0,0].pcolormesh(x,y,z)
  axs[0,0].scatter(sx,sy,alpha=0.5)
  axs[0,0].set_xlim(0,100)
  axs[0,0].set_ylim(0,50)
  
  #try to uncomment/comment this line
  #axs[0,0].set_title('original data')
  
  
  def get_rz(dx,dy,ax):
      print dx,dy
      #ix,iy are the knots for bisplrep
      ix = arange(0, 100, dx)
      iy = arange(0,50,dy)
      #ox,oy are the interpolation points (same as origianl grid)
      ox = arange(0, 100, 0.1)
      oy = arange(0,50,0.1)
      #interpolation with bisplrep
      tck = bisplrep(sx,sy,sz,task = -1, nxest = len(ix) , nyest = len(iy),tx = ix,ty = iy,s=0)
      rz = bisplev(ox,oy,tck)
      c = ax.contourf(x,y,rz,vmin=-1,vmax = 1)
  
      # scatx and scat y are just for plot
      scatx,scaty = np.mgrid[slice(0, 100, dx),
                             slice(0,50,dy)]
  
      ax.plot(scatx.flatten(),scaty.flatten(),'+',alpha = 0.5)
      ax.set_title('dx=%s dy=%s'%(dx,dy))
      return rz
  
  get_rz(dx=1,dy=1,ax=axs[1,0])
  get_rz(dx=1,dy=2,ax=axs[1,1])
  get_rz(dx=1,dy=3,ax=axs[1,2])
  get_rz(dx=2,dy=1,ax=axs[2,0])
  get_rz(dx=2,dy=2,ax=axs[2,1])
  get_rz(dx=2,dy=3,ax=axs[2,2])
  get_rz(dx=3,dy=1,ax=axs[3,0])
  get_rz(dx=3,dy=2,ax=axs[3,1])
  get_rz(dx=3,dy=3,ax=axs[3,2])
  
  #try to uncomment/comment this line
  fig.tight_layout(pad = 0.1,h_pad=0.1,w_pad=0.1)
  
  fig.show()
  </code></pre>
  
  <p>now, i try to comment/uncomment one or two lines, and the result is different...
  it's look like a memory problem.</p>
  
  <p>Can you reproduce the problem?
  Any idea to solve the situation?</p>
  
  <p>Thank you</p>
  
  <p>here are two exemple of what i get (it seems that i am not allowed to post images)...
  <a href="http://i.stack.imgur.com/gZZc4.png" rel="nofollow">http://i.stack.imgur.com/gZZc4.png</a>
  <a href="http://i.stack.imgur.com/0344u.png" rel="nofollow">http://i.stack.imgur.com/0344u.png</a></p>
  
  <p>edit: 
  i tried to use LSQBivariateSpline with the same results
  and with the f2py vertion of fitpack: dfitpack.surfit_lsq it also the same</p>