How to use param - 10 common examples

To help you get started, we’ve selected a few param examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github holoviz / param / tests / API0 / testparameterizedobject.py View on Github external
g._Dynamic_time_fn=None
        assert t.dyn!=t.dyn
        orig = t.dyn
        t.state_push()
        t.dyn
        assert t.inspect_value('dyn')!=orig
        t.state_pop()
        assert t.inspect_value('dyn')==orig



from param import parameterized

@nottest
class some_fn(param.ParameterizedFunction):
   num_phase = param.Number(18)
   frequencies = param.List([99])
   scale = param.Number(0.3)

   def __call__(self,**params_to_override):
       params = parameterized.ParamOverrides(self,params_to_override)
       num_phase = params['num_phase']
       frequencies = params['frequencies']
       scale = params['scale']
       return scale,num_phase,frequencies

instance = some_fn.instance()

@istest
class TestParameterizedFunction(unittest.TestCase):

    def _basic_tests(self,fn):
github holoviz / param / tests / API1 / testipythonmagic.py View on Github external
def setUp(self):
        super(TestParamPager, self).setUp()
        self.maxDiff = None
        class TestClass(param.Parameterized):
            u = param.Number(4)
            v = param.Number(4, constant=True)
            w = param.Number(4, readonly=True)
            x = param.String(None, allow_None=True)
            y = param.Number(4, bounds=(-1, None))
            z = param.Number(4, bounds=(-1, 100), softbounds=(-100, -200))

        self.TestClass = TestClass
        self.pager = ParamPager()
github filecoin-project / lotus / testplans / composer / app / composition.py View on Github external
def str_param(pdef):
    return param.String(
        default=pdef.get('default', ''),
        doc=pdef.get('desc', ''),
    )
github filecoin-project / lotus / testplans / composer / app / composition.py View on Github external
if 'defaults' in manifest:
            print('manifest defaults', manifest['defaults'])
            if self.builder == '':
                self.builder = manifest['defaults'].get('builder', '')
            if self.runner == '':
                self.runner = manifest['defaults'].get('runner', '')


class Resources(Base):
    memory = param.String(allow_None=True)
    cpu = param.String(allow_None=True)


class Instances(Base):
    count = param.Integer(allow_None=True)
    percentage = param.Number(allow_None=True)


class Dependency(Base):
    module = param.String()
    version = param.String()


class Build(Base):
    selectors = param.List(class_=str, allow_None=True)
    dependencies = param.List(allow_None=True)


class Run(Base):
    artifact = param.String(allow_None=True)
    test_params = param.Parameter(instantiate=True)
github holoviz / param / tests / API1 / testobjectselector.py View on Github external
def test_initialization_out_of_bounds(self):
        try:
            class Q(param.Parameterized):
                q = param.ObjectSelector(5,objects=[4])
        except ValueError:
            pass
        else:
            raise AssertionError("ObjectSelector created outside range.")
github holoviz / param / tests / API1 / testparamdepends.py View on Github external
def setUp(self):
        class P(param.Parameterized):
            a = param.Parameter()
            b = param.Parameter()

            @param.depends('a')
            def single_parameter(self):
                pass

            @param.depends('a:constant')
            def constant(self):
                pass

            @param.depends('a.param')
            def nested(self):
                pass

        self.P = P
github holoviz / param / tests / API0 / testparameterizedrepr.py View on Github external
self.A = A

        class B(param.Parameterized):  # Similar to A but no **kwargs
            a = param.Number(4, precedence=-5)
            b = param.String('B', precedence=-4)
            c = param.Number(4, precedence=0)
            d = param.Integer(-22, precedence=1)

            x = param.Number(1, precedence=2)
            def __init__(self, a, b, c=4, d=-22):
                super(B, self).__init__(a=a, b=b, c=c, name='ClassB')

        self.B = B

        class C(param.Parameterized):  # Similar to A but with *varargs
            a = param.Number(4, precedence=-5)
            b = param.String('B', precedence=-4)
            c = param.Number(4, precedence=0)
            d = param.Integer(-22, precedence=1)

            x = param.Number(1, precedence=2)
            y = param.Number(2, precedence=-1)
            z = param.Number(3, precedence=-2)

            def __init__(self, a, b, c=4, d=-22, *varargs, **kwargs):
                super(C, self).__init__(a=a, b=b, c=c, **kwargs)

        self.C = C


        class D(param.Parameterized):  # Similar to A but with missing parameters
github holoviz / param / tests / API1 / testpandas.py View on Github external
def test_series_row_number_invalid(self):
        valid_series = pandas.Series([1,2])
        invalid_series = pandas.Series([1,2,3])
        class Test(param.Parameterized):
            series = param.Series(default=valid_series, rows=2)

        test = Test()
        exception = "Row length 3 does not match declared bounds of 2"
        with self.assertRaisesRegexp(ValueError, exception):
            test.series = invalid_series
github holoviz / param / tests / API1 / testparamunion.py View on Github external
def test_param_union_warnings(self):
        class A(param.Parameterized):
            a = param.Number(1)
        a = A()
        A(**param.param_union(a))
        self.assertFalse(self.handler.records)
        A(**param.param_union())
        self.assertFalse(self.handler.records)
        A(**param.param_union(a, a))
        self.assertTrue(self.handler.records)
        self.handler.records.pop()
        A(**param.param_union(a, a, warn=False))
        self.assertFalse(self.handler.records)
github holoviz / param / tests / API0 / testdaterangeparam.py View on Github external
def test_wrong_type_default(self):
        try:
            class Q(param.Parameterized):
                a = param.DateRange(default=(1.0,2.0))
        except ValueError:
            pass
        else:
            raise AssertionError("Bad date type was accepted.")