當前位置: 首頁>>代碼示例>>Python>>正文


Python builtins.list方法代碼示例

本文整理匯總了Python中builtins.list方法的典型用法代碼示例。如果您正苦於以下問題:Python builtins.list方法的具體用法?Python builtins.list怎麽用?Python builtins.list使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在builtins的用法示例。


在下文中一共展示了builtins.list方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: standardize

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import list [as 別名]
def standardize(dataframe):
    """Scales numerical columns using their means and standard deviation to get
    z-scores: the mean of each numerical column becomes 0, and the standard
    deviation becomes 1. This can help the model converge during training.

    Args:
      dataframe: Pandas dataframe

    Returns:
      Input dataframe with the numerical columns scaled to z-scores
    """
    dtypes = list(zip(dataframe.dtypes.index, map(str, dataframe.dtypes)))
    # Normalize numeric columns.
    for column, dtype in dtypes:
        if dtype == 'float32':
            dataframe[column] -= dataframe[column].mean()
            dataframe[column] /= dataframe[column].std()
    return dataframe 
開發者ID:GoogleCloudPlatform,項目名稱:ml-on-gcp,代碼行數:20,代碼來源:utils.py

示例2: __init__

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import list [as 別名]
def __init__(self, space: StateSpace, typ: Type, smtvar: object):
        self.val_pytype = normalize_pytype(type_arg_of(typ, 1))
        self.smt_val_sort = type_to_smt_sort(self.val_pytype)
        SmtDictOrSet.__init__(self, space, typ, smtvar)
        self.val_ch_type = crosshair_type_for_python_type(self.val_pytype)
        arr_var = self._arr()
        len_var = self._len()
        self.val_missing_checker = arr_var.sort().range().recognizer(0)
        self.val_missing_constructor = arr_var.sort().range().constructor(0)
        self.val_constructor = arr_var.sort().range().constructor(1)
        self.val_accessor = arr_var.sort().range().accessor(1, 0)
        self.empty = z3.K(arr_var.sort().domain(),
                          self.val_missing_constructor())
        self._iter_cache = []
        space.add((arr_var == self.empty) == (len_var == 0))
        def list_can_be_iterated():
            list(self)
            return True
        space.defer_assumption('dict iteration is consistent with items', list_can_be_iterated) 
開發者ID:pschanely,項目名稱:CrossHair,代碼行數:21,代碼來源:builtinslib.py

示例3: _decode_header

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import list [as 別名]
def _decode_header(header):
        """Decodes an email header and returns it as a string. Any  parts of
        the header that cannot be decoded are simply ignored.
        """
        parts = list()
        try:
            decoded_header = email.header.decode_header(header)
        except (ValueError, email.header.HeaderParseError):
            return

        for value, encoding in decoded_header:
            if encoding:
                try:
                    parts.append(value.decode(encoding, "ignore"))
                except (LookupError, UnicodeError, AssertionError):
                    continue
            else:
                try:
                    parts.append(value.decode("utf-8", "ignore"))
                except AttributeError:
                    parts.append(value)
        return "".join(parts) 
開發者ID:SpamExperts,項目名稱:OrangeAssassin,代碼行數:24,代碼來源:message.py

示例4: tokenize

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import list [as 別名]
def tokenize(input, escapables={"'", '"', '\\'} | {item for item in string.whitespace} - {' '}):
    """Yield each token belonging to the windbg format in `input` that would need to be escaped using the specified `escapables`.

    If the set `escapables` is defined, then use it as the list of characters to tokenize.
    """
    result, iterable = '', iter(input)
    try:
        while True:
            char = six.next(iterable)
            if operator.contains(escapables, char):
                if result:
                    yield result
                yield char
                result = ''

            else:
                result += char
            continue

    except StopIteration:
        if result:
            yield result
        return
    return 
開發者ID:arizvisa,項目名稱:ida-minsc,代碼行數:26,代碼來源:windbg.py

示例5: collect_stdlib_distributions

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import list [as 別名]
def collect_stdlib_distributions():
    """Yield a conventional spec and the names of all top_level standard library modules."""
    distribution_spec = 'Python==%d.%d.%d' % sys.version_info[:3]
    stdlib_path = sysconfig.get_python_lib(standard_lib=True)
    distribution_top_level = [name for _, name, _ in pkgutil.iter_modules(path=[stdlib_path])]
    distribution_top_level += list(sys.builtin_module_names)
    yield distribution_spec, distribution_top_level 
開發者ID:nodev-io,項目名稱:pytest-nodev,代碼行數:9,代碼來源:collect.py

示例6: pytest_addoption

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import list [as 別名]
def pytest_addoption(parser):
    group = parser.getgroup('nodev')
    group.addoption(
        '--candidates-from-stdlib', action='store_true',
        help="Collects candidates form the Python standard library.")
    group.addoption(
        '--candidates-from-all', action='store_true',
        help="Collects candidates form the Python standard library and all installed packages. "
             "Disabled by default, see the docs.")
    group.addoption(
        '--candidates-from-specs', default=[], nargs='+',
        help="Collects candidates from installed packages. Space separated list of `pip` specs.")
    group.addoption(
        '--candidates-from-modules', default=[], nargs='+',
        help="Collects candidates from installed modules. Space separated list of module names.")
    group.addoption(
        '--candidates-includes', nargs='+',
        help="Space separated list of regexs matching full object names to include, "
             "defaults to include all objects collected via `--candidates-from-*`.")
    group.addoption(
        '--candidates-excludes', default=[], nargs='+',
        help="Space separated list of regexs matching full object names to exclude.")
    group.addoption(
        '--candidates-predicate', default='builtins:callable',
        help="Full name of the predicate passed to `inspect.getmembers`, "
             "defaults to `builtins.callable`.")
    group.addoption('--candidates-fail', action='store_true', help="Show candidates failures.") 
開發者ID:nodev-io,項目名稱:pytest-nodev,代碼行數:29,代碼來源:plugin.py

示例7: pytest_pycollect_makeitem

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import list [as 別名]
def pytest_pycollect_makeitem(collector, name, obj):
    candidate_marker = getattr(obj, 'candidate', None)
    if candidate_marker and getattr(candidate_marker, 'args', []):
        candidate_name = candidate_marker.args[0]

        def wrapper(candidate, monkeypatch, *args, **kwargs):
            if '.' in candidate_name:
                monkeypatch.setattr(candidate_name, candidate, raising=False)
            else:
                monkeypatch.setattr(inspect.getmodule(obj), candidate_name, candidate, raising=False)
            return obj(*args, **kwargs)

        wrapper.__dict__ = obj.__dict__
        return list(collector._genfunctions(name, wrapper)) 
開發者ID:nodev-io,項目名稱:pytest-nodev,代碼行數:16,代碼來源:plugin.py

示例8: test_collect_stdlib_distributions

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import list [as 別名]
def test_collect_stdlib_distributions():
    stdlib_distributions = list(collect.collect_stdlib_distributions())
    assert len(stdlib_distributions) == 1
    _, module_names = stdlib_distributions[0]
    assert len(module_names) > 10 
開發者ID:nodev-io,項目名稱:pytest-nodev,代碼行數:7,代碼來源:test_collect.py

示例9: test_collect_distributions

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import list [as 別名]
def test_collect_distributions():
    distributions = list(collect.collect_distributions(['pytest-nodev']))
    assert len(distributions) == 1
    _, module_names = distributions[0]
    assert len(module_names) == 1
    assert len(list(collect.collect_distributions(['non_existent_distribution']))) == 0 
開發者ID:nodev-io,項目名稱:pytest-nodev,代碼行數:8,代碼來源:test_collect.py

示例10: test_import_distributions

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import list [as 別名]
def test_import_distributions():
    distributions = [('pytest-nodev', ['pytest_nodev'])]
    module_names = list(collect.import_distributions(distributions))
    assert module_names == ['pytest_nodev']

    distributions = [('pytest-nodev', ['non_existent_module'])]
    module_names = list(collect.import_distributions(distributions))
    assert module_names == [] 
開發者ID:nodev-io,項目名稱:pytest-nodev,代碼行數:10,代碼來源:test_collect.py

示例11: test_generate_module_objects

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import list [as 別名]
def test_generate_module_objects():
    expected_item = ('generate_module_objects', collect.generate_module_objects)
    assert expected_item in list(collect.generate_module_objects(collect)) 
開發者ID:nodev-io,項目名稱:pytest-nodev,代碼行數:5,代碼來源:test_collect.py

示例12: test_generate_objects_from_modules

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import list [as 別名]
def test_generate_objects_from_modules():
    import re
    modules = {'pytest_nodev.collection': collect, 're': re}
    include_patterns = ['pytest_nodev.collection:generate_objects_from_modules']
    objs = collect.generate_objects_from_modules(
        modules, include_patterns, module_blacklist_pattern='re')
    assert len(list(objs)) == 1 
開發者ID:nodev-io,項目名稱:pytest-nodev,代碼行數:9,代碼來源:test_collect.py

示例13: columnar_data_chunks

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import list [as 別名]
def columnar_data_chunks(self, data_path, sa_table, chunk_size):
        """A generator function that returns chunk_size rows (or whatever is left
        at the end of the file) in columnar format
        This function also performs conversion from string to python datatype based on the given
        SQLAlchemy schema.
        """

        # An array of functions corresponding to the CSV columns that take a string and return the
        # corresponding Python datatype
        type_converters = self.table_to_conversion_funcs(sa_table)
        with self.get_csv_reader(data_path) as reader:
            num_cols = len(sa_table.columns)
            col_indices = range(num_cols)
            data = [list() for i in range(num_cols)]

            # Read in CSV and store it by column (makes passing to Arrow easier)
            for row in reader:
                # read a row
                for i in col_indices:
                    value = row[i]
                    py_type = type_converters[i]

                    value = self._convert_to_type(value, py_type)
                    data[i].append(value)

                if len(data[0]) == chunk_size:
                    yield data
                    self._clear_and_collect(data)

            # Number of rows in file is not necessarily divisible by chunk_size
            # So make sure there isn't any lingering data to process
            if data[0]:
                yield data
                self._clear_and_collect(data) 
開發者ID:hellonarrativ,項目名稱:spectrify,代碼行數:36,代碼來源:convert.py

示例14: assign

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import list [as 別名]
def assign(item, assignment, **kwargs):
    key = kwargs.get('assign')
    value = next(assignment) if kwargs.get('one') else list(assignment)
    merged = merge([item, {key: value}])
    yield DotDict(merged) if kwargs.get('dictize') else merged 
開發者ID:nerevu,項目名稱:riko,代碼行數:7,代碼來源:__init__.py

示例15: __init__

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import list [as 別名]
def __init__(self, *args, length=None, graph=None, name=None, dependencies=None, **kwargs):
        self.args = args
        self.kwargs = kwargs
        self.length = length
        self.graph = Graph.get_active_graph(graph)
        # Choose a name for the operation and add the operation to the graph
        self._name = None
        self.name = name or uuid.uuid4().hex
        # Get a list of all dependencies relevant to this operation
        self.dependencies = [] if dependencies is None else dependencies
        self.dependencies.extend(self.graph.dependencies)
        # Get the stack context so we can report where the operation was defined
        self._stack = traceback.extract_stack() 
開發者ID:spotify,項目名稱:pythonflow,代碼行數:15,代碼來源:core.py


注:本文中的builtins.list方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。