Best Python code snippet using dbt-osmosis_python
res_user.py
Source:res_user.py
...7 website_page_ids = fields.Many2many('website.page', 'user_website_page_rel', 'user_id', 'page_id',8 string='Page To Hide', help='Select Page To Hide From This User')9 @api.model10 def create(self, values):11 self.env['website.menu'].clear_caches()12 self.env['website.page'].clear_caches()13 return super(Users, self).create(values)14 def write(self, values):15 self.env['website.menu'].clear_caches()16 self.env['website.page'].clear_caches()17 return super(Users, self).write(values)18class WebsiteMenu(models.Model):19 _inherit = 'website.menu'20 hide_user_ids = fields.Many2many('res.users', 'user_website_menu_rel', 'menu_id', 'user_id',21 string='Hide From Users', help='Select User To Hide This Menu')22 hide_group_ids = fields.Many2many('res.groups', 'group_website_menu_rel', 'menu_id', 'group_id',23 string='Hide From Groups', help='Select Groups To Hide This Menu')24 @api.model25 def create(self, values):26 self.env['website.menu'].clear_caches()27 self.env['website.page'].clear_caches()28 return super(WebsiteMenu, self).create(values)29 def write(self, values):30 self.env['website.menu'].clear_caches()31 self.env['website.page'].clear_caches()32 return super(WebsiteMenu, self).write(values)33class WebsitePage(models.Model):34 _inherit = 'website.page'35 hide_user_ids = fields.Many2many('res.users', 'user_website_page_rel', 'page_id', 'user_id', string='Hide From Users')36 hide_group_ids = fields.Many2many('res.groups', 'group_website_page_rel', 'page_id', 'group_id', string='Hide From Groups')37 @api.model38 def create(self, values):39 self.env['website.menu'].clear_caches()40 self.env['website.page'].clear_caches()41 return super(WebsitePage, self).create(values)42 def write(self, values):43 self.env['website.menu'].clear_caches()44 self.env['website.page'].clear_caches()45 return super(WebsitePage, self).write(values)46class ResGroups(models.Model):47 _inherit = 'res.groups'48 hide_menu_ids = fields.Many2many('website.menu', 'group_website_menu_rel', 'group_id', 'menu_id', string='Menu To Hide')49 hide_page_ids = fields.Many2many('website.page', 'group_website_page_rel', 'group_id', 'page_id', string='Page To Hide')50 @api.model51 def create(self, values):52 self.env['website.menu'].clear_caches()53 self.env['website.page'].clear_caches()54 return super(ResGroups, self).create(values)55 def write(self, values):56 self.env['website.menu'].clear_caches()57 self.env['website.page'].clear_caches()58 return super(ResGroups, self).write(values)59class WebsiteHideMenuPageSetting(models.Model):60 _name = 'website.hide.menu.page.setting'61 _description = 'Website Hide Menu Page Setting'62 name = fields.Char()63 internal_menu_hide = fields.Many2many('website.menu', 'internal_user_menu_rel', 'generic_setting_id', 'user_id',64 string='Hide Menu From All Internal Users')65 internal_page_hide = fields.Many2many('website.page', 'internal_user_page_rel', 'generic_setting_id', 'user_id',66 string='Hide Page From All Internal Users')67 portal_menu_hide = fields.Many2many('website.menu', 'portal_user_menu_rel', 'generic_setting_id', 'user_id',68 string='Hide Menu From Portal Users')69 portal_page_hide = fields.Many2many('website.page', 'portal_user_page_rel', 'generic_setting_id', 'user_id',70 string='Hide Page From Portal Users')71 public_menu_hide = fields.Many2many('website.menu', 'public_user_menu_rel', 'generic_setting_id', 'user_id',...
test_get_pretrained_vggface_specs.py
Source:test_get_pretrained_vggface_specs.py
1from plato.tools.common.config import float_precision2from quva_code.utils.face_features import get_lab_face_vgg_features_dataset_version3from quva_code.utils.pretrained_vggface_specs import get_trained_vggface_net4import numpy as np5__author__ = 'peter'6def test_get_trained_vggface_specs(clear_caches = False):7 training_faces, training_labels, test_faces, test_labels = get_lab_face_vgg_features_dataset_version('theano_faces_numlabels', clear_caches = False)8 net = get_trained_vggface_net(clear_caches=clear_caches)9 f = net.test_call.compile(add_test_values = False)10 training_out = f(training_faces)11 test_out = f(test_faces)12 training_score = 100*np.mean(np.argmax(training_out.reshape(training_out.shape[0], -1), axis=1)==training_labels)13 test_score = 100*np.mean(np.argmax(test_out.reshape(test_out.shape[0], -1), axis=1)==test_labels)14 print 'Training score: %.3g%%' % (training_score, )15 print 'Test score: %.3g%%' % (test_score, )16 assert training_score == 10017 assert test_score == 10018 # TODO: Find out why test score is 100% when training the predictor but 93.3% here (maybe normalized outputs from fe? in training?)19def test_normalized_vggface(clear_caches = False):20 with float_precision('float32'):21 training_faces, training_labels, test_faces, test_labels = get_lab_face_vgg_features_dataset_version('theano_faces_numlabels', clear_caches = False)22 normed_training_faces = training_faces / np.mean(np.abs(training_faces))23 normed_test_faces = test_faces / np.mean(np.abs(training_faces))24 net = get_trained_vggface_net(normalize_activations=True, normalization_desired_scale=1., normalization_desired_input_scale=1., clear_caches=clear_caches)25 f = net.get_named_layer_activations.partial(test_call=True).compile(add_test_values = False)26 train_activations = f(normed_training_faces)27 test_activations = f(normed_test_faces)28 test_score = 100*np.mean(np.argmax(test_activations.values()[-1].reshape(test_activations.values()[-1].shape[0], -1), axis=1)==test_labels)29 print 'Test score: %.3g%%' % (test_score, )30 assert test_score == 10031 assert all(np.isclose(np.mean(np.abs(train_activations[layer])), 1) for layer in test_activations if layer.startswith('relu'))32if __name__ == '__main__':33 # test_get_trained_vggface_specs()...
decimal_precision.py
Source:decimal_precision.py
...16 return res[0] if res else 217 @api.model_cr18 def clear_cache(self):19 """ Deprecated, use `clear_caches` instead. """20 self.clear_caches()21 @api.model22 def create(self, data):23 res = super(DecimalPrecision, self).create(data)24 self.clear_caches()25 return res26 @api.multi27 def write(self, data):28 res = super(DecimalPrecision, self).write(data)29 self.clear_caches()30 return res31 @api.multi32 def unlink(self):33 res = super(DecimalPrecision, self).unlink()34 self.clear_caches()35 return res36class DecimalPrecisionFloat(models.AbstractModel):37 """ Override qweb.field.float to add a `decimal_precision` domain option38 and use that instead of the column's own value if it is specified39 """40 _inherit = 'ir.qweb.field.float'41 @api.model42 def precision(self, field, options=None):43 dp = options and options.get('decimal_precision')44 if dp:45 return self.env['decimal.precision'].precision_get(dp)46 return super(DecimalPrecisionFloat, self).precision(field, options=options)47class DecimalPrecisionTestModel(models.Model):48 _name = 'decimal.precision.test'...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!