How to use the cytoolz.pipe function in cytoolz

To help you get started, we’ve selected a few cytoolz examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microscopium / microscopium / microscopium / preprocess.py View on Github external
See Also
    --------
    `correct_image_illumination`, `correct_multiimage_illumination`.
    """
    # this function follows the "PyToolz" streaming data model to
    # obtain the illumination estimate.
    # first, define the functions for each individual step:
    in_range = ('image' if input_bitdepth is None
                else (0, 2**input_bitdepth - 1))
    rescale = tz.curry(exposure.rescale_intensity)
    normalize = (tz.partial(stretchlim, bottom=stretch_quantile)
                 if stretch_quantile > 0
                 else skimage.img_as_float)

    # produce a stream of properly-scaled images
    ims = (tz.pipe(fn, io.imread, rescale(in_range=in_range), normalize)
           for fn in fns)

    # take the mean of that stream
    mean_image = mean(ims)

    # return the median filter of that mean
    radius = radius or min(mean_image.shape) // 4
    illum = ndi.percentile_filter(mean_image, percentile=(quantile * 100),
                                  footprint=morphology.disk(radius))
    return illum
github ethereum / sharding / tests / handler / utils / deploy.py View on Github external
def get_contract_address_from_deploy_tx(transaction):
    return pipe(
        transaction.sender,
        to_canonical_address,
        functools.partial(generate_contract_address, nonce=0),
    )
github ethereum / trinity / tests / core / builder-tools / test_chain_initializer.py View on Github external
def test_chain_builder_initialize_chain_with_state_simple(chain_class):
    chain = pipe(
        chain_class,
        genesis(
            state=((ADDRESS_A, 'balance', 1),),
        )
    )

    header = chain.get_canonical_head()
    assert header == chain.get_canonical_block_by_number(0).header

    assert header.state_root != constants.BLANK_ROOT_HASH

    account_db = chain.get_vm().state.account_db
    assert account_db.get_balance(ADDRESS_A) == 1
github ethereum / trinity / tests / sharding / fixtures.py View on Github external
def get_contract_address_from_contract_tx(transaction):
    return pipe(
        transaction.sender,
        to_canonical_address,
        functools.partial(generate_contract_address, nonce=0),
    )
github microscopium / microscopium / microscopium / preprocess.py View on Github external
2
    >>> montaged[0].shape
    (8, 10, 3)
    >>> montaged[0][0, 0, :]
    array([2, 0, 1], dtype=uint8)
    >>> montaged[0][4, 5, :]
    array([11,  9, 10], dtype=uint8)
    >>> montaged[1][4, 5, :]
    array([23, 21, 22], dtype=uint8)
    """
    if montage_order is None:
        montage_order = cellomics.SPIRAL_CLOCKWISE_RIGHT_25
    montage_order = np.array(montage_order)
    ntiles = montage_order.size
    nchannels = len(channel_order)
    return tz.pipe(ims, c.partition(nchannels),
                        c.map(stack_channels(order=channel_order)),
                        c.partition(ntiles),
                        c.map(montage(order=montage_order)))
github FISCO-BCOS / python-sdk / client / transactions.py View on Github external
def serializable_unsigned_transaction_from_dict(transaction_dict):
    assert_valid_fields(transaction_dict)
    filled_transaction = pipe(
        transaction_dict,
        dict,
        partial(merge, TRANSACTION_DEFAULTS),
        chain_id_to_v,
        apply_formatters_to_dict(TRANSACTION_FORMATTERS),
    )
    if 'v' in filled_transaction:
        serializer = Transaction
    else:
        serializer = UnsignedTransaction
    return serializer.from_dict(filled_transaction)
github ethereum / trinity / eth / precompiles / ecpairing.py View on Github external
def _ecpairing(data: BytesOrView) -> bool:
    exponent = bn128.FQ12.one()

    processing_pipeline = (
        _process_point(data[start_idx:start_idx + 192])
        for start_idx
        in range(0, len(data), 192)
    )
    exponent = pipe(bn128.FQ12.one(), *processing_pipeline)

    result = bn128.final_exponentiate(exponent) == bn128.FQ12.one()
    return result
github ethereum / trinity / evm / vm / forks / sharding / shard_tracker.py View on Github external
def fetch_candidate_head(self):
        # Try to return a log that has the score that we are checking for,
        # checking in order of oldest to most recent.
        unchecked_logs = pipe(
            self.unchecked_logs,
            enumerate,
            tuple,
            reversed,
            tuple,
        )
        current_score = self.current_score

        for idx, log_entry in unchecked_logs:
            if log_entry['score'] == current_score:
                return self.unchecked_logs.pop(idx)
        # If no further recorded but unchecked logs exist, go to the next
        # is_new_head = true log
        while True:
            try:
                log_entry = self.get_next_log()