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
There should be some sort of base class or decorator that handles the noise and ambient options for each shape. These options are the same for all shapes.
One method would be a base class and then expose the shape names as the __call__ function so they appear to be functions:
class Shape:
def __call__(self, <params>):
shape = self.build(<params>)
<apply noise>
<apply ambient>
return shape
class Sphere(Shape):
def build(self, <params>):
<sphere building code>
sphere = Sphere().__call__
Or decorator:
def shape(shape_builder):
def wrapper(<params>):
s = shape_builder(<params>)
<apply noise>
<apply ambient>
return s
return wrapper
@shape
def sphere(<params>):
<sphere building code>
Decorators looks easier to understand what's going on.
Will either of these mess with the introspection abilities? What docstrings show up? How can we get proper docstrings?
The text was updated successfully, but these errors were encountered:
sauln
changed the title
Extract a base class
Extract a base class for shapes to handle similar features
Feb 13, 2019
There should be some sort of base class or decorator that handles the
noise
andambient
options for each shape. These options are the same for all shapes.One method would be a base class and then expose the shape names as the
__call__
function so they appear to be functions:Or decorator:
The text was updated successfully, but these errors were encountered: