BSS Eval v3 bss_eval_images_framewise

    Framewise computation of bss_eval_images.
    Wrapper to ``bss_eval`` with the right parameters.
969746
def bss_eval_images_framewise(reference_sources, estimated_sources,
                              window=30 * 44100, hop=15 * 44100,
                              compute_permutation=False):
    
    return bss_eval(
        reference_sources, estimated_sources,
        window=window, hop=hop,
        compute_permutation=compute_permutation, filters_len=512,
        framewise_filters=True,
        bsseval_sources_version=False
    )
1315842
def bss_eval_sources_framewise(reference_sources, estimated_sources,
                               window=30 * 44100, hop=15 * 44100,
                               compute_permutation=False):
    
    (sdr, isr, sir, sar, perm) = \
        bss_eval(
            reference_sources, estimated_sources,
            window=window, hop=hop,
            compute_permutation=compute_permutation, filters_len=512,
            framewise_filters=True,
            bsseval_sources_version=True)
    return (sdr, sir, sar, perm)
639318
def _make_eval_func(self, tensors, session, feed_dict, fetches,
                      callback=None):
    """"""
    if not isinstance(tensors, list):
      tensors = [tensors]
    num_tensors = len(tensors)

    def eval_func(x):
      """Function to evaluate a `Tensor`."""
      shapes = dict(zip(self._vars, self._var_shapes))
      augmented_feed_dict = {
          var: x[packing_slice].reshape(shapes[var])
          for var, packing_slice in zip(self._vars, self._packing_slices)
      }
      augmented_feed_dict.update(feed_dict)
      augmented_fetches = tensors + fetches

      augmented_fetch_vals = session.run(
          augmented_fetches, feed_dict=augmented_feed_dict)

      if callable(callback):
        callback(*augmented_fetch_vals[num_tensors:])

      return augmented_fetch_vals[:num_tensors]

    return eval_func
219922
function evalIteration(result, context, node, vars) {
    var iter = new Ruleset(scopeSelector, vars),
        push = true;

    if (node.condition) {
        var frames = context.frames;
        iter.functionRegistry = frames[0].functionRegistry;
        // ^ fixme: dirty kludge, not sure if it's related 
        // to #3054 - maybe there's more mistery (needs research)
        frames.unshift(iter);
        push = node.condition.eval(context);
        frames.shift();
    }

    if (push) {
        pushArray.apply(iter.rules, node.rules);
        result.push(iter);
    }
}
1194672
def eval_image(image, height, width, scope=None):
  
  with tf.name_scope(values=[image, height, width], name=scope,
                     default_name='eval_image'):
    # Crop the central region of the image with an area containing 87.5% of
    # the original image.
    image = tf.image.central_crop(image, central_fraction=0.875)

    # Resize the image to the original height and width.
    image = tf.expand_dims(image, 0)
    image = tf.image.resize_bilinear(image, [height, width],
                                     align_corners=False)
    image = tf.squeeze(image, [0])
    return image
424301
def bsseval(inargs=None):
    
    parser = argparse.ArgumentParser()

    parser.add_argument(
        'reference_dir',
        type=str
    )

    parser.add_argument(
        'estimates_dir',
        type=str
    )

    parser.add_argument('-o', help='output_dir')

    parser.add_argument(
        '--win', type=float, help='Window size in seconds', default=1.0
    )

    parser.add_argument(
        '--hop', type=float, help='Hop size in seconds', default=1.0
    )

    parser.add_argument(
        '-m', type=str, help='bss_eval version [`v3`, `v4`]', default='v4'
    )

    parser.add_argument(
        '--version', '-v',
        action='version',
        version='%%(prog)s %s' % util.__version__
    )

    args = parser.parse_args(inargs)

    if not args.o:
        output_dir = args.estimates_dir
    else:
        output_dir = args.o

    # evaluate an existing estimate folder with wav files
    data = eval_dir(
        args.reference_dir,
        args.estimates_dir,
        output_dir=output_dir,
        mode=args.m,
        win=args.win,
        hop=args.hop
    )

    print(data)
781057
def _EvaluateExpression(frame, expression):
  
  try:
    code = compile(expression, '<watched_expression>', 'eval')
  except (TypeError, ValueError) as e:
    # expression string contains null bytes.
    return (False, {
        'isError': True,
        'refersTo': 'VARIABLE_NAME',
        'description': {
            'format': 'Invalid expression',
            'parameters': [str(e)]}})
  except SyntaxError as e:
    return (False, {
        'isError': True,
        'refersTo': 'VARIABLE_NAME',
        'description': {
            'format': 'Expression could not be compiled: $0',
            'parameters': [e.msg]}})

  try:
    return (True, native.CallImmutable(frame, code))
  except BaseException as e:  # pylint: disable=broad-except
    return (False, {
        'isError': True,
        'refersTo': 'VARIABLE_VALUE',
        'description': {
            'format': 'Exception occurred: $0',
            'parameters': [str(e)]}})
617761
def traverse_bfs(self):
        '''
        '''
        if not isinstance(include_self, bool):
            raise TypeError("include_self must be a bool")
        q = deque(); dist = dict(); dist[self] = 0; q.append((self,0))
        while len(q) != 0:
            curr = q.popleft(); yield curr
            for c in curr[0].children:
                if c not in dist:
                    if c.edge_length is None:
                        el = 0
                    else:
                        el = c.edge_length
                    dist[c] = dist[curr[0]] + el; q.append((c,dist[c]))
            if curr[0].parent is not None and curr[0].parent not in dist:
                if curr[0].edge_length is None:
                    el = 0
                else:
                    el = curr[0].edge_length
                dist[curr[0].parent] = dist[curr[0]] + el; q.append((curr[0].parent,dist[curr[0].parent]))
552646
def eval_objfn(self):
        

        dfd = self.obfn_dfd()
        reg = self.obfn_reg()
        obj = dfd + reg[0]
        return (obj, dfd) + reg[1:]
477549
def _bsd_brshow(br=None):
    '''
    
    '''
    if __grains__['kernel'] == 'NetBSD':
        return _netbsd_brshow(br)

    ifconfig = _tool_path('ifconfig')

    ifaces = {}

    if br:
        ifaces[br] = br
    else:
        cmd = '{0} -g bridge'.format(ifconfig)
        for line in __salt__['cmd.run'](cmd, python_shell=False).splitlines():
            ifaces[line] = line

    brs = {}

    for iface in ifaces:
        cmd = '{0} {1}'.format(ifconfig, iface)
        for line in __salt__['cmd.run'](cmd, python_shell=False).splitlines():
            brs[iface] = {
                'interfaces': [],
                'stp': 'no'
            }
            line = line.lstrip()
            if line.startswith('member:'):
                brs[iface]['interfaces'].append(line.split(' ')[1])
                if 'STP' in line:
                    brs[iface]['stp'] = 'yes'

    if br:
        return brs[br]
    return brs
735251
def evaluate(self, x):
        

        if self.n_procs == 1:
            f_evals, cost_evals = self._eval_func(x)
        else:
            try:
                f_evals, cost_evals = self._syncronous_batch_evaluation(x)
            except:
                if not hasattr(self, 'parallel_error'):
                    print('Error in parallel computation. Fall back to single process!')
                else:
                    self.parallel_error = True
                f_evals, cost_evals = self._eval_func(x)

        return f_evals, cost_evals
1220694
def evaluate_expression(dbg, frame, expression, is_exec):
    '''
    '''
    if frame is None:
        return

    # Not using frame.f_globals because of https://sourceforge.net/tracker2/?func=detail&aid=2541355&group_id=85796&atid=577329
    # (Names not resolved in generator expression in method)
    # See message: http://mail.python.org/pipermail/python-list/2009-January/526522.html
    updated_globals = {}
    updated_globals.update(frame.f_globals)
    updated_globals.update(frame.f_locals)  # locals later because it has precedence over the actual globals

    try:
        expression = str(expression.replace('@LINE@', '\n'))

        if is_exec:
            try:
                # try to make it an eval (if it is an eval we can print it, otherwise we'll exec it and
                # it will have whatever the user actually did)
                compiled = compile(expression, '<string>', 'eval')
            except:
                Exec(expression, updated_globals, frame.f_locals)
                pydevd_save_locals.save_locals(frame)
            else:
                result = eval(compiled, updated_globals, frame.f_locals)
                if result is not None:  # Only print if it's not None (as python does)
                    sys.stdout.write('%s\n' % (result,))
            return

        else:
            return eval_in_context(expression, updated_globals, frame.f_locals)
    finally:
        # Should not be kept alive if an exception happens and this frame is kept in the stack.
        del updated_globals
        del frame
141840
def _update_image_flash_params(esp, address, args, image):
    
    if len(image) < 8:
        return image  # not long enough to be a bootloader image

    # unpack the (potential) image header
    magic, _, flash_mode, flash_size_freq = struct.unpack("BBBB", image[:4])
    if address != esp.BOOTLOADER_FLASH_OFFSET or magic != esp.ESP_IMAGE_MAGIC:
        return image  # not flashing a bootloader, so don't modify this

    if args.flash_mode != 'keep':
        flash_mode = {'qio':0, 'qout':1, 'dio':2, 'dout': 3}[args.flash_mode]

    flash_freq = flash_size_freq & 0x0F
    if args.flash_freq != 'keep':
        flash_freq = {'40m':0, '26m':1, '20m':2, '80m': 0xf}[args.flash_freq]

    flash_size = flash_size_freq & 0xF0
    if args.flash_size != 'keep':
        flash_size = esp.parse_flash_size_arg(args.flash_size)

    flash_params = struct.pack(b'BB', flash_mode, flash_size + flash_freq)
    if flash_params != image[2:4]:
        print('Flash params set to 0x%04x' % struct.unpack(">H", flash_params))
        image = image[0:2] + flash_params + image[4:]
    return image
62262
def eval(s, bndng=nil, filename=nil, lineno=nil)

      loadstring_and_call(s, bndng, filename, lineno)
    end
1014153
def image_by_slice_pos(pos)
      # Step 1: Try for an (exact) match:
      image = @image_positions[pos.round(2)]
      # Step 2: If no match, try to search for a close match:
      # (A close match is defined as the given slice position being within 1/3 of the
      # slice distance from an existing image instance in the series)
      if !image && @images.length > 1
        proximity = @images.collect{|img| (img.pos_slice - pos).abs}
        if proximity.min < slice_spacing / 3.0
          index = proximity.index(proximity.min)
          image = @images[index]
        end
      end
      return image
    end
66026
def eval(cls, exp, files=None):
        
        return cls.show(cls.get(exp, files=files))
229475
def _Backward3_v_Ps(P, s):
    
    if s <= sc:
        return _Backward3a_v_Ps(P, s)
    else:
        return _Backward3b_v_Ps(P, s)