query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
First test to see if the ObjectRegister works
def test_object_register(): dummy = "Stub" value = " " o_reg = ObjectRegister() o_reg[dummy] = value assert dummy in o_reg # is dummy in register? assert o_reg.Stub == value # is value correct? o_reg.Stub = 1 # can I change the value? assert o_reg.Stub == 1 # does the setter...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def register_object(self, obj):\n self.modules.append(obj)", "def register(self):\n raise NotImplementedError", "def register(self):\n raise NotImplementedError", "def test_hook_register(self):\n self.assertEqual(list(self.registry), [])\n\n item = self.DummyItem(123)\n ...
[ "0.6522508", "0.63567525", "0.63567525", "0.63141686", "0.6301099", "0.6301099", "0.62986296", "0.62878317", "0.62532073", "0.62528384", "0.6219237", "0.6157695", "0.61491543", "0.61461836", "0.61439496", "0.6071152", "0.60204035", "0.60055697", "0.59368014", "0.593578", "0.5...
0.72219026
0
Next lets see if the register_instance works
def test_decorator(): @register_instance class Manequin: """Our test object""" def __init__(self): self.value = 1 global Register korper = Manequin() assert Register.Manequin # is object in Register? assert Register.Manequin.value == 1 # is it's value correct? ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def register_instance(self, instance):\n self.instance = instance", "def registration_started(self):\n pass", "def _get_instance(self):", "def _get_instance(self):", "def test_registration(self):\n models = [BlogEntry, BlogRoll]\n pubsub.register(models)\n self.assertTrue...
[ "0.7148825", "0.6755327", "0.6734898", "0.6734898", "0.66697145", "0.66041887", "0.6599104", "0.6571648", "0.6525776", "0.65197366", "0.649908", "0.649908", "0.646479", "0.646479", "0.64578915", "0.6387077", "0.62822306", "0.627266", "0.62263185", "0.6148355", "0.61444074", ...
0.6127357
23
Allocate various types of arrays for the tests
def allocate_arrays(self): self.prng_state = np.random.get_state() # Generate arrays of random shape self.shape1 = np.random.randint(20, high=512, size=(2,)) self.shape2 = np.random.randint(20, high=512, size=(2,)) self.array1 = np.random.rand(*self.shape1).astype(np.float32) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_array( n ):", "def _init_info_arrays(self, dtype: type) -> Tuple[np.ndarray, np.ndarray]:\n if dtype in [int, float, bool] or issubclass(dtype, np.number):\n array = np.zeros(self.num_envs, dtype=dtype)\n else:\n array = np.zeros(self.num_envs, dtype=object)\n ...
[ "0.6825754", "0.6444625", "0.63543457", "0.63317055", "0.63061434", "0.6246702", "0.6245863", "0.618402", "0.61740255", "0.61383665", "0.6134396", "0.61152494", "0.61099625", "0.60825396", "0.60662067", "0.6044954", "0.6013208", "0.6001334", "0.59249824", "0.5896931", "0.5895...
0.5630084
36
Test rectangular transfer of self.d_array1 to self.d_array2
def test_cpy2d(self): # Reference o1 = self.offset1 o2 = self.offset2 T = self.transfer_shape logger.info("""Testing D->D rectangular copy with (N1_y, N1_x) = %s, (N2_y, N2_x) = %s: array2[%d:%d, %d:%d] = array1[%d:%d, %d:%d]""" % ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allocate_arrays(self):\n self.prng_state = np.random.get_state()\n # Generate arrays of random shape\n self.shape1 = np.random.randint(20, high=512, size=(2,))\n self.shape2 = np.random.randint(20, high=512, size=(2,))\n self.array1 = np.random.rand(*self.shape1).astype(np.fl...
[ "0.6161169", "0.59514517", "0.5920784", "0.58555543", "0.584373", "0.5841961", "0.5769012", "0.57632625", "0.57464427", "0.5729769", "0.5712302", "0.5710319", "0.5658859", "0.5653852", "0.56449014", "0.5638125", "0.5599991", "0.55829954", "0.5496433", "0.54961497", "0.5490821...
0.80503255
0
PutPlaceOfDeliveryRequest a model defined in OpenAPI
def __init__(self, name=None, address=None, near_address=None, coordinates=None, description=None, is_active=None, is_public=None, preferred_certificates=None, open_times=None, contact_person=None, waybill_authorizations=None, user_custom_data=None, local_vars_configuration=None): # noqa: E501 # noqa: E501 if...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def put(self, request, *args, **kwargs):\n\n payload = request.data\n\n instance = self.get_object()\n\n # validate request data body length is zero raise error message\n if len(payload) == 0:\n return APIResponse({'message': NOT_FOUND_JSON_DATA}, HTTP_400_BAD_REQUEST)\n\n ...
[ "0.5903997", "0.5893658", "0.5852392", "0.5724939", "0.55767655", "0.544517", "0.53316027", "0.5291103", "0.52791566", "0.52769244", "0.5230954", "0.5222499", "0.5211893", "0.5203915", "0.5190872", "0.5157879", "0.5118747", "0.5111841", "0.50886256", "0.50723624", "0.5069011"...
0.0
-1
Sets the name of this PutPlaceOfDeliveryRequest.
def name(self, name): if self.local_vars_configuration.client_side_validation and name is None: # noqa: E501 raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 if (self.local_vars_configuration.client_side_validation and name is not None and len(n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def name(self, name):\n\n self._set_field(\"name\", name)", "def name(self, name):\n\n self._set_field(\"name\", name.get_json())", "def setName(self, name):\n self._name = name", "def setName(self, name):\n self._name = name", "def setName(self, name): \n\n self._...
[ "0.6076372", "0.6032923", "0.6018987", "0.6018987", "0.60096157", "0.5992969", "0.5963822", "0.5963822", "0.59596694", "0.5956696", "0.5946499", "0.5946499", "0.5946499", "0.5946499", "0.5946499", "0.5938504", "0.59374225", "0.5912693", "0.5912693", "0.5912693", "0.5912693", ...
0.0
-1
Sets the address of this PutPlaceOfDeliveryRequest.
def address(self, address): if self.local_vars_configuration.client_side_validation and address is None: # noqa: E501 raise ValueError("Invalid value for `address`, must not be `None`") # noqa: E501 self._address = address
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_address(self, address):\n pass", "def address(self, address: object):\n\n self._address = address", "def address(self, address):\n if address is None:\n raise ValueError(\"Invalid value for `address`, must not be `None`\")\n\n self._address = address", "def addr...
[ "0.68177485", "0.6768427", "0.6641226", "0.6530036", "0.6525921", "0.6525921", "0.6525921", "0.6525921", "0.6525921", "0.6525921", "0.6525921", "0.6525921", "0.64892906", "0.6471068", "0.64590454", "0.6444913", "0.6377512", "0.6147737", "0.6036644", "0.6008579", "0.60085624",...
0.6639484
3
Sets the coordinates of this PutPlaceOfDeliveryRequest.
def coordinates(self, coordinates): if self.local_vars_configuration.client_side_validation and coordinates is None: # noqa: E501 raise ValueError("Invalid value for `coordinates`, must not be `None`") # noqa: E501 self._coordinates = coordinates
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_coordinates(self, coordinates):\n self.coordinates = coordinates", "def coordinates(self, coordinates):\n\n self._coordinates = coordinates", "def setCoords(self, coords):\n\n self.coords = coords", "def set_coordinates(self):\n client = Client(api_key=settings.YANDEX_GEOC...
[ "0.6460083", "0.62213266", "0.58959496", "0.5604809", "0.5557838", "0.54878265", "0.53129894", "0.53005755", "0.5284653", "0.5233954", "0.5209307", "0.5204219", "0.51615", "0.5104943", "0.5072016", "0.5042672", "0.5032309", "0.49954793", "0.49842325", "0.49693778", "0.4945690...
0.6003503
2
Sets the is_active of this PutPlaceOfDeliveryRequest.
def is_active(self, is_active): if self.local_vars_configuration.client_side_validation and is_active is None: # noqa: E501 raise ValueError("Invalid value for `is_active`, must not be `None`") # noqa: E501 self._is_active = is_active
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_active(self, is_active: bool):\n if is_active is None:\n raise ValueError(\"Invalid value for `is_active`, must not be `None`\")\n\n self._is_active = is_active", "def is_active(self, is_active):\n \n self._is_active = is_active", "def is_active(self, is_active):\n...
[ "0.6953809", "0.69315886", "0.6882505", "0.6882505", "0.6882505", "0.6882505", "0.65718555", "0.6415791", "0.6415791", "0.6415791", "0.6415791", "0.63974744", "0.63104624", "0.62700874", "0.6220443", "0.6220443", "0.6220443", "0.6220443", "0.61376953", "0.6026736", "0.5875359...
0.66459626
6
Sets the preferred_certificates of this PutPlaceOfDeliveryRequest.
def preferred_certificates(self, preferred_certificates): self._preferred_certificates = preferred_certificates
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _populate_placements(self, preferred):\n # local copy of placement energies\n self._placements = deepcopy(placements)\n \n # top right is the Imhof-approved default\n if preferred == 'top right' or not preferred:\n return\n \n # bump up the cost of ev...
[ "0.518077", "0.48272905", "0.47806227", "0.47716486", "0.47564572", "0.44579473", "0.42863858", "0.41883492", "0.40855017", "0.40254852", "0.40168348", "0.3994004", "0.39610207", "0.39524785", "0.3904179", "0.3873847", "0.3873847", "0.3866805", "0.3838608", "0.38366878", "0.3...
0.7998088
0
Sets the open_times of this PutPlaceOfDeliveryRequest.
def open_times(self, open_times): self._open_times = open_times
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def open(self, open: float):\n if open is None:\n raise ValueError(\"Invalid value for `open`, must not be `None`\") # noqa: E501\n\n self._open = open", "def opening_hours(self, opening_hours):\n if self.local_vars_configuration.client_side_validation and opening_hours is None: ...
[ "0.5362166", "0.53160775", "0.5307863", "0.5153856", "0.49001026", "0.48541027", "0.4840744", "0.47680882", "0.47231638", "0.4719516", "0.47072133", "0.4554673", "0.44046146", "0.43959165", "0.43838677", "0.43738458", "0.43536964", "0.4325754", "0.4316397", "0.42769918", "0.4...
0.80050266
0
Sets the contact_person of this PutPlaceOfDeliveryRequest.
def contact_person(self, contact_person): self._contact_person = contact_person
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def contact(self, contact):\n\n self.logger.debug(\"In 'contact' setter.\")\n\n self._contact = contact", "def contact(self, contact):\n\n self._contact = contact", "def contact(self, contact):\n\n self._contact = contact", "def contact_point(self, contact_point: object):\n\n ...
[ "0.6630224", "0.635594", "0.635594", "0.61892927", "0.6047477", "0.58275557", "0.58173245", "0.5718689", "0.54051256", "0.54051256", "0.5398608", "0.532871", "0.53125453", "0.53125453", "0.5298782", "0.5246978", "0.5200048", "0.5163523", "0.51238424", "0.50968397", "0.5069963...
0.75833505
1
Sets the user_custom_data of this PutPlaceOfDeliveryRequest.
def user_custom_data(self, user_custom_data): self._user_custom_data = user_custom_data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def custom_data(self, custom_data):\n\n self._custom_data = custom_data", "def user_defined_data(self, user_defined_data: UserDefinedDatadef):\n\n self._user_defined_data = user_defined_data", "def replace_user_data(self, new_data):\n self._user_data = new_data", "def custom_user_id(self...
[ "0.6408397", "0.58488166", "0.54311585", "0.5422966", "0.53631914", "0.5330175", "0.5229796", "0.511307", "0.5076588", "0.49836394", "0.49728966", "0.49726078", "0.49514154", "0.49293578", "0.4902357", "0.48885697", "0.4876837", "0.48690352", "0.4847708", "0.48377663", "0.483...
0.7539687
0
Returns the model properties as a dict
def to_dict(self): result = {} for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_dict(self):\n return self.properties", "def to_dict(self):\n return self.properties", "def get_properties(self):\n return self.properties", "def asdict(self):\n return self._prop_dict", "def json(self):\n rv = {\n prop: getattr(self, prop)\n f...
[ "0.7751457", "0.7751457", "0.7338234", "0.73337084", "0.72970754", "0.72771144", "0.7159149", "0.71577364", "0.71487784", "0.71487784", "0.71275115", "0.71265614", "0.71222615", "0.7106787", "0.70604354", "0.7044403", "0.70337415", "0.7023439", "0.6964421", "0.69585776", "0.6...
0.0
-1
Returns the string representation of the model
def to_str(self): return pprint.pformat(self.to_dict())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n return super().__str__() + self.model.__str__()", "def __str__(self) -> str:\n # noinspection PyUnresolvedReferences\n opts = self._meta\n if self.name_field:\n result = str(opts.get_field(self.name_field).value_from_object(self))\n else:\n ...
[ "0.8585799", "0.7814791", "0.77903897", "0.7750947", "0.7750947", "0.7713712", "0.7699211", "0.76708376", "0.76511395", "0.7601015", "0.75830185", "0.7570755", "0.7540716", "0.7523477", "0.75169474", "0.7501407", "0.7487798", "0.7487798", "0.7470098", "0.74518627", "0.7446157...
0.0
-1
For `print` and `pprint`
def __repr__(self): return self.to_str()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pprint(*args, **kwargs):\n if PRINTING:\n print(*args, **kwargs)", "def print_out():\n pass", "def custom_print(*objects):\n print(*objects, sep=OFS, end=ORS)", "def _print(self, *args):\n return _ida_hexrays.vd_printer_t__print(self, *args)", "def _printable(self):\n ...
[ "0.75569", "0.7338421", "0.69879365", "0.69852746", "0.69458014", "0.6925541", "0.689946", "0.689911", "0.6814375", "0.68072027", "0.6750999", "0.67500263", "0.67450905", "0.6699505", "0.6691665", "0.6674513", "0.66583663", "0.66097337", "0.66073257", "0.66028357", "0.6562171...
0.0
-1
Returns true if both objects are equal
def __eq__(self, other): if not isinstance(other, PutPlaceOfDeliveryRequest): return False return self.to_dict() == other.to_dict()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, other):\n return are_equal(self, other)", "def __eq__(self, other):\n return are_equal(self, other)", "def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False", "def __eq__(self, other):\n if i...
[ "0.8088132", "0.8088132", "0.8054589", "0.7982687", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", ...
0.0
-1
Returns true if both objects are not equal
def __ne__(self, other): if not isinstance(other, PutPlaceOfDeliveryRequest): return True return self.to_dict() != other.to_dict()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True", "def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)", "def __ne__(self, other) -> bool:\n return not self.__eq__(other)", "def __eq__(self, other):\n ...
[ "0.8457167", "0.8393036", "0.81455255", "0.8139734", "0.81333447", "0.8094964", "0.8093362", "0.8093362", "0.8093362", "0.80863476", "0.80863476", "0.8077286", "0.8077286", "0.806682", "0.80435175", "0.80435175", "0.80435175", "0.80435175", "0.80435175", "0.80435175", "0.8043...
0.0
-1
Rearragne data matrix X of size (n_stylesdim_x, n_contents) to (n_styles, n_contents, dim_x)
def to_3dim(X: torch.Tensor, target_size: Tuple[int, int, int], dtype=torch.float32) -> torch.Tensor: assert X.ndim == 2 n_styles, n_contents, dim_x = target_size assert X.shape[0] == n_styles * dim_x assert X.shape[1] == n_contents target = torch.zeros(target_size, dtype=X.dtype) for s in ran...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reshape_mat(self, data):\n if len(data['x'][0]) < self.num_ofdim:\n x = data['x']\n x_plus = np.zeros([len(x), self.num_ofdim - len(x[0])])\n data['x'] = np.append(x, x_plus, axis=1)\n return data", "def resh(x):\r\n a = x.shape[0]\r\n b = x.shape[1]\r\n ...
[ "0.58718014", "0.54547006", "0.5412315", "0.53561217", "0.5170308", "0.51700735", "0.516899", "0.5136886", "0.5003184", "0.49826095", "0.49826095", "0.48986864", "0.48977488", "0.48833293", "0.48665738", "0.48594663", "0.48462933", "0.48333767", "0.48239657", "0.48218593", "0...
0.5035376
8
Training logic for an epoch
def _train_epoch(self, epoch): self.model.train() self.train_metrics.reset() for batch_idx, (data, target_seg, target_class) in enumerate(self.data_loader): data, target_seg, target_class = data.to(self.device), target_seg.to(self.device), target_class.to(self.device) se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _train_epoch(self, epoch):\n raise NotImplementedError", "def _train_epoch(self, epoch):\n raise NotImplementedError", "def _train_epoch(self, epoch):\n raise NotImplementedError", "def _train_epoch(self, epoch):\n raise NotImplementedError", "def train_one_epoch(self):\n ...
[ "0.84083605", "0.84083605", "0.84083605", "0.84083605", "0.81284416", "0.8044275", "0.795282", "0.7818035", "0.7789884", "0.7776823", "0.7748766", "0.7745458", "0.77287894", "0.7725468", "0.76904434", "0.7620618", "0.7620618", "0.7620618", "0.7620618", "0.7620618", "0.7610982...
0.7407834
49
Validate after training an epoch
def _valid_epoch(self, epoch): self.model.eval() self.valid_metrics.reset() with torch.no_grad(): for batch_idx, (data, target_seg, target_class) in enumerate(self.valid_data_loader): data, target_seg, target_class = data.to(self.device), target_seg.to(self.device), t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validation_epoch(self):\n self.model.eval()\n\n # Compute for training set\n train_loss, train_acc = compute_loss_and_accuracy(\n self.dataloader_train, self.model, self.loss_criterion\n )\n self.TRAIN_ACC.append(train_acc)\n self.TRAIN_LOSS.append(train_los...
[ "0.79534644", "0.78457445", "0.7790192", "0.76798767", "0.7650407", "0.75477976", "0.75045013", "0.7459676", "0.74196595", "0.73464423", "0.729629", "0.72881", "0.7285671", "0.7259691", "0.7237066", "0.72170967", "0.717824", "0.7166362", "0.7154711", "0.71380985", "0.71259", ...
0.7779426
3
format and display input data on tensorboard
def _visualize_input(self, input): self.writer.add_image('input', make_grid(input[0, 0, :, :], nrow=8, normalize=True))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format():\n train_data.info() # retreiving general info about train data\n print('Number of rows and columns of train set:', train_data.shape)\n print('dtype: ', train_data.dtypes) # analyse data type of each column\n print('First 3 rows of the train data:', train_data.head(3))", "def showInput...
[ "0.69057506", "0.6352291", "0.62028694", "0.5871135", "0.5687523", "0.5672438", "0.56449336", "0.56428796", "0.5618645", "0.5578692", "0.55682015", "0.55551356", "0.55546844", "0.5553714", "0.5549513", "0.55420536", "0.5539764", "0.55274934", "0.55232847", "0.5508486", "0.548...
0.6598129
1
format and display output and target data on tensorboard
def _visualize_prediction(self, input, output, target): out_b1 = binary(output) out_b1 = impose_labels_on_image(input[0, 0, :, :], target[0, :, :], out_b1[0, 1, :, :]) self.writer.add_image('output', make_grid(out_b1, nrow=8, normalize=False))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def args_to_tensorboard(writer, args):\n\n txt = \"\"\n for arg in vars(args):\n txt += arg + \": \" + str(getattr(args, arg)) + \"<br/>\"\n\n writer.add_text('command_line_parameters', txt, 0)", "def to_tensorboard(self, **kwargs) -> 'PlotLosses':\n self.outputs.append(outputs.Tensorboard...
[ "0.6666576", "0.66039413", "0.65872866", "0.65118855", "0.64563", "0.6371887", "0.6223408", "0.6148363", "0.61152786", "0.60947365", "0.60759556", "0.60550654", "0.6026349", "0.59551936", "0.5932281", "0.59251475", "0.590935", "0.5873628", "0.5835232", "0.5829114", "0.5814904...
0.5765577
26
Do not return anything, modify s inplace instead.
def reverseString(self, s) -> None: # 방법 1 s.reverse() # 방법 2 # half_len = int(len(s) / 2) # for i in range(half_len): # temp = s[i] # s[i] = s[len(s) - 1 - i] # s[len(s) - 1 - i] = temp
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def r(self, s):\n\t\tif self.m() > 0:\n\t\t\tself.setto(s)", "def copy(self):\r\n return self.replace()", "def test_string_inplace_update(self):\r\n vm = String.value_manager(None, None, 'str')\r\n assert not vm.changed\r\n vm.value += 's'\r\n assert vm.changed", "def setto...
[ "0.627839", "0.5948614", "0.59482366", "0.59214234", "0.58858985", "0.5761662", "0.57322884", "0.5647384", "0.5646522", "0.55934894", "0.5593134", "0.5581352", "0.55702233", "0.5528644", "0.5454121", "0.5444118", "0.5401756", "0.5359094", "0.5344482", "0.5342857", "0.53393996...
0.49923488
48
Replaces the crypto key in the keys/ folder. This key has to be sync'ed across all cloud instances until we use proper key management. This function intentionally has no command line option due to its rarity.
def write_key(): key = fernet.Fernet.generate_key() keyfile = open(KEY_PATH,'wb') keyfile.write(key) keyfile.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def replace_key(newKey, oldKey, filename, ssh):\n ssh.exec_command(\"sed -i 's;%s;%s;g' %s\" % (oldKey, newKey, filename))", "def test_rekey_defaults(self, settings):\n old_key = b'0' * 32\n new_key = b'1' * 32\n\n settings.CHITON_ENCRYPTION_KEY = new_key\n settings.CHITON_PREVIOUS...
[ "0.63903826", "0.5915563", "0.57853013", "0.57296944", "0.5701325", "0.5640512", "0.5525865", "0.5520725", "0.5461842", "0.54392695", "0.5428072", "0.5419951", "0.540152", "0.53930956", "0.53822595", "0.5379103", "0.5364567", "0.536304", "0.5328512", "0.53189105", "0.5316111"...
0.51862335
28
Returns the encrypted version of the given raw string.
def encrypt_string(self, raw_string): return self.fernet_instance.encrypt(raw_string.encode('utf-8'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encrypted(data: str) -> str:\n return b64encode(data.encode('ascii')).decode('ascii')", "def encrypt(self, string):\n return self.__Cipher(self.OP_ENCRYPT).update(string)", "def __decrypt(string: str) -> str:\n key = 171\n result = \"\"\n i: int\n for i in string:\...
[ "0.68234164", "0.6811647", "0.674292", "0.6731018", "0.65214574", "0.6518302", "0.64426047", "0.6384672", "0.6362766", "0.6348285", "0.6306222", "0.62142736", "0.62036544", "0.6144075", "0.61147386", "0.60869455", "0.6019685", "0.6001533", "0.5989513", "0.59647626", "0.595060...
0.81583804
0
Returns the raw version of the given encrypted string.
def decrypt_string(self, encrypted_string): return self.fernet_instance.decrypt(encrypted_string.encode('utf-8')).decode('utf-8')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encrypt_string(self, raw_string):\n return self.fernet_instance.encrypt(raw_string.encode('utf-8'))", "def encrypted(data: str) -> str:\n return b64encode(data.encode('ascii')).decode('ascii')", "def raw_password_to_string(raw_string):\n return hashlib.sha256(str(raw_string).encode('utf-8')).h...
[ "0.71437955", "0.65881705", "0.6477882", "0.64496297", "0.63538414", "0.62263876", "0.60818547", "0.60766107", "0.6060412", "0.6047937", "0.60411847", "0.59877646", "0.59608394", "0.587944", "0.58562565", "0.5847599", "0.5836144", "0.5808924", "0.5767597", "0.5747277", "0.573...
0.6516151
2
Token builder helper class to create digest tokens that can be used with the Phenix platform.
def __init__(self): self.application_id = None self.secret = None self.token = {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build(self):\n token = DigestTokens()\n\n if not self.application_id:\n raise ValueError('application_id must be set using the \\\n \"with_application_id\" method before calling \"build\"')\n\n if not self.secret:\n raise ValueError('secret...
[ "0.7009748", "0.6283412", "0.61528003", "0.59743154", "0.59382457", "0.5930618", "0.59070903", "0.5873708", "0.5859789", "0.58429897", "0.58213156", "0.5754376", "0.567526", "0.56632096", "0.5655496", "0.56375253", "0.5617134", "0.55772907", "0.5519892", "0.5487191", "0.54808...
0.0
-1
The application ID used to sign the token. (required)
def with_application_id(self, application_id): if not isinstance(application_id, str): raise TypeError('Application Id must be a string') self.application_id = application_id return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ApplicationId(self) -> _n_0_t_0:", "def app_id(self) -> str:\n return self._app_id", "def app_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"app_id\")", "def app_id(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"app_id\")", "def app_id(self):\n return s...
[ "0.73115987", "0.72504157", "0.7124278", "0.70661306", "0.7051917", "0.7039097", "0.69642985", "0.69584894", "0.6954219", "0.6904534", "0.68569523", "0.6851584", "0.67558306", "0.6727432", "0.6726882", "0.6648573", "0.6648573", "0.6648573", "0.6524289", "0.64912724", "0.64359...
0.0
-1
The secret used to sign the token. (required)
def with_secret(self, secret): if not isinstance(secret, str): raise TypeError('Secret must be a string') self.secret = secret return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def secret(self):\n return self._secret", "def signing_secret(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"signing_secret\")", "def secret(self) -> str:\n return pulumi.get(self, \"secret\")", "def secret(self) -> str:\n return pulumi.get(self, \"secret\")", ...
[ "0.76498646", "0.75493485", "0.7544454", "0.7544454", "0.75068426", "0.74685127", "0.7464547", "0.7414411", "0.7377902", "0.7368211", "0.71865225", "0.71200866", "0.7114842", "0.7114842", "0.71128416", "0.71058685", "0.7092571", "0.7067026", "0.7067026", "0.70635796", "0.6999...
0.0
-1
The backend URI. (optional)
def with_uri(self, uri): if not isinstance(uri, str): raise TypeError('URI must be a string') self.token['uri'] = uri return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getBackend(self):\n return self.header['BACKEND']", "def backend(self) -> str:\n return self.__class__.BACKEND_NAME", "def get_backend():\n return _BACKEND", "def backend(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"backend\")", "def get_backend():\n return __SETTING...
[ "0.73152083", "0.7286011", "0.7179595", "0.69450295", "0.680573", "0.6770195", "0.67253417", "0.6694524", "0.65874857", "0.6514576", "0.64425635", "0.6429373", "0.6398925", "0.63962746", "0.6385044", "0.638325", "0.6379678", "0.6366209", "0.6364358", "0.63564456", "0.63564456...
0.0
-1
Set a capability for the token, e.g. to publish a stream. (optional)
def with_capability(self, capability): if not isinstance(capability, str): raise TypeError('Capability must be a string') token = self.token capabilities = set(token['capabilities']) if 'capabilities' in token else set([]) capabilities.add(capability) self.token['c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_capabilities(self, capabilities: WlSeat.capability) -> None:\n lib.wlr_seat_set_capabilities(self._ptr, capabilities)", "def addCapability(self, capability):\n self.capabilities.add(capability)", "def _add_capability(self, msg, identity):\n\n # FIXME retoken on token collision with...
[ "0.62619406", "0.6175175", "0.6047601", "0.5966227", "0.5726368", "0.5592567", "0.5539734", "0.55156046", "0.5501202", "0.5486496", "0.548406", "0.54332685", "0.536398", "0.53598034", "0.53598034", "0.5254867", "0.5194692", "0.5161786", "0.5160273", "0.5152895", "0.5136831", ...
0.70643526
0
Expires the token in the given time.
def expires_in_seconds(self, seconds): if not isinstance(seconds, int): raise TypeError('Seconds must be an int') self.token['expires'] = int((datetime.now().timestamp() + seconds)*1000.0) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def expire(self):\n logging.debug(\"Expiring token as wanted...\")\n self.expiration = datetime.now() - timedelta(seconds=(10))", "def _set_token_expiration_time(self, expires_in):\n self.token_expiration_time = dt.datetime.utcnow() + dt.timedelta(0, expires_in) # timedelta(days, seconds)",...
[ "0.76917213", "0.6979363", "0.6799405", "0.67159325", "0.66909903", "0.65411913", "0.6493937", "0.64727396", "0.6457241", "0.6428322", "0.62765664", "0.62321156", "0.61634", "0.6146268", "0.61437196", "0.6119173", "0.60557485", "0.6051389", "0.5999419", "0.5987485", "0.596032...
0.623812
11
Expires the token at the given dateime
def expires_at(self, ex_datetime): if not isinstance(ex_datetime, datetime): raise TypeError('datetime must be a valid date') self.token['expires'] = int(ex_datetime.timestamp()*1000.0) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def expire(self):\n logging.debug(\"Expiring token as wanted...\")\n self.expiration = datetime.now() - timedelta(seconds=(10))", "def _set_token_expiration_time(self, expires_in):\n self.token_expiration_time = dt.datetime.utcnow() + dt.timedelta(0, expires_in) # timedelta(days, seconds)",...
[ "0.74925524", "0.6965725", "0.6959143", "0.6788541", "0.6774638", "0.67563754", "0.66536474", "0.6632384", "0.660434", "0.6483804", "0.6436141", "0.64021134", "0.6360263", "0.6308414", "0.6307253", "0.6307253", "0.6266561", "0.6252453", "0.62354916", "0.6176458", "0.61094713"...
0.6907802
3
Limit the token to authentication only. (optional)
def for_authenticate_only(self): self.token['type'] = 'auth' return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _require_login(self):\n self.client.credentials(HTTP_AUTHORIZATION='Token ' + str(self.token))", "def auth_token(self):", "def _validate_token(self):\n if not self.token:\n self.login()\n if not self.token:\n # TODO: create exception for this\n # Access...
[ "0.7105954", "0.6667656", "0.6514181", "0.6469955", "0.64583325", "0.63503695", "0.63232756", "0.62646914", "0.6217762", "0.61985016", "0.61006", "0.6099132", "0.60379267", "0.6015517", "0.6010944", "0.60016906", "0.5979614", "0.5959321", "0.594469", "0.5930242", "0.5928187",...
0.7511397
0
Limit the token to streaming only. (optional)
def for_streaming_only(self): self.token['type'] = 'stream' return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, limitedstream):\n self.limitedstream = limitedstream", "def server_streaming(self) -> global___Snippet.ServerStreaming:", "def streaming_request(self) -> global___Snippet.SimpleRequestInitialization:", "def _limit_helper(stream: Union[BinaryIO, Generator, List], limit: int) -> Gener...
[ "0.60577446", "0.576815", "0.57674104", "0.56763136", "0.56058735", "0.5560593", "0.54444104", "0.5395247", "0.53115624", "0.5293115", "0.5288135", "0.5238549", "0.5235168", "0.52204764", "0.5201178", "0.5187488", "0.5171711", "0.51633424", "0.5124375", "0.5108288", "0.507085...
0.7863806
0
Limit the token to publishing only. (optional)
def for_publishing_only(self): self.token['type'] = 'publish' return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_add_permission(self, request):\n if not settings.PUBLISHER_CODE:\n return False\n return super().has_add_permission(request)", "def is_public_token(token):\n return (\n token.payload\n and token.payload.get(\"roles\") == [NONE]\n and token.payload.get(\"co...
[ "0.54844", "0.54165137", "0.5385421", "0.5319278", "0.53190047", "0.5302831", "0.51823705", "0.5133519", "0.5131273", "0.5131162", "0.51177657", "0.50790566", "0.50438625", "0.5034893", "0.500718", "0.4995648", "0.49872646", "0.4960588", "0.4882561", "0.4860834", "0.48247495"...
0.79604816
0
Limit the token to the specified session ID. (optional)
def for_session(self, session_id): if not isinstance(session_id, str): raise TypeError('Session Id must be a string') self.token['sessionId'] = session_id return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _update_token(token):\n session.token = token", "def get_token(self, session, **kwargs):\n return None", "def login_token(self, token):\n self.token = token # this will also set the refresh_token to None", "def set_mobile_session(id_token):\n try:\n user = google.oauth2.id_tok...
[ "0.59704345", "0.5825555", "0.55893874", "0.5477177", "0.536369", "0.5326675", "0.52724814", "0.52422607", "0.52193546", "0.5193504", "0.51333624", "0.5124961", "0.512454", "0.5087074", "0.5080296", "0.50701594", "0.5069392", "0.50401187", "0.50152", "0.50027496", "0.4987716"...
0.6013787
0
Limit the token to the specified remote address. (optional)
def for_remote_address(self, remote_address): if not isinstance(remote_address, str): raise TypeError('Remote Address must be a string') self.token['remoteAddress'] = remote_address return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_token_info_remote(self, token_info_url):", "def request(self, token):\n pass", "def RemoteEndPoint(self) -> _n_5_t_2:", "def RemoteEndPoint(self) -> _n_5_t_1:", "def RemoteEndPoint(self) -> _n_5_t_1:", "def request_token_url(self): # pragma: no cover\n raise NotImplementedError()",...
[ "0.54644215", "0.5210578", "0.5100081", "0.5062072", "0.5062072", "0.49818325", "0.49592954", "0.4892904", "0.48131654", "0.48083392", "0.47912484", "0.4739382", "0.47248766", "0.47165176", "0.46989724", "0.4686481", "0.4672394", "0.46668348", "0.46643445", "0.46341494", "0.4...
0.6179291
0
Limit the token to the specified origin stream ID. (optional)
def for_origin_stream(self, origin_stream_id): if not isinstance(origin_stream_id, str): raise TypeError('Origin Stream Id must be a string') self.token['originStreamId'] = origin_stream_id return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def for_streaming_only(self):\n self.token['type'] = 'stream'\n\n return self", "def origin_id(self, origin_id):\n\n self._origin_id = origin_id", "def token_id_from(self, token_id_from):\n\n self._token_id_from = token_id_from", "def get_channel_stream(self, stream_args, origin):...
[ "0.5534165", "0.54561955", "0.53313065", "0.49888474", "0.49621314", "0.4875266", "0.4807816", "0.4779869", "0.47702262", "0.47550067", "0.47452444", "0.46652195", "0.4636593", "0.46063805", "0.4602795", "0.45823655", "0.45739326", "0.45626962", "0.4554549", "0.4541904", "0.4...
0.7007976
0
Limit the token to the specified channel ID. (optional)
def for_channel(self, channel_id): if not isinstance(channel_id, str): raise TypeError('Channel ID must be a string') self.for_tag('channelId:{}'.format(channel_id)) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def cclimit(self, ctx, limit_amount: int = None):\n if limit_amount is None:\n return await ctx.send_help()\n if limit_amount < 0:\n return await ctx.send(\"You need to use a number larger than 0.\")\n await self.config.limit.set(limit_amount)\n await ctx.sen...
[ "0.5936086", "0.58824795", "0.57529366", "0.57121193", "0.57084006", "0.57061315", "0.5675261", "0.55601346", "0.55402774", "0.55343854", "0.544267", "0.54274446", "0.53523386", "0.5313491", "0.5306997", "0.52759963", "0.52693397", "0.52605224", "0.5251249", "0.5242523", "0.5...
0.50766903
28
Limit the token to the specified channel alias. (optional)
def for_channel_alias(self, channel_alias): if not isinstance(channel_alias, str): raise TypeError('Channel Alias must be a string') self.for_tag('channelAlias:{}'.format(channel_alias)) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def channel_access_token(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"channel_access_token\")", "async def cclimit(self, ctx, limit_amount: int = None):\n if limit_amount is None:\n return await ctx.send_help()\n if limit_amount < 0:\n return await ...
[ "0.56562996", "0.5192465", "0.5055396", "0.5030429", "0.48632553", "0.4810923", "0.47978848", "0.47668964", "0.4738913", "0.46901718", "0.46724027", "0.4672042", "0.46369606", "0.46153092", "0.45997238", "0.45752332", "0.4561803", "0.4559696", "0.4552768", "0.45245716", "0.45...
0.5702281
0
Limit the token to the specified room ID. (optional)
def for_room(self, room_id): if not isinstance(room_id, str): raise TypeError('Room ID must be a string') self.for_tag('roomId:{}'.format(room_id)) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def room_to_read_only(self, room_id):\n # set room to read-only\n response = requests.patch(\n f\"{self.uri}/rooms/{room_id}/attribute/id/text\",\n json={\"attribute\": \"readonly\", \"value\": \"True\"},\n headers={\"Authorization\": f\"Bearer {self.token}\"},\n ...
[ "0.55621105", "0.5426208", "0.51994264", "0.51904845", "0.5157681", "0.51059484", "0.50616014", "0.50450844", "0.5039581", "0.50214154", "0.49993423", "0.49977985", "0.49938306", "0.49395907", "0.49322966", "0.48919842", "0.48741508", "0.48704398", "0.48625404", "0.4838289", ...
0.5008069
10
Limit the token to the specified room alias. (optional)
def for_room_alias(self, room_alias): if not isinstance(room_alias, str): raise TypeError('Room Alias must be a string') self.for_tag('roomAlias:{}'.format(room_alias)) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def deletealias(self, ctx, alias, mem_id: int, mode=\"idol\"):\n alias = alias.replace(\"_\", \" \")\n if mode.lower() in [\"idol\", \"member\", \"members\", \"idols\"]:\n obj = await self.ex.u_group_members.get_member(mem_id)\n name = f\"{obj.full_name} ({obj.stage_name})...
[ "0.48553815", "0.47974828", "0.47712502", "0.4765508", "0.47145182", "0.46774754", "0.46155646", "0.46057123", "0.46009037", "0.45790952", "0.45714125", "0.45700288", "0.45267746", "0.4501701", "0.44909224", "0.4374284", "0.43716162", "0.43599826", "0.4358302", "0.43562332", ...
0.57757866
0
Limit the token to the specified tag on the origin stream. (optional)
def for_tag(self, tag): if not isinstance(tag, str): raise TypeError('Tag must be a string') self.token['requiredTag'] = tag return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next_token(self, context, token):", "def for_streaming_only(self):\n self.token['type'] = 'stream'\n\n return self", "def updateTag(self, authenticationToken, tag):\r\n pass", "def token(self, token):\n\n self._token = token", "def token(self, token):\n\n self._token = to...
[ "0.57777685", "0.5351099", "0.5214884", "0.5155102", "0.5155102", "0.4888451", "0.4850415", "0.48312423", "0.47413683", "0.47393548", "0.4733733", "0.47291398", "0.4727417", "0.47127685", "0.46923047", "0.46893948", "0.46803626", "0.4658257", "0.4621659", "0.46118456", "0.458...
0.4747601
8
Apply the tag to the stream when it is setup. (optional)
def apply_tag(self, tag): if not isinstance(tag, str): raise TypeError('Tag must be a string') token = self.token apply_tags = set(token['applyTags']) if 'applyTags' in token else set() apply_tags.add(tag) self.token['applyTags'] = list(apply_tags) return ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _HandleTag(self, input_line, tag, output_stream):\n if tag not in self._open_tags:\n self._OpenTag(input_line, tag, output_stream)\n else:\n self._CloseTag(input_line, tag, output_stream)", "def tag(self, tag):\n self.tag = tag", "def tag(self, tag):\n\n self._tag = tag", "d...
[ "0.61478925", "0.6118014", "0.6011416", "0.6011416", "0.6011416", "0.6011416", "0.5999301", "0.5905584", "0.58045685", "0.57613564", "0.5724124", "0.56950116", "0.56664157", "0.5655396", "0.56345576", "0.563412", "0.5623479", "0.5594282", "0.5590867", "0.55425113", "0.5542511...
0.49773872
58
Build the signed token
def build(self): token = DigestTokens() if not self.application_id: raise ValueError('application_id must be set using the \ "with_application_id" method before calling "build"') if not self.secret: raise ValueError('secret must be set using...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _build_signature(self):\n sig_contents = \\\n self.payload + \".\" + \\\n b64encode(b\"application/xml\").decode(\"ascii\") + \".\" + \\\n b64encode(b\"base64url\").decode(\"ascii\") + \".\" + \\\n b64encode(b\"RSA-SHA256\").decode(\"ascii\")\n sig_hash...
[ "0.6664714", "0.64297086", "0.636979", "0.6257425", "0.6235636", "0.62269235", "0.6215452", "0.620243", "0.61873454", "0.6109761", "0.6107653", "0.6098172", "0.605793", "0.6022945", "0.5983509", "0.5927956", "0.5914759", "0.5901994", "0.58837533", "0.58827204", "0.5882324", ...
0.74539524
0
make sure the shuffled sequence does not lose any elements
def test_decode(self): self.assertEqual( hex_to_b64(self.hex_string), self.expect_result )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_shuffle(self):\n random.shuffle(self.seq)\n self.seq.sort()\n self.assertEqual(self.seq, range(10))", "def test_shuffle(self):\n r = self.RNA(\"UUUUCCCCAAAAGGGG\")\n s = r.shuffle()\n self.assertNotEqual(r, s)\n self.assertEqualItems(r, s)", "def test_s...
[ "0.75482666", "0.74879754", "0.71228105", "0.70709866", "0.7006968", "0.6793258", "0.67546386", "0.6753882", "0.66764843", "0.6596472", "0.6590754", "0.6590754", "0.65671426", "0.6523371", "0.6473894", "0.6473151", "0.6466011", "0.6466011", "0.64310604", "0.64198136", "0.6419...
0.0
-1
creates a new compilation engine with the given input and output
def __init__(self, inpt, outpt): self.tokenizer = JackTokenizer(inpt) self.symbol_table = SymbolTable() self.code_writer = VMWriter(outpt) self.class_name = None self.label_index = 0 self.compile_class()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_engine(self, input):\n return", "def __create_execution_engine(self):\n target = self.binding.Target.from_default_triple()\n target_machine = target.create_target_machine()\n backing_mod = binding.parse_assembly(\"\")\n engine = binding.create_mcjit_compiler(backing_...
[ "0.68125397", "0.65761006", "0.651195", "0.651195", "0.651195", "0.6220326", "0.60901946", "0.6087107", "0.6024652", "0.5952252", "0.5927771", "0.5926563", "0.5822195", "0.5791559", "0.57531047", "0.5751278", "0.5742589", "0.57242006", "0.57177174", "0.5706596", "0.5705054", ...
0.58511925
12
compiles a complete class
def compile_class(self): self.tokenizer.advance() # ignore 'class' keyword self.class_name = self.tokenizer.identifier() self.tokenizer.advance() self.tokenizer.advance() # ignore '{' symbol while self.tokenizer.curtok < len(self.tokenizer.tokens) - 1: dec = s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compile_class(self):\n\t\t\n\t\txml = '<class>\\n' + self.tokenizer.keyword() + self.tokenizer.identifier() + self.tokenizer.symbol()\n\n\t\tself.outfile.write(xml)", "def compile(self):\n\n\t\twhile(self.tokenizer.has_more_tokens()):\n\n\t\t\tif self.tokenizer.get_token() == 'class':\n\t\t\t\tself.compile_c...
[ "0.7345077", "0.70924985", "0.6796033", "0.6782586", "0.658691", "0.6350718", "0.6341831", "0.62512016", "0.6195713", "0.6145655", "0.61391705", "0.61391705", "0.61386114", "0.605397", "0.605353", "0.5922235", "0.59199834", "0.5835646", "0.5799892", "0.57497466", "0.57380176"...
0.75520575
0
compiles a complete method, function or constructor
def compile_subroutine(self): self.symbol_table.start_subroutine() func_type = self.tokenizer.key_word() self.tokenizer.advance() self.tokenizer.advance() # ignore the return type of the function func_name = self.class_name + "." + self.tokenizer.identifier() self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compile(self):\n raise NotImplementedError()", "def __compile_subroutine_body(self):\r\n self.compile_statements()", "def compile(self):\n\n\t\twhile(self.tokenizer.has_more_tokens()):\n\n\t\t\tif self.tokenizer.get_token() == 'class':\n\t\t\t\tself.compile_class()\n\t\t\telif self.tokenizer....
[ "0.7122685", "0.70046073", "0.6941051", "0.69288325", "0.69202787", "0.6875751", "0.6820653", "0.6811628", "0.66644967", "0.6570711", "0.65058327", "0.6425481", "0.6422159", "0.63993543", "0.6328704", "0.63063186", "0.63039833", "0.6284907", "0.6284418", "0.62655216", "0.6241...
0.70149505
1
compiles a static declaration or a field declaration
def compile_var_dec(self): var_kind = SymbolTable.KEY2ENUM[self.tokenizer.key_word()] self.tokenizer.advance() tok_type = self.tokenizer.token_type() if tok_type == JackTokenizer.KEYWORD_T: var_type = self.tokenizer.key_word() else: var_type = self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compile_class(self):\r\n self.tokenizer.advance() # ignore 'class' keyword\r\n self.class_name = self.tokenizer.identifier()\r\n self.tokenizer.advance()\r\n self.tokenizer.advance() # ignore '{' symbol\r\n while self.tokenizer.curtok < len(self.tokenizer.tokens) - 1:\r\n ...
[ "0.5971691", "0.56881565", "0.5662439", "0.5661217", "0.55370194", "0.54972905", "0.5491543", "0.537461", "0.5179423", "0.51772547", "0.51236063", "0.50624144", "0.4992937", "0.49721813", "0.4969132", "0.4961225", "0.49396598", "0.49110854", "0.48925692", "0.48781055", "0.487...
0.46924675
36
compiles a (possibly empty) parameter list not including parentheses
def compile_parameter_list(self): var_type = None while True: self.tokenizer.advance() tok_type = self.tokenizer.token_type() if tok_type == JackTokenizer.KEYWORD_T: var_type = self.tokenizer.key_word() elif tok_type == JackTokenizer...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compile_parameter_list(self) -> None:\n if self._get_current_token() != ')':\n var_type = self._get_current_token()\n self._consume_type()\n\n self.table.define(self._get_current_token(), var_type, Kind.ARG)\n self._consume(TokenTypes.IDENTIFIER)\n ...
[ "0.70801806", "0.6877128", "0.6378339", "0.6040842", "0.59524256", "0.5888855", "0.58112115", "0.5777761", "0.5720453", "0.5696444", "0.5536624", "0.54903793", "0.5452463", "0.5431968", "0.5419633", "0.54116756", "0.54111105", "0.54099673", "0.5350463", "0.5343245", "0.534324...
0.6088443
3
compiles a sequence of statements, not including the enclosing "{}"
def compile_statements(self): tok_type = self.tokenizer.token_type() while tok_type == JackTokenizer.KEYWORD_T: key = self.tokenizer.key_word() if key == "let": self.compile_let() elif key == "do": self.compile_do() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compile_statements(self):\n\t\n\t\tif self.tokenizer.get_token() == 'do':\n\t\t\tself.compile_do()\n\t\telif self.tokenizer.get_token() == 'let':\n\t\t\tself.compile_let()\n\t\telif self.tokenizer.get_token() == 'while':\n\t\t\tself.compile_while()\n\t\telif self.tokenizer.get_token() == 'return':\n\t\t\tself....
[ "0.75589675", "0.7019048", "0.672143", "0.6697218", "0.6517987", "0.64978373", "0.64847785", "0.6292182", "0.6128917", "0.5995169", "0.5977094", "0.5945606", "0.5886187", "0.5850196", "0.5706215", "0.57057124", "0.57051194", "0.56963694", "0.56932306", "0.5675147", "0.5630193...
0.69941765
2
compile a do statement
def compile_do(self): self.tokenizer.advance() # ignore 'do' keyword func_name = self.tokenizer.identifier() var_type = self.symbol_table.type_of(func_name) n_args = 0 if var_type: self.code_writer.write_push(self.symbol_table.kind_of(func_name), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compile_do(self) -> None:\n self._consume('do')\n self.compile_subroutine_call()\n self.writer.write_pop('TEMP', 0) # void method\n self._consume(';')", "def compile_do(self):\n\n\t\txml = '<doStatement>\\n' + self.tokenizer.keyword() + self.tokenizer.identifier()\n\n\t\tif self....
[ "0.7731854", "0.7476447", "0.65631324", "0.6170741", "0.56916237", "0.5522174", "0.5387398", "0.53237134", "0.5298152", "0.52630836", "0.52493423", "0.5230324", "0.5228078", "0.52264786", "0.51874954", "0.5172265", "0.5170777", "0.5116289", "0.5071028", "0.50559103", "0.50476...
0.74331874
2
compiles a let statement
def compile_let(self): self.tokenizer.advance() # ignore 'let' keyword var_name = self.tokenizer.identifier() kind = self.symbol_table.kind_of(var_name) ind = self.symbol_table.index_of(var_name) self.tokenizer.advance() sym = self.tokenizer.symbol() is_ar...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compile_let(self) -> None:\n self._consume('let')\n name = self._get_current_token()\n kind = convert_kind(self.table.kind_of(name))\n index = self.table.index_of(name)\n\n self._consume(TokenTypes.IDENTIFIER)\n if self._get_current_token() == '[':\n self._c...
[ "0.73564106", "0.72491395", "0.7166526", "0.6516337", "0.6221294", "0.6105278", "0.6005555", "0.5933077", "0.5905761", "0.5885362", "0.5634257", "0.5587453", "0.5564042", "0.5523054", "0.5512737", "0.5454524", "0.54349154", "0.5341546", "0.5339458", "0.531304", "0.530831", ...
0.7684182
0
compiles a while statement
def compile_while(self): lab1 = self.class_name + ".L" + str(self.label_index) self.label_index += 1 lab2 = self.class_name + ".L" + str(self.label_index) self.label_index += 1 self.tokenizer.advance() # ignore 'while' keyword self.tokenizer.advance() # ignore '('...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compile_while(self) -> None:\n self._consume('while')\n self._consume('(')\n\n while_lbl = f\"WHILE_{self._while_count}\"\n while_false_lbl = f\"WHILE_FALSE{self._while_count}\"\n self._while_count += 1\n self.writer.write_label(while_lbl)\n\n self.compile_expre...
[ "0.7955481", "0.776042", "0.7662631", "0.7374275", "0.7131139", "0.71004325", "0.70531285", "0.7040795", "0.6986955", "0.69267535", "0.69196093", "0.69127405", "0.6842747", "0.6212009", "0.61005455", "0.60468936", "0.6012953", "0.5999755", "0.59282243", "0.5804145", "0.578901...
0.7888832
1
compiles a return statement
def compile_return(self): self.tokenizer.advance() if self.tokenizer.token_type() == JackTokenizer.SYMBOL_T and self.tokenizer.symbol() == ";": self.code_writer.write_push("constant", 0) else: self.compile_expression() self.code_writer.write_return()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compile_return(self):\n\n\t\txml = '<returnStatement>\\n' + self.tokenizer.keyword()\n\t\tself.outfile.write(xml)\n\n\t\tif self.tokenizer.get_token() != ';':\n\t\t\tself.compile_expression()\n\n\t\txml = self.tokenizer.symbol() + '</returnStatement>\\n'\n\t\tself.outfile.write(xml)", "def compile_return(sel...
[ "0.7594602", "0.75319594", "0.71452075", "0.6909647", "0.68616664", "0.6687466", "0.65710676", "0.652341", "0.6279737", "0.6262663", "0.6223273", "0.6188292", "0.617591", "0.61289674", "0.59650666", "0.5962612", "0.5933766", "0.5873438", "0.58618015", "0.58410645", "0.5826408...
0.7245663
2
compiles an if\else statement
def compile_if(self): lab1 = self.class_name + ".L" + str(self.label_index) self.label_index += 1 lab2 = self.class_name + ".L" + str(self.label_index) self.label_index += 1 self.tokenizer.advance() # ignore 'if' keyword self.tokenizer.advance() # ignore '(' symbo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compile_if(self):\r\n else_label = \"ELSE_\" + str(self.__if_count)\r\n end_label = \"END_IF_\" + str(self.__if_count)\r\n self.__if_count += 1\r\n self.__advance(n=2)\r\n self.compile_expression()\r\n self.__vmwriter.write_arithmetic(\"not\")\r\n self.__vmwrite...
[ "0.7727683", "0.7289224", "0.72581816", "0.68175304", "0.6810607", "0.661387", "0.65655905", "0.6555208", "0.6516338", "0.6474446", "0.6472909", "0.6414552", "0.64119923", "0.6258708", "0.6228315", "0.621231", "0.61874413", "0.6169468", "0.6071389", "0.6052652", "0.60436004",...
0.7691382
1
compiles a (possibly empty) comma separated expression list
def compile_expression_list(self): n_expressions = 0 while True: tok_type = self.tokenizer.token_type() if tok_type == JackTokenizer.SYMBOL_T: sym = self.tokenizer.symbol() if sym == ")": break elif sym =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compile_expression_list(self):\n\n\t\tself.compile_expression()\n\n\t\twhile(self.tokenizer.get_token() == ','):\n\t\t\tself.outfile.write(self.tokenizer.symbol())\n\t\t\tself.compile_expression()", "def compile_expression_list(self) -> int:\n n_args = 0\n\n if self._get_current_token() != ')':...
[ "0.7832312", "0.71106184", "0.65448207", "0.6429112", "0.62829477", "0.6227067", "0.6078659", "0.60175455", "0.58949816", "0.58610445", "0.5756176", "0.57423204", "0.5708315", "0.5526907", "0.5511897", "0.54655975", "0.54565", "0.5421775", "0.54128385", "0.5408563", "0.536056...
0.64618796
3
Get secret from secret service
def get_secret(self, token, owner_type, resource_type, source, name): try: token = "Bearer " + token metadata = (('authorization', token),) owner_type = ResourceOwnerType.Value(owner_type) resource_type = ResourceType.Value(resource_type) source = Res...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_secret(secret):\n if isinstance(secret, AwsSecret):\n result = aws_cli([\n 'secretsmanager',\n '--region', secret.region,\n 'get-secret-value',\n '--secret-id', secret.arn\n ])\n\n \"\"\"\n Result will be of the form:\n {\n...
[ "0.7876364", "0.77615315", "0.7694051", "0.7657492", "0.75929713", "0.75847775", "0.75797004", "0.75692135", "0.7512623", "0.7512623", "0.74721676", "0.7460301", "0.74577284", "0.74248636", "0.74248636", "0.73171264", "0.7313317", "0.72957635", "0.72957635", "0.71956354", "0....
0.64663106
98
Return the config. Use this method to get the bot config
def get_config(self) -> Dict[str, Any]: if self.config is None: self.config = self.load_config() return self.config
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def config(self):\n if self.__config is None:\n self.__config = self._get_config(self.bot)\n return self.__config", "def get_config(self):\n return self.config", "def getConfig(self):\n \n return self.config", "def get_config():\n return CONFIG", "def config...
[ "0.8793585", "0.825753", "0.8087057", "0.7923807", "0.7904086", "0.78217363", "0.78192705", "0.78192705", "0.78192705", "0.78192705", "0.78192705", "0.78192705", "0.78192705", "0.78192705", "0.78192705", "0.78192705", "0.78192705", "0.78192705", "0.78192705", "0.78192705", "0...
0.7942068
4
Extract information for sys.argv and load the bot configuration
def load_config(self) -> Dict[str, Any]: # Load all configs config: Dict[str, Any] = self.load_from_files(self.args.get("config", [])) return config
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_arguments(argv):\n\tif argv[0] in ('1', '2'):\n\t\tconos_config['endpoint'] = endpoint[argv[0]]\n\telse:\n\t\tusage()\n\n\tif argv[1] in ('dev', 'test', 'int', 'prod'):\n\t\tconos_config['environment'] = argv[1]\n\t\tconos_config['sts_url'] = eval(argv[1] + '_sts_url')\n\t\tconos_config['aicuu_url'] = eva...
[ "0.7061687", "0.64792365", "0.63791585", "0.63641816", "0.6280541", "0.6233762", "0.6233762", "0.61830795", "0.6156966", "0.6153224", "0.6123412", "0.60791194", "0.607641", "0.60395724", "0.6026321", "0.60259324", "0.6018109", "0.6004645", "0.600403", "0.59953845", "0.5993967...
0.0
-1
Check that the HoleM51 object is correct
def check(self): Rbo = self.get_Rbo() alpha = self.comp_alpha() if self.W0 < (self.W2 + self.W3): raise S51_WCheckError("You must have W2+W3 < W0") if Rbo < self.H0 + self.H2: raise S51_RHCheckError("You must have H0+H2 < Rbo") if alpha > pi / 2: raise S51_AlphaCheckError...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_full_house_properties(self):\n self.assertEqual(self.hand.flushInd, 0)\n self.assertEqual(self.hand.straightInd, 0)\n self.assertEqual(self.hand.straightHead, 0)\n self.assertEqual(self.hand.postHandType, 4)\n self.assertEqual(self.hand.postHandValue, 171)", "def check...
[ "0.6389238", "0.6138588", "0.6076156", "0.6029584", "0.60056037", "0.60027415", "0.5961152", "0.5958448", "0.5958351", "0.59574455", "0.5934016", "0.59121776", "0.5896677", "0.58715385", "0.5870168", "0.58549494", "0.58464986", "0.58349705", "0.582925", "0.58279985", "0.58042...
0.6223342
1
Map observation data to empirical CDF quantiles in place.
def _transform_observation_data( self, observation_data: List[ObservationData], ) -> List[ObservationData]: # TODO (jej): Transform covariances. if self.winsorize: winsorization_rates = {} for metric_name, vals in self.percentiles.items(): n = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def quantile_transform(X, *, axis=..., n_quantiles=..., output_distribution=..., ignore_implicit_zeros=..., subsample=..., random_state=..., copy=...):\n ...", "def ecdf_quantiles(data_quantiles, performance_measure, ecdf_parameter):\n from statsmodels.distributions.empirical_distribution import ECDF\n\n ...
[ "0.5898078", "0.5854797", "0.58402777", "0.5831225", "0.5804016", "0.571265", "0.56208575", "0.5602898", "0.5595195", "0.5581166", "0.5550828", "0.55504656", "0.546441", "0.5462287", "0.542158", "0.54096085", "0.540888", "0.5403378", "0.5393875", "0.5387819", "0.53789145", ...
0.60944504
0
Create a tau analysis algorithm sequence
def makeDiTauAnalysisSequence( dataType, workingPoint, deepCopyOutput = False, postfix = '' ): if dataType not in ["data", "mc", "afii"] : raise ValueError ("invalid data type: " + dataType) if postfix != '' : postfix = '_' + postfix pass splitWP = wor...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_tau_functions(self, **kwargs):\n tau1x,tau2x,dens,col = self.select_data(**kwargs)\n\n # ddens = (10**dens[1]-10**dens[0])\n #dlogdens = (dens[1]-dens[0])\n #dlndens = dlogdens * np.log(10)\n\n def tau(meandens, line=tau1x, sigma=1.0, hightail=False,\n ...
[ "0.6678921", "0.64726853", "0.59206873", "0.58965874", "0.5889418", "0.58359766", "0.58147067", "0.5737234", "0.56830996", "0.56643397", "0.56588525", "0.56533486", "0.56486934", "0.5611884", "0.5595678", "0.55607104", "0.55576503", "0.55543387", "0.55469376", "0.55081576", "...
0.5796416
7
Import content from fpath and puts it into a Python module. Returns the module.
def load_recipe(root: Path) -> None: module_name = 'dotops.recipes.' + root.name fpath = find_recipe(root) try: _ast = import_file_to_ast(fpath, module_name) mod = imp.new_module(module_name) mod.__file__ = fpath eval(ast_compile(_ast, fpath, "exec"), _globals(root, mod)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def import_file(name: Text, file_path: Text):\n\n spec = spec_from_file_location(f\"luh3417.{name}\", file_path)\n module = module_from_spec(spec)\n spec.loader.exec_module(module)\n\n return module", "def import_module_from_file(f_path, verbose=True):\n # get absolute path\n f_path = os.path.a...
[ "0.68160796", "0.6811874", "0.6781548", "0.6760454", "0.66912633", "0.6654619", "0.6637428", "0.6599749", "0.6581477", "0.6511371", "0.63773304", "0.6327028", "0.62901616", "0.6283164", "0.62297213", "0.6172371", "0.6172371", "0.6172371", "0.6159115", "0.6159115", "0.6137258"...
0.0
-1
Test Users Are Listed on User Page
def test_user_listed(self): url = reverse('admin:core_user_changelist') res = self.client.get(url) #assert are django checks on http request is 200 self.assertContains(res, self.user.name) self.assertContains(res, self.user.email)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_users_listed(self):\n # the url is defined in django admin documentation\n # it generate the url for the list of user page\n # it is good using that instead of the url in case it changes\n url = reverse('admin:core_user_changelist')\n res = self.client.get(url)\n\n ...
[ "0.8124728", "0.80238926", "0.79463685", "0.7838391", "0.7786036", "0.75236106", "0.74479085", "0.7121244", "0.7078165", "0.69479847", "0.680003", "0.66679984", "0.66044194", "0.65990674", "0.6565116", "0.65329105", "0.6504518", "0.6474638", "0.6463932", "0.64483243", "0.6435...
0.76845825
5
Test User Edit Page Functioning
def test_user_page_change_page(self): url = reverse('admin:core_user_change', args=[self.user.id]) # houw args workd # admin/core/usre/ res = self.client.get(url) #checking response for 200 ok page works self.assertEqual(res.status_code, 200)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_provider_user_edit(self):\n browser = self.browser\n browser.get(self.base_url)\n wait = WebDriverWait(browser, 10)\n\n user = self.getUser()\n self.assertTrue(user.login())\n\n browser.get(self.base_url + \"user/me/edit\")\n\n pass1 = wait.until(\n ...
[ "0.7720228", "0.77047116", "0.74995023", "0.74353683", "0.7335236", "0.7279572", "0.72357357", "0.72062695", "0.7197021", "0.71928006", "0.7165932", "0.7125301", "0.7110623", "0.7105635", "0.7068543", "0.70568454", "0.70303935", "0.7024331", "0.70119196", "0.69808865", "0.697...
0.670942
40
Test Create Page User Is Working
def test_create_user_page(self): url = reverse('admin:core_user_add') res = self.client.get(url) self.assertEqual(res.status_code, 200)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_user_page(self):\n\n # Get the admin url and send a GET request\n url = reverse('admin:core_user_add')\n res = self.client.get(url)\n\n # Assertions\n self.assertEqual(res.status_code, 200)", "def test_createUser_single(self):\n #TODO: this and other test...
[ "0.7967953", "0.78794813", "0.77616847", "0.77616847", "0.77616847", "0.7539795", "0.7418349", "0.7406909", "0.73963964", "0.7326523", "0.7249234", "0.7249234", "0.72076356", "0.71943235", "0.7188387", "0.718378", "0.7145582", "0.7144657", "0.71303326", "0.71269745", "0.71253...
0.81040174
3
Return the last five published polls.
def get_queryset(self): return Poll.objects.order_by('-pub_date')[:5]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def latest_question(questions):\n return questions.order_by('-pub_date')[:5]", "def get_queryset(self):\n #.1 below code was showing future poll/questions\n #.1 return Question.objects.order_by('-pub_date')[:5]\n\n #re-defining\n \"\"\"\n Return the last five published quest...
[ "0.7059502", "0.68990624", "0.6736997", "0.6610546", "0.65707564", "0.64962935", "0.6420193", "0.6103467", "0.6092696", "0.6053481", "0.6053481", "0.6045828", "0.60050005", "0.5983273", "0.5981904", "0.5981904", "0.59585816", "0.592744", "0.592744", "0.592744", "0.592744", ...
0.70417947
1
Verifies format_note_line is properly functioning
def test_format_note_line(self, timestamp, note, expectation): self.assertEqual( expectation, Plugin().format_note_line(timestamp, note) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test(self):\n self.note(\"Test Note\", \"\"\" This is a note.\nsecond line\"\"\", \"date\")", "def testBadLine(self):\n\n self.assertRaises(\n ValueError,\n tools._trackInfo,\n 'not a real line'\n )", "def test_text_multiline(self):\n self.assertEqua...
[ "0.63763535", "0.6088162", "0.6052769", "0.5908646", "0.58638895", "0.58430326", "0.58398646", "0.5815939", "0.5808479", "0.5801687", "0.5766474", "0.5717834", "0.5704316", "0.56848854", "0.56711686", "0.5639434", "0.5638027", "0.56326956", "0.5625865", "0.56150144", "0.56107...
0.82377183
0
Get all the notes and chords from the midi files
def get_notes(n_notes=3): notes = [] for ii, file in enumerate(glob.glob("data/maestro-v2.0.0/2004/*.midi")): if ii >= n_notes: break pickle_file_name = file[:-4] + 'pkl' if os.path.isfile(pickle_file_name): print(f'Reading parsed file: {pickle_file_name}') ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_notes():\n notes = []\n durs = []\n\n for file in glob.glob(\"D:\\\\anthems\\\\data\\\\*.mid\"):\n midi = converter.parse(file)\n\n print(\"Parsing %s\" % file)\n\n notes_to_parse = None\n\n try:\n s2 = instrument.partitionByInstrument(midi)\n note...
[ "0.79301363", "0.7536378", "0.7083482", "0.6557107", "0.65365964", "0.638125", "0.6212812", "0.6065463", "0.60483277", "0.5995753", "0.5991631", "0.5934174", "0.5896727", "0.5851554", "0.579453", "0.57905567", "0.57853305", "0.57399046", "0.5710731", "0.570966", "0.56802684",...
0.7196914
2
Prepare the sequences used by the Neural Network
def prepare_sequences(notes, n_vocab): sequence_length = GLOBAL_SEQUENCE_LENGTH # Get all pitch names pitchnames = sorted(set(item for item in notes)) # Create a dictionary to map pitches to integers note_to_int = dict((note, number) for number, note in enumerate(pitchnames)) network_input = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prepare_sequences(notes, n_vocab):\n sequence_length = 50\n\n # get all pitch names\n pitchnames = sorted(set(item for item in notes))\n\n # create a dictionary to map pitches to integers\n note_to_int = dict((note, number) for number, note in enumerate(pitchnames))\n\n network_input = []\n ...
[ "0.6689426", "0.6478123", "0.64326185", "0.64018196", "0.6347999", "0.6346381", "0.619188", "0.61806005", "0.61420333", "0.61329055", "0.61148167", "0.6100435", "0.608873", "0.60376334", "0.603599", "0.601905", "0.60031384", "0.5962889", "0.5943119", "0.5938684", "0.59183395"...
0.65555423
1
Generate notes from the neural network based on a sequence of notes
def generate_notes(model, network_input, n_vocab): # pick a random sequence from the input as a starting point for the prediction start = np.random.randint(0, len(network_input)-1) # Get pitch names and store in a dictionary pitchnames = sorted(set(item for item in notes)) int_to_note = dict((n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_notes(model, training_notes, note_translator):\n\n # pick a random sequence from the input as a starting point for the prediction\n sequence_length = model.sequence_length\n note_reverse_translator = {index: note for note, index in note_translator.items()}\n init_state = data_preprocess.pr...
[ "0.75724083", "0.75357854", "0.7140033", "0.7138525", "0.7112814", "0.6966233", "0.69008785", "0.6879311", "0.6497627", "0.61884177", "0.6184555", "0.6086288", "0.59519565", "0.5931394", "0.5835027", "0.5832675", "0.5720372", "0.5715914", "0.56507623", "0.5642474", "0.5600574...
0.7653167
0
convert the output from the prediction to notes and create a midi file from the notes
def create_midi(prediction_output, filename): offset = 0 output_notes = [] # create note and chord objects based on the values generated by the model for item in prediction_output: pattern = item # pattern is a chord if ('.' in pattern) or pattern.isdigit(): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_midi(prediction_output, model_file):\n offset = 0\n output_notes = []\n\n # create note and chord objects based on the values generated by the model\n for pattern in prediction_output:\n # pattern is a chord\n if ('.' in pattern) or pattern.isdigit():\n notes_in_chor...
[ "0.79950756", "0.7954297", "0.79236674", "0.7789785", "0.671896", "0.660403", "0.6532247", "0.6258551", "0.6235759", "0.62201077", "0.6185511", "0.61558264", "0.6133344", "0.60906225", "0.6084611", "0.60755897", "0.60568166", "0.60479105", "0.60397", "0.6035738", "0.6019836",...
0.8151729
0
Convert a metric's OC time series to list of Azure data points.
def create_data_points(self, time_series, metric_descriptor): data_points = [] for point in time_series.points: # TODO: Possibly encode namespace in name data_point = DataPoint(ns=metric_descriptor.name, name=metric_descriptor.name, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_twodim_list(self):\n if self._timestampFormat is None:\n return self._timeseriesData\n\n datalist = []\n append = datalist.append\n convert = TimeSeries.convert_epoch_to_timestamp\n for entry in self._timeseriesData:\n append([convert(entry[0], sel...
[ "0.5604662", "0.560111", "0.5588779", "0.545325", "0.5367597", "0.53425586", "0.52977", "0.52824956", "0.52455235", "0.5179696", "0.51406455", "0.5069293", "0.5068566", "0.50647616", "0.49761406", "0.49100855", "0.490695", "0.4901837", "0.4899198", "0.48926318", "0.4870198", ...
0.5541618
3
Transmit the data envelopes to the ingestion service. Does not perform retry logic. For partial success and nonretryable failure, simply outputs result to logs. This function should never throw exception.
def _transmit_without_retry(self, envelopes): # Contains logic from transport._transmit # TODO: Remove this function from exporter and consolidate with # transport._transmit to cover all exporter use cases. Uses cases # pertain to properly handling failures and implementing a retry ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send(self, result):\n\n logger.debug(\"Checking if we should send {}\".format(result))\n if result.is_failure() and self.will_publish(result):\n message = self._construct_message(result)\n headers = {\n \"Content-Type\": \"application/json\"\n }\n\n...
[ "0.5656892", "0.5287145", "0.5174026", "0.515644", "0.51534945", "0.5118591", "0.5063369", "0.5057553", "0.50450146", "0.5035203", "0.50120544", "0.49986604", "0.49908283", "0.49884164", "0.49834234", "0.49751616", "0.49745554", "0.49649167", "0.49632606", "0.4957523", "0.493...
0.736348
0
A somewhat strange case where the right hand side is constant and thus we don't need to use the information in y.
def rhs_fenics(y,t): #print "time: ",t uprev.vector()[:]=y f.t = t #dolfin needs to know the current time for cos(t) uprime_solver.solve() return uprime_solution.vector().array()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def y(self, x):\n return x", "def y(self):\n pass", "def y(self) -> int:", "def _prepare_y(self,y):\n y_i = np.ones(y.shape, dtype=np.float64, order=\"C\")\n y_i[y != 1] = -1.0\n return y_i", "def _derY(self, x, y):\n raise NotImplementedError()", "def y(self):\...
[ "0.7393856", "0.69137716", "0.6871106", "0.6628756", "0.66229767", "0.6590499", "0.6571285", "0.64413816", "0.6343707", "0.6302943", "0.6266832", "0.6266832", "0.6266832", "0.6266832", "0.6266832", "0.6266832", "0.6266832", "0.6266832", "0.6266832", "0.6266832", "0.6257375", ...
0.0
-1
dy/dt = f(y,t) with y(0)=1 dy/dt = 2y > solution y(t) = c exp(2t)
def rhs(y,t): return math.cos(t)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ret_f(t,y):\n\n f = np.zeros(3)\n f[0] = 77.27*(y(1) - y(0)*y(1)+ y(0)-8.375e-6*y(0)*y(0))\n f[1] = (1.0/77.27)*(-y(1)-y(0)*y(1)+y(2))\n f[2] = 0.161*(y(0)-y(2))\n\n return f", "def dY_dt(self, y, t=0):\n\t\t \n\t\t#variables\n\t\tpSgg = y[0] / float(sum(y))\n\t\tpSgh = y[3] / float(sum(y))...
[ "0.69780666", "0.6871589", "0.6852503", "0.6789334", "0.6778427", "0.66323686", "0.6560891", "0.6533457", "0.65250427", "0.6490271", "0.64422923", "0.6435977", "0.64358383", "0.6398747", "0.6392627", "0.6340595", "0.63075", "0.62892526", "0.62366945", "0.62335855", "0.6227496...
0.0
-1
podmd Accepts a Bycon `byc` object a Bycon `h_o` handover object with its `target_values` representing `_id` objects of a `variants` collection The function creates a basic BED file and returns its local path. A standard use would be to create a link to this file and submit it as `hgt.customText` parameter to the UCSC ...
def _write_variants_bedfile(h_o, p_f, p_t, byc): local_paths = byc.get("local_paths") if not local_paths: return False tmp_path = Path( path.join( *local_paths[ "server_tmp_dir_loc" ]) ) if not tmp_path.is_dir(): return False v_ret = 0 v_max = 1000 if len( h_o["target_valu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_file(material_id):\n apr=get_doc_from_MP(material_id)\n mat_list=generate_matrix(apr)\n formu=POSCAR_title(apr)\n cell_for=generate_cell_formula(apr)\n needed_dos=generate_dos_str(material_id)\n revise_dos=dos_into_string(needed_dos)\n ordered_list=generate_ordered_list(revise_dos...
[ "0.523093", "0.51998866", "0.5158229", "0.5140045", "0.5118935", "0.50558704", "0.5029571", "0.49992138", "0.49688032", "0.48805413", "0.4840689", "0.48012224", "0.47752804", "0.47610596", "0.47577068", "0.47528267", "0.4687908", "0.46316627", "0.4619879", "0.46195143", "0.46...
0.5394805
0
The index of the edge key in an equilibrium structure.
def index_from_model(self, model, structure): try: return structure.edge_index[self.key] except TypeError: return tuple([structure.edge_index[k] for k in self.key])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key(self):\r\n\t\treturn ( hashE(self.edge),self.p1,self.p2);", "def node_index(self, key):\n return self._key_to_node_index[key]", "def edges_key(graph):\n return tuple(graph.edges())", "def get_index(self, key):\n return self.keys.index(key)", "def edge_index(indexed_triangle, ed...
[ "0.69453967", "0.6640415", "0.6603783", "0.6572264", "0.6566291", "0.65475166", "0.65134764", "0.65052545", "0.6482312", "0.64436454", "0.6403377", "0.63573134", "0.6352896", "0.6352896", "0.6338956", "0.63289213", "0.63231397", "0.62645197", "0.62625116", "0.6258962", "0.623...
0.6424732
10
r"""Compute the ctc loss with batched labels.
def ctc_loss(inputs, padding_mask=-1, **kwargs): args = ArgHelper.parse(locals()) inputs[0] = activation_ops.softmax(inputs[0], axis=2) op_lib = loss_ops_lib.Operator if context.executing_eagerly(): raise NotImplementedError else: return op_lib.blend('CTCLoss', **args)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ctc_loss(label_length, ctc_input_length, labels, probs):\n label_length = tf.cast(tf.squeeze(label_length), dtype=tf.int32)\n ctc_input_length = tf.cast(tf.squeeze(ctc_input_length), dtype=tf.int32)\n sparse_labels = tf.cast(tf.keras.backend.ctc_label_dense_to_sparse(labels, label_length), dtype=tf.in...
[ "0.6970509", "0.68200433", "0.6804985", "0.6726371", "0.6681177", "0.6646176", "0.6607578", "0.6524093", "0.64642483", "0.6374277", "0.61923236", "0.6092338", "0.6085526", "0.60759014", "0.60613245", "0.6043316", "0.6035013", "0.59991264", "0.5978405", "0.5954415", "0.5942769...
0.70889
0
r"""Compute the elementwise absolute value difference.
def l1_loss(inputs, reduction='mean', **kwargs): args = ArgHelper.parse(locals()) args['reduction'] = reduction.upper() op_lib = loss_ops_lib.L1Loss if context.executing_eagerly(): return op_lib \ .instantiate(reduction=args['reduction']) \ .apply(inputs) else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def abs(array):\n return np.abs(array)", "def absolute_value(x):\n x_star = x.clone()\n x_star[1] *= -1\n return elementwise_mult(x, x_star)[0].sqrt_()", "def abs_(a):", "def absolute_difference(x1: np.ndarray, x2: np.ndarray) -> float:\n assert isinstance(x1, np.ndarray) and isinstance(x2, np...
[ "0.69788164", "0.6964427", "0.6954321", "0.68909156", "0.68321335", "0.6825986", "0.67846584", "0.676503", "0.665343", "0.6612451", "0.66115755", "0.66112155", "0.6566696", "0.6485016", "0.64668524", "0.64620847", "0.6413898", "0.6408128", "0.64043254", "0.6324162", "0.630435...
0.0
-1
r"""Compute the elementwise squared error.
def l2_loss(inputs, reduction='mean', **kwargs): args = ArgHelper.parse(locals()) args['reduction'] = reduction.upper() op_lib = loss_ops_lib.L2Loss if context.executing_eagerly(): return op_lib \ .instantiate(reduction=args['reduction']) \ .apply(inputs) else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def squared_error(a, b):\n return (a - b)**2", "def rms_error(self, X, y) :\n ### ========== TODO : START ========== ###\n # part h: compute RMSE\n n, d = X.shape\n error = np.sqrt(self.cost(X,y)/n)\n ### ========== TODO : END ========== ###\n return error", "def Me...
[ "0.70697165", "0.6690482", "0.6645244", "0.6612147", "0.65794015", "0.65507746", "0.6526567", "0.6521677", "0.64709365", "0.6470684", "0.6470531", "0.6406789", "0.6403659", "0.63983536", "0.6370437", "0.6363914", "0.635806", "0.633491", "0.6334258", "0.6305452", "0.6280436", ...
0.0
-1
r"""Compute the negative likelihood loss with sparse labels.
def nll_loss( inputs, axis=1, ignore_index=None, reduction='valid', **kwargs ): args = ArgHelper.parse(locals()) args['reduction'] = reduction.upper() op_lib = loss_ops_lib.NLLLoss if context.executing_eagerly(): return op_lib \ .instantiate( axis...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sparse_nll_loss(probs, labels, epsilon=1e-9, scope=None):\n with tf.name_scope(scope, \"log_loss\"):\n labels = tf.one_hot(labels, tf.shape(probs)[1], axis=1)\n losses = - tf.reduce_sum(labels * tf.log(probs + epsilon), 1)\n return losses", "def sparse_nll_...
[ "0.7014988", "0.7014988", "0.7014988", "0.7014988", "0.69838434", "0.6676288", "0.65585726", "0.6471683", "0.6253885", "0.6216614", "0.6169275", "0.61666584", "0.6152545", "0.61438704", "0.61434895", "0.6123603", "0.6062964", "0.6035631", "0.6029464", "0.5992437", "0.5945079"...
0.0
-1
r"""Compute the sigmoid cross entropy with contiguous targets.
def sigmoid_cross_entropy(inputs, reduction='valid', **kwargs): args = ArgHelper.parse(locals()) args['reduction'] = reduction.upper() op_lib = loss_ops_lib.SigmoidCrossEntropy if context.executing_eagerly(): return op_lib \ .instantiate(reduction=args['reduction']) \ .ap...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_sigmoid_cross_entropy(self):\n loss_op = pointwise_losses.SigmoidCrossEntropy()\n\n y_pred = loss_op.final_activation_op({\n \"logits\": self.logits,\n \"metadata\": {\n \"mask\": self.mask\n }\n })\n assert np.isclose(y_pred[0][0...
[ "0.733087", "0.7251085", "0.70497286", "0.7024441", "0.68964267", "0.6850176", "0.6775583", "0.6740799", "0.6706655", "0.6696851", "0.66841483", "0.66245735", "0.6619512", "0.6565874", "0.65273166", "0.6526585", "0.6509253", "0.6495321", "0.6495321", "0.64779925", "0.6461931"...
0.6762066
7
r"""Compute the sigmoid focal loss with sparse labels.
def sigmoid_focal_loss( inputs, axis=1, alpha=0.25, gamma=2., negative_index=None, reduction='valid', **kwargs ): args = ArgHelper.parse(locals()) args['alpha'] = float(args['alpha']) args['gamma'] = float(args['gamma']) args['reduction'] = reduction.upper() op_lib = loss...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def focal_loss_sigmoid(labels, logits, alpha=0.5, gamma=2):\n\n prob = logits.sigmoid()\n labels = torch.nn.functional.one_hot(labels.squeeze().long(), num_classes=prob.shape[1])\n\n cross_ent = torch.clamp(logits, min=0) - logits * labels + torch.log(1+torch.exp(-torch.abs(logits)))\n prob_t = (la...
[ "0.7132021", "0.7093548", "0.66306", "0.6588871", "0.65455276", "0.6520407", "0.64797497", "0.6420658", "0.6377443", "0.63494956", "0.63168055", "0.62914336", "0.62914336", "0.6280836", "0.6270551", "0.6268474", "0.6265231", "0.6265231", "0.6265231", "0.6265231", "0.6265231",...
0.65818846
4
r"""Compute the elementwise error transited from L1 and L2.
def smooth_l1_loss(inputs, beta=1., reduction='mean', **kwargs): args = ArgHelper.parse(locals()) args['beta'] = float(args['beta']) args['reduction'] = reduction.upper() op_lib = loss_ops_lib.SmoothL1Loss if context.executing_eagerly(): return op_lib \ .instantiate( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_error(d1, d2):\n square_sum = 0.0\n for i in range(len(d1)):\n square_sum += pow( distributions_EMD(d1[i], d2[i]), 2)\n return math.sqrt(square_sum)", "def errorEMat(E1, E2):\n E1_normalized = E1 / E1[2][2];\n E2_normalized = E2 / E2[2][2];\n return torch.norm(E1_normalized...
[ "0.66480964", "0.6408133", "0.63674414", "0.6302799", "0.62619704", "0.62610716", "0.625721", "0.62301993", "0.61891586", "0.61241555", "0.6061378", "0.6036818", "0.60175693", "0.5936132", "0.58897555", "0.584485", "0.57753235", "0.57597107", "0.57388484", "0.5727462", "0.572...
0.0
-1
r"""Compute the softmax cross entropy with contiguous targets.
def softmax_cross_entropy(inputs, axis=1, reduction='mean', **kwargs): args = ArgHelper.parse(locals()) args['reduction'] = reduction.upper() op_lib = loss_ops_lib.SoftmaxCrossEntropy if context.executing_eagerly(): return op_lib \ .instantiate( axis=axis, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cross_entropy(input: Tensor, target: Tensor) -> Tensor:\n norm_log = log_softmax(input, 1)\n\n np_one_hot = np.eye(input.shape[1])[target.data]\n tensor_one_hot = tensor(np_one_hot, 'one-hot', False, True)\n\n mask = -norm_log * tensor_one_hot\n mask_sum = sum(mask, 1)\n loss = sum(mask_sum, ...
[ "0.7206213", "0.71602994", "0.71359116", "0.7133334", "0.7103154", "0.6957571", "0.6934931", "0.6868393", "0.6858417", "0.6841772", "0.6818581", "0.68184334", "0.67718226", "0.6725869", "0.67039573", "0.66911614", "0.668195", "0.665026", "0.6638869", "0.6636618", "0.65985984"...
0.67265826
13
r"""Compute the softmax cross entropy with sparse labels.
def sparse_softmax_cross_entropy( inputs, axis=1, ignore_index=None, reduction='valid', **kwargs ): args = ArgHelper.parse(locals()) args['reduction'] = reduction.upper() op_lib = loss_ops_lib.SparseSoftmaxCrossEntropy if context.executing_eagerly(): return op_lib \ ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sparse_cross_entropy(true, pred, axis=-1, epsilon=1e-7):\n true = ivy.one_hot(true, pred.shape[axis])\n return cross_entropy(true, pred, axis, epsilon)", "def sparse_cross_entropy_with_probs(probs, labels, name=None):\n with tf.name_scope(name, \"SparseSoftmaxCrossEntropyWithProb\", [probs, labels])...
[ "0.75729984", "0.7483392", "0.7342698", "0.7261253", "0.71876013", "0.71847457", "0.7153395", "0.708201", "0.70781726", "0.707635", "0.7052675", "0.7032999", "0.6964066", "0.69560903", "0.69532275", "0.6948643", "0.69474673", "0.6936967", "0.6919669", "0.6887562", "0.68827564...
0.75418687
1
Get a normalized path and create a directory if it doesn't exist
def get_path(dir_name, file_format, args): fname = "{exp}-excl-{excl}".format(exp=args.exp, excl=args.feature_set) path = os.path.join(SAVE_ROOT, dir_name, args.rbp, fname + file_format) # make the directory if it doesn't exist_ok os.makedi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_dir_if_needed(path):\n\n if not os.path.exists(path):\n os.makedirs(path)\n return path", "def fix_path(path):\n path = os.path.normpath(path)\n os.makedirs(path, exist_ok=True)\n return path", "def _normalize_path(path):\n if path is None:\n directory = BASE_PATH\n ...
[ "0.73886275", "0.7341739", "0.7287668", "0.7276798", "0.72392887", "0.72309655", "0.721909", "0.7198315", "0.71643466", "0.71285844", "0.7112931", "0.70983285", "0.70932275", "0.70858145", "0.70818454", "0.7024364", "0.7011929", "0.70076835", "0.70046", "0.69750345", "0.69701...
0.0
-1
Initialize the object for use.
def __init__(self): # regular expressions used for matching non-standard date formats # TODO: move to separate file self.regexes = { 'match': {}, 'substitution': {}, 'capture': {} } # years before 0 self.regexes['match']['suffix-b...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init(self):\n pass", "def init(self):\n pass", "def init(self):\n pass", "def init(self):\n pass", "def init(self):\n pass", "def init(self):\n pass", "def init(self):\n pass", "def init(self):\n pass", "def initialize(self):\n pass...
[ "0.8585764", "0.8585764", "0.8585764", "0.8585764", "0.8585764", "0.8585764", "0.8585764", "0.8585764", "0.84923893", "0.84923893", "0.84923893", "0.84923893", "0.84923893", "0.8478491", "0.8464105", "0.8458038", "0.8458038", "0.8438537", "0.8438537", "0.8438537", "0.8401424"...
0.0
-1
Returns a set of decades that covers all of the years and year ranges in the data. data can be a single string or a set of strings disjoint whether or not to exclude decades in the interim between the earliest and latest decades
def decades(self, data, disjoint=True): decade_set = set() try: # multi valued assert isinstance(data, set) for datum in data: preprocessed_year_data = self._extract_year_data(datum) decade_set = decade_set | self._enumerate_decades(pr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def years(self, data, disjoint=True):\n\n year_set = set()\n try:\n # multi valued\n assert isinstance(data, set)\n for datum in data:\n preprocessed_year_data = self._extract_year_data(datum)\n year_set = year_set | self._enumerate_years...
[ "0.6242524", "0.584959", "0.58418256", "0.5749594", "0.55666363", "0.55094856", "0.54740614", "0.54646933", "0.5412162", "0.5407114", "0.5374574", "0.53573066", "0.53103226", "0.5309206", "0.5307339", "0.5235848", "0.5222081", "0.5171749", "0.51681775", "0.5146663", "0.513659...
0.7365615
0
Returns a set of years that covers all of the years and year ranges in the data. data can be a single string or a set of strings disjoint whether or not to exclude years in the interim between the earliest and latest years
def years(self, data, disjoint=True): year_set = set() try: # multi valued assert isinstance(data, set) for datum in data: preprocessed_year_data = self._extract_year_data(datum) year_set = year_set | self._enumerate_years(preprocessed...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def t_range_years(t_range):\r\n start_year = int(t_range[0].split(\"-\")[0])\r\n end_year = int(t_range[1].split(\"-\")[0])\r\n end_month = int(t_range[1].split(\"-\")[1])\r\n end_day = int(t_range[1].split(\"-\")[2])\r\n if end_month == 1 and end_day == 1:\r\n year_range_list = np.arange(sta...
[ "0.6668446", "0.64742446", "0.6461352", "0.6017229", "0.60148984", "0.5969544", "0.593733", "0.59081143", "0.57882893", "0.5774196", "0.5734059", "0.56695604", "0.56593835", "0.56580514", "0.5633372", "0.5602902", "0.55264854", "0.55252516", "0.55181205", "0.5500564", "0.5471...
0.7573435
0
Maps a match of regexes['match']['date'] to a tuple of years, or a single year. m the re.match object
def _date_match_to_int_or_tuple(self, m): years = set() try: if m[0] != '': # yyyy-dd-mm years = int(m[0][0:4]) elif m[1] != '': # year-range derived from a century century = int(re.match(re.compile('\\d+'), m[1]).g...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _year_range(m):\n return (m.group(1), m.group(2))", "def _extract_year_data(self, date_string):\n\n try:\n # first see if dateutil can parse the date string\n # simplest case, a single year\n return {parse(date_string).year}\n\n except ValueError:\n ...
[ "0.7254186", "0.6608783", "0.6011262", "0.5957045", "0.59214723", "0.59050083", "0.5880262", "0.58387053", "0.5810087", "0.58070123", "0.57679784", "0.57420975", "0.57067704", "0.5700978", "0.56853163", "0.5677188", "0.56761444", "0.56604224", "0.56588614", "0.5644384", "0.56...
0.7606871
0
Return a set of decades. If disjoint is false, returns a set of decades that spans the entire range. preprocessed_data a heterogeneous set of ints and tuples of ints
def _enumerate_decades(self, preprocessed_data, disjoint): if disjoint: decades = set() for decade in preprocessed_data: if isinstance(decade, int): decades.add(decade // 10 * 10) elif isinstance(decade, tuple): dec...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decades(self, data, disjoint=True):\n\n decade_set = set()\n try:\n # multi valued\n assert isinstance(data, set)\n for datum in data:\n preprocessed_year_data = self._extract_year_data(datum)\n decade_set = decade_set | self._enumera...
[ "0.7483984", "0.51474196", "0.5103328", "0.5055087", "0.50201726", "0.50139266", "0.49108776", "0.48341992", "0.4811175", "0.4799761", "0.47267008", "0.46881026", "0.46321952", "0.4605094", "0.45930317", "0.45531568", "0.4522701", "0.45008975", "0.44996762", "0.44854528", "0....
0.7381708
1
Return a set of years. If disjoint is false, returns a set of years that spans the entire range. preprocessed_data a heterogeneous set of ints and tuples of ints
def _enumerate_years(self, preprocessed_data, disjoint): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def years(self, data, disjoint=True):\n\n year_set = set()\n try:\n # multi valued\n assert isinstance(data, set)\n for datum in data:\n preprocessed_year_data = self._extract_year_data(datum)\n year_set = year_set | self._enumerate_years...
[ "0.80802757", "0.6195092", "0.6097575", "0.6085509", "0.5956418", "0.57805914", "0.5775583", "0.57030433", "0.56905186", "0.55768806", "0.5571027", "0.55363435", "0.5514044", "0.54679793", "0.54667073", "0.54420847", "0.5440692", "0.54319644", "0.5420999", "0.5370453", "0.531...
0.7213386
1
Extracts the year(s) and/or year range(s) embedded in the date_string, and return a set of ints (year) and/or tuples of ints (year range, start/end). date_string the string containing the dirty date
def _extract_year_data(self, date_string): try: # first see if dateutil can parse the date string # simplest case, a single year return {parse(date_string).year} except ValueError: try: # strip alphabetical chars and spaces from the left ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def string_to_years(s):\n pattern = r'\\d\\d\\d\\d'\n r = re.compile(pattern)\n min_year = 1960\n max_year = datetime.now().year + 1\n return list(filter(lambda y: y >= min_year and y <= max_year, map(int, r.findall(s))))", "def _year_range(m):\n return (m.group(1), m.group(2))", "def parse_y...
[ "0.71493185", "0.7043156", "0.68464625", "0.67900616", "0.63941294", "0.62800896", "0.6208942", "0.6202308", "0.6173974", "0.60687256", "0.6009146", "0.5986021", "0.5980821", "0.59670657", "0.59482944", "0.5917469", "0.58205444", "0.57989943", "0.574035", "0.5707159", "0.5699...
0.8044839
0
i is a string that represents a year with a possibly missing ones value, like "199?" or "199?". Round down to the nearest decade.
def _resolve_unknown_ones(self, i): m = re.compile('(^\\d{4}$)').match(i) if m is not None: return int(m.group(1)) else: m = re.compile('(^\\d{1,3})[-*?]$').match(i) return i if m is None else int(m.group(1) + '0')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decade(year):\r\n # get the first 3 digits of the year\r\n partial = (year[0]//10).item()\r\n # add a 0 to the end, return as decade\r\n return partial * 10", "def translate_years(val):\n if val.find(\"-\") > 0:\n tokens = re.findall(\"[0-9]+\", val)\n one = int(tokens[0])\n ...
[ "0.6792026", "0.65144795", "0.64973646", "0.64911294", "0.63963395", "0.6301948", "0.6170404", "0.61197406", "0.6097923", "0.6078981", "0.6054153", "0.598611", "0.5985679", "0.5947528", "0.5931075", "0.5913055", "0.5898607", "0.5834762", "0.5772921", "0.5737773", "0.57252026"...
0.5021449
90