当前位置: 首页>>代码示例>>Python>>正文


Python toolz.pipe方法代码示例

本文整理汇总了Python中toolz.pipe方法的典型用法代码示例。如果您正苦于以下问题:Python toolz.pipe方法的具体用法?Python toolz.pipe怎么用?Python toolz.pipe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在toolz的用法示例。


在下文中一共展示了toolz.pipe方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_sample

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import pipe [as 别名]
def test_sample():
    """Test the sample data transformer."""
    data = _create_dataframe(20)
    result = pipe(data, sample(n=10))
    assert len(result) == 10
    assert isinstance(result, pd.DataFrame)
    data = _create_data_with_values(20)
    result = sample(data, n=10)
    assert isinstance(result, dict)
    assert "values" in result
    assert len(result["values"]) == 10
    data = _create_dataframe(20)
    result = pipe(data, sample(frac=0.5))
    assert len(result) == 10
    assert isinstance(result, pd.DataFrame)
    data = _create_data_with_values(20)
    result = sample(data, frac=0.5)
    assert isinstance(result, dict)
    assert "values" in result
    assert len(result["values"]) == 10 
开发者ID:altair-viz,项目名称:altair,代码行数:22,代码来源:test_data.py

示例2: test_dataframe_to_json

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import pipe [as 别名]
def test_dataframe_to_json():
    """Test to_json
    - make certain the filename is deterministic
    - make certain the file contents match the data
    """
    data = _create_dataframe(10)
    try:
        result1 = pipe(data, to_json)
        result2 = pipe(data, to_json)
        filename = result1["url"]
        output = pd.read_json(filename)
    finally:
        os.remove(filename)

    assert result1 == result2
    assert output.equals(data) 
开发者ID:altair-viz,项目名称:altair,代码行数:18,代码来源:test_data.py

示例3: test_dataframe_to_csv

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import pipe [as 别名]
def test_dataframe_to_csv():
    """Test to_csv with dataframe input
    - make certain the filename is deterministic
    - make certain the file contents match the data
    """
    data = _create_dataframe(10)
    try:
        result1 = pipe(data, to_csv)
        result2 = pipe(data, to_csv)
        filename = result1["url"]
        output = pd.read_csv(filename)
    finally:
        os.remove(filename)

    assert result1 == result2
    assert output.equals(data) 
开发者ID:altair-viz,项目名称:altair,代码行数:18,代码来源:test_data.py

示例4: test_dict_to_csv

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import pipe [as 别名]
def test_dict_to_csv():
    """Test to_csv with dict input
    - make certain the filename is deterministic
    - make certain the file contents match the data
    """
    data = _create_data_with_values(10)
    try:
        result1 = pipe(data, to_csv)
        result2 = pipe(data, to_csv)
        filename = result1["url"]
        output = pd.read_csv(filename).to_dict(orient="records")
    finally:
        os.remove(filename)

    assert result1 == result2
    assert data == {"values": output} 
开发者ID:altair-viz,项目名称:altair,代码行数:18,代码来源:test_data.py

示例5: _valid_log_files

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import pipe [as 别名]
def _valid_log_files(log_dir):
    def _valid_or_warn(log_file):
        if log_file.has_valid_filename():
            return True

        logging.warning("Invalid filename: %s", log_file.filename())
        return False

    def _to_paths(triple):
        root, _, files_in_dir = triple
        return [os.path.join(root, file_in_dir) for file_in_dir in files_in_dir]

    return pipe(os.walk(log_dir),
                mapcatz(_to_paths),
                mapz(LogFile),
                filterz(_valid_or_warn)) 
开发者ID:flosell,项目名称:trailscraper,代码行数:18,代码来源:cloudtrail.py

示例6: plot

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import pipe [as 别名]
def plot(self, gpu_measurement='sm', num_gpus=1, plot_width=600, plot_height=400, y_range=(0, 110)):
        """ Plot the specified GPU measurement

        Parameters
        ----------
        gpu_measurement: GPU measurement to plot possible values
        num_gpus: Number of GPUs to plot ['pwr', 'temp', 'sm', 'mem', 'enc', 'dec', 'mclk', 'pclk']
        plot_width:
        plot_height:
        y_range:

        Returns
        -------
        Bokeh Figure
        """
        df = pipe(self._log_file,
                  parse_log,
                  extract(gpu_measurement))
        return plot(df,
                    num_gpus=num_gpus,
                    plot_width=plot_width,
                    plot_height=plot_height,
                    y_range=y_range) 
开发者ID:msalvaris,项目名称:gpu_monitor,代码行数:25,代码来源:gpu_logger.py

示例7: get_contract_address

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import pipe [as 别名]
def get_contract_address(task_uuid):
    await_tr = partial(await_blockchain_success_evil, timeout=timeout)
    return pipe(task_uuid, await_tr, lambda r: r.get('contract_address')) 
开发者ID:teamsempo,项目名称:SempoBlockchain,代码行数:5,代码来源:composite.py

示例8: _open_image

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import pipe [as 别名]
def _open_image(self, image_path):
        return pipe(image_path, _open_to_array, _rescale) 
开发者ID:microsoft,项目名称:seismic-deeplearning,代码行数:4,代码来源:data.py

示例9: _open_mask

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import pipe [as 别名]
def _open_mask(self, mask_path):
        return pipe(mask_path, _open_to_array) 
开发者ID:microsoft,项目名称:seismic-deeplearning,代码行数:4,代码来源:data.py

示例10: test_limit_rows

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import pipe [as 别名]
def test_limit_rows():
    """Test the limit_rows data transformer."""
    data = _create_dataframe(10)
    result = limit_rows(data, max_rows=20)
    assert data is result
    with pytest.raises(MaxRowsError):
        pipe(data, limit_rows(max_rows=5))
    data = _create_data_with_values(10)
    result = pipe(data, limit_rows(max_rows=20))
    assert data is result
    with pytest.raises(MaxRowsError):
        limit_rows(data, max_rows=5) 
开发者ID:altair-viz,项目名称:altair,代码行数:14,代码来源:test_data.py

示例11: test_to_values

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import pipe [as 别名]
def test_to_values():
    """Test the to_values data transformer."""
    data = _create_dataframe(10)
    result = pipe(data, to_values)
    assert result == {"values": data.to_dict(orient="records")} 
开发者ID:altair-viz,项目名称:altair,代码行数:7,代码来源:test_data.py

示例12: test_type_error

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import pipe [as 别名]
def test_type_error():
    """Ensure that TypeError is raised for types other than dict/DataFrame."""
    for f in (sample, limit_rows, to_values):
        with pytest.raises(TypeError):
            pipe(0, f) 
开发者ID:altair-viz,项目名称:altair,代码行数:7,代码来源:test_data.py

示例13: __call__

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import pipe [as 别名]
def __call__(self, coords):
        return tz.pipe(coords, *self) 
开发者ID:napari,项目名称:napari,代码行数:4,代码来源:transforms.py

示例14: simplified

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import pipe [as 别名]
def simplified(self) -> 'Transform':
        """Return the composite of the transforms inside the transform chain."""
        if len(self) == 0:
            return None
        if len(self) == 1:
            return self[0]
        else:
            return tz.pipe(self[0], *[tf.compose for tf in self[1:]]) 
开发者ID:napari,项目名称:napari,代码行数:10,代码来源:transforms.py

示例15: last_event_timestamp_in_dir

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import pipe [as 别名]
def last_event_timestamp_in_dir(log_dir):
    """Return the timestamp of the most recent event in the given directory"""
    most_recent_file = pipe(_valid_log_files(log_dir),
                            sortedz(key=LogFile.timestamp),
                            lastz,
                            LogFile.records,
                            sortedz(key=lambda record: record.event_time),
                            lastz)

    return most_recent_file.event_time 
开发者ID:flosell,项目名称:trailscraper,代码行数:12,代码来源:cloudtrail.py


注:本文中的toolz.pipe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。