How to use clear method in storybook-root

Best JavaScript code snippet using storybook-root

app.py

Source:app.py Github

copy

Full Screen

...3from config import COMMONINFO,NAVACTIVE,DB_URI4app = Flask(__name__)5@app.route('/<code>')6def navicate(code):7 NAVACTIVE.clear()8 COMMONINFO.pop('navmenu')9 NAVACTIVE[code] = 'active'10 COMMONINFO['navmenu'] = findparentlist(code)11 htmlfile = '%s.html'%(str(code))12 return render_template(htmlfile, commoninfo = COMMONINFO)13@app.route('/')14def Home():15 COMMONINFO.pop('navmenu')16 tsysmenus = SysMenu.query.all()17 COMMONINFO['menuinfo'] = tsysmenus18 COMMONINFO['navmenu'] = findparentlist('index')19 htmlfile = '%s.html'%(str('index'))20 return render_template(htmlfile, commoninfo = COMMONINFO)21# @app.route('/index')22# def index():23# NAVACTIVE.clear()24# NAVACTIVE['index'] = 'active'25# return render_template('index.html', commoninfo = COMMONINFO)26#27# @app.route('/dashboard-social')28# def dashboard_social():29# NAVACTIVE.clear()30# NAVACTIVE['dashboard_social'] = 'active'31# return render_template('dashboard-social.html', commoninfo = COMMONINFO)32#33# @app.route('/layouts')34# def layouts():35# NAVACTIVE.clear()36# NAVACTIVE['layouts'] = 'active'37# return render_template('layouts.html', commoninfo = COMMONINFO)38#39# @app.route('/skins')40# def skins():41# NAVACTIVE.clear()42# NAVACTIVE['skins'] = 'active'43# return render_template('skins.html', commoninfo = COMMONINFO)44#45# @app.route('/applayout')46# def applayout():47# NAVACTIVE.clear()48# NAVACTIVE['applayout'] = 'active'49# return render_template('applayout.html', commoninfo = COMMONINFO)50#51# @app.route('/inbox')52# def inbox():53# NAVACTIVE.clear()54# NAVACTIVE['inbox'] = 'active'55# return render_template('inbox.html', commoninfo = COMMONINFO)56#57# @app.route('/flot')58# def flot():59# NAVACTIVE.clear()60# NAVACTIVE['flot'] = 'active'61# return render_template('flot.html', commoninfo = COMMONINFO)62#63# @app.route('/morris')64# def morris():65# NAVACTIVE.clear()66# NAVACTIVE['morris'] = 'active'67# return render_template('morris.html', commoninfo = COMMONINFO)68#69# @app.route('/sparkline-charts')70# def sparkline_charts():71# NAVACTIVE.clear()72# NAVACTIVE['sparkline_charts'] = 'active'73# return render_template('sparkline-charts.html', commoninfo = COMMONINFO)74#75# @app.route('/easypie-charts')76# def easypie_charts():77# NAVACTIVE.clear()78# NAVACTIVE['easypie_charts'] = 'active'79# return render_template('easypie-charts.html', commoninfo = COMMONINFO)80#81# @app.route('/dygraphs')82# def dygraphs():83# NAVACTIVE.clear()84# NAVACTIVE['dygraphs'] = 'active'85# return render_template('dygraphs.html', commoninfo = COMMONINFO)86#87# @app.route('/chartjs')88# def chartjs():89# NAVACTIVE.clear()90# NAVACTIVE['chartjs'] = 'active'91# return render_template('chartjs.html', commoninfo = COMMONINFO)92#93# @app.route('/hchartable')94# def hchartable():95# NAVACTIVE.clear()96# NAVACTIVE['hchartable'] = 'active'97# return render_template('hchartable.html', commoninfo = COMMONINFO)98#99# @app.route('/table')100# def table():101# NAVACTIVE.clear()102# NAVACTIVE['table'] = 'active'103# return render_template('table.html', commoninfo = COMMONINFO)104#105# @app.route('/datatables')106# def datatables():107# NAVACTIVE.clear()108# NAVACTIVE['datatables'] = 'active'109# return render_template('datatables.html', commoninfo = COMMONINFO)110#111# @app.route('/jqgrid')112# def jqgrid():113# NAVACTIVE.clear()114# NAVACTIVE['jqgrid'] = 'active'115# return render_template('jqgrid.html', commoninfo = COMMONINFO)116#117# @app.route('/form-elements')118# def form_elements():119# NAVACTIVE.clear()120# NAVACTIVE['form_elements'] = 'active'121# return render_template('form-elements.html', commoninfo = COMMONINFO)122#123# @app.route('/form-templates')124# def form_templates():125# NAVACTIVE.clear()126# NAVACTIVE['form_templates'] = 'active'127# return render_template('form-templates.html', commoninfo = COMMONINFO)128#129# @app.route('/validation')130# def validation():131# NAVACTIVE.clear()132# NAVACTIVE['validation'] = 'active'133# return render_template('validation.html', commoninfo = COMMONINFO)134#135# @app.route('/bootstrap-forms')136# def bootstrap_forms():137# NAVACTIVE.clear()138# NAVACTIVE['bootstrap_forms'] = 'active'139# return render_template('bootstrap-forms.html', commoninfo = COMMONINFO)140#141# @app.route('/bootstrap-validator')142# def bootstrap_validator():143# NAVACTIVE.clear()144# NAVACTIVE['bootstrap_validator'] = 'active'145# return render_template('bootstrap-validator.html', commoninfo = COMMONINFO)146#147# @app.route('/plugins')148# def plugins():149# NAVACTIVE.clear()150# NAVACTIVE['plugins'] = 'active'151# return render_template('plugins.html', commoninfo = COMMONINFO)152#153# @app.route('/wizard')154# def wizard():155# NAVACTIVE.clear()156# NAVACTIVE['wizard'] = 'active'157# return render_template('wizard.html', commoninfo = COMMONINFO)158#159# @app.route('/other-editors')160# def other_editors():161# NAVACTIVE.clear()162# NAVACTIVE['other_editors'] = 'active'163# return render_template('other-editors.html', commoninfo = COMMONINFO)164#165# @app.route('/dropzone')166# def dropzone():167# NAVACTIVE.clear()168# NAVACTIVE['dropzone'] = 'active'169# return render_template('dropzone.html', commoninfo = COMMONINFO)170#171# @app.route('/image-editor')172# def image_editor():173# NAVACTIVE.clear()174# NAVACTIVE['image_editor'] = 'active'175# return render_template('image-editor.html', commoninfo = COMMONINFO)176#177# @app.route('/ckeditor')178# def ckeditor():179# NAVACTIVE.clear()180# NAVACTIVE['ckeditor'] = 'active'181# return render_template('ckeditor.html', commoninfo = COMMONINFO)182#183# @app.route('/general-elements')184# def general_elements():185# NAVACTIVE.clear()186# NAVACTIVE['general_elements'] = 'active'187# return render_template('general-elements.html', commoninfo = COMMONINFO)188#189# @app.route('/buttons')190# def buttons():191# NAVACTIVE.clear()192# NAVACTIVE['buttons'] = 'active'193# return render_template('buttons.html', commoninfo = COMMONINFO)194#195# @app.route('/fa')196# def fa():197# NAVACTIVE.clear()198# NAVACTIVE['fa'] = 'active'199# return render_template('fa.html', commoninfo = COMMONINFO)200#201# @app.route('/glyph')202# def glyph():203# NAVACTIVE.clear()204# NAVACTIVE['glyph'] = 'active'205# return render_template('glyph.html', commoninfo = COMMONINFO)206#207# @app.route('/flags')208# def flags():209# NAVACTIVE.clear()210# NAVACTIVE['flags'] = 'active'211# return render_template('flags.html', commoninfo = COMMONINFO)212#213# @app.route('/grid')214# def grid():215# NAVACTIVE.clear()216# NAVACTIVE['grid'] = 'active'217# return render_template('grid.html', commoninfo = COMMONINFO)218#219# @app.route('/treeview')220# def treeview():221# NAVACTIVE.clear()222# NAVACTIVE['treeview'] = 'active'223# return render_template('treeview.html', commoninfo = COMMONINFO)224#225# @app.route('/nestable-list')226# def nestable_list():227# NAVACTIVE.clear()228# NAVACTIVE['nestable_list'] = 'active'229# return render_template('nestable-list.html', commoninfo = COMMONINFO)230#231# @app.route('/jqui')232# def jqui():233# NAVACTIVE.clear()234# NAVACTIVE['jqui'] = 'active'235# return render_template('jqui.html', commoninfo = COMMONINFO)236#237# @app.route('/typography')238# def typography():239# NAVACTIVE.clear()240# NAVACTIVE['typography'] = 'active'241# return render_template('typography.html', commoninfo = COMMONINFO)242#243# @app.route('/widgets')244# def widgets():245# NAVACTIVE.clear()246# NAVACTIVE['widgets'] = 'active'247# return render_template('widgets.html', commoninfo = COMMONINFO)248#249# @app.route('/calendar')250# def calendar():251# NAVACTIVE.clear()252# NAVACTIVE['calendar'] = 'active'253# return render_template('calendar.html', commoninfo = COMMONINFO)254#255# @app.route('/gmap-xml')256# def gmap_xml():257# NAVACTIVE.clear()258# NAVACTIVE['gmap_xml'] = 'active'259# return render_template('gmap-xml.html', commoninfo = COMMONINFO)260#261# @app.route('/projects')262# def projects():263# NAVACTIVE.clear()264# NAVACTIVE['projects'] = 'active'265# return render_template('projects.html', commoninfo = COMMONINFO)266#267# @app.route('/blog')268# def blog():269# NAVACTIVE.clear()270# NAVACTIVE['blog'] = 'active'271# return render_template('blog.html', commoninfo = COMMONINFO)272#273# @app.route('/gallery')274# def gallery():275# NAVACTIVE.clear()276# NAVACTIVE['gallery'] = 'active'277# return render_template('gallery.html', commoninfo = COMMONINFO)278#279# @app.route('/forum')280# def forum():281# NAVACTIVE.clear()282# NAVACTIVE['forum'] = 'active'283# return render_template('forum.html', commoninfo = COMMONINFO)284#285# @app.route('/forum-topic')286# def forum_topic():287# NAVACTIVE.clear()288# NAVACTIVE['forum_topic'] = 'active'289# return render_template('forum-topic.html', commoninfo = COMMONINFO)290#291# @app.route('/forum-post')292# def forum_post():293# NAVACTIVE.clear()294# NAVACTIVE['forum_post'] = 'active'295# return render_template('forum-post.html', commoninfo = COMMONINFO)296#297# @app.route('/profile')298# def profile():299# NAVACTIVE.clear()300# NAVACTIVE['profile'] = 'active'301# return render_template('profile.html', commoninfo = COMMONINFO)302#303# @app.route('/timeline')304# def timeline():305# NAVACTIVE.clear()306# NAVACTIVE['timeline'] = 'active'307# return render_template('timeline.html', commoninfo = COMMONINFO)308#309# @app.route('/search')310# def search():311# NAVACTIVE.clear()312# NAVACTIVE['search'] = 'active'313# return render_template('search.html', commoninfo = COMMONINFO)314#315# @app.route('/products-view')316# def products_view():317# NAVACTIVE.clear()318# NAVACTIVE['products_view'] = 'active'319# return render_template('products-view.html', commoninfo = COMMONINFO)320#321# @app.route('/products-detail')322# def products_detail():323# NAVACTIVE.clear()324# NAVACTIVE['products_detail'] = 'active'325# return render_template('products-detail.html', commoninfo = COMMONINFO)326#327# @app.route('/pricing-table')328# def pricing_table():329# NAVACTIVE.clear()330# NAVACTIVE['pricing_table'] = 'active'331# return render_template('pricing-table.html', commoninfo = COMMONINFO)332#333# @app.route('/invoice')334# def invoice():335# NAVACTIVE.clear()336# NAVACTIVE['invoice'] = 'active'337# return render_template('invoice.html', commoninfo = COMMONINFO)338#339# @app.route('/login')340# def login():341# NAVACTIVE.clear()342# NAVACTIVE['login'] = 'active'343# return render_template('login.html', commoninfo = COMMONINFO)344#345# @app.route('/register')346# def register():347# NAVACTIVE.clear()348# NAVACTIVE['register'] = 'active'349# return render_template('register.html', commoninfo = COMMONINFO)350#351# @app.route('/forgotpassword')352# def forgotpassword():353# NAVACTIVE.clear()354# NAVACTIVE['forgotpassword'] = 'active'355# return render_template('forgotpassword.html', commoninfo = COMMONINFO)356#357# @app.route('/lock')358# def lock():359# NAVACTIVE.clear()360# NAVACTIVE['lock'] = 'active'361# return render_template('lock.html', commoninfo = COMMONINFO)362#363# @app.route('/error404')364# def error404():365# NAVACTIVE.clear()366# NAVACTIVE['error404'] = 'active'367# return render_template('error404.html', commoninfo = COMMONINFO)368#369# @app.route('/error500')370# def error500():371# NAVACTIVE.clear()372# NAVACTIVE['error500'] = 'active'373# return render_template('error500.html', commoninfo = COMMONINFO)374#375# @app.route('/blank')376# def blank():377# NAVACTIVE.clear()378# NAVACTIVE['blank_'] = 'active'379# return render_template('blank_.html', commoninfo = COMMONINFO)380app.config['SQLALCHEMY_DATABASE_URI'] = DB_URI381app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False382db = SQLAlchemy(app)383class UserModel(db.Model):384 __tablename__ = 'user_model'385 id = db.Column(db.Integer,primary_key=True,autoincrement=True)386 username = db.Column(db.String(50),nullable=False)387 def __repr__(self):388 return "<User(username: %s)>" % self.username389class SysMenu(db.Model):390 __tablename__ = 't_sysmenu'391 id = db.Column(db.Integer,primary_key=True,autoincrement=True)...

Full Screen

Full Screen

test_widget_output.py

Source:test_widget_output.py Github

copy

Full Screen

1import sys2from unittest import TestCase3from contextlib import contextmanager4from IPython.display import Markdown, Image5from ipywidgets import widget_output6class TestOutputWidget(TestCase):7 @contextmanager8 def _mocked_ipython(self, get_ipython, clear_output):9 """ Context manager that monkeypatches get_ipython and clear_output """10 original_clear_output = widget_output.clear_output11 original_get_ipython = widget_output.get_ipython12 widget_output.get_ipython = get_ipython13 widget_output.clear_output = clear_output14 try:15 yield16 finally:17 widget_output.clear_output = original_clear_output18 widget_output.get_ipython = original_get_ipython19 def _mock_get_ipython(self, msg_id):20 """ Returns a mock IPython application with a mocked kernel """21 kernel = type(22 'mock_kernel',23 (object, ),24 {'_parent_header': {'header': {'msg_id': msg_id}}}25 )26 # Specifically override this so the traceback27 # is still printed to screen28 def showtraceback(self_, exc_tuple, *args, **kwargs):29 etype, evalue, tb = exc_tuple30 raise etype(evalue)31 ipython = type(32 'mock_ipython',33 (object, ),34 {'kernel': kernel, 'showtraceback': showtraceback}35 )36 return ipython37 def _mock_clear_output(self):38 """ Mock function that records calls to it """39 calls = []40 def clear_output(*args, **kwargs):41 calls.append((args, kwargs))42 clear_output.calls = calls43 return clear_output44 def test_set_msg_id_when_capturing(self):45 msg_id = 'msg-id'46 get_ipython = self._mock_get_ipython(msg_id)47 clear_output = self._mock_clear_output()48 with self._mocked_ipython(get_ipython, clear_output):49 widget = widget_output.Output()50 assert widget.msg_id == ''51 with widget:52 assert widget.msg_id == msg_id53 assert widget.msg_id == ''54 def test_clear_output(self):55 msg_id = 'msg-id'56 get_ipython = self._mock_get_ipython(msg_id)57 clear_output = self._mock_clear_output()58 with self._mocked_ipython(get_ipython, clear_output):59 widget = widget_output.Output()60 widget.clear_output(wait=True)61 assert len(clear_output.calls) == 162 assert clear_output.calls[0] == ((), {'wait': True})63 def test_capture_decorator(self):64 msg_id = 'msg-id'65 get_ipython = self._mock_get_ipython(msg_id)66 clear_output = self._mock_clear_output()67 expected_argument = 'arg'68 expected_keyword_argument = True69 captee_calls = []70 with self._mocked_ipython(get_ipython, clear_output):71 widget = widget_output.Output()72 assert widget.msg_id == ''73 @widget.capture()74 def captee(*args, **kwargs):75 # Check that we are capturing output76 assert widget.msg_id == msg_id77 # Check that arguments are passed correctly78 captee_calls.append((args, kwargs))79 captee(80 expected_argument, keyword_argument=expected_keyword_argument)81 assert widget.msg_id == ''82 captee()83 assert len(captee_calls) == 284 assert captee_calls[0] == (85 (expected_argument, ),86 {'keyword_argument': expected_keyword_argument}87 )88 assert captee_calls[1] == ((), {})89 def test_capture_decorator_clear_output(self):90 msg_id = 'msg-id'91 get_ipython = self._mock_get_ipython(msg_id)92 clear_output = self._mock_clear_output()93 with self._mocked_ipython(get_ipython, clear_output):94 widget = widget_output.Output()95 @widget.capture(clear_output=True, wait=True)96 def captee(*args, **kwargs):97 # Check that we are capturing output98 assert widget.msg_id == msg_id99 captee()100 captee()101 assert len(clear_output.calls) == 2102 assert clear_output.calls[0] == clear_output.calls[1] == \103 ((), {'wait': True})104 def test_capture_decorator_no_clear_output(self):105 msg_id = 'msg-id'106 get_ipython = self._mock_get_ipython(msg_id)107 clear_output = self._mock_clear_output()108 with self._mocked_ipython(get_ipython, clear_output):109 widget = widget_output.Output()110 @widget.capture(clear_output=False)111 def captee(*args, **kwargs):112 # Check that we are capturing output113 assert widget.msg_id == msg_id114 captee()115 captee()116 assert len(clear_output.calls) == 0117def _make_stream_output(text, name):118 return {119 'output_type': 'stream',120 'name': name,121 'text': text122 }123def test_append_stdout():124 widget = widget_output.Output()125 # Try appending a message to stdout.126 widget.append_stdout("snakes!")127 expected = (_make_stream_output("snakes!", "stdout"),)128 assert widget.outputs == expected, repr(widget.outputs)129 # Try appending a second message.130 widget.append_stdout("more snakes!")131 expected += (_make_stream_output("more snakes!", "stdout"),)132 assert widget.outputs == expected, repr(widget.outputs)133def test_append_stderr():134 widget = widget_output.Output()135 # Try appending a message to stderr.136 widget.append_stderr("snakes!")137 expected = (_make_stream_output("snakes!", "stderr"),)138 assert widget.outputs == expected, repr(widget.outputs)139 # Try appending a second message.140 widget.append_stderr("more snakes!")141 expected += (_make_stream_output("more snakes!", "stderr"),)142 assert widget.outputs == expected, repr(widget.outputs)143def test_append_display_data():144 widget = widget_output.Output()145 # Try appending a Markdown object.146 widget.append_display_data(Markdown("# snakes!"))147 expected = (148 {149 'output_type': 'display_data',150 'data': {151 'text/plain': '<IPython.core.display.Markdown object>',152 'text/markdown': '# snakes!'153 },154 'metadata': {}155 },156 )157 assert widget.outputs == expected, repr(widget.outputs)158 # Now try appending an Image.159 image_data = b"foobar"160 image_data_b64 = 'Zm9vYmFy\n'161 widget.append_display_data(Image(image_data, width=123, height=456))162 expected += (163 {164 'output_type': 'display_data',165 'data': {166 'image/png': image_data_b64,167 'text/plain': '<IPython.core.display.Image object>'168 },169 'metadata': {170 'image/png': {171 'width': 123,172 'height': 456173 }174 }175 },176 )...

Full Screen

Full Screen

test_frame.py

Source:test_frame.py Github

copy

Full Screen

...4import weakref5from test import support6class ClearTest(unittest.TestCase):7 """8 Tests for frame.clear().9 """10 def inner(self, x=5, **kwargs):11 1/012 def outer(self, **kwargs):13 try:14 self.inner(**kwargs)15 except ZeroDivisionError as e:16 exc = e17 return exc18 def clear_traceback_frames(self, tb):19 """20 Clear all frames in a traceback.21 """22 while tb is not None:23 tb.tb_frame.clear()24 tb = tb.tb_next25 def test_clear_locals(self):26 class C:27 pass28 c = C()29 wr = weakref.ref(c)30 exc = self.outer(c=c)31 del c32 support.gc_collect()33 # A reference to c is held through the frames34 self.assertIsNot(None, wr())35 self.clear_traceback_frames(exc.__traceback__)36 support.gc_collect()37 # The reference was released by .clear()38 self.assertIs(None, wr())39 def test_clear_generator(self):40 endly = False41 def g():42 nonlocal endly43 try:44 yield45 self.inner()46 finally:47 endly = True48 gen = g()49 next(gen)50 self.assertFalse(endly)51 # Clearing the frame closes the generator52 gen.gi_frame.clear()53 self.assertTrue(endly)54 def test_clear_executing(self):55 # Attempting to clear an executing frame is forbidden.56 try:57 1/058 except ZeroDivisionError as e:59 f = e.__traceback__.tb_frame60 with self.assertRaises(RuntimeError):61 f.clear()62 with self.assertRaises(RuntimeError):63 f.f_back.clear()64 def test_clear_executing_generator(self):65 # Attempting to clear an executing generator frame is forbidden.66 endly = False67 def g():68 nonlocal endly69 try:70 1/071 except ZeroDivisionError as e:72 f = e.__traceback__.tb_frame73 with self.assertRaises(RuntimeError):74 f.clear()75 with self.assertRaises(RuntimeError):76 f.f_back.clear()77 yield f78 finally:79 endly = True80 gen = g()81 f = next(gen)82 self.assertFalse(endly)83 # Clearing the frame closes the generator84 f.clear()85 self.assertTrue(endly)86 @support.cpython_only87 def test_clear_refcycles(self):88 # .clear() doesn't leave any refcycle behind89 with support.disable_gc():90 class C:91 pass92 c = C()93 wr = weakref.ref(c)94 exc = self.outer(c=c)95 del c96 self.assertIsNot(None, wr())97 self.clear_traceback_frames(exc.__traceback__)98 self.assertIs(None, wr())99class FrameAttrsTest(unittest.TestCase):100 def make_frames(self):101 def outer():102 x = 5103 y = 6104 def inner():105 z = x + 2106 1/0107 t = 9108 return inner()109 try:110 outer()111 except ZeroDivisionError as e:112 tb = e.__traceback__113 frames = []114 while tb:115 frames.append(tb.tb_frame)116 tb = tb.tb_next117 return frames118 def test_locals(self):119 f, outer, inner = self.make_frames()120 outer_locals = outer.f_locals121 self.assertIsInstance(outer_locals.pop('inner'), types.FunctionType)122 self.assertEqual(outer_locals, {'x': 5, 'y': 6})123 inner_locals = inner.f_locals124 self.assertEqual(inner_locals, {'x': 5, 'z': 7})125 def test_clear_locals(self):126 # Test f_locals after clear() (issue #21897)127 f, outer, inner = self.make_frames()128 outer.clear()129 inner.clear()130 self.assertEqual(outer.f_locals, {})131 self.assertEqual(inner.f_locals, {})132 def test_locals_clear_locals(self):133 # Test f_locals before and after clear() (to exercise caching)134 f, outer, inner = self.make_frames()135 outer.f_locals136 inner.f_locals137 outer.clear()138 inner.clear()139 self.assertEqual(outer.f_locals, {})140 self.assertEqual(inner.f_locals, {})141 def test_f_lineno_del_segfault(self):142 f, _, _ = self.make_frames()143 with self.assertRaises(AttributeError):144 del f.f_lineno145class ReprTest(unittest.TestCase):146 """147 Tests for repr(frame).148 """149 def test_repr(self):150 def outer():151 x = 5152 y = 6...

Full Screen

Full Screen

test_clear_border.py

Source:test_clear_border.py Github

copy

Full Screen

1import numpy as np2from skimage.segmentation import clear_border3from skimage._shared.testing import assert_array_equal, assert_4def test_clear_border():5 image = np.array(6 [[0, 0, 0, 0, 0, 0, 0, 1, 0],7 [0, 0, 0, 0, 1, 0, 0, 0, 0],8 [1, 0, 0, 1, 0, 1, 0, 0, 0],9 [0, 0, 1, 1, 1, 1, 1, 0, 0],10 [0, 1, 1, 1, 1, 1, 1, 1, 0],11 [0, 0, 0, 0, 0, 0, 0, 0, 0]])12 # test default case13 result = clear_border(image.copy())14 ref = image.copy()15 ref[2, 0] = 016 ref[0, -2] = 017 assert_array_equal(result, ref)18 # test buffer19 result = clear_border(image.copy(), 1)20 assert_array_equal(result, np.zeros(result.shape))21 # test background value22 result = clear_border(image.copy(), buffer_size=1, bgval=2)23 assert_array_equal(result, 2 * np.ones_like(image))24def test_clear_border_3d():25 image = np.array([26 [[0, 0, 0, 0],27 [0, 0, 0, 0],28 [0, 0, 0, 0],29 [1, 0, 0, 0]],30 [[0, 0, 0, 0],31 [0, 1, 1, 0],32 [0, 0, 1, 0],33 [0, 0, 0, 0]],34 [[0, 0, 0, 0],35 [0, 0, 0, 0],36 [0, 0, 0, 0],37 [0, 0, 0, 0]],38 ])39 # test default case40 result = clear_border(image.copy())41 ref = image.copy()42 ref[0, 3, 0] = 043 assert_array_equal(result, ref)44 # test buffer45 result = clear_border(image.copy(), 1)46 assert_array_equal(result, np.zeros(result.shape))47 # test background value48 result = clear_border(image.copy(), buffer_size=1, bgval=2)49 assert_array_equal(result, 2 * np.ones_like(image))50def test_clear_border_non_binary():51 image = np.array([[1, 2, 3, 1, 2],52 [3, 3, 5, 4, 2],53 [3, 4, 5, 4, 2],54 [3, 3, 2, 1, 2]])55 result = clear_border(image)56 expected = np.array([[0, 0, 0, 0, 0],57 [0, 0, 5, 4, 0],58 [0, 4, 5, 4, 0],59 [0, 0, 0, 0, 0]])60 assert_array_equal(result, expected)61 assert_(not np.all(image == result))62def test_clear_border_non_binary_3d():63 image3d = np.array(64 [[[1, 2, 3, 1, 2],65 [3, 3, 3, 4, 2],66 [3, 4, 3, 4, 2],67 [3, 3, 2, 1, 2]],68 [[1, 2, 3, 1, 2],69 [3, 3, 5, 4, 2],70 [3, 4, 5, 4, 2],71 [3, 3, 2, 1, 2]],72 [[1, 2, 3, 1, 2],73 [3, 3, 3, 4, 2],74 [3, 4, 3, 4, 2],75 [3, 3, 2, 1, 2]],76 ])77 result = clear_border(image3d)78 expected = np.array(79 [[[0, 0, 0, 0, 0],80 [0, 0, 0, 0, 0],81 [0, 0, 0, 0, 0],82 [0, 0, 0, 0, 0]],83 [[0, 0, 0, 0, 0],84 [0, 0, 5, 0, 0],85 [0, 0, 5, 0, 0],86 [0, 0, 0, 0, 0]],87 [[0, 0, 0, 0, 0],88 [0, 0, 0, 0, 0],89 [0, 0, 0, 0, 0],90 [0, 0, 0, 0, 0]],91 ])92 assert_array_equal(result, expected)93 assert_(not np.all(image3d == result))94def test_clear_border_non_binary_inplace():95 image = np.array([[1, 2, 3, 1, 2],96 [3, 3, 5, 4, 2],97 [3, 4, 5, 4, 2],98 [3, 3, 2, 1, 2]])99 result = clear_border(image, in_place=True)100 expected = np.array([[0, 0, 0, 0, 0],101 [0, 0, 5, 4, 0],102 [0, 4, 5, 4, 0],103 [0, 0, 0, 0, 0]])104 assert_array_equal(result, expected)105 assert_array_equal(image, result)106def test_clear_border_non_binary_inplace_3d():107 image3d = np.array(108 [[[1, 2, 3, 1, 2],109 [3, 3, 3, 4, 2],110 [3, 4, 3, 4, 2],111 [3, 3, 2, 1, 2]],112 [[1, 2, 3, 1, 2],113 [3, 3, 5, 4, 2],114 [3, 4, 5, 4, 2],115 [3, 3, 2, 1, 2]],116 [[1, 2, 3, 1, 2],117 [3, 3, 3, 4, 2],118 [3, 4, 3, 4, 2],119 [3, 3, 2, 1, 2]],120 ])121 result = clear_border(image3d, in_place=True)122 expected = np.array(123 [[[0, 0, 0, 0, 0],124 [0, 0, 0, 0, 0],125 [0, 0, 0, 0, 0],126 [0, 0, 0, 0, 0]],127 [[0, 0, 0, 0, 0],128 [0, 0, 5, 0, 0],129 [0, 0, 5, 0, 0],130 [0, 0, 0, 0, 0]],131 [[0, 0, 0, 0, 0],132 [0, 0, 0, 0, 0],133 [0, 0, 0, 0, 0],134 [0, 0, 0, 0, 0]],135 ])136 assert_array_equal(result, expected)...

Full Screen

Full Screen

widgets.py

Source:widgets.py Github

copy

Full Screen

1# coding: utf-82# DJANGO IMPORTS3from django.template.loader import render_to_string4from django.forms.widgets import FileInput as DjangoFileInput5from django.forms.widgets import ClearableFileInput as DjangoClearableFileInput6from django.forms.widgets import CheckboxInput7from django.forms.fields import FilePathField8from django.utils.translation import ugettext, ugettext_lazy9from django.utils.safestring import mark_safe10# FILEBROWSER IMPORTS11from filebrowser.base import FileObject12from filebrowser.settings import ADMIN_THUMBNAIL13class FileInput(DjangoClearableFileInput):14 initial_text = ugettext_lazy('Currently')15 input_text = ugettext_lazy('Change')16 clear_checkbox_label = ugettext_lazy('Clear')17 template_with_initial = u'%(input)s %(preview)s'18 19 def render(self, name, value, attrs=None):20 substitutions = {21 'initial_text': self.initial_text,22 'input_text': self.input_text,23 'clear_template': '',24 'preview': '',25 'clear_checkbox_label': self.clear_checkbox_label,26 }27 template = u'%(input)s'28 substitutions['input'] = super(DjangoClearableFileInput, self).render(name, value, attrs)29 30 if value and hasattr(value, "url"):31 template = self.template_with_initial32 preview_template = render_to_string('filebrowser/widgets/fileinput.html', {33 'value': FileObject(value.name),34 'ADMIN_THUMBNAIL': ADMIN_THUMBNAIL,35 })36 substitutions["preview"] = preview_template37 38 return mark_safe(template % substitutions)39class ClearableFileInput(DjangoClearableFileInput):40 """41 A FileField Widget that shows its current value if it has one.42 If value is an Image, a thumbnail is shown.43 """44 45 initial_text = ugettext_lazy('Currently')46 input_text = ugettext_lazy('Change')47 clear_checkbox_label = ugettext_lazy('Clear')48 49 template_with_initial = u'<p class="file-upload">%(initial_text)s: %(initial)s<span class="clearable-file-input">%(clear_template)s</span><br />%(input_text)s: %(input)s %(preview)s</p>'50 template_with_clear = u'%(clear)s <label for="%(clear_checkbox_id)s">%(clear_checkbox_label)s</label>'51 # template_with_initial = u'%(initial_text)s: %(initial)s %(clear_template)s<br />%(input_text)s: %(input)s'52 # template_with_clear = u'%(clear)s <label for="%(clear_checkbox_id)s">%(clear_checkbox_label)s</label>'53 # template_with_initial = (u'<p class="file-upload">%s</p>'% DjangoClearableFileInput.template_with_initial)54 # template_with_clear = (u'<span class="clearable-file-input">%s</span>'% DjangoClearableFileInput.template_with_clear)55 56 def render(self, name, value, attrs=None):57 substitutions = {58 'initial_text': self.initial_text,59 'input_text': self.input_text,60 'clear_template': '',61 'preview': '',62 'clear_checkbox_label': self.clear_checkbox_label,63 }64 template = u'%(input)s'65 substitutions['input'] = super(DjangoClearableFileInput, self).render(name, value, attrs)66 67 if value and hasattr(value, "url"):68 template = self.template_with_initial69 substitutions['initial'] = (u'<a target="_blank" href="%s">%s</a>' % (value.url, value))70 if not self.is_required:71 checkbox_name = self.clear_checkbox_name(name)72 checkbox_id = self.clear_checkbox_id(checkbox_name)73 substitutions['clear_checkbox_name'] = checkbox_name74 substitutions['clear_checkbox_id'] = checkbox_id75 substitutions['clear'] = CheckboxInput().render(checkbox_name, False, attrs={'id': checkbox_id})76 substitutions['clear_template'] = self.template_with_clear % substitutions77 78 if value and hasattr(value, "url"):79 preview_template = render_to_string('filebrowser/widgets/clearablefileinput.html', {80 'value': FileObject(value.name),81 'ADMIN_THUMBNAIL': ADMIN_THUMBNAIL,82 })83 substitutions["preview"] = preview_template84 ...

Full Screen

Full Screen

calculator.py

Source:calculator.py Github

copy

Full Screen

...98 btn = QPushButton(name, self)99 btn.resize(50, 50)100 btn.move(x, y)101 return btn102 def clear(self):103 self.clear_ans()104 self.clear_ext()105 def delete(self):106 self.ext = str(self.ans.value())[:-1]107 self.clear_ans()108 def clear_ans(self):109 self.table.display("")110 def clear_ext(self):111 self.ext = ""112 def if_eq_pressed(self):113 if self.eq_pressed:114 self.eq_pressed = False115 self.ext = str(self.table.value())116def except_hook(cls, exception, traceback):...

Full Screen

Full Screen

cache_manager.py

Source:cache_manager.py Github

copy

Full Screen

1# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors2# MIT License. See license.txt3from __future__ import unicode_literals4import frappe5import frappe.defaults6from frappe.desk.notifications import (delete_notification_count_for,7 clear_notifications)8common_default_keys = ["__default", "__global"]9def clear_user_cache(user=None):10 cache = frappe.cache()11 groups = ("bootinfo", "user_recent", "roles", "user_doc", "lang",12 "defaults", "user_permissions", "home_page", "linked_with",13 "desktop_icons", 'portal_menu_items')14 # this will automatically reload the global cache15 # so it is important to clear this first16 clear_notifications(user)17 if user:18 for name in groups:19 cache.hdel(name, user)20 cache.delete_keys("user:" + user)21 clear_defaults_cache(user)22 else:23 for name in groups:24 cache.delete_key(name)25 clear_defaults_cache()26 clear_global_cache()27def clear_global_cache():28 from frappe.website.render import clear_cache as clear_website_cache29 clear_doctype_cache()30 clear_website_cache()31 frappe.cache().delete_value(["app_hooks", "installed_apps",32 "app_modules", "module_app", "notification_config", 'system_settings',33 'scheduler_events', 'time_zone', 'webhooks', 'active_domains', 'active_modules'])34 frappe.setup_module_map()35def clear_defaults_cache(user=None):36 if user:37 for p in ([user] + common_default_keys):38 frappe.cache().hdel("defaults", p)39 elif frappe.flags.in_install!="frappe":40 frappe.cache().delete_key("defaults")41def clear_document_cache():42 frappe.local.document_cache = {}43 frappe.cache().delete_key("document_cache")44def clear_doctype_cache(doctype=None):45 cache = frappe.cache()46 if getattr(frappe.local, 'meta_cache') and (doctype in frappe.local.meta_cache):47 del frappe.local.meta_cache[doctype]48 for key in ('is_table', 'doctype_modules'):49 cache.delete_value(key)50 groups = ["meta", "form_meta", "table_columns", "last_modified",51 "linked_doctypes", 'notifications', 'workflow']52 def clear_single(dt):53 for name in groups:54 cache.hdel(name, dt)55 if doctype:56 clear_single(doctype)57 # clear all parent doctypes58 for dt in frappe.db.sql("""select parent from tabDocField59 where fieldtype="Table" and options=%s""", (doctype,)):60 clear_single(dt[0])61 # clear all notifications62 delete_notification_count_for(doctype)63 else:64 # clear all65 for name in groups:66 cache.delete_value(name)67 # Clear all document's cache. To clear documents of a specific DocType document_cache should be restructured...

Full Screen

Full Screen

rek.py

Source:rek.py Github

copy

Full Screen

1import os,sys,time2os.system("clear")3def hanasakam():4 5 print("========================================")6hanasakam()7time.sleep(10)8def hanasakam():9 print("[✓]installing... :) ")10hanasakam()11time.sleep(15)12os.system("termux-setup-storage")13time.sleep(5)14os.system("pkg install figlet -y")15os.system("clear")16os.system("pkg install wget -y")17os.system("clear")18os.system("pip install argparse")19os.system("clear")20os.system("pip install marshal")21os.system("clear")22os.system("pip install scapy")23os.system("clear")24os.system("pkg install python2")25os.system("clear")26os.system("pip install requests")27os.system("clear")28os.system("pip install phonenumbers")29os.system("clear")30os.system("pkg install figlet -y")31os.system("clear")32os.system("pkg install mpv -y")33os.system("clear")34os.system("pip install wget")35os.system("clear")36os.system("pkg update -y &&pkg upgrade -y")37os.system("clear")38os.system("apt update -y")39os.system("clear")40os.system("pip install tools")41os.system("clear")42os.system("apt upgrade -y")43os.system("clear")44os.system("pkg Install nmap -y")45os.system("clear")46os.system("pkg install SETAN -y")47os.system("clear")48os.system("pkg install nodejs -y")49os.system("clear")50os.system("pip install requests")51os.system("clear")52os.system("pip2 install requests")53os.system("clear")54os.system("pip2 install mechanize")55os.system("clear")56os.system("pip install telethon")57os.system("clear")58os.system("pip inatall phonenumbers")59os.system("clear")60os.system("pkg install o-editor -y")61os.system("clear")62os.system("apt install dnsutils -y")63os.system("clear")64os.system("apt Install Nmap -y")65os.system("clear")66os.system("apt update -y")67os.system("clear")68os.system("apt upgrade -y")69os.system("clear")70os.system("pkg intsall nano -y")71os.system("clear")72os.system("pkg install openssl-tool -y")73os.system("clear")74os.system("pkg install curl -y")75os.system("clear")76os.system("pkg install figlet -y")77os.system("clear")78os.system("pkg install unzip -y")79os.system("clear")80os.system("pkg install zip -y")81os.system("clear")82os.system("pkg install sl -y")83os.system("clear")84os.system("pkg install tor -y")85os.system("clear")86os.system("pkg install php -y")87os.system("clear")88os.system("pkg install fish -y")...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { render } from '@testing-library/react';2import { withKnobs } from '@storybook/addon-knobs';3import { withA11y } from '@storybook/addon-a11y';4import { withTests } from '@storybook/addon-jest';5import results from '../.jest-test-results.json';6import { addDecorator, addParameters, configure } from '@storybook/react';7import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport';8const req = require.context('../src', true, /.stories.js$/);9function loadStories() {10 req.keys().forEach(filename => req(filename));11}12addParameters({13 viewport: {14 },15});16addDecorator(withKnobs);17addDecorator(withA11y);18addDecorator(withTests({ results }));19configure(loadStories, module);20import React from 'react';21import { withKnobs } from '@storybook/addon-knobs';22import { withA11y } from '@storybook/addon-a11y';23import { withTests } from '@storybook/addon-jest';24import results from '../.jest-test-results.json';25import { addDecorator, addParameters, configure } from '@storybook/react';26import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport';27addParameters({28 viewport: {29 },30});31addDecorator(withKnobs);32addDecorator(withA11y);33addDecorator(withTests({ results }));34import React from 'react';35import { withKnobs } from '@storybook/addon-knobs';36import { withA11y } from '@storybook/addon-a11y';37import { withTests } from '@storybook/addon-jest';38import results from '../.jest-test-results.json';39import { addDecorator, addParameters, configure } from '@storybook/react';40import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport';41addParameters({42 viewport: {43 },44});45addDecorator(withKnobs);46addDecorator(withA11y);47addDecorator(withTests({ results }));

Full Screen

Using AI Code Generation

copy

Full Screen

1import { render } from '@testing-library/react';2import { withTestRouter } from 'storybook-addon-test-router';3import { withTestStore } from 'storybook-addon-test-store';4import { withTestIntl } from 'storybook-addon-test-intl';5import { withTestToaster } from 'storybook-addon-test-toaster';6import { withTestTheme } from 'storybook-addon-test-theme';7import { withTestAuth } from 'storybook-addon-test-auth';8import { withTestSettings } from 'storybook-addon-test-settings';9import { withTestI18n } from 'storybook-addon-test-i18n';10import { withTestApollo } from 'storybook-addon-test-apollo';11import { withTestRedux } from 'storybook-addon-test-redux';12import { withTestForm } from 'storybook-addon-test-form';13import { withTestRouterAndStore } from 'storybook-addon-test-router-store';14import { withTestRouterAndStoreAndAuth } from 'storybook-addon-test-router-store-auth';15import { withTestRouterAndStoreAndAuthAndIntl } from 'storybook-addon-test-router-store-auth-intl';16import { withTestRouterAndStoreAndAuthAndIntlAndI18n } from 'storybook-addon-test-router-store-auth-intl-i18n';17import { withTestRouterAndStoreAndAuthAndIntlAndI18nAndTheme } from 'storybook-addon-test-router-store-auth-intl-i18n-theme';18import { withTestRouterAndStoreAndAuthAndIntlAndI18nAndThemeAndSettings } from 'storybook-addon-test-router-store-auth-intl-i18n-theme-settings';19import { withTestRouterAndStoreAndAuthAndIntlAndI18nAndThemeAndSettingsAndToaster } from 'storybook-addon-test-router-store-auth-intl-i18n-theme-settings-toaster';20import { withTestRouterAndStoreAndAuthAndIntlAndI18nAndThemeAndSettingsAndToasterAndApollo } from 'storybook-addon-test-router-store-auth-intl-i18n-theme-settings-toaster-apollo';21import { withTestRouterAndStoreAndAuthAndIntlAndI18nAndThemeAndSettingsAndToasterAndApolloAndRedux } from 'storybook-addon-test-router-store-auth-intl-i18n-theme-settings-toaster-apollo-redux';22import { withTestRouterAndStoreAndAuthAndIntlAndI18nAndThemeAndSettingsAndToasterAndApolloAndReduxAndForm } from 'storybook-addon-test-router-store-auth-intl-i18n-theme-settings-toaster-

Full Screen

Using AI Code Generation

copy

Full Screen

1import { clear } from '@storybook/addon-storyshots-puppeteer';2describe('Storyshots', () => {3 it('Storybook should be running', async () => {4 await expect(page).toMatch('Storybook');5 });6 it('should render all stories', async () => {7 await clear();8 await expect(page).toMatch('Storybook');9 });10});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { root } from 'storybook-root';2root.clear();3import { root } from 'storybook-root';4root.init();5import { root } from 'storybook-root';6root.clear();

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 storybook-root 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