scikit-tda / tadasets

Synthetic data sets apt for Topological Data Analysis
http://tadasets.scikit-tda.org
MIT License
34 stars 7 forks source link

Extract a base class for shapes to handle similar features #4

Open sauln opened 5 years ago

sauln commented 5 years ago

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>