Skip to content

Commit 796d0f1

Browse files
committed
BREAK(modifs): rename MAPPED-->KEYWORD
1 parent f723b49 commit 796d0f1

File tree

6 files changed

+39
-39
lines changed

6 files changed

+39
-39
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ Changelog
9090

9191
v8.3.0.dev0 (XX May 2020, @ankostis): drop sol-finalize
9292
=======================================================
93+
+ BREAK: rename ``mapped --> keyword``, which conveys the mot important meaning.
9394
+ DROP Solution.finalized() method -- has stopped being used to reverse values
9495
since sfxed have been introduced (v7+).
9596

docs/source/operations.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ to the :func:`.operation` factory, specifically:
152152
:attr:`.FunctionalOperation.op_provides`, :attr:`.FunctionalOperation._fn_provides`
153153

154154
Declarations of *needs* and *provides* is affected by :term:`modifier`\s like
155-
:func:`.mapped`:
155+
:func:`.keyword`:
156156

157157
Map inputs to different function arguments
158158
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
159-
.. autofunction:: graphtik.modifiers.mapped
159+
.. autofunction:: graphtik.modifiers.keyword
160160
:noindex:
161161

162162
Operations may execute with missing inputs
@@ -179,7 +179,7 @@ Aliased `provides`
179179
Sometimes, you need to interface functions & operations where they name a
180180
:term:`dependency` differently.
181181
This is doable without introducing "pipe-through" interface operation, either
182-
by annotating certain `needs` with :func:`.mapped` `modifiers` (above), or
182+
by annotating certain `needs` with :func:`.keyword` `modifiers` (above), or
183183
by :term:`alias`\sing certain `provides` to different names:
184184

185185
>>> op = operation(str,

graphtik/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from .op import NO_RESULT, NO_RESULT_BUT_SFX, operation
1616
from .pipeline import NULL_OP, compose
1717
from .modifiers import (
18-
mapped,
18+
keyword,
1919
optional,
2020
sfx,
2121
sfxed,

graphtik/modifiers.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
When printed, *modifiers* annotate regular or sideffect dependencies with
1919
these **diacritics**::
2020
21-
> : mapped (fn_keyword)
21+
> : keyword (fn_keyword)
2222
? : optional (fn_keyword)
2323
* : vararg
2424
+ : varargs
@@ -34,7 +34,7 @@
3434
_modifier_cstor_matrix = {
3535
# (7, kw, opt, sfxed, sfx): (STR, REPR, FUNC) OR None
3636
70000: None,
37-
71000: ( "%(dep)s", "'%(dep)s'(%(kw)s)" , "mapped"),
37+
71000: ( "%(dep)s", "'%(dep)s'(%(kw)s)" , "keyword"),
3838
71100: ( "%(dep)s", "'%(dep)s'(?%(kw)s)" , "optional"),
3939
70200: ( "%(dep)s", "'%(dep)s'(*)" , "vararg"),
4040
70300: ( "%(dep)s", "'%(dep)s'(+)" , "varargs"),
@@ -75,7 +75,7 @@ class _Modifier(str):
7575
7676
It is private, in the sense that users should use only:
7777
78-
- the factory functions :func:`.mapped`, :func:`optional` etc,
78+
- the factory functions :func:`.keyword`, :func:`optional` etc,
7979
- the predicates :func:`is_optional()`, :func:`is_pure_sfx()` predicates, etc,
8080
- and the :func:`dep_renamed()`, :func:`dep_stripped()` conversion functions
8181
@@ -101,7 +101,7 @@ class _Modifier(str):
101101
fn_kwarg: str
102102
#: required is None, regular optional or varargish?
103103
#: :func:`is_optional()` returns it.
104-
#: All regulars are `mapped`.
104+
#: All regulars are `keyword`.
105105
optional: _Optionals
106106
#: Has value only for sideffects: the pure-sideffect string or
107107
#: the existing :term:`sideffected` dependency.
@@ -235,11 +235,11 @@ def _modifier(
235235
return _Modifier(name, fn_kwarg, optional, sideffected, sfx_list, _repr, func)
236236

237237

238-
def mapped(name: str, fn_kwarg: str = None):
238+
def keyword(name: str, fn_kwarg: str = None):
239239
"""
240-
Annotate a :term:`needs` that (optionally) map `inputs` name --> argument-name.
240+
Annotate a :term:`needs` that (optionally) maps `inputs` name --> *keyword* argument name.
241241
242-
The value of a mapped dependencies is passed in as *keyword argument*
242+
The value of a *keyword* dependency is passed in as *keyword argument*
243243
to the underlying function.
244244
245245
:param fn_kwarg:
@@ -261,11 +261,11 @@ def mapped(name: str, fn_kwarg: str = None):
261261
262262
In case the name of the function arguments is different from the name in the
263263
`inputs` (or just because the name in the `inputs` is not a valid argument-name),
264-
you may *map* it with the 2nd argument of :func:`.mapped`:
264+
you may *map* it with the 2nd argument of :func:`.keyword`:
265265
266-
>>> from graphtik import operation, compose, mapped
266+
>>> from graphtik import operation, compose, keyword
267267
268-
>>> @operation(needs=['a', mapped("name-in-inputs", "b")], provides="sum")
268+
>>> @operation(needs=['a', keyword("name-in-inputs", "b")], provides="sum")
269269
... def myadd(a, *, b):
270270
... return a + b
271271
>>> myadd
@@ -284,7 +284,7 @@ def mapped(name: str, fn_kwarg: str = None):
284284
285285
.. graphtik::
286286
"""
287-
# Must pass a truthy `fn_kwarg` bc cstor cannot not know its mapped.
287+
# Must pass a truthy `fn_kwarg` bc cstor cannot not know its keyword.
288288
return _modifier(name, fn_kwarg=fn_kwarg or name)
289289

290290

@@ -294,7 +294,7 @@ def optional(name: str, fn_kwarg: str = None):
294294
295295
received only if present in the `inputs` (when operation is invoked).
296296
297-
The value of an optional is passed in as a *keyword argument*
297+
The value of an *optional* dependency is passed in as a *keyword argument*
298298
to the underlying function.
299299
300300
:param fn_kwarg:
@@ -331,7 +331,7 @@ def optional(name: str, fn_kwarg: str = None):
331331
>>> graph(a=5)
332332
{'a': 5, 'sum': 5}
333333
334-
Like :func:`.mapped` you may map input-name to a different function-argument:
334+
Like :func:`.keyword` you may map input-name to a different function-argument:
335335
336336
>>> operation(needs=['a', optional("quasi-real", "b")],
337337
... provides="sum"
@@ -657,9 +657,9 @@ def sfxed_varargs(dependency: str, sfx0: str, *sfx_list: str):
657657

658658
def is_mapped(dep) -> Optional[str]:
659659
"""
660-
Check if a :term:`dependency` is mapped (and get it).
660+
Check if a :term:`dependency` is keyword (and get it).
661661
662-
All non-varargish optionals are "mapped" (including sideffected ones).
662+
All non-varargish optionals are "keyword" (including sideffected ones).
663663
664664
:return:
665665
the :attr:`fn_kwarg`
@@ -727,7 +727,7 @@ def dep_renamed(dep, ren):
727727
"""
728728
Renames `dep` as `ren` or call `ren`` (if callable) to decide its name,
729729
730-
preserving any :func:`mapped` to old-name.
730+
preserving any :func:`keyword` to old-name.
731731
732732
For :term:`sideffected` it renames the dependency (not the *sfx-list*) --
733733
you have to do it that manually with a custom renamer-function, if ever

graphtik/plot.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -624,9 +624,8 @@ class Theme:
624624
#: Rendered if ``fn_kwarg`` exists in `nx_attrs`.
625625
kw_edge_mapping_fn_kwarg = {
626626
"fontsize": 11, # default: 14
627-
"label": make_template(
628-
"<<I>(mapped)</I><BR/>{{ nx_attrs['fn_kwarg'] | eee }}>"
629-
),
627+
"fontname": "italic",
628+
"label": make_template("<&gt;{{ nx_attrs['fn_kwarg'] | eee }}>"),
630629
}
631630
kw_edge_pruned = {"color": Ref("pruned_color")}
632631
kw_edge_rescheduled = {"style": ["dashed"]}

test/test_modifiers.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
dep_renamed,
77
dep_singularized,
88
dep_stripped,
9-
mapped,
9+
keyword,
1010
optional,
1111
sfx,
1212
sfxed,
@@ -26,9 +26,9 @@ def test_serialize_modifier(ser_method):
2626
@pytest.mark.parametrize(
2727
"mod, exp",
2828
[
29-
(lambda: mapped("b", None), "b"),
30-
(lambda: mapped("b", ""), "b"),
31-
(lambda: mapped("b", "bb"), "b"),
29+
(lambda: keyword("b", None), "b"),
30+
(lambda: keyword("b", ""), "b"),
31+
(lambda: keyword("b", "bb"), "b"),
3232
(lambda: optional("b"), "b"),
3333
(lambda: optional("b", "bb"), "b"),
3434
(lambda: vararg("c"), "c"),
@@ -51,9 +51,9 @@ def test_modifs_str(mod, exp):
5151
@pytest.mark.parametrize(
5252
"mod, exp",
5353
[
54-
(lambda: mapped("b", None), "'b'(>)"),
55-
(lambda: mapped("b", ""), "'b'(>)"),
56-
(lambda: mapped("b", "bb"), "'b'(>'bb')"),
54+
(lambda: keyword("b", None), "'b'(>)"),
55+
(lambda: keyword("b", ""), "'b'(>)"),
56+
(lambda: keyword("b", "bb"), "'b'(>'bb')"),
5757
(lambda: optional("b"), "'b'(?)"),
5858
(lambda: optional("b", "bb"), "'b'(?>'bb')"),
5959
(lambda: vararg("c"), "'c'(*)"),
@@ -81,9 +81,9 @@ def test_modifs_repr(mod, exp, ser_method):
8181
@pytest.mark.parametrize(
8282
"mod, exp",
8383
[
84-
(mapped("b", None), "mapped('b')"),
85-
(mapped("b", ""), "mapped('b')"),
86-
(mapped("b", "bb"), "mapped('b', 'bb')"),
84+
(keyword("b", None), "keyword('b')"),
85+
(keyword("b", ""), "keyword('b')"),
86+
(keyword("b", "bb"), "keyword('b', 'bb')"),
8787
(optional("b"), "optional('b')"),
8888
(optional("b", "bb"), "optional('b', 'bb')"),
8989
(vararg("c"), "vararg('c')"),
@@ -110,14 +110,14 @@ def test_modifs_cmd(mod, exp, ser_method):
110110

111111
def test_recreation():
112112
assert optional(optional("a")) == optional("a")
113-
assert mapped(mapped("a", 1), 1) == mapped("a", 1)
113+
assert keyword(keyword("a", 1), 1) == keyword("a", 1)
114114
assert vararg(vararg("a")) == vararg("a")
115115
assert varargs(varargs("a")) == varargs("a")
116116

117117

118118
def test_recreation_repr():
119119
assert repr(optional(optional("a"))) == repr(optional("a"))
120-
assert repr(mapped(mapped("a", 1), 1)) == repr(mapped("a", 1))
120+
assert repr(keyword(keyword("a", 1), 1)) == repr(keyword("a", 1))
121121
assert repr(vararg(vararg("a"))) == repr(vararg("a"))
122122
assert repr(varargs(varargs("a"))) == repr(varargs("a"))
123123

@@ -141,9 +141,9 @@ def test_sideffected_bad(call, exp):
141141
"mod, exp",
142142
[
143143
("b", "'p.b'"),
144-
(mapped("b", None), "'p.b'(>'b')"),
145-
(mapped("b", ""), "'p.b'(>'b')"),
146-
(mapped("b", "bb"), "'p.b'(>'bb')"),
144+
(keyword("b", None), "'p.b'(>'b')"),
145+
(keyword("b", ""), "'p.b'(>'b')"),
146+
(keyword("b", "bb"), "'p.b'(>'bb')"),
147147
(optional("b"), "'p.b'(?>'b')"),
148148
(optional("b", "bb"), "'p.b'(?>'bb')"),
149149
(vararg("c"), "'p.c'(*)"),
@@ -172,7 +172,7 @@ def test_modifs_rename_fn(mod, exp):
172172
"mod, exp",
173173
[
174174
(lambda: "s", "'D'"),
175-
(lambda: mapped("b", "bb"), "'D'(>'bb')"),
175+
(lambda: keyword("b", "bb"), "'D'(>'bb')"),
176176
(lambda: optional("b"), "'D'(?>'b')"),
177177
(lambda: optional("b", "bb"), "'D'(?>'bb')"),
178178
(lambda: vararg("c"), "'D'(*)"),

0 commit comments

Comments
 (0)