How to use implement method in Sure

Best Python code snippet using sure_python

scm.py

Source:scm.py Github

copy

Full Screen

...86 def svn_revision_from_commit_text(self, commit_text):87 match = re.search(self.commit_success_regexp(), commit_text, re.MULTILINE)88 return match.group('svn_revision')89 @staticmethod90 def _subclass_must_implement():91 raise NotImplementedError("subclasses must implement")92 @classmethod93 def in_working_directory(cls, path, executive=None):94 SCM._subclass_must_implement()95 def find_checkout_root(self, path):96 SCM._subclass_must_implement()97 @staticmethod98 def commit_success_regexp():99 SCM._subclass_must_implement()100 def status_command(self):101 self._subclass_must_implement()102 def add(self, path):103 self.add_list([path])104 def add_list(self, paths):105 self._subclass_must_implement()106 def delete(self, path):107 self.delete_list([path])108 def delete_list(self, paths):109 self._subclass_must_implement()110 def exists(self, path):111 self._subclass_must_implement()112 def changed_files(self, git_commit=None):113 self._subclass_must_implement()114 def changed_files_for_revision(self, revision):115 self._subclass_must_implement()116 def revisions_changing_file(self, path, limit=5):117 self._subclass_must_implement()118 def added_files(self):119 self._subclass_must_implement()120 def conflicted_files(self):121 self._subclass_must_implement()122 def display_name(self):123 self._subclass_must_implement()124 def head_svn_revision(self):125 return self.svn_revision(self.checkout_root)126 def svn_revision(self, path):127 """Returns the latest svn revision found in the checkout."""128 self._subclass_must_implement()129 def timestamp_of_revision(self, path, revision):130 self._subclass_must_implement()131 def create_patch(self, git_commit=None, changed_files=None):132 self._subclass_must_implement()133 def committer_email_for_revision(self, revision):134 self._subclass_must_implement()135 def contents_at_revision(self, path, revision):136 self._subclass_must_implement()137 def diff_for_revision(self, revision):138 self._subclass_must_implement()139 def diff_for_file(self, path, log=None):140 self._subclass_must_implement()141 def show_head(self, path):142 self._subclass_must_implement()143 def apply_reverse_diff(self, revision):144 self._subclass_must_implement()145 def revert_files(self, file_paths):146 self._subclass_must_implement()147 def commit_with_message(self, message, username=None, password=None, git_commit=None, force_squash=False, changed_files=None):148 self._subclass_must_implement()149 def svn_commit_log(self, svn_revision):150 self._subclass_must_implement()151 def last_svn_commit_log(self):152 self._subclass_must_implement()153 def svn_blame(self, path):154 self._subclass_must_implement()155 def has_working_directory_changes(self):156 self._subclass_must_implement()157 def discard_working_directory_changes(self):158 self._subclass_must_implement()159 #--------------------------------------------------------------------------160 # Subclasses must indicate if they support local commits,161 # but the SCM baseclass will only call local_commits methods when this is true.162 @staticmethod163 def supports_local_commits():164 SCM._subclass_must_implement()165 def local_commits(self):166 return []167 def has_local_commits(self):168 return len(self.local_commits()) > 0169 def discard_local_commits(self):170 return171 def remote_merge_base(self):172 SCM._subclass_must_implement()173 def commit_locally_with_message(self, message):174 _log.error("Your source control manager does not support local commits.")175 sys.exit(1)176 def local_changes_exist(self):177 return (self.supports_local_commits() and self.has_local_commits()) or self.has_working_directory_changes()178 def discard_local_changes(self):179 if self.has_working_directory_changes():180 self.discard_working_directory_changes()181 if self.has_local_commits():...

Full Screen

Full Screen

operators.py

Source:operators.py Github

copy

Full Screen

1"""2Collection of the core mathematical operators used throughout the code base.3"""4import math5# ## Task 0.16# Implementation of a prelude of elementary functions.7def mul(x, y):8 ":math:`f(x, y) = x * y`"9 # TODO: Implement for Task 0.1.10 raise NotImplementedError('Need to implement for Task 0.1')11def id(x):12 ":math:`f(x) = x`"13 # TODO: Implement for Task 0.1.14 raise NotImplementedError('Need to implement for Task 0.1')15def add(x, y):16 ":math:`f(x, y) = x + y`"17 # TODO: Implement for Task 0.1.18 raise NotImplementedError('Need to implement for Task 0.1')19def neg(x):20 ":math:`f(x) = -x`"21 # TODO: Implement for Task 0.1.22 raise NotImplementedError('Need to implement for Task 0.1')23def lt(x, y):24 ":math:`f(x) =` 1.0 if x is less than y else 0.0"25 # TODO: Implement for Task 0.1.26 raise NotImplementedError('Need to implement for Task 0.1')27def eq(x, y):28 ":math:`f(x) =` 1.0 if x is equal to y else 0.0"29 # TODO: Implement for Task 0.1.30 raise NotImplementedError('Need to implement for Task 0.1')31def max(x, y):32 ":math:`f(x) =` x if x is greater than y else y"33 # TODO: Implement for Task 0.1.34 raise NotImplementedError('Need to implement for Task 0.1')35def is_close(x, y):36 ":math:`f(x) = |x - y| < 1e-2` "37 # TODO: Implement for Task 0.1.38 raise NotImplementedError('Need to implement for Task 0.1')39def sigmoid(x):40 r"""41 :math:`f(x) = \frac{1.0}{(1.0 + e^{-x})}`42 (See `<https://en.wikipedia.org/wiki/Sigmoid_function>`_ .)43 Calculate as44 :math:`f(x) = \frac{1.0}{(1.0 + e^{-x})}` if x >=0 else :math:`\frac{e^x}{(1.0 + e^{x})}`45 for stability.46 Args:47 x (float): input48 Returns:49 float : sigmoid value50 """51 # TODO: Implement for Task 0.1.52 raise NotImplementedError('Need to implement for Task 0.1')53def relu(x):54 """55 :math:`f(x) =` x if x is greater than 0, else 056 (See `<https://en.wikipedia.org/wiki/Rectifier_(neural_networks)>`_ .)57 Args:58 x (float): input59 Returns:60 float : relu value61 """62 # TODO: Implement for Task 0.1.63 raise NotImplementedError('Need to implement for Task 0.1')64EPS = 1e-665def log(x):66 ":math:`f(x) = log(x)`"67 return math.log(x + EPS)68def exp(x):69 ":math:`f(x) = e^{x}`"70 return math.exp(x)71def log_back(x, d):72 r"If :math:`f = log` as above, compute d :math:`d \times f'(x)`"73 # TODO: Implement for Task 0.1.74 raise NotImplementedError('Need to implement for Task 0.1')75def inv(x):76 ":math:`f(x) = 1/x`"77 # TODO: Implement for Task 0.1.78 raise NotImplementedError('Need to implement for Task 0.1')79def inv_back(x, d):80 r"If :math:`f(x) = 1/x` compute d :math:`d \times f'(x)`"81 # TODO: Implement for Task 0.1.82 raise NotImplementedError('Need to implement for Task 0.1')83def relu_back(x, d):84 r"If :math:`f = relu` compute d :math:`d \times f'(x)`"85 # TODO: Implement for Task 0.1.86 raise NotImplementedError('Need to implement for Task 0.1')87# ## Task 0.388# Small library of elementary higher-order functions for practice.89def map(fn):90 """91 Higher-order map.92 .. image:: figs/Ops/maplist.png93 See `<https://en.wikipedia.org/wiki/Map_(higher-order_function)>`_94 Args:95 fn (one-arg function): Function from one value to one value.96 Returns:97 function : A function that takes a list, applies `fn` to each element, and returns a98 new list99 """100 # TODO: Implement for Task 0.3.101 raise NotImplementedError('Need to implement for Task 0.3')102def negList(ls):103 "Use :func:`map` and :func:`neg` to negate each element in `ls`"104 # TODO: Implement for Task 0.3.105 raise NotImplementedError('Need to implement for Task 0.3')106def zipWith(fn):107 """108 Higher-order zipwith (or map2).109 .. image:: figs/Ops/ziplist.png110 See `<https://en.wikipedia.org/wiki/Map_(higher-order_function)>`_111 Args:112 fn (two-arg function): combine two values113 Returns:114 function : takes two equally sized lists `ls1` and `ls2`, produce a new list by115 applying fn(x, y) on each pair of elements.116 """117 # TODO: Implement for Task 0.3.118 raise NotImplementedError('Need to implement for Task 0.3')119def addLists(ls1, ls2):120 "Add the elements of `ls1` and `ls2` using :func:`zipWith` and :func:`add`"121 # TODO: Implement for Task 0.3.122 raise NotImplementedError('Need to implement for Task 0.3')123def reduce(fn, start):124 r"""125 Higher-order reduce.126 .. image:: figs/Ops/reducelist.png127 Args:128 fn (two-arg function): combine two values129 start (float): start value :math:`x_0`130 Returns:131 function : function that takes a list `ls` of elements132 :math:`x_1 \ldots x_n` and computes the reduction :math:`fn(x_3, fn(x_2,133 fn(x_1, x_0)))`134 """135 # TODO: Implement for Task 0.3.136 raise NotImplementedError('Need to implement for Task 0.3')137def sum(ls):138 "Sum up a list using :func:`reduce` and :func:`add`."139 # TODO: Implement for Task 0.3.140 raise NotImplementedError('Need to implement for Task 0.3')141def prod(ls):142 "Product of a list using :func:`reduce` and :func:`mul`."143 # TODO: Implement for Task 0.3....

Full Screen

Full Screen

test_graph.py

Source:test_graph.py Github

copy

Full Screen

1from unittest import TestCase2from treesvm.graph.Graph import Graph3__author__ = 'phizaz'4class TestGraph(TestCase):5 def test_Link(self):6 for implement in ('matrix', 'hash'):7 g = Graph(10, implement=implement)8 assert g.link(0, 1, 2)[0][1] == 29 assert g.link(0, 1, 10)[0][1] == 1010 assert g.link(1, 2, 20)[1][2] == 2011 connection = g.link(2, 1, 10)12 assert connection[2][1] == 1013 assert connection[1][2] == 2014 assert g.link(0, 1, 1)[0][1] == 115 def test_DoubleLink(self):16 for implement in ('matrix', 'hash'):17 g = Graph(10, implement=implement)18 connection = g.double_link(0, 1, 2)19 assert connection[0][1] == 220 assert connection[1][0] == 221 def test_MST(self):22 for implement in ('matrix', 'hash'):23 g = Graph(10, implement=implement)24 def Link(link):25 g.link(link[0], link[1], link[2])26 g.link(link[1], link[0], link[2])27 links = [28 (0, 1, 2),29 (1, 2, 3),30 (0, 2, 1),31 (3, 4, 2),32 (4, 1, 1),33 ]34 for i, link in enumerate(links, 1):35 Link(link)36 MST = g.mst()37 def Assert(link):38 assert (link in MST) or ((link[1], link[0], link[2]) in MST)39 assert len(MST) == 440 # note that the MST might have many results, and those should not be clarified as wrong ones41 Assert(links[0])42 Assert(links[2])43 Assert(links[4])44 Assert(links[3])45 def test_Unlink(self):46 for implement in ('matrix', 'hash'):47 g = Graph(10, implement=implement)48 g.link(0, 1, 10)49 g.link(1, 0, 1)50 tmp = g.unlink(0, 1)51 if implement == 'matrix':52 assert tmp[0][1] == float('inf')53 else:54 assert not 1 in tmp[0]55 assert tmp[1][0] == 156 def test_ConnectedWith(self):57 for implement in ('matrix', 'hash'):58 g = Graph(10, implement=implement)59 def Link(link):60 g.link(link[1], link[0], link[2])61 g.link(link[0], link[1], link[2])62 links = [63 (0, 1, 2),64 (1, 2, 3),65 (0, 2, 1),66 (3, 4, 2),67 (4, 1, 1),68 ]69 for i, link in enumerate(links, 1):70 Link(link)71 assert set(g.connected_with(0)) == set([0, 1, 2, 3, 4])72 g.unlink(4,1)73 g.unlink(1,4)74 assert set(g.connected_with(4)) == set([3,4])75 assert set(g.connected_with(1)) == set([0,1,2])76 def test_sum_weight(self):77 for implement in ('matrix', 'hash'):78 g = Graph(10, implement=implement)79 def Link(link):80 g.link(link[1], link[0], link[2])81 g.link(link[0], link[1], link[2])82 links = [83 (0, 1, 2),84 (1, 2, 3),85 (0, 2, 1),86 (3, 4, 2),87 (4, 1, 1),88 ]89 for i, link in enumerate(links, 1):90 Link(link)91 res = g.sum_weight(0)92 assert res[0] == 9 and len(res[1]) == 593 g.unlink(1,4)94 g.unlink(4,1)95 res = g.sum_weight(0)96 assert res[0] == 6 and len(res[1]) == 397 res = g.sum_weight(4)98 assert res[0] == 2 and len(res[1]) == 199 def test_double_unlink(self):100 for implement in ('matrix', 'hash'):101 g = Graph(10, implement=implement)102 def Link(link):103 g.link(link[1], link[0], link[2])104 g.link(link[0], link[1], link[2])105 links = [106 (0, 1, 2),107 (1, 2, 3),108 (0, 2, 1),109 (3, 4, 2),110 (4, 1, 1),111 ]112 for i, link in enumerate(links, 1):113 Link(link)114 g.double_unlink(1,4)115 res = g.sum_weight(0)116 assert res[0] == 6 and len(res[1]) == 3117 res = g.sum_weight(4)...

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 Sure 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