How to use pydash - 10 common examples

To help you get started, we’ve selected a few pydash 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 synesthesiam / voice2json / voice2json / utils.py View on Github external
def should_convert_wav(profile: Dict[str, Any], wav_io: BinaryIO) -> bool:
    expected_rate = int(pydash.get(profile, "audio.format.sample-rate-hertz", 16000))
    expected_width = int(pydash.get(profile, "audio.format.sample-width-bits", 16)) // 8
    expected_channels = int(pydash.get(profile, "audio.format.channel-count", 1))

    with wave.open(wav_io, "rb") as wav_file:
        rate, width, channels = (
            wav_file.getframerate(),
            wav_file.getsampwidth(),
            wav_file.getnchannels(),
        )

        return (
            (rate != expected_rate)
            or (width != expected_width)
            or (channels != expected_channels)
        )
github dgilland / pydash / tests / test_chaining.py View on Github external
def test_chaining_commit():
    chain = _.chain([1, 2, 3, 4]).power(2).sum()
    committed = chain.commit()

    assert chain is not committed
    assert chain.value() == committed.value()
github kengz / SLM-Lab / test / lib / test_util.py View on Github external
def test_cast_list(test_list, test_str):
    assert ps.is_list(test_list)
    assert ps.is_list(util.cast_list(test_list))

    assert not ps.is_list(test_str)
    assert ps.is_list(util.cast_list(test_str))
github kengz / SLM-Lab / test / lib / test_util.py View on Github external
def test_cast_list(test_list, test_str):
    assert ps.is_list(test_list)
    assert ps.is_list(util.cast_list(test_list))

    assert not ps.is_list(test_str)
    assert ps.is_list(util.cast_list(test_str))
github kengz / SLM-Lab / test / spec / test_dist_spec.py View on Github external
def run_trial_test_dist(spec_file, spec_name=False):
    spec = spec_util.get(spec_file, spec_name)
    spec = spec_util.override_test_spec(spec)
    info_space = InfoSpace()
    info_space.tick('trial')
    spec['meta']['distributed'] = True
    spec['meta']['max_session'] = 2

    trial = Trial(spec, info_space)
    # manually run the logic to obtain global nets for testing to ensure global net gets updated
    global_nets = trial.init_global_nets()
    # only test first network
    if ps.is_list(global_nets):  # multiagent only test first
        net = list(global_nets[0].values())[0]
    else:
        net = list(global_nets.values())[0]
    session_datas = trial.parallelize_sessions(global_nets)
    trial.session_data_dict = {data.index[0]: data for data in session_datas}
    trial_data = analysis.analyze_trial(trial)
    trial.close()
    assert isinstance(trial_data, pd.DataFrame)
github dgilland / pydash / tests / test_predicates.py View on Github external
def test_is_empty(case, expected):
    assert _.is_empty(case) == expected
github dgilland / pydash / tests / test_utilities.py View on Github external
def test_property_(case, arg, expected):
    assert _.map_(arg, _.property_(case)) == expected
github dgilland / pydash / tests / test_functions.py View on Github external
def test_partial_as_iteratee():
    func = _.partial(lambda offset, value, *args: value + offset, 5)
    case = [1, 2, 3]
    expected = [6, 7, 8]
    _.map_(case, func) == expected
github dgilland / pydash / tests / test_collections.py View on Github external
def test_map_(case, expected, sort_results):
    actual = _.map_(*case)

    if sort_results:
        actual = sorted(actual)

    assert actual == expected
github dgilland / pydash / tests / test_annotations.py View on Github external
def test_annotated_iteratee():
    assert _.map_([1, 2], typed_function) == [2, 3]

pydash

The kitchen sink of Python utility libraries for doing "stuff" in a functional way. Based on the Lo-Dash Javascript library.

MIT
Latest version published 17 days ago

Package Health Score

90 / 100
Full package analysis

Similar packages