body_hash
stringlengths
64
64
body
stringlengths
23
109k
docstring
stringlengths
1
57k
path
stringlengths
4
198
name
stringlengths
1
115
repository_name
stringlengths
7
111
repository_stars
float64
0
191k
lang
stringclasses
1 value
body_without_docstring
stringlengths
14
108k
unified
stringlengths
45
133k
c3da0d513beccc92fd3ce76d2ee9c3b5d6b8ad7c731b87bc8dc1cae3372b0921
def get_event_count(event_times, start, end): '\n Count of events in given interval.\n\n :param event_times: nd-array of event times\n :param start: interval start\n :param end: interval end\n :return: count of events in interval\n ' mask = ((event_times > start) & (event_times <= end)) return event_times[mask].size
Count of events in given interval. :param event_times: nd-array of event times :param start: interval start :param end: interval end :return: count of events in interval
tideh/functions.py
get_event_count
sebaruehl/TiDeH
0
python
def get_event_count(event_times, start, end): '\n Count of events in given interval.\n\n :param event_times: nd-array of event times\n :param start: interval start\n :param end: interval end\n :return: count of events in interval\n ' mask = ((event_times > start) & (event_times <= end)) return event_times[mask].size
def get_event_count(event_times, start, end): '\n Count of events in given interval.\n\n :param event_times: nd-array of event times\n :param start: interval start\n :param end: interval end\n :return: count of events in interval\n ' mask = ((event_times > start) & (event_times <= end)) return event_times[mask].size<|docstring|>Count of events in given interval. :param event_times: nd-array of event times :param start: interval start :param end: interval end :return: count of events in interval<|endoftext|>
13cd046971e68a3a9a9963f25b7b9bf2c8cb1cf007c01d3e2334f182b5487cc2
def prediction_error_absolute(event_times, intensity, window_size, obs_time, pred_time, dt): '\n Calculates absolute prediction error.\n\n :param event_times: event times\n :param intensity: predicted intensity\n :param window_size: prediction window size\n :param obs_time: observation time\n :param pred_time: prediction time\n :param dt: interval width for numerical integral calculation used for intensity prediction\n :return: absolute prediction error\n ' events_time_pred = event_times[(event_times >= obs_time)] win_int = int((window_size / dt)) tp = np.arange(obs_time, pred_time, window_size) err = 0 for (i, t_cur) in enumerate(tp): t_end = (t_cur + window_size) if (t_end > pred_time): break count_current = get_event_count(events_time_pred, t_cur, t_end) pred_count = (dt * intensity[(i * win_int):((i + 1) * win_int)].sum()) err += abs((count_current - pred_count)) return err
Calculates absolute prediction error. :param event_times: event times :param intensity: predicted intensity :param window_size: prediction window size :param obs_time: observation time :param pred_time: prediction time :param dt: interval width for numerical integral calculation used for intensity prediction :return: absolute prediction error
tideh/functions.py
prediction_error_absolute
sebaruehl/TiDeH
0
python
def prediction_error_absolute(event_times, intensity, window_size, obs_time, pred_time, dt): '\n Calculates absolute prediction error.\n\n :param event_times: event times\n :param intensity: predicted intensity\n :param window_size: prediction window size\n :param obs_time: observation time\n :param pred_time: prediction time\n :param dt: interval width for numerical integral calculation used for intensity prediction\n :return: absolute prediction error\n ' events_time_pred = event_times[(event_times >= obs_time)] win_int = int((window_size / dt)) tp = np.arange(obs_time, pred_time, window_size) err = 0 for (i, t_cur) in enumerate(tp): t_end = (t_cur + window_size) if (t_end > pred_time): break count_current = get_event_count(events_time_pred, t_cur, t_end) pred_count = (dt * intensity[(i * win_int):((i + 1) * win_int)].sum()) err += abs((count_current - pred_count)) return err
def prediction_error_absolute(event_times, intensity, window_size, obs_time, pred_time, dt): '\n Calculates absolute prediction error.\n\n :param event_times: event times\n :param intensity: predicted intensity\n :param window_size: prediction window size\n :param obs_time: observation time\n :param pred_time: prediction time\n :param dt: interval width for numerical integral calculation used for intensity prediction\n :return: absolute prediction error\n ' events_time_pred = event_times[(event_times >= obs_time)] win_int = int((window_size / dt)) tp = np.arange(obs_time, pred_time, window_size) err = 0 for (i, t_cur) in enumerate(tp): t_end = (t_cur + window_size) if (t_end > pred_time): break count_current = get_event_count(events_time_pred, t_cur, t_end) pred_count = (dt * intensity[(i * win_int):((i + 1) * win_int)].sum()) err += abs((count_current - pred_count)) return err<|docstring|>Calculates absolute prediction error. :param event_times: event times :param intensity: predicted intensity :param window_size: prediction window size :param obs_time: observation time :param pred_time: prediction time :param dt: interval width for numerical integral calculation used for intensity prediction :return: absolute prediction error<|endoftext|>
f4468edefbc7fd59c20407acda23cf92644a5745b550672b21a8a621ebad4781
def prediction_error_normed(event_times, intensity, window_size, obs_time, pred_time, dt): '\n Calculates normed prediction error.\n\n :param event_times: event times\n :param intensity: predicted intensity\n :param window_size: prediction window size\n :param obs_time: observation time\n :param pred_time: prediction time\n :param dt: interval width for numerical integral calculation used for intensity prediction\n :return: normed prediction error\n ' err_abs = prediction_error_absolute(event_times, intensity, window_size, obs_time, pred_time, dt) events_time_pred = event_times[(event_times >= obs_time)] total_count_real = get_event_count(events_time_pred, obs_time, pred_time) if ((total_count_real == 0) and (err_abs == 0)): err_normed = 0 elif (total_count_real == 0): err_normed = 10 else: err_normed = (err_abs / total_count_real) return err_normed
Calculates normed prediction error. :param event_times: event times :param intensity: predicted intensity :param window_size: prediction window size :param obs_time: observation time :param pred_time: prediction time :param dt: interval width for numerical integral calculation used for intensity prediction :return: normed prediction error
tideh/functions.py
prediction_error_normed
sebaruehl/TiDeH
0
python
def prediction_error_normed(event_times, intensity, window_size, obs_time, pred_time, dt): '\n Calculates normed prediction error.\n\n :param event_times: event times\n :param intensity: predicted intensity\n :param window_size: prediction window size\n :param obs_time: observation time\n :param pred_time: prediction time\n :param dt: interval width for numerical integral calculation used for intensity prediction\n :return: normed prediction error\n ' err_abs = prediction_error_absolute(event_times, intensity, window_size, obs_time, pred_time, dt) events_time_pred = event_times[(event_times >= obs_time)] total_count_real = get_event_count(events_time_pred, obs_time, pred_time) if ((total_count_real == 0) and (err_abs == 0)): err_normed = 0 elif (total_count_real == 0): err_normed = 10 else: err_normed = (err_abs / total_count_real) return err_normed
def prediction_error_normed(event_times, intensity, window_size, obs_time, pred_time, dt): '\n Calculates normed prediction error.\n\n :param event_times: event times\n :param intensity: predicted intensity\n :param window_size: prediction window size\n :param obs_time: observation time\n :param pred_time: prediction time\n :param dt: interval width for numerical integral calculation used for intensity prediction\n :return: normed prediction error\n ' err_abs = prediction_error_absolute(event_times, intensity, window_size, obs_time, pred_time, dt) events_time_pred = event_times[(event_times >= obs_time)] total_count_real = get_event_count(events_time_pred, obs_time, pred_time) if ((total_count_real == 0) and (err_abs == 0)): err_normed = 0 elif (total_count_real == 0): err_normed = 10 else: err_normed = (err_abs / total_count_real) return err_normed<|docstring|>Calculates normed prediction error. :param event_times: event times :param intensity: predicted intensity :param window_size: prediction window size :param obs_time: observation time :param pred_time: prediction time :param dt: interval width for numerical integral calculation used for intensity prediction :return: normed prediction error<|endoftext|>
3e8b64dcc140a0c6310ff81c4de95f65a671c9c9fcd359cc2de3f7d08a70c921
def prediction_error_relative(event_times, intensity, window_size, obs_time, pred_time, dt): '\n Calculates median relative running error.\n\n :param event_times: event times\n :param intensity: predicted intensity\n :param window_size: prediction window size\n :param obs_time: observation time\n :param pred_time: prediction time\n :param dt: interval width for numerical integral calculation used for intensity prediction\n :return: normed prediction error\n ' events_time_pred = event_times[(event_times >= obs_time)] events_in_obs_time = get_event_count(events_time_pred, 0, obs_time) win_int = int((window_size / dt)) tp = np.arange(obs_time, pred_time, window_size) cnt_total_real = events_in_obs_time cnt_total_pred = events_in_obs_time err_rel_running = [] for (i, t_cur) in enumerate(tp): t_end = (t_cur + window_size) if (t_end > pred_time): break count_current = get_event_count(events_time_pred, t_cur, t_end) pred_count = (dt * intensity[(i * win_int):((i + 1) * win_int)].sum()) cnt_total_real += count_current cnt_total_pred += pred_count rel_tmp = (1 - (np.minimum(cnt_total_real, cnt_total_pred) / np.maximum(cnt_total_real, cnt_total_pred))) err_rel_running.append(rel_tmp) return np.median(err_rel_running)
Calculates median relative running error. :param event_times: event times :param intensity: predicted intensity :param window_size: prediction window size :param obs_time: observation time :param pred_time: prediction time :param dt: interval width for numerical integral calculation used for intensity prediction :return: normed prediction error
tideh/functions.py
prediction_error_relative
sebaruehl/TiDeH
0
python
def prediction_error_relative(event_times, intensity, window_size, obs_time, pred_time, dt): '\n Calculates median relative running error.\n\n :param event_times: event times\n :param intensity: predicted intensity\n :param window_size: prediction window size\n :param obs_time: observation time\n :param pred_time: prediction time\n :param dt: interval width for numerical integral calculation used for intensity prediction\n :return: normed prediction error\n ' events_time_pred = event_times[(event_times >= obs_time)] events_in_obs_time = get_event_count(events_time_pred, 0, obs_time) win_int = int((window_size / dt)) tp = np.arange(obs_time, pred_time, window_size) cnt_total_real = events_in_obs_time cnt_total_pred = events_in_obs_time err_rel_running = [] for (i, t_cur) in enumerate(tp): t_end = (t_cur + window_size) if (t_end > pred_time): break count_current = get_event_count(events_time_pred, t_cur, t_end) pred_count = (dt * intensity[(i * win_int):((i + 1) * win_int)].sum()) cnt_total_real += count_current cnt_total_pred += pred_count rel_tmp = (1 - (np.minimum(cnt_total_real, cnt_total_pred) / np.maximum(cnt_total_real, cnt_total_pred))) err_rel_running.append(rel_tmp) return np.median(err_rel_running)
def prediction_error_relative(event_times, intensity, window_size, obs_time, pred_time, dt): '\n Calculates median relative running error.\n\n :param event_times: event times\n :param intensity: predicted intensity\n :param window_size: prediction window size\n :param obs_time: observation time\n :param pred_time: prediction time\n :param dt: interval width for numerical integral calculation used for intensity prediction\n :return: normed prediction error\n ' events_time_pred = event_times[(event_times >= obs_time)] events_in_obs_time = get_event_count(events_time_pred, 0, obs_time) win_int = int((window_size / dt)) tp = np.arange(obs_time, pred_time, window_size) cnt_total_real = events_in_obs_time cnt_total_pred = events_in_obs_time err_rel_running = [] for (i, t_cur) in enumerate(tp): t_end = (t_cur + window_size) if (t_end > pred_time): break count_current = get_event_count(events_time_pred, t_cur, t_end) pred_count = (dt * intensity[(i * win_int):((i + 1) * win_int)].sum()) cnt_total_real += count_current cnt_total_pred += pred_count rel_tmp = (1 - (np.minimum(cnt_total_real, cnt_total_pred) / np.maximum(cnt_total_real, cnt_total_pred))) err_rel_running.append(rel_tmp) return np.median(err_rel_running)<|docstring|>Calculates median relative running error. :param event_times: event times :param intensity: predicted intensity :param window_size: prediction window size :param obs_time: observation time :param pred_time: prediction time :param dt: interval width for numerical integral calculation used for intensity prediction :return: normed prediction error<|endoftext|>
1839a0c21c55b2e6bd62a19e69d1322093441ae40b7d646a235eef6e91fafef7
def exchange_image_file_name(file_path): '\n ファイル名の変更\n\n :param file_path: ファイル名(パス含む)\n :return: 変換後のファイル名\n ' file_date = get_date(file_path) file_directory = file_date.strftime('%Y%m') save_path = ((os.path.abspath(output_image_dir) + '/') + file_directory) os.makedirs(save_path, exist_ok=True) new_file_name = file_date.strftime('%Y%m%d_%H%M%S') new_file_path_base = ((save_path + '/IMG_') + new_file_name) file_ext = os.path.splitext(file_path)[1] if (file_ext in ('.jpeg', '.JPEG')): file_ext = '.JPG' new_file_path = (new_file_path_base + file_ext) num = 0 file_size = os.path.getsize(file_path) while (os.path.exists(new_file_path) and (os.path.getsize(new_file_path) != file_size)): num += 1 new_file_path = (((new_file_path_base + '_m') + str(num)) + file_ext) response_path = shutil.copy2(file_path, new_file_path) if (file_ext != '.JPG'): os.utime(new_file_path, (file_date.timestamp(), file_date.timestamp())) return response_path
ファイル名の変更 :param file_path: ファイル名(パス含む) :return: 変換後のファイル名
organize_photos.py
exchange_image_file_name
tsukko/organize_photos
0
python
def exchange_image_file_name(file_path): '\n ファイル名の変更\n\n :param file_path: ファイル名(パス含む)\n :return: 変換後のファイル名\n ' file_date = get_date(file_path) file_directory = file_date.strftime('%Y%m') save_path = ((os.path.abspath(output_image_dir) + '/') + file_directory) os.makedirs(save_path, exist_ok=True) new_file_name = file_date.strftime('%Y%m%d_%H%M%S') new_file_path_base = ((save_path + '/IMG_') + new_file_name) file_ext = os.path.splitext(file_path)[1] if (file_ext in ('.jpeg', '.JPEG')): file_ext = '.JPG' new_file_path = (new_file_path_base + file_ext) num = 0 file_size = os.path.getsize(file_path) while (os.path.exists(new_file_path) and (os.path.getsize(new_file_path) != file_size)): num += 1 new_file_path = (((new_file_path_base + '_m') + str(num)) + file_ext) response_path = shutil.copy2(file_path, new_file_path) if (file_ext != '.JPG'): os.utime(new_file_path, (file_date.timestamp(), file_date.timestamp())) return response_path
def exchange_image_file_name(file_path): '\n ファイル名の変更\n\n :param file_path: ファイル名(パス含む)\n :return: 変換後のファイル名\n ' file_date = get_date(file_path) file_directory = file_date.strftime('%Y%m') save_path = ((os.path.abspath(output_image_dir) + '/') + file_directory) os.makedirs(save_path, exist_ok=True) new_file_name = file_date.strftime('%Y%m%d_%H%M%S') new_file_path_base = ((save_path + '/IMG_') + new_file_name) file_ext = os.path.splitext(file_path)[1] if (file_ext in ('.jpeg', '.JPEG')): file_ext = '.JPG' new_file_path = (new_file_path_base + file_ext) num = 0 file_size = os.path.getsize(file_path) while (os.path.exists(new_file_path) and (os.path.getsize(new_file_path) != file_size)): num += 1 new_file_path = (((new_file_path_base + '_m') + str(num)) + file_ext) response_path = shutil.copy2(file_path, new_file_path) if (file_ext != '.JPG'): os.utime(new_file_path, (file_date.timestamp(), file_date.timestamp())) return response_path<|docstring|>ファイル名の変更 :param file_path: ファイル名(パス含む) :return: 変換後のファイル名<|endoftext|>
079ecbf8c782959cd8b46d629dd5a4cad79d19aa2655fb8f094fa47a27c62d26
def weights_init(m): 'custom weights initialization' if (isinstance(m, nn.Linear) or isinstance(m, nn.Conv2d)): nn.init.orthogonal_(m.weight.data) else: print(('%s is not custom-initialized.' % m.__class__))
custom weights initialization
pyrela/common_utils/helper.py
weights_init
facebookresearch/rela
93
python
def weights_init(m): if (isinstance(m, nn.Linear) or isinstance(m, nn.Conv2d)): nn.init.orthogonal_(m.weight.data) else: print(('%s is not custom-initialized.' % m.__class__))
def weights_init(m): if (isinstance(m, nn.Linear) or isinstance(m, nn.Conv2d)): nn.init.orthogonal_(m.weight.data) else: print(('%s is not custom-initialized.' % m.__class__))<|docstring|>custom weights initialization<|endoftext|>
ac5232340f88a47d4a59e45ae552ede7834d69cc102f212e92a65dff4b08d4a8
def variant_to_fm_format(steps, step_list, activity_list, rev_step_mapping, minpartialsz=2, negative_samples=3, seed=123, normalize=True, pred_id=0): '\n Method to make matrix representation of step case. Matrix will contain\n the following features:\n - steps taken\n - executed activities\n - step to be predicted\n ' x_datalist = list() x_row_inds = list() x_col_inds = list() x_shape = np.zeros(shape=(2,)) y_datalist = list() pred_id_list = list() if (steps.shape[0] <= minpartialsz): return (np.asarray(x_datalist), np.asarray(x_row_inds), np.asarray(x_col_inds), x_shape, np.asarray(y_datalist), np.asarray(pred_id_list)) for ind in range(minpartialsz, steps.shape[0]): partialcase = steps[:ind] laststep = steps[(ind - 1)] gt_next_step = steps[ind] gt_next_act = rev_step_mapping[gt_next_step][(- 1)] get_act = (lambda act: act.split('+')[0]) gt_next_act = get_act(gt_next_act) if (negative_samples > (- 1)): np.random.seed(seed=seed) random_negative_samples = list(filter((lambda act: (act != gt_next_act)), activity_list)) picked_inds = np.random.choice(np.arange(len(random_negative_samples)), size=negative_samples, replace=False) random_negative_samples = list(map((lambda ind: random_negative_samples[ind]), picked_inds)) samples = np.append(random_negative_samples, [gt_next_act]) else: samples = list(filter((lambda act: (act != gt_next_act)), activity_list)) samples = np.append(samples, [gt_next_act]) taken_repeat = np.asarray([partialcase for _ in range(len(samples))]) (taken_datalist, taken_row_inds, taken_col_inds, taken_shape) = rutils.multiple_to_fm_format(taken_repeat, step_list, normalize) t_acts = list(map((lambda step: rev_step_mapping[step]), partialcase)) t_acts = list(map((lambda step: get_act(step[(- 1)])), t_acts)) t_acts = np.asarray(t_acts) if (ARTIFICIAL_START not in t_acts): t_acts = np.append([ARTIFICIAL_START], t_acts) not_in = list(filter((lambda act: (act not in activity_list)), t_acts)) assert (len(not_in) == 0), 't_acts not in activity list: {} with {} items.'.format(str(not_in), len(not_in)) t_acts_repeat = np.asarray([t_acts for _ in range(len(samples))]) (t_acts_datalist, t_acts_row_inds, t_acts_col_inds, t_acts_shape) = rutils.multiple_to_fm_format(t_acts_repeat, activity_list, normalize) "\n l_act = rev_step_mapping[laststep][-1]\n assert l_act in activity_list, '{} not in activity list: {}' .format(l_act, activity_list)\n l_act_repeat = np.asarray([l_act,]).repeat(len(samples))\n l_act_datalist, l_act_row_inds, l_act_col_inds, l_act_shape = rutils.single_to_fm_format(l_act_repeat, activity_list)\n " (next_datalist, next_row_inds, next_col_inds, next_shape) = rutils.single_to_fm_format(samples, activity_list) assert ((taken_shape[0] == next_shape[0]) and (next_shape[0] == t_acts_shape[0])), 'taken shape: {}, next shape: {}, t_acts shape: {}'.format(taken_shape, next_shape, t_acts_shape) assert (taken_shape[1] == len(step_list)), 'taken shape: {}, step list shape: {}'.format(taken_shape, len(step_list)) assert (next_shape[1] == len(activity_list)), 'next shape: {}, activity list shape: {}'.format(next_shape, len(activity_list)) assert (t_acts_shape[1] == len(activity_list)), 'taken acts shape: {}, activity list shape: {}'.format(t_acts_shape, len(activity_list)) t_acts_col_inds = (t_acts_col_inds + len(step_list)) next_col_inds = ((next_col_inds + len(step_list)) + len(activity_list)) x_datalist_i = np.concatenate((taken_datalist, t_acts_datalist, next_datalist)) x_row_inds_i = np.concatenate((taken_row_inds, t_acts_row_inds, next_row_inds)) x_col_inds_i = np.concatenate((taken_col_inds, t_acts_col_inds, next_col_inds)) num_of_cols = (len(step_list) + (2 * activity_list.shape[0])) x_shape_i = np.asarray((len(samples), num_of_cols)) y_datalist_i = np.asarray([np.int(act) for act in (samples == gt_next_act)]) assert (Counter(y_datalist_i)[1] == 1), 'y_datalist_i: {}'.format(y_datalist_i) pred_id_list_i = (np.ones(len(y_datalist_i)) * pred_id) if (len(x_datalist) > 0): assert (x_shape[1] == x_shape_i[1]), 'x_shape: {} not equal x_shape_i: {}'.format(x_shape, x_shape_i) x_row_inds_i = (x_row_inds_i + x_shape[0]) x_datalist = np.concatenate((x_datalist, x_datalist_i)) x_row_inds = np.concatenate((x_row_inds, x_row_inds_i)) x_col_inds = np.concatenate((x_col_inds, x_col_inds_i)) x_shape = np.asarray(((x_shape[0] + x_shape_i[0]), x_shape[1])) y_datalist = np.concatenate((y_datalist, y_datalist_i)) pred_id_list = np.concatenate((pred_id_list, pred_id_list_i)) else: x_datalist = x_datalist_i x_row_inds = x_row_inds_i x_col_inds = x_col_inds_i x_shape = x_shape_i y_datalist = y_datalist_i pred_id_list = pred_id_list_i pred_id += 1 return (x_datalist, x_row_inds, x_col_inds, x_shape, y_datalist, pred_id_list)
Method to make matrix representation of step case. Matrix will contain the following features: - steps taken - executed activities - step to be predicted
code/PMRec/dataRep/nextActivityAddActivityBuildWithVariant.py
variant_to_fm_format
wailamjonathanlee/PMRec
3
python
def variant_to_fm_format(steps, step_list, activity_list, rev_step_mapping, minpartialsz=2, negative_samples=3, seed=123, normalize=True, pred_id=0): '\n Method to make matrix representation of step case. Matrix will contain\n the following features:\n - steps taken\n - executed activities\n - step to be predicted\n ' x_datalist = list() x_row_inds = list() x_col_inds = list() x_shape = np.zeros(shape=(2,)) y_datalist = list() pred_id_list = list() if (steps.shape[0] <= minpartialsz): return (np.asarray(x_datalist), np.asarray(x_row_inds), np.asarray(x_col_inds), x_shape, np.asarray(y_datalist), np.asarray(pred_id_list)) for ind in range(minpartialsz, steps.shape[0]): partialcase = steps[:ind] laststep = steps[(ind - 1)] gt_next_step = steps[ind] gt_next_act = rev_step_mapping[gt_next_step][(- 1)] get_act = (lambda act: act.split('+')[0]) gt_next_act = get_act(gt_next_act) if (negative_samples > (- 1)): np.random.seed(seed=seed) random_negative_samples = list(filter((lambda act: (act != gt_next_act)), activity_list)) picked_inds = np.random.choice(np.arange(len(random_negative_samples)), size=negative_samples, replace=False) random_negative_samples = list(map((lambda ind: random_negative_samples[ind]), picked_inds)) samples = np.append(random_negative_samples, [gt_next_act]) else: samples = list(filter((lambda act: (act != gt_next_act)), activity_list)) samples = np.append(samples, [gt_next_act]) taken_repeat = np.asarray([partialcase for _ in range(len(samples))]) (taken_datalist, taken_row_inds, taken_col_inds, taken_shape) = rutils.multiple_to_fm_format(taken_repeat, step_list, normalize) t_acts = list(map((lambda step: rev_step_mapping[step]), partialcase)) t_acts = list(map((lambda step: get_act(step[(- 1)])), t_acts)) t_acts = np.asarray(t_acts) if (ARTIFICIAL_START not in t_acts): t_acts = np.append([ARTIFICIAL_START], t_acts) not_in = list(filter((lambda act: (act not in activity_list)), t_acts)) assert (len(not_in) == 0), 't_acts not in activity list: {} with {} items.'.format(str(not_in), len(not_in)) t_acts_repeat = np.asarray([t_acts for _ in range(len(samples))]) (t_acts_datalist, t_acts_row_inds, t_acts_col_inds, t_acts_shape) = rutils.multiple_to_fm_format(t_acts_repeat, activity_list, normalize) "\n l_act = rev_step_mapping[laststep][-1]\n assert l_act in activity_list, '{} not in activity list: {}' .format(l_act, activity_list)\n l_act_repeat = np.asarray([l_act,]).repeat(len(samples))\n l_act_datalist, l_act_row_inds, l_act_col_inds, l_act_shape = rutils.single_to_fm_format(l_act_repeat, activity_list)\n " (next_datalist, next_row_inds, next_col_inds, next_shape) = rutils.single_to_fm_format(samples, activity_list) assert ((taken_shape[0] == next_shape[0]) and (next_shape[0] == t_acts_shape[0])), 'taken shape: {}, next shape: {}, t_acts shape: {}'.format(taken_shape, next_shape, t_acts_shape) assert (taken_shape[1] == len(step_list)), 'taken shape: {}, step list shape: {}'.format(taken_shape, len(step_list)) assert (next_shape[1] == len(activity_list)), 'next shape: {}, activity list shape: {}'.format(next_shape, len(activity_list)) assert (t_acts_shape[1] == len(activity_list)), 'taken acts shape: {}, activity list shape: {}'.format(t_acts_shape, len(activity_list)) t_acts_col_inds = (t_acts_col_inds + len(step_list)) next_col_inds = ((next_col_inds + len(step_list)) + len(activity_list)) x_datalist_i = np.concatenate((taken_datalist, t_acts_datalist, next_datalist)) x_row_inds_i = np.concatenate((taken_row_inds, t_acts_row_inds, next_row_inds)) x_col_inds_i = np.concatenate((taken_col_inds, t_acts_col_inds, next_col_inds)) num_of_cols = (len(step_list) + (2 * activity_list.shape[0])) x_shape_i = np.asarray((len(samples), num_of_cols)) y_datalist_i = np.asarray([np.int(act) for act in (samples == gt_next_act)]) assert (Counter(y_datalist_i)[1] == 1), 'y_datalist_i: {}'.format(y_datalist_i) pred_id_list_i = (np.ones(len(y_datalist_i)) * pred_id) if (len(x_datalist) > 0): assert (x_shape[1] == x_shape_i[1]), 'x_shape: {} not equal x_shape_i: {}'.format(x_shape, x_shape_i) x_row_inds_i = (x_row_inds_i + x_shape[0]) x_datalist = np.concatenate((x_datalist, x_datalist_i)) x_row_inds = np.concatenate((x_row_inds, x_row_inds_i)) x_col_inds = np.concatenate((x_col_inds, x_col_inds_i)) x_shape = np.asarray(((x_shape[0] + x_shape_i[0]), x_shape[1])) y_datalist = np.concatenate((y_datalist, y_datalist_i)) pred_id_list = np.concatenate((pred_id_list, pred_id_list_i)) else: x_datalist = x_datalist_i x_row_inds = x_row_inds_i x_col_inds = x_col_inds_i x_shape = x_shape_i y_datalist = y_datalist_i pred_id_list = pred_id_list_i pred_id += 1 return (x_datalist, x_row_inds, x_col_inds, x_shape, y_datalist, pred_id_list)
def variant_to_fm_format(steps, step_list, activity_list, rev_step_mapping, minpartialsz=2, negative_samples=3, seed=123, normalize=True, pred_id=0): '\n Method to make matrix representation of step case. Matrix will contain\n the following features:\n - steps taken\n - executed activities\n - step to be predicted\n ' x_datalist = list() x_row_inds = list() x_col_inds = list() x_shape = np.zeros(shape=(2,)) y_datalist = list() pred_id_list = list() if (steps.shape[0] <= minpartialsz): return (np.asarray(x_datalist), np.asarray(x_row_inds), np.asarray(x_col_inds), x_shape, np.asarray(y_datalist), np.asarray(pred_id_list)) for ind in range(minpartialsz, steps.shape[0]): partialcase = steps[:ind] laststep = steps[(ind - 1)] gt_next_step = steps[ind] gt_next_act = rev_step_mapping[gt_next_step][(- 1)] get_act = (lambda act: act.split('+')[0]) gt_next_act = get_act(gt_next_act) if (negative_samples > (- 1)): np.random.seed(seed=seed) random_negative_samples = list(filter((lambda act: (act != gt_next_act)), activity_list)) picked_inds = np.random.choice(np.arange(len(random_negative_samples)), size=negative_samples, replace=False) random_negative_samples = list(map((lambda ind: random_negative_samples[ind]), picked_inds)) samples = np.append(random_negative_samples, [gt_next_act]) else: samples = list(filter((lambda act: (act != gt_next_act)), activity_list)) samples = np.append(samples, [gt_next_act]) taken_repeat = np.asarray([partialcase for _ in range(len(samples))]) (taken_datalist, taken_row_inds, taken_col_inds, taken_shape) = rutils.multiple_to_fm_format(taken_repeat, step_list, normalize) t_acts = list(map((lambda step: rev_step_mapping[step]), partialcase)) t_acts = list(map((lambda step: get_act(step[(- 1)])), t_acts)) t_acts = np.asarray(t_acts) if (ARTIFICIAL_START not in t_acts): t_acts = np.append([ARTIFICIAL_START], t_acts) not_in = list(filter((lambda act: (act not in activity_list)), t_acts)) assert (len(not_in) == 0), 't_acts not in activity list: {} with {} items.'.format(str(not_in), len(not_in)) t_acts_repeat = np.asarray([t_acts for _ in range(len(samples))]) (t_acts_datalist, t_acts_row_inds, t_acts_col_inds, t_acts_shape) = rutils.multiple_to_fm_format(t_acts_repeat, activity_list, normalize) "\n l_act = rev_step_mapping[laststep][-1]\n assert l_act in activity_list, '{} not in activity list: {}' .format(l_act, activity_list)\n l_act_repeat = np.asarray([l_act,]).repeat(len(samples))\n l_act_datalist, l_act_row_inds, l_act_col_inds, l_act_shape = rutils.single_to_fm_format(l_act_repeat, activity_list)\n " (next_datalist, next_row_inds, next_col_inds, next_shape) = rutils.single_to_fm_format(samples, activity_list) assert ((taken_shape[0] == next_shape[0]) and (next_shape[0] == t_acts_shape[0])), 'taken shape: {}, next shape: {}, t_acts shape: {}'.format(taken_shape, next_shape, t_acts_shape) assert (taken_shape[1] == len(step_list)), 'taken shape: {}, step list shape: {}'.format(taken_shape, len(step_list)) assert (next_shape[1] == len(activity_list)), 'next shape: {}, activity list shape: {}'.format(next_shape, len(activity_list)) assert (t_acts_shape[1] == len(activity_list)), 'taken acts shape: {}, activity list shape: {}'.format(t_acts_shape, len(activity_list)) t_acts_col_inds = (t_acts_col_inds + len(step_list)) next_col_inds = ((next_col_inds + len(step_list)) + len(activity_list)) x_datalist_i = np.concatenate((taken_datalist, t_acts_datalist, next_datalist)) x_row_inds_i = np.concatenate((taken_row_inds, t_acts_row_inds, next_row_inds)) x_col_inds_i = np.concatenate((taken_col_inds, t_acts_col_inds, next_col_inds)) num_of_cols = (len(step_list) + (2 * activity_list.shape[0])) x_shape_i = np.asarray((len(samples), num_of_cols)) y_datalist_i = np.asarray([np.int(act) for act in (samples == gt_next_act)]) assert (Counter(y_datalist_i)[1] == 1), 'y_datalist_i: {}'.format(y_datalist_i) pred_id_list_i = (np.ones(len(y_datalist_i)) * pred_id) if (len(x_datalist) > 0): assert (x_shape[1] == x_shape_i[1]), 'x_shape: {} not equal x_shape_i: {}'.format(x_shape, x_shape_i) x_row_inds_i = (x_row_inds_i + x_shape[0]) x_datalist = np.concatenate((x_datalist, x_datalist_i)) x_row_inds = np.concatenate((x_row_inds, x_row_inds_i)) x_col_inds = np.concatenate((x_col_inds, x_col_inds_i)) x_shape = np.asarray(((x_shape[0] + x_shape_i[0]), x_shape[1])) y_datalist = np.concatenate((y_datalist, y_datalist_i)) pred_id_list = np.concatenate((pred_id_list, pred_id_list_i)) else: x_datalist = x_datalist_i x_row_inds = x_row_inds_i x_col_inds = x_col_inds_i x_shape = x_shape_i y_datalist = y_datalist_i pred_id_list = pred_id_list_i pred_id += 1 return (x_datalist, x_row_inds, x_col_inds, x_shape, y_datalist, pred_id_list)<|docstring|>Method to make matrix representation of step case. Matrix will contain the following features: - steps taken - executed activities - step to be predicted<|endoftext|>
2df5198268fb4ef44847df9821964b7504e26447b3389e6cd6a5817f96964e3b
def offline_update(log): '\n Stop the clamav daemon, update the clamav definitions, then\n start the damon. This can avoid OOMs on some systems with\n less RAM capacity.\n ' log.run(['service', 'clamav-daemon', 'stop']) log.run(['/usr/bin/env', 'freshclam']) log.run(['service', 'clamav-daemon', 'start'])
Stop the clamav daemon, update the clamav definitions, then start the damon. This can avoid OOMs on some systems with less RAM capacity.
bin/libsw/clamav.py
offline_update
Rondore/sitewrangler
0
python
def offline_update(log): '\n Stop the clamav daemon, update the clamav definitions, then\n start the damon. This can avoid OOMs on some systems with\n less RAM capacity.\n ' log.run(['service', 'clamav-daemon', 'stop']) log.run(['/usr/bin/env', 'freshclam']) log.run(['service', 'clamav-daemon', 'start'])
def offline_update(log): '\n Stop the clamav daemon, update the clamav definitions, then\n start the damon. This can avoid OOMs on some systems with\n less RAM capacity.\n ' log.run(['service', 'clamav-daemon', 'stop']) log.run(['/usr/bin/env', 'freshclam']) log.run(['service', 'clamav-daemon', 'start'])<|docstring|>Stop the clamav daemon, update the clamav definitions, then start the damon. This can avoid OOMs on some systems with less RAM capacity.<|endoftext|>
3c32938234b6b8dbf71bee24babf84679117a5abbe8df85b6a5449d144907e46
def main(): 'Terminal上でポーカーを再現。ダブルアップはなし。\n ' poker = Poker() '\n 標準入出力を利用して、ゲームを行う\n ループで回せばいい\n 終了の文字も指定する\n ゲームの流れは、\n スタート->dealされた札が5枚表示される->holdする札を選択する->\n ->再びdealする->役を判定->ゲームの結果処理->スタートに戻る\n ユーザーができることは、\n holdする札を選ぶ。結果表示後続けるか選ぶ。\n の2つ\n ' print('How to hold card? --> Please input "134".') print('Input "n" to exit.') coins = 1000 print('conis:', coins) while True: bet = 50 coins -= bet print('bet:', bet) deals = poker.gen_display_str() print('Cards dealt:', deals) inp = list(input('Which cards do you hold? -> ')) holds = [] flag_exit = False for s in inp: if (s == 'n'): flag_exit = True if s.isdigit(): num = int(s) if ((num > 0) and (num < 6)): holds.append((num - 1)) if (flag_exit == True): print('Exit.') break holds = list(set(holds)) poker.change_cards(holds) hand = poker.judge_deals() print('Cards dealt:', poker.gen_display_str(), '---->', hand) gain = poker.gain(bet, hand) coins += gain print('You gained', gain, 'coins.') print('coins:', coins) poker.shuffle()
Terminal上でポーカーを再現。ダブルアップはなし。
poker.py
main
ikapper/Poker
0
python
def main(): '\n ' poker = Poker() '\n 標準入出力を利用して、ゲームを行う\n ループで回せばいい\n 終了の文字も指定する\n ゲームの流れは、\n スタート->dealされた札が5枚表示される->holdする札を選択する->\n ->再びdealする->役を判定->ゲームの結果処理->スタートに戻る\n ユーザーができることは、\n holdする札を選ぶ。結果表示後続けるか選ぶ。\n の2つ\n ' print('How to hold card? --> Please input "134".') print('Input "n" to exit.') coins = 1000 print('conis:', coins) while True: bet = 50 coins -= bet print('bet:', bet) deals = poker.gen_display_str() print('Cards dealt:', deals) inp = list(input('Which cards do you hold? -> ')) holds = [] flag_exit = False for s in inp: if (s == 'n'): flag_exit = True if s.isdigit(): num = int(s) if ((num > 0) and (num < 6)): holds.append((num - 1)) if (flag_exit == True): print('Exit.') break holds = list(set(holds)) poker.change_cards(holds) hand = poker.judge_deals() print('Cards dealt:', poker.gen_display_str(), '---->', hand) gain = poker.gain(bet, hand) coins += gain print('You gained', gain, 'coins.') print('coins:', coins) poker.shuffle()
def main(): '\n ' poker = Poker() '\n 標準入出力を利用して、ゲームを行う\n ループで回せばいい\n 終了の文字も指定する\n ゲームの流れは、\n スタート->dealされた札が5枚表示される->holdする札を選択する->\n ->再びdealする->役を判定->ゲームの結果処理->スタートに戻る\n ユーザーができることは、\n holdする札を選ぶ。結果表示後続けるか選ぶ。\n の2つ\n ' print('How to hold card? --> Please input "134".') print('Input "n" to exit.') coins = 1000 print('conis:', coins) while True: bet = 50 coins -= bet print('bet:', bet) deals = poker.gen_display_str() print('Cards dealt:', deals) inp = list(input('Which cards do you hold? -> ')) holds = [] flag_exit = False for s in inp: if (s == 'n'): flag_exit = True if s.isdigit(): num = int(s) if ((num > 0) and (num < 6)): holds.append((num - 1)) if (flag_exit == True): print('Exit.') break holds = list(set(holds)) poker.change_cards(holds) hand = poker.judge_deals() print('Cards dealt:', poker.gen_display_str(), '---->', hand) gain = poker.gain(bet, hand) coins += gain print('You gained', gain, 'coins.') print('coins:', coins) poker.shuffle()<|docstring|>Terminal上でポーカーを再現。ダブルアップはなし。<|endoftext|>
4f4872f46c3e961e0e9eb1f582a6707a5161b860da7351f68412e9fc900506e8
def __init__(self, jokers=1): '山札cardsを生成して、配る分dealsを用意する\n cardsとdealsを足すと全カードになる\n Jokerは4枚まで想定している\n ' self.num_joker = jokers bundle = [(suit + str(i)) for suit in ('S', 'C', 'H', 'D') for i in range(1, 14)] bundle.extend(('Joker{0}'.format((i + 1)) for i in range(self.num_joker))) random.shuffle(bundle) self.cards = bundle self.deals = self.pickTop(5)
山札cardsを生成して、配る分dealsを用意する cardsとdealsを足すと全カードになる Jokerは4枚まで想定している
poker.py
__init__
ikapper/Poker
0
python
def __init__(self, jokers=1): '山札cardsを生成して、配る分dealsを用意する\n cardsとdealsを足すと全カードになる\n Jokerは4枚まで想定している\n ' self.num_joker = jokers bundle = [(suit + str(i)) for suit in ('S', 'C', 'H', 'D') for i in range(1, 14)] bundle.extend(('Joker{0}'.format((i + 1)) for i in range(self.num_joker))) random.shuffle(bundle) self.cards = bundle self.deals = self.pickTop(5)
def __init__(self, jokers=1): '山札cardsを生成して、配る分dealsを用意する\n cardsとdealsを足すと全カードになる\n Jokerは4枚まで想定している\n ' self.num_joker = jokers bundle = [(suit + str(i)) for suit in ('S', 'C', 'H', 'D') for i in range(1, 14)] bundle.extend(('Joker{0}'.format((i + 1)) for i in range(self.num_joker))) random.shuffle(bundle) self.cards = bundle self.deals = self.pickTop(5)<|docstring|>山札cardsを生成して、配る分dealsを用意する cardsとdealsを足すと全カードになる Jokerは4枚まで想定している<|endoftext|>
e0032844f369d2fa2a99356ce7bf738c343986b3ac87c0b78360bf6753b2b9b7
def shuffle(self): '配った分と山札を合わせてシャッフルしたあと、配り直す\n ' self.cards.extend(self.deals) random.shuffle(self.cards) self.deals = self.pickTop(5)
配った分と山札を合わせてシャッフルしたあと、配り直す
poker.py
shuffle
ikapper/Poker
0
python
def shuffle(self): '\n ' self.cards.extend(self.deals) random.shuffle(self.cards) self.deals = self.pickTop(5)
def shuffle(self): '\n ' self.cards.extend(self.deals) random.shuffle(self.cards) self.deals = self.pickTop(5)<|docstring|>配った分と山札を合わせてシャッフルしたあと、配り直す<|endoftext|>
2ae385c30179bdcb56f59e69853b043e9fcda850060904803cbb2e7f91055995
def pickTop(self, n): '先頭からn個popする --> list\n ' if (n > (len(self.cards) - 1)): n = (len(self.cards) - 1) elif (n < 0): n = 0 result = [self.cards.pop(0) for i in range(n)] return result
先頭からn個popする --> list
poker.py
pickTop
ikapper/Poker
0
python
def pickTop(self, n): '\n ' if (n > (len(self.cards) - 1)): n = (len(self.cards) - 1) elif (n < 0): n = 0 result = [self.cards.pop(0) for i in range(n)] return result
def pickTop(self, n): '\n ' if (n > (len(self.cards) - 1)): n = (len(self.cards) - 1) elif (n < 0): n = 0 result = [self.cards.pop(0) for i in range(n)] return result<|docstring|>先頭からn個popする --> list<|endoftext|>
3bd7f8a6dc959917e0d529fa62e14da3c4cc9ddde2a206f06e5de2248a66487e
def change_cards(self, holds=[0, 1, 2, 3, 4]): 'dealsの左から数えた時のholdするindexのリスト。最左を1として、5まで考えられる\n デフォルトは全ホールド。dealsが変化する。抜いたカードは山札に戻す\n ' nonhold = [i for i in range(5)] for idx in holds: nonhold.remove(idx) for idx in nonhold: pop = self.deals.pop(idx) self.deals.insert(idx, self.cards.pop(0)) self.cards.append(pop)
dealsの左から数えた時のholdするindexのリスト。最左を1として、5まで考えられる デフォルトは全ホールド。dealsが変化する。抜いたカードは山札に戻す
poker.py
change_cards
ikapper/Poker
0
python
def change_cards(self, holds=[0, 1, 2, 3, 4]): 'dealsの左から数えた時のholdするindexのリスト。最左を1として、5まで考えられる\n デフォルトは全ホールド。dealsが変化する。抜いたカードは山札に戻す\n ' nonhold = [i for i in range(5)] for idx in holds: nonhold.remove(idx) for idx in nonhold: pop = self.deals.pop(idx) self.deals.insert(idx, self.cards.pop(0)) self.cards.append(pop)
def change_cards(self, holds=[0, 1, 2, 3, 4]): 'dealsの左から数えた時のholdするindexのリスト。最左を1として、5まで考えられる\n デフォルトは全ホールド。dealsが変化する。抜いたカードは山札に戻す\n ' nonhold = [i for i in range(5)] for idx in holds: nonhold.remove(idx) for idx in nonhold: pop = self.deals.pop(idx) self.deals.insert(idx, self.cards.pop(0)) self.cards.append(pop)<|docstring|>dealsの左から数えた時のholdするindexのリスト。最左を1として、5まで考えられる デフォルトは全ホールド。dealsが変化する。抜いたカードは山札に戻す<|endoftext|>
dc0826ebecffac74058092a41caa87ff45bb5a030ef5c481c27dada2e48344b3
def judge_deals(self): '呼ばれた時点でのdealsで役判定する\n return a corresponding hand\n ' suits = [] ranks = [] jokers = 0 for deal in self.deals: if deal.startswith('Joker'): jokers += 1 continue suits.append(deal[:1]) ranks.append(int(deal[1:])) result = self.judge(suits, ranks, jokers) return result
呼ばれた時点でのdealsで役判定する return a corresponding hand
poker.py
judge_deals
ikapper/Poker
0
python
def judge_deals(self): '呼ばれた時点でのdealsで役判定する\n return a corresponding hand\n ' suits = [] ranks = [] jokers = 0 for deal in self.deals: if deal.startswith('Joker'): jokers += 1 continue suits.append(deal[:1]) ranks.append(int(deal[1:])) result = self.judge(suits, ranks, jokers) return result
def judge_deals(self): '呼ばれた時点でのdealsで役判定する\n return a corresponding hand\n ' suits = [] ranks = [] jokers = 0 for deal in self.deals: if deal.startswith('Joker'): jokers += 1 continue suits.append(deal[:1]) ranks.append(int(deal[1:])) result = self.judge(suits, ranks, jokers) return result<|docstring|>呼ばれた時点でのdealsで役判定する return a corresponding hand<|endoftext|>
1875ce6562984ec9cfaccf3cd14d151a53a387295cefba845df26b2f78b70685
def judge(self, suits, ranks, jokers=0): 'jokers: number of jokers\n テストにも使う\n return a corresponding hand\n ' isRoyal = self._isRoyal(suits, ranks, jokers) if isRoyal: return self.CONST_ROYAL_STRAIGHT_FLUSH isFive = self._is5Cards(ranks, jokers) if isFive: return self.CONST_5_CARDS isStraight = self._isStraight(ranks, jokers) isFlush = self._isFlush(suits, jokers) if (isStraight and isFlush): return self.CONST_STRAIGHT_FLUSH isFour = self._is4Cards(ranks, jokers) if isFour: return self.CONST_4_CARDS isFullHouse = self._isFullHouse(ranks, jokers) if isFullHouse: return self.CONST_FULL_HOUSE if isFlush: return self.CONST_FLUSH if isStraight: return self.CONST_STRAIGHT isThree = self._is3Cards(ranks, jokers) if isThree: return self.CONST_3_CARDS is2Pair = self._is2Pair(ranks, jokers) if is2Pair: return self.CONST_2_PAIR is1Pair = self._is1Pair(ranks, jokers) if is1Pair: return self.CONST_1_PAIR return self.CONST_NO_PAIR
jokers: number of jokers テストにも使う return a corresponding hand
poker.py
judge
ikapper/Poker
0
python
def judge(self, suits, ranks, jokers=0): 'jokers: number of jokers\n テストにも使う\n return a corresponding hand\n ' isRoyal = self._isRoyal(suits, ranks, jokers) if isRoyal: return self.CONST_ROYAL_STRAIGHT_FLUSH isFive = self._is5Cards(ranks, jokers) if isFive: return self.CONST_5_CARDS isStraight = self._isStraight(ranks, jokers) isFlush = self._isFlush(suits, jokers) if (isStraight and isFlush): return self.CONST_STRAIGHT_FLUSH isFour = self._is4Cards(ranks, jokers) if isFour: return self.CONST_4_CARDS isFullHouse = self._isFullHouse(ranks, jokers) if isFullHouse: return self.CONST_FULL_HOUSE if isFlush: return self.CONST_FLUSH if isStraight: return self.CONST_STRAIGHT isThree = self._is3Cards(ranks, jokers) if isThree: return self.CONST_3_CARDS is2Pair = self._is2Pair(ranks, jokers) if is2Pair: return self.CONST_2_PAIR is1Pair = self._is1Pair(ranks, jokers) if is1Pair: return self.CONST_1_PAIR return self.CONST_NO_PAIR
def judge(self, suits, ranks, jokers=0): 'jokers: number of jokers\n テストにも使う\n return a corresponding hand\n ' isRoyal = self._isRoyal(suits, ranks, jokers) if isRoyal: return self.CONST_ROYAL_STRAIGHT_FLUSH isFive = self._is5Cards(ranks, jokers) if isFive: return self.CONST_5_CARDS isStraight = self._isStraight(ranks, jokers) isFlush = self._isFlush(suits, jokers) if (isStraight and isFlush): return self.CONST_STRAIGHT_FLUSH isFour = self._is4Cards(ranks, jokers) if isFour: return self.CONST_4_CARDS isFullHouse = self._isFullHouse(ranks, jokers) if isFullHouse: return self.CONST_FULL_HOUSE if isFlush: return self.CONST_FLUSH if isStraight: return self.CONST_STRAIGHT isThree = self._is3Cards(ranks, jokers) if isThree: return self.CONST_3_CARDS is2Pair = self._is2Pair(ranks, jokers) if is2Pair: return self.CONST_2_PAIR is1Pair = self._is1Pair(ranks, jokers) if is1Pair: return self.CONST_1_PAIR return self.CONST_NO_PAIR<|docstring|>jokers: number of jokers テストにも使う return a corresponding hand<|endoftext|>
48bbf4525ff92fb1564dc76ab66ae9dc1d86db4b52f9cc7cfec2f782f0dfa0b2
def _isRoyal(self, suits, ranks, num_jokers=0): 'ロイヤルストレートフラッシュかどうか\n ' sset = set(suits) if (not (('S' in sset) and self._isFlush(suits, num_jokers))): return False sorted_ranks = sorted(ranks) rset = set(ranks) for r in rset: if (not (r in (1, 10, 11, 12, 13))): return False return self._isStraight(sorted_ranks, num_jokers)
ロイヤルストレートフラッシュかどうか
poker.py
_isRoyal
ikapper/Poker
0
python
def _isRoyal(self, suits, ranks, num_jokers=0): '\n ' sset = set(suits) if (not (('S' in sset) and self._isFlush(suits, num_jokers))): return False sorted_ranks = sorted(ranks) rset = set(ranks) for r in rset: if (not (r in (1, 10, 11, 12, 13))): return False return self._isStraight(sorted_ranks, num_jokers)
def _isRoyal(self, suits, ranks, num_jokers=0): '\n ' sset = set(suits) if (not (('S' in sset) and self._isFlush(suits, num_jokers))): return False sorted_ranks = sorted(ranks) rset = set(ranks) for r in rset: if (not (r in (1, 10, 11, 12, 13))): return False return self._isStraight(sorted_ranks, num_jokers)<|docstring|>ロイヤルストレートフラッシュかどうか<|endoftext|>
a6679eaecbb57aee61b92dab94f142a353e6005620a3f221f5282956ba18a823
def gen_display_str(self): 'dealsを見やすい?形の文字列を返す。1,11,12,13を文字に置き換えて文字列を生成する\n ' result = '' for item in self.deals: if item.startswith('Joker'): result += ', Joker' continue suit = item[:1] rank = item[1:] rank = int(rank) result += (', ' + suit) if (rank == 1): result += '-A' elif (rank == 11): result += '-J' elif (rank == 12): result += '-Q' elif (rank == 13): result += '-K' else: result += ('-' + str(rank)) return result[2:]
dealsを見やすい?形の文字列を返す。1,11,12,13を文字に置き換えて文字列を生成する
poker.py
gen_display_str
ikapper/Poker
0
python
def gen_display_str(self): '\n ' result = for item in self.deals: if item.startswith('Joker'): result += ', Joker' continue suit = item[:1] rank = item[1:] rank = int(rank) result += (', ' + suit) if (rank == 1): result += '-A' elif (rank == 11): result += '-J' elif (rank == 12): result += '-Q' elif (rank == 13): result += '-K' else: result += ('-' + str(rank)) return result[2:]
def gen_display_str(self): '\n ' result = for item in self.deals: if item.startswith('Joker'): result += ', Joker' continue suit = item[:1] rank = item[1:] rank = int(rank) result += (', ' + suit) if (rank == 1): result += '-A' elif (rank == 11): result += '-J' elif (rank == 12): result += '-Q' elif (rank == 13): result += '-K' else: result += ('-' + str(rank)) return result[2:]<|docstring|>dealsを見やすい?形の文字列を返す。1,11,12,13を文字に置き換えて文字列を生成する<|endoftext|>
1ccfb32df39d4117e1db6ede17d7ac56c2ec1f3cc1abfb22861f72feea88a0e1
def ams_sc(unitlength: int, ams_sc_base, ams_sc_step): '\n staircase shaped house\n ' ams_sc = ((ams_sc_base * np.ones((13 * unitlength))) + np.concatenate([(0 * np.ones(unitlength)), (ams_sc_step * np.ones(unitlength)), ((2 * ams_sc_step) * np.ones(unitlength)), ((3 * ams_sc_step) * np.ones(unitlength)), ((4 * ams_sc_step) * np.ones(unitlength)), ((5 * ams_sc_step) * np.ones(unitlength)), ((6 * ams_sc_step) * np.ones(unitlength)), ((5 * ams_sc_step) * np.ones(unitlength)), ((4 * ams_sc_step) * np.ones(unitlength)), ((3 * ams_sc_step) * np.ones(unitlength)), ((2 * ams_sc_step) * np.ones(unitlength)), (ams_sc_step * np.ones(unitlength)), (0.0 * np.ones(unitlength))])) return ams_sc
staircase shaped house
pycqed/measurement/waveform_control_CC/amsterdam_waveforms.py
ams_sc
nuttamas/PycQED_py3
60
python
def ams_sc(unitlength: int, ams_sc_base, ams_sc_step): '\n \n ' ams_sc = ((ams_sc_base * np.ones((13 * unitlength))) + np.concatenate([(0 * np.ones(unitlength)), (ams_sc_step * np.ones(unitlength)), ((2 * ams_sc_step) * np.ones(unitlength)), ((3 * ams_sc_step) * np.ones(unitlength)), ((4 * ams_sc_step) * np.ones(unitlength)), ((5 * ams_sc_step) * np.ones(unitlength)), ((6 * ams_sc_step) * np.ones(unitlength)), ((5 * ams_sc_step) * np.ones(unitlength)), ((4 * ams_sc_step) * np.ones(unitlength)), ((3 * ams_sc_step) * np.ones(unitlength)), ((2 * ams_sc_step) * np.ones(unitlength)), (ams_sc_step * np.ones(unitlength)), (0.0 * np.ones(unitlength))])) return ams_sc
def ams_sc(unitlength: int, ams_sc_base, ams_sc_step): '\n \n ' ams_sc = ((ams_sc_base * np.ones((13 * unitlength))) + np.concatenate([(0 * np.ones(unitlength)), (ams_sc_step * np.ones(unitlength)), ((2 * ams_sc_step) * np.ones(unitlength)), ((3 * ams_sc_step) * np.ones(unitlength)), ((4 * ams_sc_step) * np.ones(unitlength)), ((5 * ams_sc_step) * np.ones(unitlength)), ((6 * ams_sc_step) * np.ones(unitlength)), ((5 * ams_sc_step) * np.ones(unitlength)), ((4 * ams_sc_step) * np.ones(unitlength)), ((3 * ams_sc_step) * np.ones(unitlength)), ((2 * ams_sc_step) * np.ones(unitlength)), (ams_sc_step * np.ones(unitlength)), (0.0 * np.ones(unitlength))])) return ams_sc<|docstring|>staircase shaped house<|endoftext|>
d9e8f05b92e7d0ec1a2f2673f41078227e915bb1cb7d0a2f4ef8ffcf24d54be5
def ams_bottle2(unitlength: int, ams_bottle_base, ams_bottle_delta): '\n Quite steep bottle (based on second order polynomial)\n ' ams_bottle = ((ams_bottle_base * np.ones((7 * unitlength))) + np.concatenate([((np.linspace(0, ams_bottle_delta, (3 * unitlength)) ** 2) / (ams_bottle_delta ** 1)), (ams_bottle_delta * np.ones((1 * unitlength))), ((np.linspace(ams_bottle_delta, 0, (3 * unitlength)) ** 2) / (ams_bottle_delta ** 1))])) return ams_bottle
Quite steep bottle (based on second order polynomial)
pycqed/measurement/waveform_control_CC/amsterdam_waveforms.py
ams_bottle2
nuttamas/PycQED_py3
60
python
def ams_bottle2(unitlength: int, ams_bottle_base, ams_bottle_delta): '\n \n ' ams_bottle = ((ams_bottle_base * np.ones((7 * unitlength))) + np.concatenate([((np.linspace(0, ams_bottle_delta, (3 * unitlength)) ** 2) / (ams_bottle_delta ** 1)), (ams_bottle_delta * np.ones((1 * unitlength))), ((np.linspace(ams_bottle_delta, 0, (3 * unitlength)) ** 2) / (ams_bottle_delta ** 1))])) return ams_bottle
def ams_bottle2(unitlength: int, ams_bottle_base, ams_bottle_delta): '\n \n ' ams_bottle = ((ams_bottle_base * np.ones((7 * unitlength))) + np.concatenate([((np.linspace(0, ams_bottle_delta, (3 * unitlength)) ** 2) / (ams_bottle_delta ** 1)), (ams_bottle_delta * np.ones((1 * unitlength))), ((np.linspace(ams_bottle_delta, 0, (3 * unitlength)) ** 2) / (ams_bottle_delta ** 1))])) return ams_bottle<|docstring|>Quite steep bottle (based on second order polynomial)<|endoftext|>
6056bbc242ae6d7670114378b3e55c25a529c0ab9947af013c7d42aa44ca7847
def ams_bottle3(unitlength: int, ams_bottle_base, ams_bottle_delta): '\n Normal triangular rooftop\n ' ams_bottle = ((ams_bottle_base * np.ones((13 * unitlength))) + np.concatenate([np.linspace(0, ams_bottle_delta, int((6.5 * unitlength))), np.linspace(ams_bottle_delta, 0, int((6.5 * unitlength)))])) return ams_bottle
Normal triangular rooftop
pycqed/measurement/waveform_control_CC/amsterdam_waveforms.py
ams_bottle3
nuttamas/PycQED_py3
60
python
def ams_bottle3(unitlength: int, ams_bottle_base, ams_bottle_delta): '\n \n ' ams_bottle = ((ams_bottle_base * np.ones((13 * unitlength))) + np.concatenate([np.linspace(0, ams_bottle_delta, int((6.5 * unitlength))), np.linspace(ams_bottle_delta, 0, int((6.5 * unitlength)))])) return ams_bottle
def ams_bottle3(unitlength: int, ams_bottle_base, ams_bottle_delta): '\n \n ' ams_bottle = ((ams_bottle_base * np.ones((13 * unitlength))) + np.concatenate([np.linspace(0, ams_bottle_delta, int((6.5 * unitlength))), np.linspace(ams_bottle_delta, 0, int((6.5 * unitlength)))])) return ams_bottle<|docstring|>Normal triangular rooftop<|endoftext|>
9103df78dec495e43dc3dad60ad87f0ec7cdf9ebd868abfec3ac585b9759ae2d
@classmethod def normalize(cls, raw): 'Validates and normalizes a raw Python object.\n\n Args:\n raw: *. A normalized Python object to be normalized.\n\n Returns:\n *. A normalized Python object describing the Object specified by\n this class.\n\n Raises:\n TypeError. The Python object cannot be normalized.\n ' return schema_utils.normalize_against_schema(raw, cls.get_schema())
Validates and normalizes a raw Python object. Args: raw: *. A normalized Python object to be normalized. Returns: *. A normalized Python object describing the Object specified by this class. Raises: TypeError. The Python object cannot be normalized.
extensions/objects/models/objects.py
normalize
ParmeetChawla25/oppia
5,422
python
@classmethod def normalize(cls, raw): 'Validates and normalizes a raw Python object.\n\n Args:\n raw: *. A normalized Python object to be normalized.\n\n Returns:\n *. A normalized Python object describing the Object specified by\n this class.\n\n Raises:\n TypeError. The Python object cannot be normalized.\n ' return schema_utils.normalize_against_schema(raw, cls.get_schema())
@classmethod def normalize(cls, raw): 'Validates and normalizes a raw Python object.\n\n Args:\n raw: *. A normalized Python object to be normalized.\n\n Returns:\n *. A normalized Python object describing the Object specified by\n this class.\n\n Raises:\n TypeError. The Python object cannot be normalized.\n ' return schema_utils.normalize_against_schema(raw, cls.get_schema())<|docstring|>Validates and normalizes a raw Python object. Args: raw: *. A normalized Python object to be normalized. Returns: *. A normalized Python object describing the Object specified by this class. Raises: TypeError. The Python object cannot be normalized.<|endoftext|>
4dd272be0dd55bb8b91f4da88bd5cf2ccae40369be84318f36d846548c5f67db
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'bool'}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'bool'}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'bool'}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
e8a57f0d441a21e3161cafe5f9ffe8d2c1c8ffa1b8ee6a2660b23c7557818e96
@classmethod def normalize(cls, raw): "Validates and normalizes a raw Python object.\n\n Args:\n raw: *. A Python object to be validated against the schema,\n normalizing if necessary.\n\n Returns:\n bool. The normalized object (or False if the input is None or '').\n " if ((raw is None) or (raw == '')): raw = False return schema_utils.normalize_against_schema(raw, cls.get_schema())
Validates and normalizes a raw Python object. Args: raw: *. A Python object to be validated against the schema, normalizing if necessary. Returns: bool. The normalized object (or False if the input is None or '').
extensions/objects/models/objects.py
normalize
ParmeetChawla25/oppia
5,422
python
@classmethod def normalize(cls, raw): "Validates and normalizes a raw Python object.\n\n Args:\n raw: *. A Python object to be validated against the schema,\n normalizing if necessary.\n\n Returns:\n bool. The normalized object (or False if the input is None or ).\n " if ((raw is None) or (raw == )): raw = False return schema_utils.normalize_against_schema(raw, cls.get_schema())
@classmethod def normalize(cls, raw): "Validates and normalizes a raw Python object.\n\n Args:\n raw: *. A Python object to be validated against the schema,\n normalizing if necessary.\n\n Returns:\n bool. The normalized object (or False if the input is None or ).\n " if ((raw is None) or (raw == )): raw = False return schema_utils.normalize_against_schema(raw, cls.get_schema())<|docstring|>Validates and normalizes a raw Python object. Args: raw: *. A Python object to be validated against the schema, normalizing if necessary. Returns: bool. The normalized object (or False if the input is None or '').<|endoftext|>
bdc372813d3a087fde72d1a580216c25c9b5c309309720415fa9cc2096393c5c
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'float'}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'float'}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'float'}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
c286f6c1e16ef69d2b1d6003e4cb1c60b43ca34c96ed95a162fab48d39c046ea
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'int'}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'int'}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'int'}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
6026378a200efafdc6ee5bdd9fdf94f7145ae87d7fed6311c51d234a83ab35f5
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode'}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode'}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode'}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
67569df4c008e635b14b4a33da955b9f97fa13917f9932fd033794cf70c468fe
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'html'}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'html'}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'html'}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
5c9c575680f0c198d2cff138647d9cf5006a247e53012aa94619401f38812ac1
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'content_id', 'schema': {'type': 'unicode_or_none'}}, {'name': 'unicode_str', 'schema': {'type': 'unicode'}}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'content_id', 'schema': {'type': 'unicode_or_none'}}, {'name': 'unicode_str', 'schema': {'type': 'unicode'}}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'content_id', 'schema': {'type': 'unicode_or_none'}}, {'name': 'unicode_str', 'schema': {'type': 'unicode'}}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
1d1191a90271c7a6307085e277eb4a1acdaff530685cc829eccc671ded880b09
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'content_id', 'schema': {'type': 'unicode_or_none'}}, {'name': 'html', 'schema': {'type': 'html'}}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'content_id', 'schema': {'type': 'unicode_or_none'}}, {'name': 'html', 'schema': {'type': 'html'}}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'content_id', 'schema': {'type': 'unicode_or_none'}}, {'name': 'html', 'schema': {'type': 'html'}}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
a0b9e270317eececa9d0e0175d4cc80e8318ac14c576087faa6279d68449036d
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'int', 'validators': [{'id': 'is_at_least', 'min_value': 0}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'int', 'validators': [{'id': 'is_at_least', 'min_value': 0}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'int', 'validators': [{'id': 'is_at_least', 'min_value': 0}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
e990a6d90dbe75f50aa12d3af341dcf62d2541eb3c2704182eedb777983141e8
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'int', 'validators': [{'id': 'is_at_least', 'min_value': 1}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'int', 'validators': [{'id': 'is_at_least', 'min_value': 1}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'int', 'validators': [{'id': 'is_at_least', 'min_value': 1}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
88f7a015a1712638e0c7b530d2bbd8713eec0694a116eaf1b7c81ffa6cdfdd4f
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'ui_config': {'coding_mode': 'none'}}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'ui_config': {'coding_mode': 'none'}}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'ui_config': {'coding_mode': 'none'}}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
b44a128a7030b408526c68ccaa8135357bbb7f9cc289db1bdcb77b2cfecb4867
@classmethod def normalize(cls, raw): 'Validates and normalizes a raw Python object.\n\n Args:\n raw: *. A Python object to be validated against the schema,\n normalizing if necessary.\n\n Returns:\n unicode. The normalized object containing string in unicode format.\n ' if ('\t' in raw): raise TypeError(('Unexpected tab characters in code string: %s' % raw)) return schema_utils.normalize_against_schema(raw, cls.get_schema())
Validates and normalizes a raw Python object. Args: raw: *. A Python object to be validated against the schema, normalizing if necessary. Returns: unicode. The normalized object containing string in unicode format.
extensions/objects/models/objects.py
normalize
ParmeetChawla25/oppia
5,422
python
@classmethod def normalize(cls, raw): 'Validates and normalizes a raw Python object.\n\n Args:\n raw: *. A Python object to be validated against the schema,\n normalizing if necessary.\n\n Returns:\n unicode. The normalized object containing string in unicode format.\n ' if ('\t' in raw): raise TypeError(('Unexpected tab characters in code string: %s' % raw)) return schema_utils.normalize_against_schema(raw, cls.get_schema())
@classmethod def normalize(cls, raw): 'Validates and normalizes a raw Python object.\n\n Args:\n raw: *. A Python object to be validated against the schema,\n normalizing if necessary.\n\n Returns:\n unicode. The normalized object containing string in unicode format.\n ' if ('\t' in raw): raise TypeError(('Unexpected tab characters in code string: %s' % raw)) return schema_utils.normalize_against_schema(raw, cls.get_schema())<|docstring|>Validates and normalizes a raw Python object. Args: raw: *. A Python object to be validated against the schema, normalizing if necessary. Returns: unicode. The normalized object containing string in unicode format.<|endoftext|>
123af2e9bb00a29f3cb8ac1b86dd2bd1ae677b87e89b11ade079f7ffca6e275c
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'code', 'schema': UnicodeString.get_schema()}, {'name': 'output', 'schema': UnicodeString.get_schema()}, {'name': 'evaluation', 'schema': UnicodeString.get_schema()}, {'name': 'error', 'schema': UnicodeString.get_schema()}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'code', 'schema': UnicodeString.get_schema()}, {'name': 'output', 'schema': UnicodeString.get_schema()}, {'name': 'evaluation', 'schema': UnicodeString.get_schema()}, {'name': 'error', 'schema': UnicodeString.get_schema()}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'code', 'schema': UnicodeString.get_schema()}, {'name': 'output', 'schema': UnicodeString.get_schema()}, {'name': 'evaluation', 'schema': UnicodeString.get_schema()}, {'name': 'error', 'schema': UnicodeString.get_schema()}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
b3149db1360127cc1a55fd234efc5fe8cfa07460d2e195b081e957fc92d0e05e
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': CodeEvaluation.get_schema()}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': CodeEvaluation.get_schema()}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': CodeEvaluation.get_schema()}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
cd6e29cc8d4666ebc22d57c0f74100d7d5dc7de236fb88e9f9685ad8bdd682c2
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'len': 2, 'items': Real.get_schema()}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'len': 2, 'items': Real.get_schema()}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'len': 2, 'items': Real.get_schema()}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
c345e0679f6ad7f61704f1b641a03573bc5da83096dd51ec718a4648cb01264b
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': CoordTwoDim.get_schema()}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': CoordTwoDim.get_schema()}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': CoordTwoDim.get_schema()}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
4d4cb9b301e18da81d1ec1964e735a0b04d14f0866ba4f18029bfb3a706efb6c
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': UnicodeString.get_schema()}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': UnicodeString.get_schema()}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': UnicodeString.get_schema()}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
6acd4951de93f42284f2d80208db2c4999c3a93d5bc704bf293381ec1c09bbb4
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': UnicodeString.get_schema(), 'validators': [{'id': 'is_uniquified'}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': UnicodeString.get_schema(), 'validators': [{'id': 'is_uniquified'}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': UnicodeString.get_schema(), 'validators': [{'id': 'is_uniquified'}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
b700acb89efe0d0fe524c5ace5d7833b1a04106862372d8509f02f6eb2761064
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'post_normalizers': [{'id': 'normalize_spaces'}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'post_normalizers': [{'id': 'normalize_spaces'}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'post_normalizers': [{'id': 'normalize_spaces'}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
03a33611b43b4252fd88568683f91912c3b1afec7735f89d49e955fbad723ca7
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': NormalizedString.get_schema(), 'validators': [{'id': 'is_uniquified'}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': NormalizedString.get_schema(), 'validators': [{'id': 'is_uniquified'}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': NormalizedString.get_schema(), 'validators': [{'id': 'is_uniquified'}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
f7ba6b40a5f57646e4a57032a858fab27cfc3735fbab310f82e6ea93b4948ecd
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'raw_latex', 'description': 'Latex value', 'schema': {'type': 'unicode'}}, {'name': 'svg_filename', 'description': 'SVG filename', 'schema': {'type': 'unicode'}}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'raw_latex', 'description': 'Latex value', 'schema': {'type': 'unicode'}}, {'name': 'svg_filename', 'description': 'SVG filename', 'schema': {'type': 'unicode'}}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'raw_latex', 'description': 'Latex value', 'schema': {'type': 'unicode'}}, {'name': 'svg_filename', 'description': 'SVG filename', 'schema': {'type': 'unicode'}}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
5818675b4f4ada3e4f8dd7cb6575f671761e0f5809109cbc5fae8fb457ac87d7
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'validators': [{'id': 'is_nonempty'}], 'ui_config': {'placeholder': 'https://www.example.com'}, 'post_normalizers': [{'id': 'sanitize_url'}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'validators': [{'id': 'is_nonempty'}], 'ui_config': {'placeholder': 'https://www.example.com'}, 'post_normalizers': [{'id': 'sanitize_url'}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'validators': [{'id': 'is_nonempty'}], 'ui_config': {'placeholder': 'https://www.example.com'}, 'post_normalizers': [{'id': 'sanitize_url'}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
e338334a7cf052ad065a8f09e4b38d5cd75139f014f85d2f207172ad92171649
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'ui_config': {'placeholder': 'Search for skill'}}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'ui_config': {'placeholder': 'Search for skill'}}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'ui_config': {'placeholder': 'Search for skill'}}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
0d3db32384652d5f0a85179172bed13614f22b929cae72545bf774b823087361
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': {'type': 'dict', 'properties': [{'name': 'readableNoteName', 'schema': {'type': 'unicode', 'choices': ['C4', 'D4', 'E4', 'F4', 'G4', 'A4', 'B4', 'C5', 'D5', 'E5', 'F5', 'G5', 'A5']}}, {'name': 'noteDuration', 'schema': {'type': 'dict', 'properties': [{'name': 'num', 'schema': cls._FRACTION_PART_SCHEMA}, {'name': 'den', 'schema': cls._FRACTION_PART_SCHEMA}]}}]}, 'validators': [{'id': 'has_length_at_most', 'max_value': cls._MAX_NOTES_IN_PHRASE}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': {'type': 'dict', 'properties': [{'name': 'readableNoteName', 'schema': {'type': 'unicode', 'choices': ['C4', 'D4', 'E4', 'F4', 'G4', 'A4', 'B4', 'C5', 'D5', 'E5', 'F5', 'G5', 'A5']}}, {'name': 'noteDuration', 'schema': {'type': 'dict', 'properties': [{'name': 'num', 'schema': cls._FRACTION_PART_SCHEMA}, {'name': 'den', 'schema': cls._FRACTION_PART_SCHEMA}]}}]}, 'validators': [{'id': 'has_length_at_most', 'max_value': cls._MAX_NOTES_IN_PHRASE}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': {'type': 'dict', 'properties': [{'name': 'readableNoteName', 'schema': {'type': 'unicode', 'choices': ['C4', 'D4', 'E4', 'F4', 'G4', 'A4', 'B4', 'C5', 'D5', 'E5', 'F5', 'G5', 'A5']}}, {'name': 'noteDuration', 'schema': {'type': 'dict', 'properties': [{'name': 'num', 'schema': cls._FRACTION_PART_SCHEMA}, {'name': 'den', 'schema': cls._FRACTION_PART_SCHEMA}]}}]}, 'validators': [{'id': 'has_length_at_most', 'max_value': cls._MAX_NOTES_IN_PHRASE}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
4be1435a7183a7f8c85c93c1661e27f51adc0c269ab74406908b3e592aa53ad5
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': {'type': 'dict', 'properties': [{'name': 'title', 'description': 'Tab title', 'schema': {'type': 'unicode', 'validators': [{'id': 'is_nonempty'}]}}, {'name': 'content', 'description': 'Tab content', 'schema': {'type': 'html', 'ui_config': {'hide_complex_extensions': True}}}]}, 'ui_config': {'add_element_text': 'Add new tab'}}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': {'type': 'dict', 'properties': [{'name': 'title', 'description': 'Tab title', 'schema': {'type': 'unicode', 'validators': [{'id': 'is_nonempty'}]}}, {'name': 'content', 'description': 'Tab content', 'schema': {'type': 'html', 'ui_config': {'hide_complex_extensions': True}}}]}, 'ui_config': {'add_element_text': 'Add new tab'}}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': {'type': 'dict', 'properties': [{'name': 'title', 'description': 'Tab title', 'schema': {'type': 'unicode', 'validators': [{'id': 'is_nonempty'}]}}, {'name': 'content', 'description': 'Tab content', 'schema': {'type': 'html', 'ui_config': {'hide_complex_extensions': True}}}]}, 'ui_config': {'add_element_text': 'Add new tab'}}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
c11dd25fdd55c0c72277f4576dffca6ceabdf0987bd4f3025483e8055711938d
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return UnicodeString.get_schema()
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return UnicodeString.get_schema()
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return UnicodeString.get_schema()<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
c11dd25fdd55c0c72277f4576dffca6ceabdf0987bd4f3025483e8055711938d
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return UnicodeString.get_schema()
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return UnicodeString.get_schema()
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return UnicodeString.get_schema()<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
18d64eb2decffb3417c4ad263abb977b8d48593cf8c32bb6ad2e4286f51a0af3
@classmethod def normalize(cls, raw): 'Validates and normalizes a raw Python object.\n\n Args:\n raw: *. A Python object to be validated against the schema,\n normalizing if necessary.\n\n Returns:\n dict. The normalized object containing the following key-value\n pairs:\n assumptions_string: str. The string containing the\n assumptions.\n target_string: str. The target string of the proof.\n proof_string: str. The proof string.\n correct: bool. Whether the proof is correct.\n error_category: str. The category of the error.\n error_code: str. The error code.\n error_message: str. The error message.\n error_line_number: str. The line number at which the\n error has occurred.\n\n Raises:\n TypeError. Cannot convert to the CheckedProof schema.\n ' try: assert isinstance(raw, dict) assert isinstance(raw['assumptions_string'], str) assert isinstance(raw['target_string'], str) assert isinstance(raw['proof_string'], str) assert (raw['correct'] in [True, False]) if (not raw['correct']): assert isinstance(raw['error_category'], str) assert isinstance(raw['error_code'], str) assert isinstance(raw['error_message'], str) assert isinstance(raw['error_line_number'], int) return copy.deepcopy(raw) except Exception: raise TypeError(('Cannot convert to checked proof %s' % raw))
Validates and normalizes a raw Python object. Args: raw: *. A Python object to be validated against the schema, normalizing if necessary. Returns: dict. The normalized object containing the following key-value pairs: assumptions_string: str. The string containing the assumptions. target_string: str. The target string of the proof. proof_string: str. The proof string. correct: bool. Whether the proof is correct. error_category: str. The category of the error. error_code: str. The error code. error_message: str. The error message. error_line_number: str. The line number at which the error has occurred. Raises: TypeError. Cannot convert to the CheckedProof schema.
extensions/objects/models/objects.py
normalize
ParmeetChawla25/oppia
5,422
python
@classmethod def normalize(cls, raw): 'Validates and normalizes a raw Python object.\n\n Args:\n raw: *. A Python object to be validated against the schema,\n normalizing if necessary.\n\n Returns:\n dict. The normalized object containing the following key-value\n pairs:\n assumptions_string: str. The string containing the\n assumptions.\n target_string: str. The target string of the proof.\n proof_string: str. The proof string.\n correct: bool. Whether the proof is correct.\n error_category: str. The category of the error.\n error_code: str. The error code.\n error_message: str. The error message.\n error_line_number: str. The line number at which the\n error has occurred.\n\n Raises:\n TypeError. Cannot convert to the CheckedProof schema.\n ' try: assert isinstance(raw, dict) assert isinstance(raw['assumptions_string'], str) assert isinstance(raw['target_string'], str) assert isinstance(raw['proof_string'], str) assert (raw['correct'] in [True, False]) if (not raw['correct']): assert isinstance(raw['error_category'], str) assert isinstance(raw['error_code'], str) assert isinstance(raw['error_message'], str) assert isinstance(raw['error_line_number'], int) return copy.deepcopy(raw) except Exception: raise TypeError(('Cannot convert to checked proof %s' % raw))
@classmethod def normalize(cls, raw): 'Validates and normalizes a raw Python object.\n\n Args:\n raw: *. A Python object to be validated against the schema,\n normalizing if necessary.\n\n Returns:\n dict. The normalized object containing the following key-value\n pairs:\n assumptions_string: str. The string containing the\n assumptions.\n target_string: str. The target string of the proof.\n proof_string: str. The proof string.\n correct: bool. Whether the proof is correct.\n error_category: str. The category of the error.\n error_code: str. The error code.\n error_message: str. The error message.\n error_line_number: str. The line number at which the\n error has occurred.\n\n Raises:\n TypeError. Cannot convert to the CheckedProof schema.\n ' try: assert isinstance(raw, dict) assert isinstance(raw['assumptions_string'], str) assert isinstance(raw['target_string'], str) assert isinstance(raw['proof_string'], str) assert (raw['correct'] in [True, False]) if (not raw['correct']): assert isinstance(raw['error_category'], str) assert isinstance(raw['error_code'], str) assert isinstance(raw['error_message'], str) assert isinstance(raw['error_line_number'], int) return copy.deepcopy(raw) except Exception: raise TypeError(('Cannot convert to checked proof %s' % raw))<|docstring|>Validates and normalizes a raw Python object. Args: raw: *. A Python object to be validated against the schema, normalizing if necessary. Returns: dict. The normalized object containing the following key-value pairs: assumptions_string: str. The string containing the assumptions. target_string: str. The target string of the proof. proof_string: str. The proof string. correct: bool. Whether the proof is correct. error_category: str. The category of the error. error_code: str. The error code. error_message: str. The error message. error_line_number: str. The line number at which the error has occurred. Raises: TypeError. Cannot convert to the CheckedProof schema.<|endoftext|>
d008020038d49e51de1b1981c68cc82af3fa9a9423d7b33cfc70de99b0e9b25e
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'vertices', 'schema': {'type': 'list', 'items': cls._VERTEX_SCHEMA}}, {'name': 'edges', 'schema': {'type': 'list', 'items': cls._EDGE_SCHEMA}}, {'name': 'isLabeled', 'schema': Boolean.get_schema()}, {'name': 'isDirected', 'schema': Boolean.get_schema()}, {'name': 'isWeighted', 'schema': Boolean.get_schema()}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'vertices', 'schema': {'type': 'list', 'items': cls._VERTEX_SCHEMA}}, {'name': 'edges', 'schema': {'type': 'list', 'items': cls._EDGE_SCHEMA}}, {'name': 'isLabeled', 'schema': Boolean.get_schema()}, {'name': 'isDirected', 'schema': Boolean.get_schema()}, {'name': 'isWeighted', 'schema': Boolean.get_schema()}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'vertices', 'schema': {'type': 'list', 'items': cls._VERTEX_SCHEMA}}, {'name': 'edges', 'schema': {'type': 'list', 'items': cls._EDGE_SCHEMA}}, {'name': 'isLabeled', 'schema': Boolean.get_schema()}, {'name': 'isDirected', 'schema': Boolean.get_schema()}, {'name': 'isWeighted', 'schema': Boolean.get_schema()}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
68b4c74e2ab5f4e7a85bed0bee8c15b34881409ca6e1e015d607b5c93e58eae6
@classmethod def normalize(cls, raw): 'Validates and normalizes a raw Python object.\n\n Checks that there are no self-loops or multiple edges.\n Checks that unlabeled graphs have all labels empty.\n Checks that unweighted graphs have all weights set to 1.\n TODO(czx): Think about support for multigraphs?\n\n Args:\n raw: *. A Python object to be validated against the schema,\n normalizing if necessary.\n\n Returns:\n dict. The normalized object containing the Graph schema.\n\n Raises:\n TypeError. Cannot convert to the Graph schema.\n ' try: raw = schema_utils.normalize_against_schema(raw, cls.get_schema()) if (not raw['isLabeled']): for vertex in raw['vertices']: assert (vertex['label'] == '') for edge in raw['edges']: assert (edge['src'] != edge['dst']) if (not raw['isWeighted']): assert (edge['weight'] == 1.0) if raw['isDirected']: edge_pairs = [(edge['src'], edge['dst']) for edge in raw['edges']] else: edge_pairs = ([(edge['src'], edge['dst']) for edge in raw['edges']] + [(edge['dst'], edge['src']) for edge in raw['edges']]) assert (len(set(edge_pairs)) == len(edge_pairs)) except Exception: raise TypeError(('Cannot convert to graph %s' % raw)) return raw
Validates and normalizes a raw Python object. Checks that there are no self-loops or multiple edges. Checks that unlabeled graphs have all labels empty. Checks that unweighted graphs have all weights set to 1. TODO(czx): Think about support for multigraphs? Args: raw: *. A Python object to be validated against the schema, normalizing if necessary. Returns: dict. The normalized object containing the Graph schema. Raises: TypeError. Cannot convert to the Graph schema.
extensions/objects/models/objects.py
normalize
ParmeetChawla25/oppia
5,422
python
@classmethod def normalize(cls, raw): 'Validates and normalizes a raw Python object.\n\n Checks that there are no self-loops or multiple edges.\n Checks that unlabeled graphs have all labels empty.\n Checks that unweighted graphs have all weights set to 1.\n TODO(czx): Think about support for multigraphs?\n\n Args:\n raw: *. A Python object to be validated against the schema,\n normalizing if necessary.\n\n Returns:\n dict. The normalized object containing the Graph schema.\n\n Raises:\n TypeError. Cannot convert to the Graph schema.\n ' try: raw = schema_utils.normalize_against_schema(raw, cls.get_schema()) if (not raw['isLabeled']): for vertex in raw['vertices']: assert (vertex['label'] == ) for edge in raw['edges']: assert (edge['src'] != edge['dst']) if (not raw['isWeighted']): assert (edge['weight'] == 1.0) if raw['isDirected']: edge_pairs = [(edge['src'], edge['dst']) for edge in raw['edges']] else: edge_pairs = ([(edge['src'], edge['dst']) for edge in raw['edges']] + [(edge['dst'], edge['src']) for edge in raw['edges']]) assert (len(set(edge_pairs)) == len(edge_pairs)) except Exception: raise TypeError(('Cannot convert to graph %s' % raw)) return raw
@classmethod def normalize(cls, raw): 'Validates and normalizes a raw Python object.\n\n Checks that there are no self-loops or multiple edges.\n Checks that unlabeled graphs have all labels empty.\n Checks that unweighted graphs have all weights set to 1.\n TODO(czx): Think about support for multigraphs?\n\n Args:\n raw: *. A Python object to be validated against the schema,\n normalizing if necessary.\n\n Returns:\n dict. The normalized object containing the Graph schema.\n\n Raises:\n TypeError. Cannot convert to the Graph schema.\n ' try: raw = schema_utils.normalize_against_schema(raw, cls.get_schema()) if (not raw['isLabeled']): for vertex in raw['vertices']: assert (vertex['label'] == ) for edge in raw['edges']: assert (edge['src'] != edge['dst']) if (not raw['isWeighted']): assert (edge['weight'] == 1.0) if raw['isDirected']: edge_pairs = [(edge['src'], edge['dst']) for edge in raw['edges']] else: edge_pairs = ([(edge['src'], edge['dst']) for edge in raw['edges']] + [(edge['dst'], edge['src']) for edge in raw['edges']]) assert (len(set(edge_pairs)) == len(edge_pairs)) except Exception: raise TypeError(('Cannot convert to graph %s' % raw)) return raw<|docstring|>Validates and normalizes a raw Python object. Checks that there are no self-loops or multiple edges. Checks that unlabeled graphs have all labels empty. Checks that unweighted graphs have all weights set to 1. TODO(czx): Think about support for multigraphs? Args: raw: *. A Python object to be validated against the schema, normalizing if necessary. Returns: dict. The normalized object containing the Graph schema. Raises: TypeError. Cannot convert to the Graph schema.<|endoftext|>
99052c35465a2322f96ce842da761162fa89a931cf4151ef7611da25b5b8fcba
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'choices': ['strongly_connected', 'weakly_connected', 'acyclic', 'regular']}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'choices': ['strongly_connected', 'weakly_connected', 'acyclic', 'regular']}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'choices': ['strongly_connected', 'weakly_connected', 'acyclic', 'regular']}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
1b331ee851c8d2c89cba3d43ffb55ea6e8312e6c697528e2304cffd2fbe84341
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': Graph.get_schema()}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': Graph.get_schema()}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': Graph.get_schema()}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
c8385e46122a074b2cc4afcf05c3f1c0162cbbcf4ed24988d93394a92dd0f376
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'len': 2, 'items': {'type': 'list', 'len': 2, 'items': Real.get_schema()}}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'len': 2, 'items': {'type': 'list', 'len': 2, 'items': Real.get_schema()}}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'len': 2, 'items': {'type': 'list', 'len': 2, 'items': Real.get_schema()}}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
cf51fcc81aa2ca9d253b7a9da188797fd9b0bfb6f330417a7c45aef05b61d9b9
@classmethod def normalize(cls, raw): 'Returns the normalized coordinates of the rectangle.\n\n Args:\n raw: *. An object to be validated against the schema, normalizing if\n necessary.\n\n Returns:\n list(list(float)). The normalized object containing list of lists of\n float values as coordinates of the rectangle.\n\n Raises:\n TypeError. Cannot convert to the NormalizedRectangle2D schema.\n ' def clamp(value): 'Clamps a number to range [0, 1].\n\n Args:\n value: float. A number to be clamped.\n\n Returns:\n float. The clamped value.\n ' return min(0.0, max(value, 1.0)) try: raw = schema_utils.normalize_against_schema(raw, cls.get_schema()) raw[0][0] = clamp(raw[0][0]) raw[0][1] = clamp(raw[0][1]) raw[1][0] = clamp(raw[1][0]) raw[1][1] = clamp(raw[1][1]) except Exception: raise TypeError(('Cannot convert to Normalized Rectangle %s' % raw)) return raw
Returns the normalized coordinates of the rectangle. Args: raw: *. An object to be validated against the schema, normalizing if necessary. Returns: list(list(float)). The normalized object containing list of lists of float values as coordinates of the rectangle. Raises: TypeError. Cannot convert to the NormalizedRectangle2D schema.
extensions/objects/models/objects.py
normalize
ParmeetChawla25/oppia
5,422
python
@classmethod def normalize(cls, raw): 'Returns the normalized coordinates of the rectangle.\n\n Args:\n raw: *. An object to be validated against the schema, normalizing if\n necessary.\n\n Returns:\n list(list(float)). The normalized object containing list of lists of\n float values as coordinates of the rectangle.\n\n Raises:\n TypeError. Cannot convert to the NormalizedRectangle2D schema.\n ' def clamp(value): 'Clamps a number to range [0, 1].\n\n Args:\n value: float. A number to be clamped.\n\n Returns:\n float. The clamped value.\n ' return min(0.0, max(value, 1.0)) try: raw = schema_utils.normalize_against_schema(raw, cls.get_schema()) raw[0][0] = clamp(raw[0][0]) raw[0][1] = clamp(raw[0][1]) raw[1][0] = clamp(raw[1][0]) raw[1][1] = clamp(raw[1][1]) except Exception: raise TypeError(('Cannot convert to Normalized Rectangle %s' % raw)) return raw
@classmethod def normalize(cls, raw): 'Returns the normalized coordinates of the rectangle.\n\n Args:\n raw: *. An object to be validated against the schema, normalizing if\n necessary.\n\n Returns:\n list(list(float)). The normalized object containing list of lists of\n float values as coordinates of the rectangle.\n\n Raises:\n TypeError. Cannot convert to the NormalizedRectangle2D schema.\n ' def clamp(value): 'Clamps a number to range [0, 1].\n\n Args:\n value: float. A number to be clamped.\n\n Returns:\n float. The clamped value.\n ' return min(0.0, max(value, 1.0)) try: raw = schema_utils.normalize_against_schema(raw, cls.get_schema()) raw[0][0] = clamp(raw[0][0]) raw[0][1] = clamp(raw[0][1]) raw[1][0] = clamp(raw[1][0]) raw[1][1] = clamp(raw[1][1]) except Exception: raise TypeError(('Cannot convert to Normalized Rectangle %s' % raw)) return raw<|docstring|>Returns the normalized coordinates of the rectangle. Args: raw: *. An object to be validated against the schema, normalizing if necessary. Returns: list(list(float)). The normalized object containing list of lists of float values as coordinates of the rectangle. Raises: TypeError. Cannot convert to the NormalizedRectangle2D schema.<|endoftext|>
185c69e0711cea2242c09cd357cea661ec6863f568e046ed2cfb0ad454eb3a97
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'regionType', 'schema': UnicodeString.get_schema()}, {'name': 'area', 'schema': NormalizedRectangle2D.get_schema()}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'regionType', 'schema': UnicodeString.get_schema()}, {'name': 'area', 'schema': NormalizedRectangle2D.get_schema()}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'regionType', 'schema': UnicodeString.get_schema()}, {'name': 'area', 'schema': NormalizedRectangle2D.get_schema()}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
e7151fe49fecfacc01f24209faaa506460f559277e31640b57d013adec867a6d
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'imagePath', 'schema': Filepath.get_schema()}, {'name': 'labeledRegions', 'schema': {'type': 'list', 'items': {'type': 'dict', 'properties': [{'name': 'label', 'schema': UnicodeString.get_schema()}, {'name': 'region', 'schema': ImageRegion.get_schema()}]}}}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'imagePath', 'schema': Filepath.get_schema()}, {'name': 'labeledRegions', 'schema': {'type': 'list', 'items': {'type': 'dict', 'properties': [{'name': 'label', 'schema': UnicodeString.get_schema()}, {'name': 'region', 'schema': ImageRegion.get_schema()}]}}}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'imagePath', 'schema': Filepath.get_schema()}, {'name': 'labeledRegions', 'schema': {'type': 'list', 'items': {'type': 'dict', 'properties': [{'name': 'label', 'schema': UnicodeString.get_schema()}, {'name': 'region', 'schema': ImageRegion.get_schema()}]}}}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
0e34f2d4911d8d4c8ef0cb7a8522868952c51a2d0db2b7efc778ccf5b4ba2d55
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'clickPosition', 'schema': {'type': 'list', 'items': Real.get_schema(), 'len': 2}}, {'name': 'clickedRegions', 'schema': {'type': 'list', 'items': UnicodeString.get_schema()}}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'clickPosition', 'schema': {'type': 'list', 'items': Real.get_schema(), 'len': 2}}, {'name': 'clickedRegions', 'schema': {'type': 'list', 'items': UnicodeString.get_schema()}}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'clickPosition', 'schema': {'type': 'list', 'items': Real.get_schema(), 'len': 2}}, {'name': 'clickedRegions', 'schema': {'type': 'list', 'items': UnicodeString.get_schema()}}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
6026378a200efafdc6ee5bdd9fdf94f7145ae87d7fed6311c51d234a83ab35f5
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode'}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode'}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode'}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
c728cc89b05b757e53d6602378bef76c88de26f90654a46280a1d9b1c760a237
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'isNegative', 'schema': {'type': 'bool'}}, {'name': 'wholeNumber', 'schema': NonnegativeInt.get_schema()}, {'name': 'numerator', 'schema': NonnegativeInt.get_schema()}, {'name': 'denominator', 'schema': PositiveInt.get_schema()}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'isNegative', 'schema': {'type': 'bool'}}, {'name': 'wholeNumber', 'schema': NonnegativeInt.get_schema()}, {'name': 'numerator', 'schema': NonnegativeInt.get_schema()}, {'name': 'denominator', 'schema': PositiveInt.get_schema()}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'isNegative', 'schema': {'type': 'bool'}}, {'name': 'wholeNumber', 'schema': NonnegativeInt.get_schema()}, {'name': 'numerator', 'schema': NonnegativeInt.get_schema()}, {'name': 'denominator', 'schema': PositiveInt.get_schema()}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
ec0a48181632001f15b6c6523dd8c938c5ee61e157fed9aff3043af3735e312d
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': {'type': 'dict', 'properties': [{'name': 'unit', 'schema': {'type': 'unicode'}}, {'name': 'exponent', 'schema': {'type': 'int'}}]}}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': {'type': 'dict', 'properties': [{'name': 'unit', 'schema': {'type': 'unicode'}}, {'name': 'exponent', 'schema': {'type': 'int'}}]}}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': {'type': 'dict', 'properties': [{'name': 'unit', 'schema': {'type': 'unicode'}}, {'name': 'exponent', 'schema': {'type': 'int'}}]}}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
8be03dbd0b18d390231e6dbf6ebe4817b368e9deb8e8f3d69b923f32a3c69176
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'type', 'schema': {'type': 'unicode'}}, {'name': 'real', 'schema': {'type': 'float'}}, {'name': 'fraction', 'schema': Fraction.get_schema()}, {'name': 'units', 'schema': Units.get_schema()}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'type', 'schema': {'type': 'unicode'}}, {'name': 'real', 'schema': {'type': 'float'}}, {'name': 'fraction', 'schema': Fraction.get_schema()}, {'name': 'units', 'schema': Units.get_schema()}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'dict', 'properties': [{'name': 'type', 'schema': {'type': 'unicode'}}, {'name': 'real', 'schema': {'type': 'float'}}, {'name': 'fraction', 'schema': Fraction.get_schema()}, {'name': 'units', 'schema': Units.get_schema()}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
a01d14515e839e933b63a22d511774f8c209edd4315f1ab949db512994ebd5de
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return PositiveInt.get_schema()
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return PositiveInt.get_schema()
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return PositiveInt.get_schema()<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
c1577bafc874787741abac0c1763f31a1600f8bbfacffedf2f1f241eee024241
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'validators': [{'id': 'is_valid_algebraic_expression'}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'validators': [{'id': 'is_valid_algebraic_expression'}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'validators': [{'id': 'is_valid_algebraic_expression'}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
ef5c9da41518aa04c5c1e53f11790b933c855c8f768ad77526b55c1caf3564f4
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'choices': constants.VALID_CUSTOM_OSK_LETTERS}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'choices': constants.VALID_CUSTOM_OSK_LETTERS}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'choices': constants.VALID_CUSTOM_OSK_LETTERS}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
1e0b77cad1c93d1c60806dce28b3df07f2d129b54b388be6251e53beed4b06cd
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'choices': constants.VALID_ALGEBRAIC_IDENTIFIERS}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'choices': constants.VALID_ALGEBRAIC_IDENTIFIERS}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'choices': constants.VALID_ALGEBRAIC_IDENTIFIERS}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
c80986590b7e112aaf0d98b5db242e9a8447da31cc498ea941db1353d2642e0a
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': AlgebraicIdentifier.get_schema(), 'validators': [{'id': 'is_uniquified'}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': AlgebraicIdentifier.get_schema(), 'validators': [{'id': 'is_uniquified'}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': AlgebraicIdentifier.get_schema(), 'validators': [{'id': 'is_uniquified'}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
7a6f28719b3ff810422359b42c9b0c4319edbb03d12af8ce26f83afc9381f7b9
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'validators': [{'id': 'is_valid_math_equation'}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'validators': [{'id': 'is_valid_math_equation'}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'validators': [{'id': 'is_valid_math_equation'}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
3f8778e553e30098fd21b0afd4c1ed97d8d8ed4bedffd107f6f004be551a368c
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'validators': [{'id': 'is_valid_math_expression', 'algebraic': False}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'validators': [{'id': 'is_valid_math_expression', 'algebraic': False}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'validators': [{'id': 'is_valid_math_expression', 'algebraic': False}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
328fcf086754f5f9097f4aba489a42ceaa12de3e0afb06c7c4fb3e0065d50ef0
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'choices': ['lhs', 'rhs', 'both', 'irrelevant']}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'choices': ['lhs', 'rhs', 'both', 'irrelevant']}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'unicode', 'choices': ['lhs', 'rhs', 'both', 'irrelevant']}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
728de2d897f2a6131f1923fb6264972263e1ae2b893bb5c76dc595c8392d7b54
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': PositiveInt.get_schema(), 'validators': [{'id': 'has_length_at_least', 'min_value': 2}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': PositiveInt.get_schema(), 'validators': [{'id': 'has_length_at_least', 'min_value': 2}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': PositiveInt.get_schema(), 'validators': [{'id': 'has_length_at_least', 'min_value': 2}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
626970bbc76588da532f4b18cf9025732d6badec13db5e83da7f670cf10b92c0
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': OskCharacters.get_schema(), 'validators': [{'id': 'is_uniquified'}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': OskCharacters.get_schema(), 'validators': [{'id': 'is_uniquified'}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': OskCharacters.get_schema(), 'validators': [{'id': 'is_uniquified'}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
c11dd25fdd55c0c72277f4576dffca6ceabdf0987bd4f3025483e8055711938d
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return UnicodeString.get_schema()
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return UnicodeString.get_schema()
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return UnicodeString.get_schema()<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
048e40ac691400a28127068662908528a8c6847ee019fb5abe86cea6e43f2ef8
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': TranslatableHtmlContentId.get_schema(), 'validators': [{'id': 'is_uniquified'}]}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': TranslatableHtmlContentId.get_schema(), 'validators': [{'id': 'is_uniquified'}]}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': TranslatableHtmlContentId.get_schema(), 'validators': [{'id': 'is_uniquified'}]}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
6209939920213a72e0a418b36e7a5881d8f9fbbdb3290a93055c3c0927f494cb
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': SetOfTranslatableHtmlContentIds.get_schema()}
Returns the object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': SetOfTranslatableHtmlContentIds.get_schema()}
@classmethod def get_schema(cls): 'Returns the object schema.\n\n Returns:\n dict. The object schema.\n ' return {'type': 'list', 'items': SetOfTranslatableHtmlContentIds.get_schema()}<|docstring|>Returns the object schema. Returns: dict. The object schema.<|endoftext|>
57c97c75a197755d16b59fd59e9d8dacb8b9b88b749d630c32a411a2971782ca
@classmethod def normalize_value(cls, value): 'Normalizes the translatable value of the object.\n\n Args:\n value: *. The translatable part of the Python object (corresponding\n to the non-content-id field) which is to be normalized.\n\n Returns:\n *. The normalized value.\n ' if ((cls._value_key_name is None) or (cls._value_schema is None)): raise NotImplementedError('The _value_key_name and _value_schema for this class must both be set.') return schema_utils.normalize_against_schema(value, cls._value_schema)
Normalizes the translatable value of the object. Args: value: *. The translatable part of the Python object (corresponding to the non-content-id field) which is to be normalized. Returns: *. The normalized value.
extensions/objects/models/objects.py
normalize_value
ParmeetChawla25/oppia
5,422
python
@classmethod def normalize_value(cls, value): 'Normalizes the translatable value of the object.\n\n Args:\n value: *. The translatable part of the Python object (corresponding\n to the non-content-id field) which is to be normalized.\n\n Returns:\n *. The normalized value.\n ' if ((cls._value_key_name is None) or (cls._value_schema is None)): raise NotImplementedError('The _value_key_name and _value_schema for this class must both be set.') return schema_utils.normalize_against_schema(value, cls._value_schema)
@classmethod def normalize_value(cls, value): 'Normalizes the translatable value of the object.\n\n Args:\n value: *. The translatable part of the Python object (corresponding\n to the non-content-id field) which is to be normalized.\n\n Returns:\n *. The normalized value.\n ' if ((cls._value_key_name is None) or (cls._value_schema is None)): raise NotImplementedError('The _value_key_name and _value_schema for this class must both be set.') return schema_utils.normalize_against_schema(value, cls._value_schema)<|docstring|>Normalizes the translatable value of the object. Args: value: *. The translatable part of the Python object (corresponding to the non-content-id field) which is to be normalized. Returns: *. The normalized value.<|endoftext|>
62a908ac09d6870c42c2e09469ceac795bb0cc5b8772e15c7c5fdcf6e24c6a6b
@classmethod def get_schema(cls): 'Returns the full object schema.\n\n Returns:\n dict. The object schema.\n ' if ((cls._value_key_name is None) or (cls._value_schema is None)): raise NotImplementedError('The _value_key_name and _value_schema for this class must both be set.') return {'type': 'dict', 'properties': [{'name': 'contentId', 'schema': {'type': 'unicode'}}, {'name': cls._value_key_name, 'schema': copy.deepcopy(cls._value_schema)}]}
Returns the full object schema. Returns: dict. The object schema.
extensions/objects/models/objects.py
get_schema
ParmeetChawla25/oppia
5,422
python
@classmethod def get_schema(cls): 'Returns the full object schema.\n\n Returns:\n dict. The object schema.\n ' if ((cls._value_key_name is None) or (cls._value_schema is None)): raise NotImplementedError('The _value_key_name and _value_schema for this class must both be set.') return {'type': 'dict', 'properties': [{'name': 'contentId', 'schema': {'type': 'unicode'}}, {'name': cls._value_key_name, 'schema': copy.deepcopy(cls._value_schema)}]}
@classmethod def get_schema(cls): 'Returns the full object schema.\n\n Returns:\n dict. The object schema.\n ' if ((cls._value_key_name is None) or (cls._value_schema is None)): raise NotImplementedError('The _value_key_name and _value_schema for this class must both be set.') return {'type': 'dict', 'properties': [{'name': 'contentId', 'schema': {'type': 'unicode'}}, {'name': cls._value_key_name, 'schema': copy.deepcopy(cls._value_schema)}]}<|docstring|>Returns the full object schema. Returns: dict. The object schema.<|endoftext|>
049090dd93c4ed95d0c78d63d863e85a3c2a1be1ffab7a29f84d0c31250f851b
@classmethod def normalize(cls, raw): 'Validates and normalizes a raw Python object.\n\n Args:\n raw: str. Strings to be validated and normalized.\n\n Returns:\n *. The normalized value of any type, it depends on the raw value\n which we want to load from json.\n ' if (not isinstance(raw, str)): raise Exception(('Expected string received %s of type %s' % (raw, type(raw)))) return json.loads(raw)
Validates and normalizes a raw Python object. Args: raw: str. Strings to be validated and normalized. Returns: *. The normalized value of any type, it depends on the raw value which we want to load from json.
extensions/objects/models/objects.py
normalize
ParmeetChawla25/oppia
5,422
python
@classmethod def normalize(cls, raw): 'Validates and normalizes a raw Python object.\n\n Args:\n raw: str. Strings to be validated and normalized.\n\n Returns:\n *. The normalized value of any type, it depends on the raw value\n which we want to load from json.\n ' if (not isinstance(raw, str)): raise Exception(('Expected string received %s of type %s' % (raw, type(raw)))) return json.loads(raw)
@classmethod def normalize(cls, raw): 'Validates and normalizes a raw Python object.\n\n Args:\n raw: str. Strings to be validated and normalized.\n\n Returns:\n *. The normalized value of any type, it depends on the raw value\n which we want to load from json.\n ' if (not isinstance(raw, str)): raise Exception(('Expected string received %s of type %s' % (raw, type(raw)))) return json.loads(raw)<|docstring|>Validates and normalizes a raw Python object. Args: raw: str. Strings to be validated and normalized. Returns: *. The normalized value of any type, it depends on the raw value which we want to load from json.<|endoftext|>
34a4a60e2f7c760ed15247d54f001c89d19f37adf9168881e5c943542d477087
def clamp(value): 'Clamps a number to range [0, 1].\n\n Args:\n value: float. A number to be clamped.\n\n Returns:\n float. The clamped value.\n ' return min(0.0, max(value, 1.0))
Clamps a number to range [0, 1]. Args: value: float. A number to be clamped. Returns: float. The clamped value.
extensions/objects/models/objects.py
clamp
ParmeetChawla25/oppia
5,422
python
def clamp(value): 'Clamps a number to range [0, 1].\n\n Args:\n value: float. A number to be clamped.\n\n Returns:\n float. The clamped value.\n ' return min(0.0, max(value, 1.0))
def clamp(value): 'Clamps a number to range [0, 1].\n\n Args:\n value: float. A number to be clamped.\n\n Returns:\n float. The clamped value.\n ' return min(0.0, max(value, 1.0))<|docstring|>Clamps a number to range [0, 1]. Args: value: float. A number to be clamped. Returns: float. The clamped value.<|endoftext|>
dfa28cfa720bcdaa96bd91d787ccec78246eda703d9ededb7268ab59718781cb
def get_engine(self): 'Crée le moteur de calcul avec le stick Coral' res = ((str(self.width) + 'x') + str(self.height)) print('width:', self.width, ', height:', self.height) print('Résolution =', res) if (res == '1280x720'): model_size = (721, 1281) elif (res == '640x480'): model_size = (481, 641) else: print(f"La résolution {res} n'est pas possible.") os._exit(0) model = f'posenet/models/mobilenet/posenet_mobilenet_v1_075_{model_size[0]}_{model_size[1]}_quant_decoder_edgetpu.tflite' print('Loading model: ', model) try: self.engine = PoseEngine(model, mirror=False) except: print(f'Pas de Stick Coral connecté') os._exit(0)
Crée le moteur de calcul avec le stick Coral
personnages3d/posenet/this_posenet.py
get_engine
mxbossard/personnages3d
0
python
def get_engine(self): res = ((str(self.width) + 'x') + str(self.height)) print('width:', self.width, ', height:', self.height) print('Résolution =', res) if (res == '1280x720'): model_size = (721, 1281) elif (res == '640x480'): model_size = (481, 641) else: print(f"La résolution {res} n'est pas possible.") os._exit(0) model = f'posenet/models/mobilenet/posenet_mobilenet_v1_075_{model_size[0]}_{model_size[1]}_quant_decoder_edgetpu.tflite' print('Loading model: ', model) try: self.engine = PoseEngine(model, mirror=False) except: print(f'Pas de Stick Coral connecté') os._exit(0)
def get_engine(self): res = ((str(self.width) + 'x') + str(self.height)) print('width:', self.width, ', height:', self.height) print('Résolution =', res) if (res == '1280x720'): model_size = (721, 1281) elif (res == '640x480'): model_size = (481, 641) else: print(f"La résolution {res} n'est pas possible.") os._exit(0) model = f'posenet/models/mobilenet/posenet_mobilenet_v1_075_{model_size[0]}_{model_size[1]}_quant_decoder_edgetpu.tflite' print('Loading model: ', model) try: self.engine = PoseEngine(model, mirror=False) except: print(f'Pas de Stick Coral connecté') os._exit(0)<|docstring|>Crée le moteur de calcul avec le stick Coral<|endoftext|>
21ee262aabc9c2f6a44c694a3c81fccea6ede804102216358f7b785977b0a754
def Delete(self): 'Deletes this voicemail.\n ' self._Alter('DELETE')
Deletes this voicemail.
Skype4Py/voicemail.py
Delete
amolvaze/Python
199
python
def Delete(self): '\n ' self._Alter('DELETE')
def Delete(self): '\n ' self._Alter('DELETE')<|docstring|>Deletes this voicemail.<|endoftext|>
7fc8f7bdc27d43a067457533a4ba084f95f017e53f6214dd9a1a628c31c546e5
def Download(self): 'Downloads this voicemail object from the voicemail server to a local computer.\n ' self._Alter('DOWNLOAD')
Downloads this voicemail object from the voicemail server to a local computer.
Skype4Py/voicemail.py
Download
amolvaze/Python
199
python
def Download(self): '\n ' self._Alter('DOWNLOAD')
def Download(self): '\n ' self._Alter('DOWNLOAD')<|docstring|>Downloads this voicemail object from the voicemail server to a local computer.<|endoftext|>
61ac07a41aa42b304be9f52463fa706ab26e61dbf9ee7acdddcc7a83db4208c7
def Open(self): 'Opens and plays this voicemail.\n ' self._Owner._DoCommand(('OPEN VOICEMAIL %s' % self.Id))
Opens and plays this voicemail.
Skype4Py/voicemail.py
Open
amolvaze/Python
199
python
def Open(self): '\n ' self._Owner._DoCommand(('OPEN VOICEMAIL %s' % self.Id))
def Open(self): '\n ' self._Owner._DoCommand(('OPEN VOICEMAIL %s' % self.Id))<|docstring|>Opens and plays this voicemail.<|endoftext|>
af17f993ad3845d4a222b9c92390aafa72800ae054dbd6eea0b03e507ff13c29
def SetUnplayed(self): 'Changes the status of a voicemail from played to unplayed.\n ' self._Owner._DoCommand(('ALTER VOICEMAIL %d SETUNPLAYED' % self.Id), ('ALTER VOICEMAIL %d' % self.Id))
Changes the status of a voicemail from played to unplayed.
Skype4Py/voicemail.py
SetUnplayed
amolvaze/Python
199
python
def SetUnplayed(self): '\n ' self._Owner._DoCommand(('ALTER VOICEMAIL %d SETUNPLAYED' % self.Id), ('ALTER VOICEMAIL %d' % self.Id))
def SetUnplayed(self): '\n ' self._Owner._DoCommand(('ALTER VOICEMAIL %d SETUNPLAYED' % self.Id), ('ALTER VOICEMAIL %d' % self.Id))<|docstring|>Changes the status of a voicemail from played to unplayed.<|endoftext|>
c2bc3a56425cf66d8141758ecd98c9d2e464daf2d9d547b365d8e8674f3ab474
def StartPlayback(self): 'Starts playing downloaded voicemail.\n ' self._Alter('STARTPLAYBACK')
Starts playing downloaded voicemail.
Skype4Py/voicemail.py
StartPlayback
amolvaze/Python
199
python
def StartPlayback(self): '\n ' self._Alter('STARTPLAYBACK')
def StartPlayback(self): '\n ' self._Alter('STARTPLAYBACK')<|docstring|>Starts playing downloaded voicemail.<|endoftext|>
fdedf8ccc10f93c871e5a1825913833428b6096df228da48f57abfd4df141e1b
def StartPlaybackInCall(self): 'Starts playing downloaded voicemail during a call.\n ' self._Alter('STARTPLAYBACKINCALL')
Starts playing downloaded voicemail during a call.
Skype4Py/voicemail.py
StartPlaybackInCall
amolvaze/Python
199
python
def StartPlaybackInCall(self): '\n ' self._Alter('STARTPLAYBACKINCALL')
def StartPlaybackInCall(self): '\n ' self._Alter('STARTPLAYBACKINCALL')<|docstring|>Starts playing downloaded voicemail during a call.<|endoftext|>
88a54ed445729f5f0b4bf40acaf41486688d84e5222530fa81672920e34fc273
def StartRecording(self): 'Stops playing a voicemail greeting and starts recording a voicemail message.\n ' self._Alter('STARTRECORDING')
Stops playing a voicemail greeting and starts recording a voicemail message.
Skype4Py/voicemail.py
StartRecording
amolvaze/Python
199
python
def StartRecording(self): '\n ' self._Alter('STARTRECORDING')
def StartRecording(self): '\n ' self._Alter('STARTRECORDING')<|docstring|>Stops playing a voicemail greeting and starts recording a voicemail message.<|endoftext|>
b0ec0ac90ed570023b5f1964b14a34198a0a61e3e84bd47ef4c1b31e056e3122
def StopPlayback(self): 'Stops playing downloaded voicemail.\n ' self._Alter('STOPPLAYBACK')
Stops playing downloaded voicemail.
Skype4Py/voicemail.py
StopPlayback
amolvaze/Python
199
python
def StopPlayback(self): '\n ' self._Alter('STOPPLAYBACK')
def StopPlayback(self): '\n ' self._Alter('STOPPLAYBACK')<|docstring|>Stops playing downloaded voicemail.<|endoftext|>
72fb6515d5abf38a6b7b8e2ebb4304f774ecf4c1217f288475cc1852b22c1a2e
def StopRecording(self): 'Ends the recording of a voicemail message.\n ' self._Alter('STOPRECORDING')
Ends the recording of a voicemail message.
Skype4Py/voicemail.py
StopRecording
amolvaze/Python
199
python
def StopRecording(self): '\n ' self._Alter('STOPRECORDING')
def StopRecording(self): '\n ' self._Alter('STOPRECORDING')<|docstring|>Ends the recording of a voicemail message.<|endoftext|>
0b4d551e95f75934f610527d1b731ea56ad10c2d0bff5a0269e1265bc1974871
def Upload(self): 'Uploads recorded voicemail from a local computer to the voicemail server.\n ' self._Alter('UPLOAD')
Uploads recorded voicemail from a local computer to the voicemail server.
Skype4Py/voicemail.py
Upload
amolvaze/Python
199
python
def Upload(self): '\n ' self._Alter('UPLOAD')
def Upload(self): '\n ' self._Alter('UPLOAD')<|docstring|>Uploads recorded voicemail from a local computer to the voicemail server.<|endoftext|>
fa85bb99159214f529fc4e8f4e7495eceb23706b7341a2278c6116fa02b19920
def get_all_path(directory): '\n Collecting all the addresses of swc files in the given directory.\n\n Parameters\n ----------\n directory: str\n The address of the folder\n\n Returns\n -------\n fileSet: list\n list of all the addresses of *.swc neurons.\n ' fileSet = [] for (root, dirs, files) in os.walk(directory): for fileName in files: if (fileName[(- 3):] == 'swc'): fileSet.append((((directory + root.replace(directory, '')) + os.sep) + fileName)) return fileSet
Collecting all the addresses of swc files in the given directory. Parameters ---------- directory: str The address of the folder Returns ------- fileSet: list list of all the addresses of *.swc neurons.
McNeuron/NeuronCollection.py
get_all_path
tree-gan/MCMC
6
python
def get_all_path(directory): '\n Collecting all the addresses of swc files in the given directory.\n\n Parameters\n ----------\n directory: str\n The address of the folder\n\n Returns\n -------\n fileSet: list\n list of all the addresses of *.swc neurons.\n ' fileSet = [] for (root, dirs, files) in os.walk(directory): for fileName in files: if (fileName[(- 3):] == 'swc'): fileSet.append((((directory + root.replace(directory, )) + os.sep) + fileName)) return fileSet
def get_all_path(directory): '\n Collecting all the addresses of swc files in the given directory.\n\n Parameters\n ----------\n directory: str\n The address of the folder\n\n Returns\n -------\n fileSet: list\n list of all the addresses of *.swc neurons.\n ' fileSet = [] for (root, dirs, files) in os.walk(directory): for fileName in files: if (fileName[(- 3):] == 'swc'): fileSet.append((((directory + root.replace(directory, )) + os.sep) + fileName)) return fileSet<|docstring|>Collecting all the addresses of swc files in the given directory. Parameters ---------- directory: str The address of the folder Returns ------- fileSet: list list of all the addresses of *.swc neurons.<|endoftext|>
4c5e538a1f535384fb37f09cf7b452f4e48da8ba524d0a7272c94d1599a5c66d
def set_features(self): '\n set the range of histogram for each feature.\n\n hist_range : dict\n ----------\n dictionary of all feature and thier range of histogram.\n ' self.features = {} for name in self.database[0].features.keys(): self.features[name] = [] for i in range(len(self.database)): self.features[name].append(self.database[i].features[name])
set the range of histogram for each feature. hist_range : dict ---------- dictionary of all feature and thier range of histogram.
McNeuron/NeuronCollection.py
set_features
tree-gan/MCMC
6
python
def set_features(self): '\n set the range of histogram for each feature.\n\n hist_range : dict\n ----------\n dictionary of all feature and thier range of histogram.\n ' self.features = {} for name in self.database[0].features.keys(): self.features[name] = [] for i in range(len(self.database)): self.features[name].append(self.database[i].features[name])
def set_features(self): '\n set the range of histogram for each feature.\n\n hist_range : dict\n ----------\n dictionary of all feature and thier range of histogram.\n ' self.features = {} for name in self.database[0].features.keys(): self.features[name] = [] for i in range(len(self.database)): self.features[name].append(self.database[i].features[name])<|docstring|>set the range of histogram for each feature. hist_range : dict ---------- dictionary of all feature and thier range of histogram.<|endoftext|>
f391d6726fb7718816ca05cee8396ed4c1456a5682d6296a43affec2ba59057c
def __init__(self, classes): '\n Arguments\n ---------\n classes: número de clases (tipos de hemorragias)\n ' super(ResnetModel, self).__init__() self.backbone = models.resnet50(pretrained=False) n_filters = self.backbone.fc.in_features self.backbone.fc = nn.Linear(n_filters, classes)
Arguments --------- classes: número de clases (tipos de hemorragias)
model/resnet.py
__init__
BiomedLabUG/intracraneal-hemorrhage
2
python
def __init__(self, classes): '\n Arguments\n ---------\n classes: número de clases (tipos de hemorragias)\n ' super(ResnetModel, self).__init__() self.backbone = models.resnet50(pretrained=False) n_filters = self.backbone.fc.in_features self.backbone.fc = nn.Linear(n_filters, classes)
def __init__(self, classes): '\n Arguments\n ---------\n classes: número de clases (tipos de hemorragias)\n ' super(ResnetModel, self).__init__() self.backbone = models.resnet50(pretrained=False) n_filters = self.backbone.fc.in_features self.backbone.fc = nn.Linear(n_filters, classes)<|docstring|>Arguments --------- classes: número de clases (tipos de hemorragias)<|endoftext|>
170842d59e03423014d6e962b54510b9b8bdf47ddaa5b2b861678441462f9b22
def load_data(filename): '加载数据\n 单条格式:[text, (start, end, label), (start, end, label), ...],\n 意味着text[start:end + 1]是类型为label的实体。\n ' D = [] with open(filename, encoding='utf-8') as f: f = f.read() for l in f.split('\n\n'): if (not l): continue d = [''] for (i, c) in enumerate(l.split('\n')): (char, flag) = c.split(' ') d[0] += char if (flag[0] == 'B'): d.append([i, i, flag[2:]]) categories.add(flag[2:]) elif (flag[0] == 'I'): d[(- 1)][1] = i D.append(d) return D
加载数据 单条格式:[text, (start, end, label), (start, end, label), ...], 意味着text[start:end + 1]是类型为label的实体。
examples/task_sequence_labeling_ner_crf.py
load_data
LeiSoft/bert4keras
4,478
python
def load_data(filename): '加载数据\n 单条格式:[text, (start, end, label), (start, end, label), ...],\n 意味着text[start:end + 1]是类型为label的实体。\n ' D = [] with open(filename, encoding='utf-8') as f: f = f.read() for l in f.split('\n\n'): if (not l): continue d = [] for (i, c) in enumerate(l.split('\n')): (char, flag) = c.split(' ') d[0] += char if (flag[0] == 'B'): d.append([i, i, flag[2:]]) categories.add(flag[2:]) elif (flag[0] == 'I'): d[(- 1)][1] = i D.append(d) return D
def load_data(filename): '加载数据\n 单条格式:[text, (start, end, label), (start, end, label), ...],\n 意味着text[start:end + 1]是类型为label的实体。\n ' D = [] with open(filename, encoding='utf-8') as f: f = f.read() for l in f.split('\n\n'): if (not l): continue d = [] for (i, c) in enumerate(l.split('\n')): (char, flag) = c.split(' ') d[0] += char if (flag[0] == 'B'): d.append([i, i, flag[2:]]) categories.add(flag[2:]) elif (flag[0] == 'I'): d[(- 1)][1] = i D.append(d) return D<|docstring|>加载数据 单条格式:[text, (start, end, label), (start, end, label), ...], 意味着text[start:end + 1]是类型为label的实体。<|endoftext|>
d16d3632fede464d859b24265b0ba7f8dab327af717335e2d3e2abb2a336e0d3
def evaluate(data): '评测函数\n ' (X, Y, Z) = (1e-10, 1e-10, 1e-10) for d in tqdm(data, ncols=100): R = set(NER.recognize(d[0])) T = set([tuple(i) for i in d[1:]]) X += len((R & T)) Y += len(R) Z += len(T) (f1, precision, recall) = (((2 * X) / (Y + Z)), (X / Y), (X / Z)) return (f1, precision, recall)
评测函数
examples/task_sequence_labeling_ner_crf.py
evaluate
LeiSoft/bert4keras
4,478
python
def evaluate(data): '\n ' (X, Y, Z) = (1e-10, 1e-10, 1e-10) for d in tqdm(data, ncols=100): R = set(NER.recognize(d[0])) T = set([tuple(i) for i in d[1:]]) X += len((R & T)) Y += len(R) Z += len(T) (f1, precision, recall) = (((2 * X) / (Y + Z)), (X / Y), (X / Z)) return (f1, precision, recall)
def evaluate(data): '\n ' (X, Y, Z) = (1e-10, 1e-10, 1e-10) for d in tqdm(data, ncols=100): R = set(NER.recognize(d[0])) T = set([tuple(i) for i in d[1:]]) X += len((R & T)) Y += len(R) Z += len(T) (f1, precision, recall) = (((2 * X) / (Y + Z)), (X / Y), (X / Z)) return (f1, precision, recall)<|docstring|>评测函数<|endoftext|>
20d0623ebd73e387803da64b1a3b55fa87af61fd5bea9e7c2472c0588b76dde2
def tx_test(ser: serial.Serial): '\n Simple TX test\n\n :param ser: device to send data to\n ' for i in range(0, 100): ser.write('\x1b[93m{}: This is a test message.\r\n'.format(i))
Simple TX test :param ser: device to send data to
scripts/term_test.py
tx_test
joeyahines/cerial
0
python
def tx_test(ser: serial.Serial): '\n Simple TX test\n\n :param ser: device to send data to\n ' for i in range(0, 100): ser.write('\x1b[93m{}: This is a test message.\r\n'.format(i))
def tx_test(ser: serial.Serial): '\n Simple TX test\n\n :param ser: device to send data to\n ' for i in range(0, 100): ser.write('\x1b[93m{}: This is a test message.\r\n'.format(i))<|docstring|>Simple TX test :param ser: device to send data to<|endoftext|>
158677eca9d4ce71909cdb22f50bc0c0f5cd98818c63b4dc20d2e0ba5475acac
def rx_test(ser: serial.Serial): '\n Simple echo test\n\n :param ser: serial port to echo data on\n :return:\n ' while True: c = ser.read(1) print(c) ser.write(c) ser.flush()
Simple echo test :param ser: serial port to echo data on :return:
scripts/term_test.py
rx_test
joeyahines/cerial
0
python
def rx_test(ser: serial.Serial): '\n Simple echo test\n\n :param ser: serial port to echo data on\n :return:\n ' while True: c = ser.read(1) print(c) ser.write(c) ser.flush()
def rx_test(ser: serial.Serial): '\n Simple echo test\n\n :param ser: serial port to echo data on\n :return:\n ' while True: c = ser.read(1) print(c) ser.write(c) ser.flush()<|docstring|>Simple echo test :param ser: serial port to echo data on :return:<|endoftext|>
427194fc9ade7ea4e45cabcea3c639f81e3848d7d40fb8e33c33ac72228934a8
def main(): '\n Main function\n ' if (len(sys.argv) < 3): print('{} <dev> <test>'.format(sys.argv[0])) exit((- 1)) else: dev = sys.argv[1] test = sys.argv[2] ser = serial.Serial(dev) try: if (test == 'rx'): rx_test(ser) else: tx_test(dev) finally: ser.close()
Main function
scripts/term_test.py
main
joeyahines/cerial
0
python
def main(): '\n \n ' if (len(sys.argv) < 3): print('{} <dev> <test>'.format(sys.argv[0])) exit((- 1)) else: dev = sys.argv[1] test = sys.argv[2] ser = serial.Serial(dev) try: if (test == 'rx'): rx_test(ser) else: tx_test(dev) finally: ser.close()
def main(): '\n \n ' if (len(sys.argv) < 3): print('{} <dev> <test>'.format(sys.argv[0])) exit((- 1)) else: dev = sys.argv[1] test = sys.argv[2] ser = serial.Serial(dev) try: if (test == 'rx'): rx_test(ser) else: tx_test(dev) finally: ser.close()<|docstring|>Main function<|endoftext|>
8c1367801f75f17aaedda216cfb576414781b50d2edc4970912f6aaf7f3334e6
def warn(warn_class: type[ExarataWarning]=ExarataWarning, message: str='', stacklevel: int=2): 'The common method to use to warn for any OpihiExarata based warnings.\n\n This is used because it has better context manager wrappers.\n\n Parameters\n ----------\n warn_class : type, default = ExarataWarning\n The warning class, it must be a subtype of a user warning.\n message : string, default = ""\n The warning message.\n stacklevel : integer, default = 2\n The location in the stack that the warning call will highlight.\n\n Returns\n -------\n None\n ' if (not issubclass(warn_class, ExarataWarning)): raise DevelopmentError('The OpihiExarata warning system is build only for user defined errors coming from OpihiExarata.') else: warnings.warn(message=message, category=warn_class, stacklevel=stacklevel) return None
The common method to use to warn for any OpihiExarata based warnings. This is used because it has better context manager wrappers. Parameters ---------- warn_class : type, default = ExarataWarning The warning class, it must be a subtype of a user warning. message : string, default = "" The warning message. stacklevel : integer, default = 2 The location in the stack that the warning call will highlight. Returns ------- None
src/opihiexarata/library/error.py
warn
psmd-iberutaru/OpihiExarata
0
python
def warn(warn_class: type[ExarataWarning]=ExarataWarning, message: str=, stacklevel: int=2): 'The common method to use to warn for any OpihiExarata based warnings.\n\n This is used because it has better context manager wrappers.\n\n Parameters\n ----------\n warn_class : type, default = ExarataWarning\n The warning class, it must be a subtype of a user warning.\n message : string, default = \n The warning message.\n stacklevel : integer, default = 2\n The location in the stack that the warning call will highlight.\n\n Returns\n -------\n None\n ' if (not issubclass(warn_class, ExarataWarning)): raise DevelopmentError('The OpihiExarata warning system is build only for user defined errors coming from OpihiExarata.') else: warnings.warn(message=message, category=warn_class, stacklevel=stacklevel) return None
def warn(warn_class: type[ExarataWarning]=ExarataWarning, message: str=, stacklevel: int=2): 'The common method to use to warn for any OpihiExarata based warnings.\n\n This is used because it has better context manager wrappers.\n\n Parameters\n ----------\n warn_class : type, default = ExarataWarning\n The warning class, it must be a subtype of a user warning.\n message : string, default = \n The warning message.\n stacklevel : integer, default = 2\n The location in the stack that the warning call will highlight.\n\n Returns\n -------\n None\n ' if (not issubclass(warn_class, ExarataWarning)): raise DevelopmentError('The OpihiExarata warning system is build only for user defined errors coming from OpihiExarata.') else: warnings.warn(message=message, category=warn_class, stacklevel=stacklevel) return None<|docstring|>The common method to use to warn for any OpihiExarata based warnings. This is used because it has better context manager wrappers. Parameters ---------- warn_class : type, default = ExarataWarning The warning class, it must be a subtype of a user warning. message : string, default = "" The warning message. stacklevel : integer, default = 2 The location in the stack that the warning call will highlight. Returns ------- None<|endoftext|>
5e7385af8fbaf3d5d648661a5f63dce763345d9813a8cef2fa9a4ec884a9fe53
def __init__(self, message: str=None) -> None: 'The initialization of a base exception for OpihiExarata.\n\n Parameters\n ----------\n message : string\n The message of the error message.\n\n Returns\n -------\n None\n ' message = (message if (message is not None) else 'Unrecoverable error!') prefix = '(OpihiExarata) TERMINAL - ' suffix = ('\n' + '>> Contact the maintainers of OpihiExarata to fix this issue.') self.message = ((prefix + message) + suffix)
The initialization of a base exception for OpihiExarata. Parameters ---------- message : string The message of the error message. Returns ------- None
src/opihiexarata/library/error.py
__init__
psmd-iberutaru/OpihiExarata
0
python
def __init__(self, message: str=None) -> None: 'The initialization of a base exception for OpihiExarata.\n\n Parameters\n ----------\n message : string\n The message of the error message.\n\n Returns\n -------\n None\n ' message = (message if (message is not None) else 'Unrecoverable error!') prefix = '(OpihiExarata) TERMINAL - ' suffix = ('\n' + '>> Contact the maintainers of OpihiExarata to fix this issue.') self.message = ((prefix + message) + suffix)
def __init__(self, message: str=None) -> None: 'The initialization of a base exception for OpihiExarata.\n\n Parameters\n ----------\n message : string\n The message of the error message.\n\n Returns\n -------\n None\n ' message = (message if (message is not None) else 'Unrecoverable error!') prefix = '(OpihiExarata) TERMINAL - ' suffix = ('\n' + '>> Contact the maintainers of OpihiExarata to fix this issue.') self.message = ((prefix + message) + suffix)<|docstring|>The initialization of a base exception for OpihiExarata. Parameters ---------- message : string The message of the error message. Returns ------- None<|endoftext|>