__all__ = ['mstack', 'wget']

def mstack(vs, fs):
    import chumpy as ch
    import numpy as np
    lengths = [v.shape[0] for v in vs]
    f = np.vstack([fs[i]+np.sum(lengths[:i]).astype(np.uint32) for i in range(len(fs))])
    v = ch.vstack(vs)

    return v, f


def wget(url, dest_fname=None):
    import urllib.request, urllib.error, urllib.parse
    from os.path import split, join

    curdir = split(__file__)[0]
    print(url)
    

    if dest_fname is None:
        dest_fname = join(curdir, split(url)[1])

    try:
        contents = urllib.request.urlopen(url).read()
    except:
        raise Exception('Unable to get url: %s' % (url,))
    open(dest_fname, 'w').write(contents)

__all__ = ['mstack', 'wget']

def mstack(vs, fs):
    import chumpy as ch
    import numpy as np
    lengths = [v.shape[0] for v in vs]
    f = np.vstack([fs[i]+np.sum(lengths[:i]).astype(np.uint32) for i in range(len(fs))])
    v = ch.vstack(vs)

    return v, f


def wget(url, dest_fname=None):
    try: #python3
        from urllib.request import urlopen
    except: #python2
        from urllib2 import urlopen

    from os.path import split, join

    curdir = split(__file__)[0]
    print(url)
    

    if dest_fname is None:
        dest_fname = join(curdir, split(url)[1])

    try:
        contents = urlopen(url).read()
    except:
        raise Exception('Unable to get url: %s' % (url,))
    open(dest_fname, 'w').write(contents)

Fix for python2/3 compatibility issue with urllib
Fix for python2/3 compatibility issue with urllib

  __all__ = ['mstack', 'wget']
  
  def mstack(vs, fs):
      import chumpy as ch
      import numpy as np
      lengths = [v.shape[0] for v in vs]
      f = np.vstack([fs[i]+np.sum(lengths[:i]).astype(np.uint32) for i in range(len(fs))])
      v = ch.vstack(vs)
  
      return v, f
  
  
  def wget(url, dest_fname=None):
-     import urllib.request, urllib.error, urllib.parse
+     try: #python3
+         from urllib.request import urlopen
+     except: #python2
+         from urllib2 import urlopen
+ 
      from os.path import split, join
  
      curdir = split(__file__)[0]
      print(url)
      
  
      if dest_fname is None:
          dest_fname = join(curdir, split(url)[1])
  
      try:
-         contents = urllib.request.urlopen(url).read()
+         contents = urlopen(url).read()
      except:
          raise Exception('Unable to get url: %s' % (url,))
      open(dest_fname, 'w').write(contents)
  
Fix for python2/3 compatibility issue with urllib
## Code Before:
__all__ = ['mstack', 'wget']

def mstack(vs, fs):
    import chumpy as ch
    import numpy as np
    lengths = [v.shape[0] for v in vs]
    f = np.vstack([fs[i]+np.sum(lengths[:i]).astype(np.uint32) for i in range(len(fs))])
    v = ch.vstack(vs)

    return v, f


def wget(url, dest_fname=None):
    import urllib.request, urllib.error, urllib.parse
    from os.path import split, join

    curdir = split(__file__)[0]
    print(url)
    

    if dest_fname is None:
        dest_fname = join(curdir, split(url)[1])

    try:
        contents = urllib.request.urlopen(url).read()
    except:
        raise Exception('Unable to get url: %s' % (url,))
    open(dest_fname, 'w').write(contents)

## Instruction:
Fix for python2/3 compatibility issue with urllib
## Code After:
__all__ = ['mstack', 'wget']

def mstack(vs, fs):
    import chumpy as ch
    import numpy as np
    lengths = [v.shape[0] for v in vs]
    f = np.vstack([fs[i]+np.sum(lengths[:i]).astype(np.uint32) for i in range(len(fs))])
    v = ch.vstack(vs)

    return v, f


def wget(url, dest_fname=None):
    try: #python3
        from urllib.request import urlopen
    except: #python2
        from urllib2 import urlopen

    from os.path import split, join

    curdir = split(__file__)[0]
    print(url)
    

    if dest_fname is None:
        dest_fname = join(curdir, split(url)[1])

    try:
        contents = urlopen(url).read()
    except:
        raise Exception('Unable to get url: %s' % (url,))
    open(dest_fname, 'w').write(contents)
