Comments (11)
I prefer to play with the object type then add two extra kw...
example:
inputs=('a', 'b')
is equivalent to
inputs={'a':'a','b':'b'}
from schedula.
And can you combine both?
from schedula.
what do you mean?
from schedula.
Specify both auto-mapped names and explicitly mapped ones, in the same add_dispatcher()
invocation?
from schedula.
I want to avoid extra kws. I can build an utility like:
def auto_dict(*args, **kw):
return sh.combine_dict(kw, base={k: k for k in args})
what do you think?
from schedula.
In practical terms, what you suggest achieves the same, but with more code/dependencies.
What's the reason not to add new kwds?
from schedula.
I have to add for both inputs
and outputs
kw, while the utl is solving both (so less code).
from schedula.
Well, that's a valid reason.
Let's compare the two:
from utils import auto_dict
add_dispatcher(
dsp,
auto_dict('a', 'b', c='c_renamed'),
auto_dict('out_a', 'out_b', out_c='out_c_renamed'))
vs
add_dispatcher(
dsp,
{'b': 'out_b_renamed'},
{'out_b': 'out_b_renamed'},
inp_names=['a', 'b'],
out_names=['a_out', 'b_out']))
I like the use of python's kwd syntax.
Note though that most of the time, at least in co2mpas code, it would be only the last 2 kwds that are used - no that many renamed params.
But with an intermediate function you loose the opportunity to invoke sub-dispatchers directly from configuration text-files, at least not without requiring the use of that helper function, in which case, why not add the kwds anyway?
In any case, auto_dict
is totally opaque name to tell what it does, and hard to remember with all other auto-magic dict functions.
I would call it identical_kv_dict
or even shorter idkvmap
.
from schedula.
Of course the optimal would be, since most of the times only the identical kvs are used, add a new method that has the inp_names
/out_names
kwds as the first args of the new methods, and move inputs
/outputs
args at the end.
So in a nutshell, reverse the meaning of those two.
That's refactoring for DRY.
from schedula.
Something like this?
add_dispatcher(
dsp,
['a', 'b', {'c'='c_renamed'}],
('out_a', 'out_b', dict(out_c='out_c_renamed'))
And these should be invalid:
add_dispatcher(
dsp,
'abc', # valid: a sequence
('out_a', 'out_b', dict(out_c='out_c_renamed'), 'd') # INVALID: trailing element
from schedula.
Implementation example:
d.add_dispatcher(dsp, inputs=('a', {'b': 'c'}, 'd', {'e': 'f', 'g': 'h'})
equivalent:
d.add_dispatcher(dsp, inputs={'a': 'a', 'b': 'c', 'd': 'd', 'e': 'f', 'g': 'h'})
from schedula.
Related Issues (19)
- Repeatitive use of identical try...except blocks in Sol.py HOT 1
- importing `schedula` imports every module there is HOT 1
- Build as "universal" wheel
- Remove nose from `setup_requires` HOT 1
- Getting node ID with % crashes
- UNC problem on Windows & conda when launching DOT to render plots HOT 8
- Schedula broke with latest networx 2.4 due to dropped graph.node attribute HOT 1
- Split `schedula` into 2 or more packages, with the one with the very barebone serial small implementation HOT 2
- Pre releases do not work with readthedocs HOT 2
- Jinja templates should use autoescape=True to reduce risk of template injection HOT 3
- Advice on reducing memory usage of schedula for large Excel sheet from formulas
- Get one liner formula from graph node HOT 2
- Loop detection and remedy HOT 2
- Dispatch directive pfails with missing search_image_for_language() HOT 1
- doc: dispatch directive fails in ReadTheDocws HOT 8
- No wheel released in PyPi repo HOT 1
- Site fails with sphinx 1.6.2 HOT 2
- chore: filter out commits from irrelevant files in git history HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from schedula.