def test_implicit_out(): op = operation(str, "hh", provides=["A", implicit("a")]) pipe = compose(..., op) got = pipe.compute() assert got == {"A": ""} assert "(implicit)" in str(op.plot())
def test_jetsam_n_plot_with_DEBUG(): pipe = compose( "mix", operation( str, "FUNC", needs=[ "a", sfxed("b", "foo", keyword="bb"), implicit("c"), sfxed("d", "bar"), vararg("e"), varargs("f"), ], provides=[ "A", sfxed("b", "FOO", keyword="bb"), implicit("C"), sfxed("d", "BAR", optional=True), sfx("FOOBAR"), ], aliases={ "A": "aaa", "b": "bbb", "d": "ddd" }, # FIXME: "D" is implicit! ), ) with debug_enabled(True), pytest.raises(ValueError, match="^Unsolvable"): pipe.compute() with debug_enabled(True), pytest.raises( ValueError, match="^Failed matching inputs <=> needs") as exc: pipe.compute({ "a": 1, sfxed("b", "foo"): 2, "c": 3, sfxed("d", "bar"): 4, "e": 5, "f": [6, 7], }) exc.value.jetsam.plot_fpath.unlink()
def test_implicit_inp(): op = operation(str, needs=["A", implicit("a")], provides="b") pipe = compose(..., op) got = pipe.compute({"A": "val", "a": 1}) assert got == {"A": "val", "a": 1, "b": "val"} with pytest.raises(ValueError, match="Unsolvable graph"): pipe.compute({"A": "val"}) assert "(implicit)" in str(op.plot())
def test_cwd_fnop(): op = operation( str, None, needs=[ "a", "a/b", "/r/b", optional("o"), keyword("k"), implicit("i"), vararg("v1"), varargs("v2"), sfx("s1"), sfxed("s2", "s22"), vcat("vc"), ], provides=["A/B", "C", "/R"], aliases=[("A/B", "aa"), ("C", "CC"), ("/R", "RR")], cwd="root", ) exp = """ FnOp(name='str', needs=['root/a'($), 'root/a/b'($), '/r/b'($), 'root/o'($?'o'), 'root/k'($>'k'), 'root/i'($), 'root/v1'($*), 'root/v2'($+), sfx('s1'), sfxed('root/s2'($), 's22'), 'root/vc'($)], provides=['root/A/B'($), 'root/C'($), '/R'($), 'root/aa'($), 'root/CC'($), 'root/RR'($)], aliases=[('root/A/B'($), 'root/aa'($)), ('root/C'($), 'root/CC'($)), ('/R'($), 'root/RR'($))], fn='str') """ assert oneliner(op) == oneliner(exp)
for gnum, n2v in enumerate(n2v_ratios, 1) } wot_grid = pd.concat( wot_grids.values(), axis=1, keys=wot_grids.keys(), names=["gear", "item"], verify_integrity=True, ).swaplevel(axis=1) return wot_grid @autog.autographed( provides=[sfxed("gwots", "p_avail"), implicit("gwots/p_avail")], ) def attach_p_avail_in_gwots(gwots: pd.DataFrame, *, f_safety_margin) -> pd.DataFrame: """ Attaches both `p_avail` and `p_avail_stable` for all gears. .. attention: Must NOT interpolate along with wot on grid, or great INNACCURACIES. :param gwots: a df with 2-level multiindex columns, having at least (`g1`, 'p'), and optionally ('g1', 'ASM')) for each gears (as returned by :func:`interpolate_wot_on_v_grid()`). """ w = wio.pstep_factory.get().wot
( ("a", { "a": sfx("AA") }), ValueError("must not contain `sideffects"), ), ( (["a", "b"], { "a": "b" }), ValueError(r"clash with existing provides in \['a', 'b'\]"), ), ## Implicits # ( ([implicit("i")], { implicit("i"): "II" }), ValueError("must not contain `implicits"), ), ( (["i"], { "i": implicit("II") }), ValueError("must not contain `implicits"), ), ], ) def test_func_op_validation_aliases_BAD(prov_aliases, ex): with pytest.raises(type(ex), match=str(ex)): reparse_operation_data("t", None, *prov_aliases)
ok_n = cycle.loc[:, c.ok_n] p_remain = cycle.loc[:, c.p_remain] cycle.loc[idx_miss_gear] @autog.autographed( needs=[ vararg("wltc_class_data/V_cycle"), vararg("V_dsc"), vararg("V_capped"), vararg("V_compensated"), vararg("forced_cycle"), ], provides=[ sfxed("cycle", "init"), implicit("cycle/t"), implicit("cycle/V"), ], ) def init_cycle_velocity(*velocities: Union[pd.Series, pd.DataFrame]) -> pd.DataFrame: """ Concatenate velocities(series)/cycle(dataframe), cloning the last column as `V`. :param velocities: one or more velocity (same) time-indexed series & datarames (properly named), with the last one becoming the `V`, unless it already exists :return: the concatenated cycle with 2-level columns (item, gear) """
roots_head[0], v_max, wot.loc[v_max - 5 * v_step:v_max + 5 * v_step, w.p_remain_stable], ) rec = VMaxRec(v_max, n_v_max, gid, False, wot) else: rec = VMaxRec(np.NAN, np.NAN, gid, False, wot) return rec @autog.autographed( needs=[ sfxed("gwots", "p_avail"), implicit("gwots/p_resist"), ], provides=[ *VMaxRec._fields[:-2], keyword("is_n_lim_vmax", "is_n_lim"), keyword("vmax_gwot", "wot"), # `wot` causes cycle! ], inp_sideffects=[("gwots", "p_avail")], returns_dict=True, ) def calc_v_max(gwots: Union[pd.Series, pd.DataFrame]) -> VMaxRec: """ Finds maximum velocity by scanning gears from the top. TODO: accept `n_lim`