當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。