def update(self, *args, **kwargs): """ the update rectangle method """ for n in range(len(args)): if n == 0: Base.__init__(self, args[0]) elif n == 1: self.width = args[n] elif n == 2: self.height = args[n] elif n == 3: self.x = args[n] else: self.y = args[n] if not args: for key, value in kwargs.items(): if key == "id": Base.__init__(self, value) elif key == "width": self.width = value elif key == "height": self.height = value elif key == "x": self.x = value else: self.y = value
def __init__(self, width, height, x=0, y=0, id=None): """ Rectangle constructor """ Base.__init__(self, id) self.width = width self.height = height self.x = x self.y = y
def __init__(self, width, height, x=0, y=0, id=None): ''' inherit id from base ''' if type(width) is not int: raise TypeError("width must be an integer") elif width < 0: raise ValueError("width must be >= 0") else: self.__width = width if type(height) is not int: raise TypeError("height must be an integer") elif height < 0: raise ValueError("height must be >= 0") else: self.__height = height if type(y) is not int: raise TypeError("y must be an integer") elif y < 0: raise ValueError("y must be >= 0") else: self.__y = y if type(x) is not int: raise TypeError("x must be an integer") elif x < 0: raise ValueError("x must be >= 0") else: self.__x = x Base.__init__(self, id)
def __init__(self, width, height, x=0, y=0, id=None): ''' class constructor of rectangle ''' self.width = width self.height = height self.x = x self.y = y Base.__init__(self, id)
def __init__(self, width, height, x=0, y=0, id=None): """ Initialization fo the Rectangle attributes """ Base.__init__(self, id) self.width = width self.height = height self.x = x self.y = y
def update(self, *args, **kwargs): """Constructor update class rectangle""" for iter1 in range(len(args)): if iter1 == 0: Base.__init__(self, args[iter1]) elif iter1 == 1: self.width = args[iter1] elif iter1 == 2: self.height = args[iter1] elif iter1 == 3: self.x = args[iter1] else: self.y = args[iter1] if not args: for key, value in kwargs.items(): if key == 'id': Base.__init__(self, value) elif key == 'width': self.width = value elif key == 'height': self.height = value elif key == 'x': self.x = value else: self.y = value
def __init__(self, width, height, x=0, y=0, id=None): """init method for Rectangle class""" Base.__init__(self, id) self.width = width self.height = height self.x = x self.y = y
def __init__(self, width, height, x=0, y=0, id=None): """Initializer""" Base.__init__(self, id) self.width = width self.height = height self.x = x self.y = y
def test_Class_Constructor_args(self): """test Base constructor sign args""" b = Base() with self.assertRaises(TypeError) as e: b.__init__(1, 2) msg = "__init__() takes from 1 to 2 positional arguments but 3 were given" self.assertEqual(str(e.exception), msg)
def update(self, *args, **kwargs): """this method take a list and return a json string Argument : None Return : Area of rectangle """ if args and len(args) > 0: for i in range(len(args)): if i == 0: Base.__init__(self, args[i]) elif i == 1: Square.size.__set__(self, args[i]) elif i == 2: Rectangle.x.__set__(self, args[i]) elif i == 3: Rectangle.y.__set__(self, args[i]) else: for key, value in kwargs.items(): if key == 'id': Base.__init__(self, value) elif key == 'size': Square.size.__set__(self, value) elif key == 'x': Rectangle.x.__set__(self, value) elif key == 'y': Rectangle.y.__set__(self, value)
def test_D_constructor_args_2(self): '''Tests constructor signature with 2 notself args.''' with self.assertRaises(TypeError) as e: Base.__init__(self, 1, 2) msg = "__init__() takes from 1 to 2 positional arguments but 3 \ were given" self.assertEqual(str(e.exception), msg)
def __init__(self, width, height, x=0, y=0, id=None): """rectangle init""" Base.__init__(self, id) self.width = width self.height = height self.x = x self.y = y
def __init__(self, width, height, x=0, y=0, id=None): """ constructor method Args: width: is the number of the subslass. height: x, y: id: """ Base.__init__(self, id) if type(width) is not int: raise TypeError('width must be an integer') elif width <= 0: raise ValueError('width must be > 0') else: self.__width = width if type(height) is not int: raise TypeError('height must be an integer') elif height <= 0: raise ValueError('height must be > 0') else: self.__height = height if type(x) is not int: raise TypeError('x must be an integer') elif x < 0: raise ValueError('x must be >= 0') else: self.__x = x if type(y) is not int: raise TypeError('y must be an integer') elif y < 0: raise ValueError('y must be >= 0') else: self.__y = y
def __init__(self, width, height, x=0, y=0, id=None): """function 1""" Base.__init__(self, id) self.width = width self.height = height self.x = x self.y = y
def test_constructor_args(self): with self.assertRaises(TypeError) as e: Base.__init__(self, 1, 2) msg = "__init__() takes from 1 to 2 positional arguments but 3 \ were given" self.assertEqual(str(e.exception), msg)
def test_excedent__args(self): """Test Base() instantiation with leftover arguments""" with self.assertRaises(TypeError) as excep: Base.__init__(self, 12, 56) message = "__init__() takes from 1 to 2 positional arguments \ but 3 were given" self.assertEqual(str(excep.exception), message)
def test_none(self): """none""" with self.assertRaises(TypeError) as e: msg = "__init__() missing 1 required positional \ argument: 'self'" Base.__init__() self.assertEqual(msg, str(e.exception))
def __init__(self, width, height, x=0, y=0, id=None): """ the init function of Rectangle""" Base.__init__(self, id) self.width = width self.height = height self.x = x self.y = y
def __init__(self, width, height, x=0, y=0, id=None): """Constructor""" self.width = width self.height = height self.x = x self.y = y Base.__init__(self, id)
def __init__(self, entries=None): if entries: Base.__init__(self, entries) return self._id = '' self.user_id = '' self.article_id = '' self.time = ''
def __init__(self, width, height, x=0, y=0, id=None): """ method """ self.width = width self.height = height self.x = x self.y = y Base.__init__(self, id)
def __init__(self, width, height, x=0, y=0, id=None): """Define the __init__ method """ Base.__init__(self, id) """[Call the __init__ method of the Base class] """ self.width = width self.height = height self.x = x self.y = y
def __init__(self, width, height, x=0, y=0, id=None): """init func args: id (int) """ Base.__init__(self, id) self.width = width self.height = height self.x = x self.y = y
def __init__(self, n_ent, n_rel, n_nsamp=1, d=100, k=4, mp=1): Base.__init__(self, n_ent, n_rel, n_nsamp, d, k) with self.init_scope(): # Set initializer u_initializer = chainer.initializers.Uniform(dtype=self.xp.float32) # Wr self.Wr = chainer.Parameter(shape=(n_rel, k, d, d), initializer=u_initializer) self.mp = mp
def __init__(self, entries=None): if entries: Base.__init__(self, entries) return self._id = 0 self.nickname = '' self.password = '' self.email = '' self.phone = '' self.register_time = '' self.type = ''
def __init__(self, entries=None): if entries: Base.__init__(self, entries) return self._id = 0 self.created_by = 0 self.created_on = '' self.from_person = 0 self.to_person = 0 self.family_id = 0 self.type = 0 self.special = 0 self.user_id = 0
def __init__(self, size, x=0, y=0, id=None): """ constructor method Args: width: is the number of the subslass. height: x, y: id: """ Rectangle.width.__set__(self, size) Rectangle.height.__set__(self, size) Rectangle.x.__set__(self, x) Rectangle.y.__set__(self, y) Base.__init__(self, id)
def __init__(self, entries=None): self.family = "" if entries: Base.__init__(self, entries) return self._id = 0 self.user_id = 0 self.name = '' self.gender = 'M' self.living = True self.born = '' self.death = '' self.description = ''
def __init__(self, n_embed=9, n_rel=7, d=25, k=75): """ d: embedding size """ Base.__init__(self, n_embed, n_rel, d, k) with self.init_scope(): # Set initializer u_initializer = chainer.initializers.Uniform(dtype=self.xp.float32) initial_embed = self.xp.random.uniform(-0.01, 0.01, (n_embed, 2 * d)) # Entity vectors del self.embed self.embed = L.EmbedID(n_embed, 2 * d, initialW=initial_embed) # RNTN layer # - Tensors W self.w_re = chainer.Parameter(shape=(2 * d, d), initializer=u_initializer) self.w_im = chainer.Parameter(shape=(2 * d, d), initializer=u_initializer) # - Standard layer V del self.V self.V = L.Linear(in_size=4 * d, out_size=2 * d, initialW=u_initializer) # Comparison layer # - Tensors W self.wc_re = chainer.Parameter(shape=(k, d), initializer=u_initializer) self.wc_im = chainer.Parameter(shape=(k, d), initializer=u_initializer) # - Standard layer V del self.Vc self.Vc = L.Linear(in_size=4 * d, out_size=k, initialW=u_initializer) # Converter matrix (d -> n_rel) del self.C self.C = L.Linear(in_size=k, out_size=n_rel, initialW=u_initializer) # Other parameters self.comp = True
def __init__(self, n_embed=9, n_rel=7, d=25, k=75): Base.__init__(self, n_embed, n_rel, d, k) with self.init_scope(): # Set initializer u_initializer = chainer.initializers.Uniform(dtype=self.xp.float32) # RNTN layer # - Tensors W self.w = chainer.Parameter(shape=(d, 1, d), initializer=u_initializer) # Comparison layer # - Tensors W self.wc = chainer.Parameter(shape=(k, 1, d), initializer=u_initializer)
def __init__(self, *args, **kwargs): Base.__init__(self, *args, **kwargs) self.suppress_alert = 1 self.details = {}
def __init__(self, *args, **kwargs): Base.__init__(self, *args, **kwargs) self.suppress_alert = 1 self.details = {} self.balance_plan = None