How to use some_parameter method in Slash

Best Python code snippet using slash

test_caching.py

Source:test_caching.py Github

copy

Full Screen

1"""Tests the correct caching of parameters"""2import unittest3import os4import shutil5import tempfile6import logging7from livius.video.processing.job import Job8FORMAT = '[%(asctime)-15s] %(message)s'9logging.basicConfig(format=FORMAT)10logger = logging.getLogger(__name__)11logger.setLevel(logging.DEBUG)12class JDummy(Job):13 name = 'jdummy'14 attributes_to_serialize = ['some_parameter']15 output_to_cache = ['some_output']16 def __init__(self, *args, **kwargs):17 super(JDummy, self).__init__(*args, **kwargs)18 def run(self, *args, **kwargs):19 self.some_output = self.some_parameter20 pass21 def get_outputs(self):22 super(JDummy, self).get_outputs()23 return self.some_output24class JobCacheTest(unittest.TestCase):25 def setUp(self):26 self.temporary_folder = tempfile.mkdtemp()27 if not os.path.exists(self.temporary_folder):28 os.makedirs(self.temporary_folder)29 def tearDown(self):30 shutil.rmtree(self.temporary_folder)31 def get_job(self, **kwargs):32 return JDummy(json_prefix=self.temporary_folder, **kwargs)33 def test_cache_array_int(self):34 """Tests the ability to cache dictionaries containing strings"""35 some_parameter = [1, 1, 1, 1, 3]36 job = self.get_job(some_parameter=some_parameter)37 job.process()38 self.assertTrue(job.is_up_to_date())39 out = job.get_outputs()40 self.assertEqual(some_parameter, out)41 job2 = self.get_job(some_parameter=some_parameter)42 self.assertTrue(job2.is_up_to_date())43 def test_cache_dict_string(self):44 """Tests the ability to cache dictionaries containing strings"""45 some_parameter = {"param1": "value1", "param2": "value2"}46 job = self.get_job(some_parameter=some_parameter)47 job.process()48 self.assertTrue(job.is_up_to_date())49 out = job.get_outputs()50 self.assertEqual(some_parameter, out)51 job2 = self.get_job(some_parameter=some_parameter)...

Full Screen

Full Screen

PlaceholderGenerator.py

Source:PlaceholderGenerator.py Github

copy

Full Screen

1class PlaceholderGenerator:2 """A way to generate substitution placeholders for SQL requests3 If H is PlaceholderGenerator(positional, prefix, suffix) then H behaves4 as follows:5 str(H) returns the string positional6 H.some_parameter returns the string prefix + 'some_parameter' + suffix7 H('some_parameter') returns the string prefix + 'some_parameter' + suffix8 For example:9 H = PlaceholderGenerator('%s', '%(', ')s')10 f"SELECT {H}" # produces "SELECT %s"11 f"SELECT {H.username}" # produces "SELECT %s(username)s"12 colname = 'email'13 f"SELECT {H(colname)}" # produces "SELECT %s(email)s"14 """15 def __init__(self, positional, prefix, suffix):16 self._positional = positional17 self._prefix = prefix18 self._suffix = suffix19 def _enclose(self, a):20 return f'{self._prefix}{a}{self._suffix}'21 def __str__(self):22 return self._positional23 def __getattr__(self, a):24 if a and a[0] == '_':25 return self.__getattribute__(a)26 p = self._enclose(a)27 return p28 def __call__(self, a):...

Full Screen

Full Screen

for_chainer_issue_3.py

Source:for_chainer_issue_3.py Github

copy

Full Screen

1from chainer import Link, Chain, Parameter, Variable2from chainer import links as L3import numpy as np4class CustomChain(Chain):5 def __init__(self, some_parameter):6 super().__init__()7 if isinstance(some_parameter, Link) or isinstance(some_parameter, Parameter):8 with self.init_scope():9 self.some_parameter = some_parameter10 else:11 self.add_persistent("some_parameter", some_parameter)12def print_children_params_persistent(c: Chain):13 print(c._children, c._params, c._persistent)14print_children_params_persistent(CustomChain(np.array([1, 2, 3])))15print_children_params_persistent(CustomChain(Variable(np.array([1, 2, 3]))))16print_children_params_persistent(CustomChain(L.Bias()))...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful