You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And I noticed that some of the examples are displayed correctly e.g.
the impose_as example
and some of the examples do not display correctly e.g. with_constraint example
This seems to be related to the indentation in the docstrings where the examples that display correctly are indented compared to the 'For Example:' header or there needs to be an extra line between the example and other text'
Example of extra indentation
def impose_as(mask, offset=None):
"""generate a function, where some input tracks another input
mask should be a set of tuples of positional index and tracked index,
where the tuple should contain two different integers. The mask will be
applied to the input, before the decorated function is called.
The offset is applied to the second member of the tuple, and can accumulate.
For example,
>>> @impose_as([(0,1),(3,1),(4,5),(5,6),(5,7)])
... def same(x):
... return x
...
>>> same([9,8,7,6,5,4,3,2,1])
[9, 9, 7, 9, 5, 5, 5, 5, 1]
>>> same([0,1,0,1])
[0, 0, 0, 0]
>>> same([-1,-2,-3,-4,-5,-6,-7])
[-1, -1, -3, -1, -5, -5, -5]
>>>
>>> @impose_as([(0,1),(3,1),(4,5),(5,6),(5,7)], 10)
... def doit(x):
... return x
...
>>> doit([9,8,7,6,5,4,3,2,1])
[9, 19, 7, 9, 5, 15, 25, 25, 1]
>>> doit([0,1,0,1])
[0, 10, 0, 0]
>>> doit([-1,-2,-3,-4,-5,-6])
[-1, 9, -3, -1, -5, 5]
>>> doit([-1,-2,-3,-4,-5,-6,-7])
[-1, 9, -3, -1, -5, 5, 15]
"""
example of extra line
def discrete(samples, index=None):
"""impose a discrete set of input values for the selected function
The function's input will be mapped to the given discrete set
>>> @discrete([1.0, 2.0])
... def identity(x):
... return x
>>> identity([0.123, 1.789, 4.000])
[1.0, 2.0, 2.0]
>>> @discrete([1,3,5,7], index=(0,3))
... def squared(x):
.... return [i**2 for i in x]
>>> squared([0,2,4,6,8,10])
[1, 4, 16, 25, 64, 100]"""
example of failing
def with_constraint(ctype, *args, **kwds): #XXX: is this *at all* useful?
"""convert a set transformation to a constraints solver of the chosen type
transformation f(x) is a mapping between x and x', where x' = f(x).
ctype is a mystic.coupler type [inner, outer, inner_proxy, outer_proxy].
For example:
>>> @with_constraint(inner, kwds={'target':5.0})
... def constraint(x, target):
... return impose_mean(target, x)
...
>>> x = constraint([1,2,3,4,5])
>>> print(x)
[3.0, 4.0, 5.0, 6.0, 7.0]
>>> mean(x)
5.0
"""
The text was updated successfully, but these errors were encountered:
This is a known issue. A while ago, there was an effort to go through all the docs to make them more standards compliant (so they render better). However, not all the docs were processed, so this issue remains on several files.
I was reading through the docs at
https://mystic.readthedocs.io/en/latest/mystic.html#module-mystic.constraints
And I noticed that some of the examples are displayed correctly e.g.
the
impose_as
exampleand some of the examples do not display correctly e.g.
with_constraint
exampleThis seems to be related to the indentation in the docstrings where the examples that display correctly are indented compared to the 'For Example:' header or there needs to be an extra line between the example and other text'
Example of extra indentation
example of extra line
example of failing
The text was updated successfully, but these errors were encountered: