提交 c504fd74 authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Added new option 'implicit' to input parameters that cannot be provided by the user

上级 35da0e0d
......@@ -27,9 +27,13 @@ class SymbolicInput(object):
autoname: Bool (default: True)
See the name option.
implicit: Bool (default: False)
See help(In).
"""
def __init__(self, variable, name=None, update=None, mutable=None, strict=False, autoname=True):
def __init__(self, variable, name=None, update=None, mutable=None, strict=False, autoname=True,
implicit=False):
self.variable = variable
self.name = variable.name if (autoname and name is None) else name
if self.name is not None and not isinstance(self.name, str):
......@@ -37,6 +41,7 @@ class SymbolicInput(object):
self.update = update
self.mutable = mutable if (mutable is not None) else (update is not None)
self.strict = strict
self.implicit = implicit
def __str__(self):
if self.update:
......@@ -136,10 +141,21 @@ class In(SymbolicInput):
autoname: Bool (default: True)
See the name option.
implicit: Bool (default: False)
True: This input is implicit in the sense that the user is not allowed
to provide a value for it. Requires 'value' to be set.
False: The user can provide a value for this input.
"""
def __init__(self, variable, name=None, value=None, update=None, mutable=None, strict=False, autoname=True):
super(In, self).__init__(variable, name, update, mutable, strict, autoname)
def __init__(self, variable, name=None, value=None, update=None,
mutable=None, strict=False, autoname=True,
implicit=False):
super(In, self).__init__(variable, name, update, mutable, strict,
autoname, implicit = implicit)
self.value = value
if implicit and value is None:
raise TypeError('An implicit input must be given a default value')
class SymbolicOutput(object):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论