Construct delta-filter command
767415
def _delta_filter_command(self, infile, outfile):
        ''''''
        command = 'delta-filter'

        if self.min_id is not None:
            command += ' -i ' + str(self.min_id)

        if self.min_length is not None:
            command += ' -l ' + str(self.min_length)

        return command + ' ' + infile + ' > ' + outfile
20934
def make_filter_list(filters):
    """"""
    filter_list = []
    filter_ids = []
    for f in filters:
        filter_ids.append(f.index)
        fullname = URL_P.sub(r'`<\1>`_', f.fullname)
        filter_list.append((str(f.index + 1),
                            f.name,
                            "{0:.2f}".format(f.msun_vega),
                            "{0:.2f}".format(f.msun_ab),
                            "{0:.1f}".format(f.lambda_eff),
                            fullname))
    sortf = lambda item: int(item[0])
    filter_list.sort(key=sortf)
    return filter_list
231628
def to_h(all=false)
      filter_parameters.select{|k,v| all || !v.blank?}
    end
441574
def delta(text):
    '''
    
    '''
    text = text.strip().lower()

    _, offs = _noms(text, 0, ' \t\r\n')

    sign = '+'
    if text and text[0] in ('+', '-'):
        sign = text[0]
        offs += 1

    _, offs = _noms(text, offs, ' \t\r\n')

    sizetext, offs = _noms(text, offs, '0123456789')

    _, offs = _noms(text, offs, ' \t\r\n')

    unittext = text[offs:]

    size = int(sizetext, 0)

    if sign == '-':
        size = -size

    base = timeunits.get(unittext)
    if base is None:
        mesg = f'unknown time delta units: {unittext}'
        raise s_exc.BadTypeValu(name='time', valu=text, mesg=mesg)

    return size * base
796503
def sigmafilter(data, sigmas, passes):
    """"""
    for n in range(passes):
        meandata = np.mean(data[~np.isnan(data)])
        sigma = np.std(data[~np.isnan(data)])
        data[data > meandata+sigmas*sigma] = np.nan
        data[data < meandata-sigmas*sigma] = np.nan
    return data
1336995
def do_newfilter(self, subcmd, opts):
        
        from mdlib.filterprocessor import RULES
        print(RULES, file=self.stdout)
274790
def plot_filter_transmissions(log, filterList):
    
    ################ > IMPORTS ################
    ## STANDARD LIB ##
    ## THIRD PARTY ##
    import matplotlib.pyplot as plt
    import numpy as np
    ## LOCAL APPLICATION ##

    ################ > VARIABLE SETTINGS ######
    ################ >ACTION(S) ################
    for filterFile in filterList:
        data = np.genfromtxt(filterFile)
        plt.plot(data[:, 0], data[:, 1])

    plt.show()
    return
1310165
def __get_delta_files(self):
        """"""
        files = [(d, f) for d in self.dirs for f in listdir(d) if isfile(join(d, f))]

        deltas = OrderedDict()
        for d, f in files:
            file_ = join(d, f)

            if not Delta.is_valid_delta_name(file_):
                continue

            delta = Delta(file_)

            if d not in deltas:
                deltas[d] = []
            deltas[d].append(delta)

        # sort delta objects in each bucket
        for d in deltas:
            deltas[d].sort(key=lambda x: (x.get_version(), x.get_priority(), x.get_name()))

        return deltas
802604
def make_rule(filter, *symbolizers):
    
    scale_tests = [test for test in filter.tests if test.isMapScaled()]
    other_tests = [test for test in filter.tests if not test.isMapScaled()]
    
    # these will be replaced with values as necessary
    minscale, maxscale, filter = None, None, None
    
    for scale_test in scale_tests:

        if scale_test.op in ('>', '>='):
            if scale_test.op == '>=':
                value = scale_test.value
            elif scale_test.op == '>':
                value = scale_test.value + 1

            minscale = output.MinScaleDenominator(value)

        if scale_test.op in ('<', '<='):
            if scale_test.op == '<=':
                value = scale_test.value
            elif scale_test.op == '<':
                value = scale_test.value - 1

            maxscale = output.MaxScaleDenominator(value)
    
    filter_text = ' and '.join(test2str(test) for test in other_tests)
    
    if filter_text:
        filter = output.Filter(filter_text)

    rule = output.Rule(minscale, maxscale, filter, [s for s in symbolizers if s])
    
    return rule
966691
private Delta parseConditionalDelta() {
        Condition test = parseCondition();
        String then = _t.nextToken();
        if (!"then".equals(then)) {
            throw _t.syntaxError("Expected 'then' and instead saw '" + then + "'");
        }
        Delta delta = parseDelta();
        String next = _t.nextToken();
        if ("elif".equals(next)) {
            // The recursive call will consume the 'end' token.
            Delta otherwise = parseConditionalDelta();
            return Deltas.conditional(test, delta, otherwise);
        }
        Delta otherwise = Deltas.noop();
        if ("else".equals(next)) {
            otherwise = parseDelta();
            next = _t.nextToken();
        }
        if (!"end".equals(next)) {
            throw _t.syntaxError("Expected 'end' and instead saw '" + next + "'");
        }
        return Deltas.conditional(test, delta, otherwise);
    }
324174
def delta(a, b):
    
    diff = a - b
    return numpy.einsum("i...,i...->...", diff, diff)
367570
def _process_stream_delta(self, delta_stream):
        """"""
        for pchange in delta_stream:
            if pchange.kind == ChangeType.ADD:
                self.policy_files.setdefault(
                    pchange.file_path, PolicyCollection()).add(pchange.policy)
            elif pchange.kind == ChangeType.REMOVE:
                self.policy_files[pchange.file_path].remove(pchange.policy)
            elif pchange.kind in (ChangeType.MOVED, ChangeType.MODIFIED):
                if pchange.policy.file_path != pchange.previous.file_path:
                    self.policy_files[pchange.previous.file_path].remove(pchange.previous)
                    if (pchange.policy.file_path in self.policy_files and
                            pchange.policy.name in self.policy_files[pchange.file_path]):
                        self.policy_files[pchange.file_path][pchange.policy.name] = pchange.policy
                    else:
                        self.policy_files.setdefault(
                            pchange.file_path, PolicyCollection()).add(pchange.policy)
                else:
                    self.policy_files[pchange.file_path][pchange.policy.name] = pchange.policy
            yield pchange
1343360
def save_filter(name, filt, full=None, path='filters'):
    """

    # First we'll save the filter using its internal routine.
    # This will create the directory ./filters if it doesn't exist already.
    filt.tofile(path)

    # If full, we store the inversion output
    if full:

        # Get file name
        path = os.path.abspath(path)
        if len(name.split('.')) == 2:
            suffix = '.gz'
        else:
            suffix = ''
        fullfile = os.path.join(path, name.split('.')[0]+'_full.txt' + suffix)

        # Get number of spacing and shift values
        nspace, nshift = full[3].shape

        # Create header
        header = 'Full inversion output from empymod.fdesign.design\n'
        header += 'Line 11: Nr of spacing values\n'
        header += 'Line 12: Nr of shift values\n'
        header += 'Line 13: Best spacing value\n'
        header += 'Line 14: Best shift value\n'
        header += 'Line 15: Min amplitude or max offset\n'

        header += 'Lines 16-{}: Spacing matrix '.format(nspace+15)
        header += '({} x {})\n'.format(nspace, nshift)

        header += 'Lines {}-{}: Spacing matrix '.format(nspace+16, 2*nspace+15)
        header += '({} x {})\n'.format(nspace, nshift)

        header += 'Lines {}-{}: Spacing '.format(2*nspace+16, 3*nspace+15)
        header += 'matrix ({} x {})\n'.format(nspace, nshift)

        header += 'Line {}: Integer: 0: min amp, 1: max r'.format(3*nspace+16)

        # Create arrays; put single values in arrays of nshift values
        nr_spacing = np.r_[nspace, np.zeros(nshift-1)]
        nr_shift = np.r_[nshift, np.zeros(nshift-1)]
        best_spacing = np.r_[full[0][0], np.zeros(nshift-1)]
        best_shift = np.r_[full[0][1], np.zeros(nshift-1)]
        min_value = np.r_[np.atleast_1d(full[1]), np.zeros(nshift-1)]
        min_max = np.r_[full[4], np.zeros(nshift-1)]

        # Collect all in one array
        fullsave = np.vstack((nr_spacing, nr_shift, best_spacing, best_shift,
                              min_value, full[2][0], full[2][1], full[3],
                              min_max))

        # Save array
        np.savetxt(fullfile, fullsave, header=header)
546328
public function traceDeltaTime($delta, $over = true)
    {
        if (\is_string($delta)) {
            static $units = [
                'ns' => 1e-9,
                'us' => 1e-6,
                'ms' => 1e-3,
                's' => 1,
            ];

            foreach ($units as $unit => $multipler) {
                $length = \strlen($unit);
                if (\substr_compare($delta, $unit, -$length, $length, true) === 0) {
                    $delta = \substr($delta, 0, -$length) * $multipler;
                    break;
                }
            }
        }
        $delta = (float) $delta;

        $cb = function (\stdClass $record) use ($delta, $over) {
            if ($over) {
                if ($record->deltaTime < $delta) {
                    return self::SKIP;
                }
            }

            if ($record->deltaTime > $delta) {
                return self::SKIP;
            }

            return 0;
        };

        $this->setFilterCallback($cb, self::FILTER_EXIT);
    }
396506
function(template, delta) {
    assert.equal(typeof(template), 'object', "'template' is not an object");
    assert.equal(typeof(delta), 'object', "'delta' is not an object");

    var result = myUtils.deepClone(template);
    Object.keys(delta).forEach(function(x) {
        result[x] = myUtils.deepClone(delta[x]);
    });
    return result;
}
1198859
def apply_filters(df, filters):
        """"""
        idx = pd.Series([True]*df.shape[0])
        for k, v in list(filters.items()):
            if k not in df.columns:
                continue
            idx &= (df[k] == v)

        return df.loc[idx]
1189132
def show(self, filter=None):
        
        for command in self._commands:
            if command[0] is None:  # or command[1] in self._invalid_objects:
                continue  # Skip nill commands
            if filter and command[0] != filter:
                continue
            t = []
            for e in command:
                if isinstance(e, np.ndarray):
                    t.append('array %s' % str(e.shape))
                elif isinstance(e, str):
                    s = e.strip()
                    if len(s) > 20:
                        s = s[:18] + '... %i lines' % (e.count('\n')+1)
                    t.append(s)
                else:
                    t.append(e)
            print(tuple(t))