How to use _reset_value method in Testify

Best Python code snippet using Testify_python

RolandGp8.py

Source:RolandGp8.py Github

copy

Full Screen

...37 else:38 return False39 if data['type'] == 'flag':40 return self._record[data['position']:data['position'] + data['length']]41 def _reset_value(self, name):42 """Resets the named value to its default as defined in the device data dictionary.43 Args:44 name ([string]): The name of the value from self._gp8 to reset in self._record 45 """46 data = self._gp8[name]47 self._write_value(name, data['default'])48 def _write_value(self, name, value):49 """Write data to the self._record buffer using the data dictionary50 Args:51 name ([string]): The name of the value from self._gp8 52 value ([type]): A value/type appropriate as defined in self._gp8.53 """54 data = self._gp8[name]55 if data['type'] in ['int', 'bitwise'] and type(value) == type(0):56 if value in data['range']:57 self._record[data['position']58 :data['position'] + data['length']] = [value]59 else:60 raise ValueError61 if data['type'] == 'bool':62 if value:63 self._record[data['position']64 :data['position'] + data['length']] = [100]65 else:66 self._record[data['position']67 :data['position'] + data['length']] = [0]68 if data['type'] == 'string':69 """Pad the string to length with spaces"""70 while len(value) <= data['length']:71 value = value + " "72 self._record[data['position']:data['position'] +73 data['length']] = bytes(value, 'ascii')74 def _effect_get(self, bank, effect):75 """Read data from the sysex buffer using the data dictionary76 Args:77 bank ([string]): EFFECT_MSB or EFFECT_LSB78 effect ([string]): Effect name in self.79 Returns:80 [bool]: Effect is either on (True) or off (False).81 """82 return bool(self._read_value(bank) & self._effect_lookup[effect] == self._effect_lookup[effect])83 def _effect_set(self, bank, effect, value):84 """ Change data in the sysex buffer using the data dictionary """85 if value != bool(self._read_value(bank) & self._effect_lookup[effect] == self._effect_lookup[effect]):86 # XOR flip the bit87 self._write_value(bank, self._read_value(88 bank) ^ self._effect_lookup[effect])89 def csv_hex(self):90 """ Return the current patch as a hex string that can easily be used with 91 the send_midi utility provided by the mididings package.92 """93 csv = []94 for byte in self._record:95 csv.append(byte.to_bytes(1, 'big').hex())96 return ','.join(csv)97 @property98 def name(self):99 """ Returns the name of the patch as a string """100 data = self._gp8['NAME']101 return self._record[data['position']:data['position'] + data['length']].decode('ascii')102 @name.setter103 def name(self, value):104 """ Update the name of the patch. Automatically padded/trimmed to 16 chars """105 self._write_value('NAME', value)106 @name.deleter107 def name(self):108 """ Reset the patch name to a default value as defined in the data dictionary. """109 self._reset_value('NAME')110 @property111 def volume(self):112 """ Return the master volume as int 0-100 """113 return self._read_value('VOLUME')114 @volume.setter115 def volume(self, value):116 return self._write_value('VOLUME', value)117 @volume.deleter118 def volume(self):119 return self._reset_value('VOLUME')120 # EFFECT BIT SWITCHES121 # Dynamic Filter122 @property123 def filter(self):124 """True if the effect is on.125 Returns:126 [bool]: Effect is either on or off127 """128 return self._effect_get('EFFECT_LSB', 'DYNAMIC_FILTER')129 @filter.setter130 def filter(self, value):131 self._effect_set('EFFECT_LSB', 'DYNAMIC_FILTER', value)132 @filter.deleter133 def filter(self):134 return self._reset_value('DYNAMIC_FILTER')135 # Compressor136 @property137 def compressor(self):138 """True if the effect is on.139 Returns:140 [bool]: Effect is either on or off141 """142 return self._effect_get('EFFECT_LSB', 'COMPRESSOR')143 @compressor.setter144 def compressor(self, value):145 self._effect_set('EFFECT_LSB', 'COMPRESSOR', value)146 @compressor.deleter147 def compressor(self):148 return self._reset_value('COMPRESSOR')149 # Overdrive150 @property151 def overdrive(self):152 """True if the effect is on.153 Returns:154 [bool]: Effect is either on or off155 """156 return self._effect_get('EFFECT_LSB', 'OVERDRIVE')157 @overdrive.setter158 def overdrive(self, value):159 self._effect_set('EFFECT_LSB', 'OVERDRIVE', value)160 @overdrive.deleter161 def overdrive(self):162 return self._reset_value('OVERDRIVE')163 # Distortion164 @property165 def distortion(self):166 """True if the effect is on.167 Returns:168 [bool]: Effect is either on or off169 """170 return self._effect_get('EFFECT_LSB', 'DISTORTION')171 @distortion.setter172 def distortion(self, value):173 self._effect_set('EFFECT_LSB', 'DISTORTION', value)174 @distortion.deleter175 def distortion(self):176 return self._reset_value('DISTORTION')177 # Phaser178 @property179 def phaser(self):180 """True if the effect is on.181 Returns:182 [bool]: Effect is either on or off183 """184 return self._effect_get('EFFECT_MSB', 'PHASER')185 @phaser.setter186 def phaser(self, value):187 self._effect_set('EFFECT_MSB', 'PHASER', value)188 @phaser.deleter189 def phaser(self):190 return self._reset_value('PHASER')191 # Equalizer192 @property193 def equalizer(self):194 """True if the effect is on.195 Returns:196 [bool]: Effect is either on or off197 """198 return self._effect_get('EFFECT_MSB', 'EQUALIZER')199 @equalizer.setter200 def equalizer(self, value):201 self._effect_set('EFFECT_MSB', 'EQUALIZER', value)202 @equalizer.deleter203 def equalizer(self):204 return self._reset_value('EQUALIZER')205 # Delay206 @property207 def delay(self):208 """True if the effect is on.209 Returns:210 [bool]: Effect is either on or off211 """212 return self._effect_get('EFFECT_MSB', 'DELAY')213 @delay.setter214 def delay(self, value):215 self._effect_set('EFFECT_MSB', 'DELAY', value)216 @delay.deleter217 def delay(self):218 return self._reset_value('DELAY')219 # Chorus220 @property221 def chorus(self):222 """True if the effect is on.223 Returns:224 [bool]: Effect is either on or off225 """226 return self._effect_get('EFFECT_MSB', 'CHORUS')227 @chorus.setter228 def chorus(self, value):229 self._effect_set('EFFECT_MSB', 'CHORUS', value)230 @chorus.deleter231 def chorus(self):232 return self._reset_value('CHORUS')233 # For convenience234 @property235 def effects(self):236 """A convenience function which returns the on/off status of all available effects.237 Returns:238 [dict]: A dictionary with effect names as keys, and bool values for each.239 """240 return {241 'Phaser': self.phaser,242 'Equalizer': self.equalizer,243 'Delay': self.delay,244 'Chorus': self.chorus,245 'Dynamic Filter': self.filter,246 'Compressor': self.compressor,247 'Overdrive': self.overdrive,248 'Distortion': self.distortion,249 }250 #251 # Effect Properties252 #253 # FILTER_SENS254 @property255 def filter_sens(self):256 return self._read_value('FILTER_SENS')257 @filter_sens.setter258 def filter_sens(self, value):259 return self._write_value('FILTER_SENS', value)260 @filter_sens.deleter261 def filter_sens(self):262 self._reset_value('FILTER_SENS')263 # FILTER_CUTOFF_FREQ264 @property265 def filter_cutoff_freq(self):266 return self._read_value('FILTER_CUTOFF_FREQ')267 @filter_cutoff_freq.setter268 def filter_cutoff_freq(self, value):269 return self._write_value('FILTER_CUTOFF_FREQ', value)270 @filter_cutoff_freq.deleter271 def filter_cutoff_freq(self):272 self._reset_value('FILTER_CUTOFF_FREQ')273 # FILTER_Q274 @property275 def filter_q(self):276 return self._read_value('FILTER_Q')277 @filter_q.setter278 def filter_q(self, value):279 return self._write_value('FILTER_Q', value)280 @filter_q.deleter281 def filter_q(self):282 self._reset_value('FILTER_Q')283 # FILTER_UP_DOWN284 @property285 def filter_up_down(self):286 return self._read_value('FILTER_UP_DOWN')287 @filter_up_down.setter288 def filter_up_down(self, value):289 return self._write_value('FILTER_UP_DOWN', value)290 @filter_up_down.deleter291 def filter_up_down(self):292 self._reset_value('FILTER_UP_DOWN')293 # COMP_ATTACK294 @property295 def comp_attack(self):296 return self._read_value('COMP_ATTACK')297 @comp_attack.setter298 def comp_attack(self, value):299 return self._write_value('COMP_ATTACK', value)300 @comp_attack.deleter301 def comp_attack(self):302 self._reset_value('COMP_ATTACK')303 # COMP_SUSTAIN304 @property305 def comp_sustain(self):306 return self._read_value('COMP_SUSTAIN')307 @comp_sustain.setter308 def comp_sustain(self, value):309 return self._write_value('COMP_SUSTAIN', value)310 @comp_sustain.deleter311 def comp_sustain(self):312 self._reset_value('COMP_SUSTAIN')313 # OD_TONE314 @property315 def od_tone(self):316 return self._read_value('OD_TONE')317 @od_tone.setter318 def od_tone(self, value):319 return self._write_value('OD_TONE', value)320 @od_tone.deleter321 def od_tone(self):322 self._reset_value('OD_TONE')323 # OD_DRIVE324 @property325 def od_drive(self):326 return self._read_value('OD_DRIVE')327 @od_drive.setter328 def od_drive(self, value):329 return self._write_value('OD_DRIVE', value)330 @od_drive.deleter331 def od_drive(self):332 self._reset_value('OD_DRIVE')333 # OD_TURBO334 @property335 def od_turbo(self):336 return self._read_value('OD_TURBO')337 @od_turbo.setter338 def od_turbo(self, value):339 return self._write_value('OD_TURBO', value)340 @od_turbo.deleter341 def od_turbo(self):342 self._reset_value('OD_TURBO')343 # DIST_TONE344 @property345 def dist_tone(self):346 return self._read_value('DIST_TONE')347 @dist_tone.setter348 def dist_tone(self, value):349 return self._write_value('DIST_TONE', value)350 @dist_tone.deleter351 def dist_tone(self):352 self._reset_value('DIST_TONE')353 # DIST_DIST354 @property355 def dist_dist(self):356 return self._read_value('DIST_DIST')357 @dist_dist.setter358 def dist_dist(self, value):359 return self._write_value('DIST_DIST', value)360 @dist_dist.deleter361 def dist_dist(self):362 self._reset_value('DIST_DIST')363 # PHASER_RATE364 @property365 def phaser_rate(self):366 return self._read_value('PHASER_RATE')367 @phaser_rate.setter368 def phaser_rate(self, value):369 return self._write_value('PHASER_RATE', value)370 @phaser_rate.deleter371 def phaser_rate(self):372 self._reset_value('PHASER_RATE')373 # PHASER_DEPTH374 @property375 def phaser_depth(self):376 return self._read_value('PHASER_DEPTH')377 @phaser_depth.setter378 def phaser_depth(self, value):379 return self._write_value('PHASER_DEPTH', value)380 @phaser_depth.deleter381 def phaser_depth(self):382 self._reset_value('PHASER_DEPTH')383 # PHASER_RESONANCE384 @property385 def phaser_resonance(self):386 return self._read_value('PHASER_RESONANCE')387 @phaser_resonance.setter388 def phaser_resonance(self, value):389 return self._write_value('PHASER_RESONANCE', value)390 @phaser_resonance.deleter391 def phaser_resonance(self):392 self._reset_value('PHASER_RESONANCE')393 # EQ_HI394 @property395 def eq_hi(self):396 return self._read_value('EQ_HI')397 @eq_hi.setter398 def eq_hi(self, value):399 return self._write_value('EQ_HI', value)400 @eq_hi.deleter401 def eq_hi(self):402 self._reset_value('EQ_HI')403 # EQ_MID404 @property405 def eq_mid(self):406 return self._read_value('EQ_MID')407 @eq_mid.setter408 def eq_mid(self, value):409 return self._write_value('EQ_MID', value)410 @eq_mid.deleter411 def eq_mid(self):412 self._reset_value('EQ_MID')413 # EQ_LO414 @property415 def eq_lo(self):416 return self._read_value('EQ_LO')417 @eq_lo.setter418 def eq_lo(self, value):419 return self._write_value('EQ_LO', value)420 @eq_lo.deleter421 def eq_lo(self):422 self._reset_value('EQ_LO')423 # EQ_GAIN424 @property425 def eq_gain(self):426 return self._read_value('EQ_GAIN')427 @eq_gain.setter428 def eq_gain(self, value):429 return self._write_value('EQ_GAIN', value)430 @eq_gain.deleter431 def eq_gain(self):432 self._reset_value('EQ_GAIN')433 # DELAY_LEVEL434 @property435 def delay_level(self):436 return self._read_value('DELAY_LEVEL')437 @delay_level.setter438 def delay_level(self, value):439 return self._write_value('DELAY_LEVEL', value)440 @delay_level.deleter441 def delay_level(self):442 self._reset_value('DELAY_LEVEL')443 # DELAY_FEEDBACK444 @property445 def delay_feedback(self):446 return self._read_value('DELAY_FEEDBACK')447 @delay_feedback.setter448 def delay_feedback(self, value):449 return self._write_value('DELAY_FEEDBACK', value)450 @delay_feedback.deleter451 def delay_feedback(self):452 self._reset_value('DELAY_FEEDBACK')453 # CHORUS_RATE454 @property455 def chorus_rate(self):456 return self._read_value('CHORUS_RATE')457 @chorus_rate.setter458 def chorus_rate(self, value):459 return self._write_value('CHORUS_RATE', value)460 @chorus_rate.deleter461 def chorus_rate(self):462 self._reset_value('CHORUS_RATE')463 # CHORUS_DEPTH464 @property465 def chorus_depth(self):466 return self._read_value('CHORUS_DEPTH')467 @chorus_depth.setter468 def chorus_depth(self, value):469 return self._write_value('CHORUS_DEPTH', value)470 @chorus_depth.deleter471 def chorus_depth(self):472 self._reset_value('CHORUS_DEPTH')473 # CHORUS_LEVEL474 @property475 def chorus_level(self):476 return self._read_value('CHORUS_LEVEL')477 @chorus_level.setter478 def chorus_level(self, value):479 return self._write_value('CHORUS_LEVEL', value)480 @chorus_level.deleter481 def chorus_level(self):482 self._reset_value('CHORUS_LEVEL')483 # CHORUS_PRE_DELAY484 @property485 def chorus_pre_delay(self):486 return self._read_value('CHORUS_PRE_DELAY')487 @chorus_pre_delay.setter488 def chorus_pre_delay(self, value):489 return self._write_value('CHORUS_PRE_DELAY', value)490 @chorus_pre_delay.deleter491 def chorus_pre_delay(self):492 self._reset_value('CHORUS_PRE_DELAY')493 # CHORUS_FEEDBACK494 @property495 def chorus_feedback(self):496 return self._read_value('CHORUS_FEEDBACK')497 @chorus_feedback.setter498 def chorus_feedback(self, value):499 return self._write_value('CHORUS_FEEDBACK', value)500 @chorus_feedback.deleter501 def chorus_feedback(self):502 self._reset_value('CHORUS_FEEDBACK')503 # EV_5_PARAM504 @property505 def ev5_param(self):506 return self._read_value('EV5_PARAM')507 @ev5_param.setter508 def ev5_param(self, value):509 return self._write_value('EV5_PARAM', value)510 @ev5_param.deleter511 def ev5_param(self):512 self._reset_value('EV5_PARAM')513 # EXT_CONTROL_1514 @property515 def ext_control_1(self):516 return self._read_value('EXT_CONTROL_1')517 @ext_control_1.setter518 def ext_control_1(self, value):519 return self._write_value('EXT_CONTROL_1', value)520 @ext_control_1.deleter521 def ext_control_1(self):522 self._reset_value('EXT_CONTROL_1')523 # EXT_CONTROL_2524 @property525 def ext_control_2(self):526 return self._read_value('EXT_CONTROL_2')527 @ext_control_2.setter528 def ext_control_2(self, value):529 return self._write_value('EXT_CONTROL_2', value)530 @ext_control_2.deleter531 def ext_control_2(self):532 self._reset_value('EXT_CONTROL_2')533 # GROUP534 @property535 def group(self):536 if self._read_value('GROUP') == 64:537 return 'B'538 else:539 return 'A'540 @group.setter541 def group(self, value):542 if value == 'A':543 group = 0544 elif value == 'B':545 group = 64546 else:...

Full Screen

Full Screen

dofs.py

Source:dofs.py Github

copy

Full Screen

1from typing import Tuple2import torch3from torch.nn.parameter import Parameter4from .reparametrizations import ConstrainedAngleReparametrization5class BaseRotDOF(torch.nn.Module):6 def __init__(7 self,8 *,9 value: float = 0.0,10 interval: Tuple[float, float] = None,11 unlocked: bool = True,12 ):13 super().__init__()14 self.reparam = ConstrainedAngleReparametrization(interval)15 self.uangle = Parameter(16 self.reparam.angle2log(value).float(), requires_grad=unlocked17 )18 self._reset_value = self.uangle.data.clone()19 @property20 def value(self):21 return self.reparam.log2angle(self.uangle)22 def sample(self) -> torch.FloatTensor:23 if self.uangle.requires_grad:24 return self.reparam.log2angle(torch.rand(2) * 4 - 2) # [-2;2]25 else:26 return self.value27 def matrix(self) -> torch.FloatTensor:28 raise NotImplementedError29 def project_(self):30 self.reparam.project_inplace(self.uangle)31 def reset_(self):32 self.uangle.data[:] = self._reset_value33 def set_value(self, angle: float):34 self.uangle.data[:] = self.reparam.angle2log(angle).float()35class RotX(BaseRotDOF):36 def matrix(self) -> torch.Tensor:37 c, s = self.reparam.exp(self.uangle)38 m = torch.eye(4)39 m[1, 1] = c40 m[1, 2] = -s41 m[2, 1] = s42 m[2, 2] = c43 return m44class RotY(BaseRotDOF):45 def matrix(self) -> torch.Tensor:46 c, s = self.reparam.exp(self.uangle)47 m = torch.eye(4)48 m[0, 0] = c49 m[0, 2] = s50 m[2, 0] = -s51 m[2, 2] = c52 return m53class RotZ(BaseRotDOF):54 def matrix(self) -> torch.Tensor:55 c, s = self.reparam.exp(self.uangle)56 m = torch.eye(4)57 m[0, 0] = c58 m[0, 1] = -s59 m[1, 0] = s60 m[1, 1] = c61 return m62class BaseTransDOF(torch.nn.Module):63 def __init__(64 self,65 *,66 value: float = 0.0,67 interval: Tuple[float, float] = None,68 unlocked: bool = True,69 ):70 super().__init__()71 self.offset = Parameter(torch.tensor(value).float(), requires_grad=unlocked)72 self._reset_value = self.offset.data.clone()73 def matrix(self) -> torch.FloatTensor:74 raise NotImplementedError75 def sample(self) -> torch.FloatTensor:76 if self.offset.requires_grad:77 return torch.rand() * 10 - 5 # [-5;5]78 else:79 return self.value80 def reset_(self):81 self.offset.data.fill_(self._reset_value)82 def project_(self):83 pass84 @property85 def value(self) -> torch.FloatTensor:86 return self.offset87 def set_value(self, offset: float):88 self.offset.data.fill_(offset)89class TransX(BaseTransDOF):90 def matrix(self) -> torch.Tensor:91 m = torch.eye(4)92 m[0, 3] = self.offset93 return m94class TransY(BaseTransDOF):95 def matrix(self) -> torch.Tensor:96 m = torch.eye(4)97 m[1, 3] = self.offset98 return m99class TransZ(BaseTransDOF):100 def matrix(self) -> torch.Tensor:101 m = torch.eye(4)102 m[2, 3] = self.offset103 return m104DOF_NAMES = ["rx", "ry", "rz", "tx", "ty", "tz"]...

Full Screen

Full Screen

randomizer.py

Source:randomizer.py Github

copy

Full Screen

...17 for k, v in kwargs.items():18 setattr(self, k, v)19 for k, v in self.__dict__.items():20 if isinstance(v, BaseRandomVar):21 v._reset_value()22 self._reset_value()23 def _reset_value(self) -> None:24 self.value = None25 def _prettify(self) -> str:26 # return a prettier form of self.value27 return str(self.value)28 def __call__(self, pretty=False) -> str:29 self._reset_value()30 if pretty:31 return self._prettify()32 return self.value33 def to_dict(self):34 return {"type": "<unk>"}35 def __str__(self):36 return json.dumps(self.to_dict())37class RandomInt(BaseRandomVar):38 def __init__(self, min=0, max=5):39 super().__init__(min=min, max=max)40 def _reset_value(self):41 self.value = random.randrange(self.min, self.max)42 def to_dict(self):43 answer = dict(type="int", min=self.min, max=self.max)44 return answer45class RandomFloat(BaseRandomVar):46 def __init__(self, min=0.0, max=1.0):47 super().__init__(min=min, max=max)48 def _reset_value(self):49 self.value = random.uniform(self.min, self.max)50 def to_dict(self):51 answer = dict(type="float", min=self.min, max=self.max)52 return answer53class RandomChoice(BaseRandomVar):54 def __init__(self, *choices):55 super().__init__(choices=choices)56 def _reset_value(self):57 self.value = random.choice(self.choices)58 def to_dict(self):59 answer = dict(type="choice", choices=self.choices)60 return answer61class RandomBool(BaseRandomVar):62 def __init__(self, true_prob=0.9):63 super().__init__(true_prob=true_prob)64 def _reset_value(self):65 if random.random() < self.true_prob:66 self.value = True67 else:68 self.value = False69 def to_dict(self):70 answer = dict(type="bool", true_prob=self.true_prob)71 return answer72def get_randomizer(*vals):73 func_lookup = {74 "bool": RandomBool,75 "int": RandomInt,76 "float": RandomFloat,77 "choice": RandomChoice,78 }...

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