task_type
stringclasses
4 values
code_task
stringclasses
15 values
start_line
int64
4
1.79k
end_line
int64
4
1.8k
before
stringlengths
79
76.1k
between
stringlengths
17
806
after
stringlengths
2
72.6k
reason_categories_output
stringlengths
2
2.24k
horizon_categories_output
stringlengths
83
3.99k
reason_freq_analysis
stringclasses
150 values
horizon_freq_analysis
stringlengths
23
185
infilling_python
RL_Motion_Planning
572
572
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[' self.model.save_(dir_param)']
[' ', ' def load_model(self, dir_param):', ' self.model.load_(dir_param)', ' ', ' def process_data(self, transitions, expert=False, is_supervised=False):', ' ', ' trans = transitions.copy()', ' ', ' # Process the states and goals', " trans['states'] = self.preproces...
[]
Variable 'self' used at line 572 is defined at line 569 and has a Short-Range dependency. Variable 'dir_param' used at line 572 is defined at line 569 and has a Short-Range dependency.
{}
{'Variable Short-Range': 2}
infilling_python
RL_Motion_Planning
575
575
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[' self.model.load_(dir_param)']
[' ', ' def process_data(self, transitions, expert=False, is_supervised=False):', ' ', ' trans = transitions.copy()', ' ', ' # Process the states and goals', " trans['states'] = self.preprocess_in_state_space(trans['states'])", " trans['states_2'] = self.preprocess_in_sta...
[]
Variable 'self' used at line 575 is defined at line 574 and has a Short-Range dependency. Variable 'dir_param' used at line 575 is defined at line 574 and has a Short-Range dependency.
{}
{'Variable Short-Range': 2}
infilling_python
RL_Motion_Planning
599
601
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[" trans['terminate_skills'] = tf.cast(tf.not_equal(tf.argmax(trans['prev_skills'], axis=-1),", " tf.argmax(trans['curr_skills'], axis=-1)),", ' dtype=tf.int32)']
[' # reshape the terminate_skills to be of shape (batch_size, 1)', " trans['terminate_skills'] = tf.reshape(trans['terminate_skills'], shape=(-1, 1))", ' ', ' # Make sure the data is of type tf.float32', ' for key in trans.keys():', ' trans[key] = tf.cast(trans[key], dtype=...
[]
Variable 'trans' used at line 599 is defined at line 596 and has a Short-Range dependency. Library 'tf' used at line 599 is imported at line 20 and has a Long-Range dependency. Library 'tf' used at line 600 is imported at line 20 and has a Long-Range dependency. Variable 'trans' used at line 600 is defined at line 596 ...
{}
{'Variable Short-Range': 2, 'Library Long-Range': 3}
infilling_python
RL_Motion_Planning
603
603
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[" trans['terminate_skills'] = tf.reshape(trans['terminate_skills'], shape=(-1, 1))"]
[' ', ' # Make sure the data is of type tf.float32', ' for key in trans.keys():', ' trans[key] = tf.cast(trans[key], dtype=tf.float32)', ' print("trans :", trans)', ' return trans', ' ', ' def sample_data(self, buffer, batch_size):', ' ', ' # Sample Tran...
[]
Variable 'trans' used at line 603 is defined at line 599 and has a Short-Range dependency. Library 'tf' used at line 603 is imported at line 20 and has a Long-Range dependency.
{}
{'Variable Short-Range': 1, 'Library Long-Range': 1}
infilling_python
RL_Motion_Planning
607
607
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[' trans[key] = tf.cast(trans[key], dtype=tf.float32)']
[' print("trans :", trans)', ' return trans', ' ', ' def sample_data(self, buffer, batch_size):', ' ', ' # Sample Transitions', ' transitions: Union[Dict[int, dict], dict] = buffer.sample_transitions(batch_size)', ' ', ' # Process the transitions', ' keys = ...
[{'reason_category': 'Loop Body', 'usage_line': 607}]
Variable 'trans' used at line 607 is defined at line 603 and has a Short-Range dependency. Variable 'key' used at line 607 is part of a Loop defined at line 606 and has a Short-Range dependency. Library 'tf' used at line 607 is imported at line 20 and has a Long-Range dependency.
{'Loop Body': 1}
{'Variable Short-Range': 1, 'Variable Loop Short-Range': 1, 'Library Long-Range': 1}
infilling_python
RL_Motion_Planning
614
614
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[' transitions: Union[Dict[int, dict], dict] = buffer.sample_transitions(batch_size)']
[' ', ' # Process the transitions', ' keys = None', ' if all(isinstance(v, dict) for v in transitions.values()):', ' for skill in transitions.keys():', ' ', ' # For skills whose transition data is not None', ' if transitions[skill] is n...
[]
Library 'Union' used at line 614 is imported at line 16 and has a Long-Range dependency. Library 'Dict' used at line 614 is imported at line 16 and has a Long-Range dependency. Variable 'buffer' used at line 614 is defined at line 611 and has a Short-Range dependency. Variable 'batch_size' used at line 614 is defined a...
{}
{'Library Long-Range': 2, 'Variable Short-Range': 2}
infilling_python
RL_Motion_Planning
624
624
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[' transitions[skill], tf.constant(True, dtype=tf.bool), tf.constant(True, dtype=tf.bool)']
[' )', ' ', ' keys = transitions[skill].keys()', ' ', ' # If keys is None, No transitions were sampled', ' if keys is None:', ' raise ValueError("No transitions were sampled")', ' ', ' # Concat...
[{'reason_category': 'If Body', 'usage_line': 624}, {'reason_category': 'Loop Body', 'usage_line': 624}]
Variable 'skill' used at line 624 is part of a Loop defined at line 619 and has a Short-Range dependency. Library 'tf' used at line 624 is imported at line 20 and has a Long-Range dependency.
{'If Body': 1, 'Loop Body': 1}
{'Variable Loop Short-Range': 1, 'Library Long-Range': 1}
infilling_python
RL_Motion_Planning
639
640
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[' for key in keys:', ' combined_transitions[key].append(transitions[skill][key])']
[' ', ' for key in keys:', ' combined_transitions[key] = tf.concat(combined_transitions[key], axis=0)', ' ', ' transitions = combined_transitions', ' ', ' elif isinstance(transitions, dict):', ' transitions = self.process_data(', ' ...
[{'reason_category': 'If Body', 'usage_line': 639}, {'reason_category': 'Loop Body', 'usage_line': 639}, {'reason_category': 'Define Stop Criteria', 'usage_line': 639}, {'reason_category': 'If Body', 'usage_line': 640}, {'reason_category': 'Loop Body', 'usage_line': 640}]
Variable 'keys' used at line 639 is defined at line 617 and has a Medium-Range dependency. Variable 'combined_transitions' used at line 640 is defined at line 634 and has a Short-Range dependency. Variable 'key' used at line 640 is part of a Loop defined at line 639 and has a Short-Range dependency. Variable 'skill' us...
{'If Body': 2, 'Loop Body': 2, 'Define Stop Criteria': 1}
{'Variable Medium-Range': 1, 'Variable Short-Range': 1, 'Variable Loop Short-Range': 2}
infilling_python
RL_Motion_Planning
643
643
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[' combined_transitions[key] = tf.concat(combined_transitions[key], axis=0)']
[' ', ' transitions = combined_transitions', ' ', ' elif isinstance(transitions, dict):', ' transitions = self.process_data(', ' transitions, tf.constant(True, dtype=tf.bool), tf.constant(True, dtype=tf.bool)', ' )', ' ', ' else:', '...
[{'reason_category': 'If Body', 'usage_line': 643}, {'reason_category': 'Loop Based', 'usage_line': 643}]
Variable 'combined_transitions' used at line 643 is defined at line 634 and has a Short-Range dependency. Variable 'key' used at line 643 is part of a Loop defined at line 642 and has a Short-Range dependency. Library 'tf' used at line 643 is imported at line 20 and has a Long-Range dependency.
{'If Body': 1}
{'Variable Short-Range': 1, 'Variable Loop Short-Range': 1, 'Library Long-Range': 1}
infilling_python
RL_Motion_Planning
649
649
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[' transitions, tf.constant(True, dtype=tf.bool), tf.constant(True, dtype=tf.bool)']
[' )', ' ', ' else:', ' raise ValueError("Invalid type of transitions")', ' print("transitions: ", transitions)', ' return transitions', ' ', ' @tf.function', ' def train(self):', ' ', ' self.model.change_training_mode(training_mode=True)', ' ...
[{'reason_category': 'Elif Body', 'usage_line': 649}]
Variable 'transitions' used at line 649 is defined at line 648 and has a Short-Range dependency. Library 'tf' used at line 649 is imported at line 20 and has a Long-Range dependency.
{'Elif Body': 1}
{'Variable Short-Range': 1, 'Library Long-Range': 1}
infilling_python
RL_Motion_Planning
663
663
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[' data_policy = self.sample_data(self.offline_buffer, self.args.batch_size)']
[' loss_dict = self.model.train(data_expert, data_policy)', ' ', ' # Average the losses', ' avg_loss_dict = {}', ' for key in loss_dict.keys():', ' if key not in avg_loss_dict.keys():', ' avg_loss_dict[key] = []', ' avg_loss_dict[key].append(loss_d...
[]
Variable 'self' used at line 663 is defined at line 658 and has a Short-Range dependency.
{}
{'Variable Short-Range': 1}
infilling_python
RL_Motion_Planning
668
673
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[' for key in loss_dict.keys():', ' if key not in avg_loss_dict.keys():', ' avg_loss_dict[key] = []', ' avg_loss_dict[key].append(loss_dict[key])', ' for key in avg_loss_dict.keys():', ' avg_loss_dict[key] = tf.reduce_mean(avg_loss_dict[key])']
[' print("avg_loss_dict: ", avg_loss_dict)', ' return avg_loss_dict', ' ', ' def learn(self):', ' # This is a base class method, inherited classes must implement this method', ' raise NotImplementedError', '', '', 'class Agent(AgentBase):', ' def __init__(self, args,', ' ...
[{'reason_category': 'Define Stop Criteria', 'usage_line': 668}, {'reason_category': 'If Condition', 'usage_line': 669}, {'reason_category': 'Loop Body', 'usage_line': 669}, {'reason_category': 'Loop Body', 'usage_line': 670}, {'reason_category': 'If Body', 'usage_line': 670}, {'reason_category': 'Loop Body', 'usage_li...
Variable 'loss_dict' used at line 668 is defined at line 664 and has a Short-Range dependency. Variable 'key' used at line 669 is part of a Loop defined at line 668 and has a Short-Range dependency. Variable 'avg_loss_dict' used at line 669 is defined at line 667 and has a Short-Range dependency. Variable 'avg_loss_dic...
{'Define Stop Criteria': 2, 'If Condition': 1, 'Loop Body': 4, 'If Body': 1}
{'Variable Short-Range': 7, 'Variable Loop Short-Range': 4, 'Library Long-Range': 1}
infilling_python
RL_Motion_Planning
671
671
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[' avg_loss_dict[key].append(loss_dict[key])']
[' for key in avg_loss_dict.keys():', ' avg_loss_dict[key] = tf.reduce_mean(avg_loss_dict[key])', ' print("avg_loss_dict: ", avg_loss_dict)', ' return avg_loss_dict', ' ', ' def learn(self):', ' # This is a base class method, inherited classes must implement this method', ' ...
[{'reason_category': 'Loop Body', 'usage_line': 671}]
Variable 'avg_loss_dict' used at line 671 is defined at line 667 and has a Short-Range dependency. Variable 'key' used at line 671 is part of a Loop defined at line 668 and has a Short-Range dependency. Variable 'loss_dict' used at line 671 is defined at line 664 and has a Short-Range dependency.
{'Loop Body': 1}
{'Variable Short-Range': 2, 'Variable Loop Short-Range': 1}
infilling_python
RL_Motion_Planning
673
673
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[' avg_loss_dict[key] = tf.reduce_mean(avg_loss_dict[key])']
[' print("avg_loss_dict: ", avg_loss_dict)', ' return avg_loss_dict', ' ', ' def learn(self):', ' # This is a base class method, inherited classes must implement this method', ' raise NotImplementedError', '', '', 'class Agent(AgentBase):', ' def __init__(self, args,', ' ...
[{'reason_category': 'Loop Body', 'usage_line': 673}]
Variable 'avg_loss_dict' used at line 673 is defined at line 667 and has a Short-Range dependency. Variable 'key' used at line 673 is part of a Loop defined at line 672 and has a Short-Range dependency. Library 'tf' used at line 673 is imported at line 20 and has a Long-Range dependency.
{'Loop Body': 1}
{'Variable Short-Range': 1, 'Variable Loop Short-Range': 1, 'Library Long-Range': 1}
infilling_python
RL_Motion_Planning
700
700
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[' data_off = self.offline_buffer.sample_episodes()']
[' self.expert_buffer.load_data_into_buffer(buffered_data=data_exp, clear_buffer=True)', ' self.offline_buffer.load_data_into_buffer(buffered_data=data_exp, clear_buffer=True)', ' self.offline_buffer.load_data_into_buffer(buffered_data=data_off, clear_buffer=False)', ' ', ' with tqdm(...
[]
Variable 'self' used at line 700 is defined at line 692 and has a Short-Range dependency.
{}
{'Variable Short-Range': 1}
infilling_python
RL_Motion_Planning
715
717
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[' avg_loss_dict = self.train()', ' for key in avg_loss_dict.keys():', ' avg_loss_dict[key] = avg_loss_dict[key].numpy().item()']
[' ', ' # Log', ' if self.args.log_wandb:', ' self.wandb_logger.log(avg_loss_dict, step=log_step)', ' self.wandb_logger.log({', " 'policy_buffer_size': self.offline_buffer.get_current_size_trans(),", " ...
[{'reason_category': 'Loop Body', 'usage_line': 715}, {'reason_category': 'Loop Body', 'usage_line': 716}, {'reason_category': 'Define Stop Criteria', 'usage_line': 716}, {'reason_category': 'Loop Body', 'usage_line': 717}]
Variable 'self' used at line 715 is defined at line 692 and has a Medium-Range dependency. Variable 'avg_loss_dict' used at line 716 is defined at line 715 and has a Short-Range dependency. Variable 'avg_loss_dict' used at line 717 is defined at line 715 and has a Short-Range dependency. Variable 'key' used at line 717...
{'Loop Body': 3, 'Define Stop Criteria': 1}
{'Variable Medium-Range': 1, 'Variable Short-Range': 2, 'Variable Loop Short-Range': 1}
infilling_python
RL_Motion_Planning
859
859
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[' args = get_config_env(args, ag_in_env_goal=True)']
[' ', ' # Other Configurations', ' args.train_demos = int(args.expert_demos * args.perc_train)', ' args.val_demos = args.expert_demos - args.train_demos', ' ', ' # Set number of skills [For unsupervised skill learning]', " if args.num_skills is not None and args.skill_supervision == 'none':", " ...
[]
Function 'get_config_env' used at line 859 is defined at line 735 and has a Long-Range dependency.
{}
{'Function Long-Range': 1}
infilling_python
RL_Motion_Planning
892
892
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[' args = get_config(db=db)']
[' args.algo = algo', ' args.log_dir = log_dir', ' ', ' logger.info("---------------------------------------------------------------------------------------------")', ' config: dict = vars(args)', ' config = {key: str(value) for key, value in config.items()}', ' config = OrderedDict(sorted(config.i...
[]
Function 'get_config' used at line 892 is defined at line 758 and has a Long-Range dependency. Variable 'db' used at line 892 is defined at line 883 and has a Short-Range dependency.
{}
{'Function Long-Range': 1, 'Variable Short-Range': 1}
infilling_python
RL_Motion_Planning
903
904
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[' tf.keras.backend.clear_session()', ' tf.compat.v1.reset_default_graph()']
[' ', ' # ######################################################################################################## #', ' # ############################################# DATA LOADING ############################################# #', ' # ########################################################################...
[]
Library 'tf' used at line 903 is imported at line 20 and has a Long-Range dependency. Library 'tf' used at line 904 is imported at line 20 and has a Long-Range dependency.
{}
{'Library Long-Range': 2}
infilling_python
RL_Motion_Planning
914
915
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[' buffer_shape, args.buffer_size, args.horizon,', ' sample_transitions(args.trans_style, state_to_goal=state_to_goal(n_objs), num_options=args.c_dim),']
[' )', ' offline_buffer = ReplayBufferTf(', ' buffer_shape, args.buffer_size, args.horizon,', ' sample_transitions(args.trans_style, state_to_goal=state_to_goal(n_objs), num_options=args.c_dim)', ' )', ' if n_objs == 3:', " expert_data_file = 'three_obj_{}_train.pkl'.format(args.expert_...
[]
Variable 'args' used at line 914 is defined at line 892 and has a Medium-Range dependency. Function 'sample_transitions' used at line 915 is defined at line 142 and has a Long-Range dependency. Variable 'args' used at line 915 is defined at line 892 and has a Medium-Range dependency. Function 'state_to_goal' used at li...
{}
{'Variable Medium-Range': 2, 'Function Long-Range': 2, 'Variable Short-Range': 1}
infilling_python
RL_Motion_Planning
918
919
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[' buffer_shape, args.buffer_size, args.horizon,', ' sample_transitions(args.trans_style, state_to_goal=state_to_goal(n_objs), num_options=args.c_dim)']
[' )', ' if n_objs == 3:', " expert_data_file = 'three_obj_{}_train.pkl'.format(args.expert_behaviour)", " offline_data_file = 'three_obj_{}_offline.pkl'.format(args.expert_behaviour)", ' elif n_objs == 2:', " expert_data_file = 'two_obj_{}_train.pkl'.format(args.expert_behaviour)", " ...
[]
Variable 'args' used at line 918 is defined at line 892 and has a Medium-Range dependency. Function 'sample_transitions' used at line 919 is defined at line 142 and has a Long-Range dependency. Variable 'args' used at line 919 is defined at line 892 and has a Medium-Range dependency. Function 'state_to_goal' used at li...
{}
{'Variable Medium-Range': 2, 'Function Long-Range': 2, 'Variable Short-Range': 1}
infilling_python
RL_Motion_Planning
952
952
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[" prev_skills = repurpose_skill_seq(args, buffered_data['prev_skills'])"]
[" buffered_data['curr_skills'] = curr_skills", " buffered_data['prev_skills'] = prev_skills", ' # Add a new key "has_gt_skill" indicating that the skill is G.T.', " buffered_data['has_gt_skill'] = tf.ones_like(buffered_data['successes'], dtype=tf.float32)", ' expert_buffer.load_data_into_buffer(buffered...
[]
Function 'repurpose_skill_seq' used at line 952 is defined at line 89 and has a Long-Range dependency. Variable 'args' used at line 952 is defined at line 892 and has a Long-Range dependency. Variable 'buffered_data' used at line 952 is defined at line 948 and has a Short-Range dependency.
{}
{'Function Long-Range': 1, 'Variable Long-Range': 1, 'Variable Short-Range': 1}
infilling_python
RL_Motion_Planning
962
962
['import os', "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress TensorFlow logging", "os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # Suppress oneDNN warning", '# os.environ["CUDA_VISIBLE_DEVICES"] = "0"', 'import argparse', 'import datetime', 'import json', 'import os', 'import pickle', 'import sys', 'import time', '...
[' buffered_data = pickle.load(handle)']
[' ', ' # [Optional] Reformat the G.T. skill sequences', " curr_skills = repurpose_skill_seq(args, buffered_data['curr_skills'])", " prev_skills = repurpose_skill_seq(args, buffered_data['prev_skills'])", " buffered_data['curr_skills'] = curr_skills", " buffered_data['prev_skills'] = prev_skills", ' ...
[]
Library 'pickle' used at line 962 is imported at line 12 and has a Long-Range dependency.
{}
{'Library Long-Range': 1}
infilling_python
simplex_method
4
4
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):']
[' return sum(x*y for x,y in zip(a,b))']
['', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for j in range(len(A[0]))]', '', '# Check if a column is a pivot column', 'def isPivotCol(col):', ' return (len([c for c i...
[{'reason_category': 'Generator_Expressions', 'usage_line': 4}]
Variable 'x' used at line 4 is part of a Generator_Expressions defined at line 4 and has a Short-Range dependency. Variable 'y' used at line 4 is part of a Generator_Expressions defined at line 4 and has a Short-Range dependency. Variable 'a' used at line 4 is defined at line 3 and has a Short-Range dependency. Variabl...
{'Generator_Expressions': 1}
{'Variable Generator_Expressions Short-Range': 2, 'Variable Short-Range': 2}
infilling_python
simplex_method
8
8
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):']
[' return [row[j] for row in A]']
['', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for j in range(len(A[0]))]', '', '# Check if a column is a pivot column', 'def isPivotCol(col):', ' return (len([c for c in col if c == 0]) == len(col) - 1) and sum(col) == 1', '', '# Find the value of a variable for a pivot column',...
[{'reason_category': 'List_Comprehension', 'usage_line': 8}]
Variable 'row' used at line 8 is part of a List_Comprehension defined at line 8 and has a Short-Range dependency. Variable 'A' used at line 8 is defined at line 7 and has a Short-Range dependency. Variable 'j' used at line 8 is defined at line 7 and has a Short-Range dependency.
{'List_Comprehension': 1}
{'Variable List_Comprehension Short-Range': 1, 'Variable Short-Range': 2}
infilling_python
simplex_method
12
12
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):']
[' return [column(A, j) for j in range(len(A[0]))]']
['', '# Check if a column is a pivot column', 'def isPivotCol(col):', ' return (len([c for c in col if c == 0]) == len(col) - 1) and sum(col) == 1', '', '# Find the value of a variable for a pivot column', 'def variableValueForPivotColumn(tableau, column):', ' pivotRow = [i for (i, x) in enumerate(column) if x == 1...
[{'reason_category': 'List_Comprehension', 'usage_line': 12}]
Variable 'j' used at line 12 is part of a List_Comprehension defined at line 12 and has a Short-Range dependency. Variable 'A' used at line 12 is defined at line 11 and has a Short-Range dependency. Function 'column' used at line 12 is defined at line 7 and has a Short-Range dependency.
{'List_Comprehension': 1}
{'Variable List_Comprehension Short-Range': 1, 'Variable Short-Range': 1, 'Function Short-Range': 1}
infilling_python
simplex_method
16
16
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' return (len([c for c in col if c == 0]) == len(col) - 1) and sum(col) == 1']
['', '# Find the value of a variable for a pivot column', 'def variableValueForPivotColumn(tableau, column):', ' pivotRow = [i for (i, x) in enumerate(column) if x == 1][0]', ' return tableau[pivotRow][-1]', '', '# Check if we can improve the current solution', 'def canImprove(tableau):', ' lastRow = tableau[-1]'...
[{'reason_category': 'List_Comprehension', 'usage_line': 16}]
Variable 'c' used at line 16 is part of a List_Comprehension defined at line 16 and has a Short-Range dependency. Variable 'col' used at line 16 is defined at line 15 and has a Short-Range dependency.
{'List_Comprehension': 1}
{'Variable List_Comprehension Short-Range': 1, 'Variable Short-Range': 1}
infilling_python
simplex_method
20
21
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' pivotRow = [i for (i, x) in enumerate(column) if x == 1][0]', ' return tableau[pivotRow][-1]']
['', '# Check if we can improve the current solution', 'def canImprove(tableau):', ' lastRow = tableau[-1]', ' return any(x > 0 for x in lastRow[:-1])', '', "# Check if there's more than one minimum in a list", 'def moreThanOneMin(L):', ' if len(L) <= 1:', ' return False', ' x,y = heapq.nsmallest(2, L, key...
[{'reason_category': 'List_Comprehension', 'usage_line': 20}]
Variable 'i' used at line 20 is part of a List_Comprehension defined at line 20 and has a Short-Range dependency. Variable 'x' used at line 20 is part of a List_Comprehension defined at line 20 and has a Short-Range dependency. Variable 'column' used at line 20 is defined at line 19 and has a Short-Range dependency. Va...
{'List_Comprehension': 1}
{'Variable List_Comprehension Short-Range': 2, 'Variable Short-Range': 3}
infilling_python
simplex_method
25
26
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' lastRow = tableau[-1]', ' return any(x > 0 for x in lastRow[:-1])']
['', "# Check if there's more than one minimum in a list", 'def moreThanOneMin(L):', ' if len(L) <= 1:', ' return False', ' x,y = heapq.nsmallest(2, L, key=lambda x: x[1])', ' return x == y', '', '# Create an identity matrix with certain specifications', 'def identity(numRows, numCols, val=1, rowStart=0):', ...
[{'reason_category': 'Generator_Expressions', 'usage_line': 26}]
Variable 'tableau' used at line 25 is defined at line 24 and has a Short-Range dependency. Variable 'x' used at line 26 is part of a Generator_Expressions defined at line 26 and has a Short-Range dependency. Variable 'lastRow' used at line 26 is defined at line 25 and has a Short-Range dependency.
{'Generator_Expressions': 1}
{'Variable Short-Range': 2, 'Variable Generator_Expressions Short-Range': 1}
infilling_python
simplex_method
32
33
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' x,y = heapq.nsmallest(2, L, key=lambda x: x[1])', ' return x == y']
['', '# Create an identity matrix with certain specifications', 'def identity(numRows, numCols, val=1, rowStart=0):', ' return [[(val if i == j else 0) for j in range(numCols)] for i in range(rowStart, numRows)] ', '', 'def standardForm(cost, greaterThans=[], gtThreshold=[], lessThans=[], ltThreshold=[], equalities=[...
[{'reason_category': 'Lambda_Expressions', 'usage_line': 32}]
Library 'heapq' used at line 32 is imported at line 1 and has a Long-Range dependency. Variable 'L' used at line 32 is defined at line 29 and has a Short-Range dependency. Variable 'x' used at line 32 is part of a Lambda_Expressions defined at line 32 and has a Short-Range dependency. Variable 'x' used at line 33 is de...
{'Lambda_Expressions': 1}
{'Library Long-Range': 1, 'Variable Short-Range': 3, 'Variable Lambda_Expressions Short-Range': 1}
infilling_python
simplex_method
37
37
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' return [[(val if i == j else 0) for j in range(numCols)] for i in range(rowStart, numRows)] ']
['', 'def standardForm(cost, greaterThans=[], gtThreshold=[], lessThans=[], ltThreshold=[], equalities=[], eqThreshold=[], maximization=True):', ' # Initialize variables for the count of new variables and the number of rows in the tableau', ' newVars = 0', ' numRows = 0', '', ' # Adjust the number of variables ...
[{'reason_category': 'List_Comprehension', 'usage_line': 37}]
Variable 'i' used at line 37 is part of a List_Comprehension defined at line 37 and has a Short-Range dependency. Variable 'rowStart' used at line 37 is defined at line 36 and has a Short-Range dependency. Variable 'numRows' used at line 37 is defined at line 36 and has a Short-Range dependency. Variable 'j' used at li...
{'List_Comprehension': 1}
{'Variable List_Comprehension Short-Range': 2, 'Variable Short-Range': 4}
infilling_python
simplex_method
51
52
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' newVars += len(ltThreshold)', ' numRows += len(ltThreshold)']
[' ', " # Equalities don't need slack variables but add to the number of rows", ' if eqThreshold != []:', ' numRows += len(eqThreshold)', '', ' # If the problem is a minimization, convert it to a maximization by negating the cost vector ', ' if not maximization:', ' cost = [-x for x in cost]', '',...
[{'reason_category': 'If Body', 'usage_line': 51}, {'reason_category': 'If Body', 'usage_line': 52}]
Variable 'newVars' used at line 51 is defined at line 41 and has a Short-Range dependency. Variable 'ltThreshold' used at line 51 is defined at line 39 and has a Medium-Range dependency. Variable 'numRows' used at line 52 is defined at line 42 and has a Short-Range dependency. Variable 'ltThreshold' used at line 52 is ...
{'If Body': 2}
{'Variable Short-Range': 2, 'Variable Medium-Range': 2}
infilling_python
simplex_method
56
56
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' numRows += len(eqThreshold)']
['', ' # If the problem is a minimization, convert it to a maximization by negating the cost vector ', ' if not maximization:', ' cost = [-x for x in cost]', '', ' # If no new variables are needed, the problem is already in standard form', ' if newVars == 0:', ' return cost, equalities, eqThreshold'...
[{'reason_category': 'If Body', 'usage_line': 56}]
Variable 'numRows' used at line 56 is defined at line 42 and has a Medium-Range dependency. Variable 'eqThreshold' used at line 56 is defined at line 39 and has a Medium-Range dependency.
{'If Body': 1}
{'Variable Medium-Range': 2}
infilling_python
simplex_method
60
60
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' cost = [-x for x in cost]']
['', ' # If no new variables are needed, the problem is already in standard form', ' if newVars == 0:', ' return cost, equalities, eqThreshold', '', ' # Extend the cost function with zeros for the new slack variables', ' newCost = list(cost) + [0] * newVars', ' constraints = []', ' threshold = []', '',...
[{'reason_category': 'If Body', 'usage_line': 60}, {'reason_category': 'List_Comprehension', 'usage_line': 60}]
Variable 'x' used at line 60 is part of a List_Comprehension defined at line 60 and has a Short-Range dependency. Variable 'cost' used at line 60 is defined at line 39 and has a Medium-Range dependency.
{'If Body': 1, 'List_Comprehension': 1}
{'Variable List_Comprehension Short-Range': 1, 'Variable Medium-Range': 1}
infilling_python
simplex_method
67
67
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' newCost = list(cost) + [0] * newVars']
[' constraints = []', ' threshold = []', '', " # Prepare the constraints for each condition ('greater than', 'less than', 'equal to')", ' oldConstraints = [(greaterThans, gtThreshold, -1), (lessThans, ltThreshold, 1), (equalities, eqThreshold, 0)]', ' offset = 0', '', ' # Process each set of constraints', '...
[]
Variable 'cost' used at line 67 is defined at line 39 and has a Medium-Range dependency. Variable 'newVars' used at line 67 is defined at line 41 and has a Medium-Range dependency.
{}
{'Variable Medium-Range': 2}
infilling_python
simplex_method
78
78
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' constraints += [c + r for c, r in zip(constraintList, identity(numRows, newVars, coefficient, offset))]']
[' # Append the thresholds for each constraint', ' threshold += oldThreshold', ' # Increase the offset for the identity matrix used for the next set of constraints', ' offset += len(oldThreshold)', '', ' return newCost, constraints, threshold', '', "'''", ' simplex: [float], [[float]], [float] -...
[{'reason_category': 'Loop Body', 'usage_line': 78}, {'reason_category': 'List_Comprehension', 'usage_line': 78}]
Variable 'constraints' used at line 78 is defined at line 68 and has a Short-Range dependency. Variable 'c' used at line 78 is part of a List_Comprehension defined at line 78 and has a Short-Range dependency. Variable 'r' used at line 78 is part of a List_Comprehension defined at line 78 and has a Short-Range dependenc...
{'Loop Body': 1, 'List_Comprehension': 1}
{'Variable Short-Range': 2, 'Variable List_Comprehension Short-Range': 2, 'Variable Loop Short-Range': 2, 'Function Long-Range': 1, 'Variable Long-Range': 2}
infilling_python
simplex_method
80
80
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' threshold += oldThreshold']
[' # Increase the offset for the identity matrix used for the next set of constraints', ' offset += len(oldThreshold)', '', ' return newCost, constraints, threshold', '', "'''", ' simplex: [float], [[float]], [float] -> [float], float', ' Solve the given standard-form linear program:', ' max <c,x>'...
[{'reason_category': 'Loop Body', 'usage_line': 80}]
Variable 'threshold' used at line 80 is defined at line 69 and has a Medium-Range dependency. Variable 'oldThreshold' used at line 80 is part of a Loop defined at line 76 and has a Short-Range dependency.
{'Loop Body': 1}
{'Variable Medium-Range': 1, 'Variable Loop Short-Range': 1}
infilling_python
simplex_method
82
82
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' offset += len(oldThreshold)']
['', ' return newCost, constraints, threshold', '', "'''", ' simplex: [float], [[float]], [float] -> [float], float', ' Solve the given standard-form linear program:', ' max <c,x>', ' s.t. Ax = b', ' x >= 0', ' providing the optimal solution x* and the value of the objective function', "'''"...
[{'reason_category': 'Loop Body', 'usage_line': 82}]
Variable 'offset' used at line 82 is defined at line 73 and has a Short-Range dependency. Variable 'oldThreshold' used at line 82 is part of a Loop defined at line 76 and has a Short-Range dependency.
{'Loop Body': 1}
{'Variable Short-Range': 1, 'Variable Loop Short-Range': 1}
infilling_python
simplex_method
96
97
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' tableau = [row[:] + [x] for row, x in zip(A, b)]', ' tableau.append([ci for ci in c] + [0])']
[' print("Initial tableau:")', ' for row in tableau:', ' print(row)', ' print()', '', ' # Iterate until no improvements can be made', ' while canImprove(tableau):', ' # Choose entering variable (minimum positive index of the last row)', ' column_choices = [(i,x) for (i,x) in enumerate(tableau[-...
[{'reason_category': 'List_Comprehension', 'usage_line': 96}, {'reason_category': 'List_Comprehension', 'usage_line': 97}]
Variable 'row' used at line 96 is part of a List_Comprehension defined at line 96 and has a Short-Range dependency. Variable 'x' used at line 96 is part of a List_Comprehension defined at line 96 and has a Short-Range dependency. Variable 'A' used at line 96 is defined at line 94 and has a Short-Range dependency. Varia...
{'List_Comprehension': 2}
{'Variable List_Comprehension Short-Range': 3, 'Variable Short-Range': 4}
infilling_python
simplex_method
106
107
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' column_choices = [(i,x) for (i,x) in enumerate(tableau[-1][:-1]) if x > 0]', ' column = min(column_choices, key=lambda a: a[1])[0]']
['', ' # Check for unboundedness', ' if all(row[column] <= 0 for row in tableau):', " raise Exception('Linear program is unbounded.')", '', ' # Check for degeneracy: more than one minimizer of the quotient', ' quotients = [(i, r[-1] / r[column]) for i,r in enumerate(tableau[:-1]) if r[column...
[{'reason_category': 'Loop Body', 'usage_line': 106}, {'reason_category': 'List_Comprehension', 'usage_line': 106}, {'reason_category': 'Loop Body', 'usage_line': 107}, {'reason_category': 'Lambda_Expressions', 'usage_line': 107}]
Variable 'i' used at line 106 is part of a List_Comprehension defined at line 106 and has a Short-Range dependency. Variable 'x' used at line 106 is part of a List_Comprehension defined at line 106 and has a Short-Range dependency. Variable 'tableau' used at line 106 is defined at line 97 and has a Short-Range dependen...
{'Loop Body': 2, 'List_Comprehension': 1, 'Lambda_Expressions': 1}
{'Variable List_Comprehension Short-Range': 2, 'Variable Short-Range': 2, 'Variable Lambda_Expressions Short-Range': 1}
infilling_python
simplex_method
110
111
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' if all(row[column] <= 0 for row in tableau):', " raise Exception('Linear program is unbounded.')"]
['', ' # Check for degeneracy: more than one minimizer of the quotient', ' quotients = [(i, r[-1] / r[column]) for i,r in enumerate(tableau[:-1]) if r[column] > 0]', '', ' if moreThanOneMin(quotients):', " raise Exception('Linear program is degenerate.')", '', ' # Chosing leaving variable (r...
[{'reason_category': 'Loop Body', 'usage_line': 110}, {'reason_category': 'If Condition', 'usage_line': 110}, {'reason_category': 'Generator_Expressions', 'usage_line': 110}, {'reason_category': 'Loop Body', 'usage_line': 111}, {'reason_category': 'If Body', 'usage_line': 111}]
Variable 'row' used at line 110 is part of a Generator_Expressions defined at line 110 and has a Short-Range dependency. Variable 'tableau' used at line 110 is defined at line 97 and has a Medium-Range dependency. Variable 'column' used at line 110 is defined at line 107 and has a Short-Range dependency.
{'Loop Body': 2, 'If Condition': 1, 'Generator_Expressions': 1, 'If Body': 1}
{'Variable Generator_Expressions Short-Range': 1, 'Variable Medium-Range': 1, 'Variable Short-Range': 1}
infilling_python
simplex_method
114
114
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' quotients = [(i, r[-1] / r[column]) for i,r in enumerate(tableau[:-1]) if r[column] > 0]']
['', ' if moreThanOneMin(quotients):', " raise Exception('Linear program is degenerate.')", '', ' # Chosing leaving variable (row index minimizing the quotient)', ' row = min(quotients, key=lambda x: x[1])[0]', '', ' #pivots on the chosen row and column', ' pivot = row, column', '', ' ...
[{'reason_category': 'Loop Body', 'usage_line': 114}, {'reason_category': 'List_Comprehension', 'usage_line': 114}]
Variable 'i' used at line 114 is part of a List_Comprehension defined at line 114 and has a Short-Range dependency. Variable 'r' used at line 114 is part of a List_Comprehension defined at line 114 and has a Short-Range dependency. Variable 'tableau' used at line 114 is defined at line 97 and has a Medium-Range depende...
{'Loop Body': 1, 'List_Comprehension': 1}
{'Variable List_Comprehension Short-Range': 2, 'Variable Medium-Range': 1, 'Variable Short-Range': 1}
infilling_python
simplex_method
120
120
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' row = min(quotients, key=lambda x: x[1])[0]']
['', ' #pivots on the chosen row and column', ' pivot = row, column', '', ' print("Next pivot index is=%d,%d \\n" % pivot)', ' i,j = pivot', ' pivotDenom = tableau[i][j]', '', ' # Normalize the pivot row', ' tableau[i] = [x / pivotDenom for x in tableau[i]]', '', ' # Zero out the...
[{'reason_category': 'Loop Body', 'usage_line': 120}, {'reason_category': 'Lambda_Expressions', 'usage_line': 120}]
Variable 'quotients' used at line 120 is defined at line 114 and has a Short-Range dependency. Variable 'x' used at line 120 is part of a Lambda_Expressions defined at line 120 and has a Short-Range dependency.
{'Loop Body': 1, 'Lambda_Expressions': 1}
{'Variable Short-Range': 1, 'Variable Lambda_Expressions Short-Range': 1}
infilling_python
simplex_method
123
123
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' pivot = row, column']
['', ' print("Next pivot index is=%d,%d \\n" % pivot)', ' i,j = pivot', ' pivotDenom = tableau[i][j]', '', ' # Normalize the pivot row', ' tableau[i] = [x / pivotDenom for x in tableau[i]]', '', ' # Zero out the other entries in the pivot column', ' for k,row in enumerate(tableau):', ...
[{'reason_category': 'Loop Body', 'usage_line': 123}]
Variable 'row' used at line 123 is defined at line 120 and has a Short-Range dependency. Variable 'column' used at line 123 is defined at line 107 and has a Medium-Range dependency.
{'Loop Body': 1}
{'Variable Short-Range': 1, 'Variable Medium-Range': 1}
infilling_python
simplex_method
127
127
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' pivotDenom = tableau[i][j]']
['', ' # Normalize the pivot row', ' tableau[i] = [x / pivotDenom for x in tableau[i]]', '', ' # Zero out the other entries in the pivot column', ' for k,row in enumerate(tableau):', ' if k != i:', ' pivotRowMultiple = [y * tableau[k][j] for y in tableau[i]]', ' tableau...
[{'reason_category': 'Loop Body', 'usage_line': 127}]
Variable 'tableau' used at line 127 is defined at line 97 and has a Medium-Range dependency. Variable 'i' used at line 127 is defined at line 126 and has a Short-Range dependency. Variable 'j' used at line 127 is defined at line 126 and has a Short-Range dependency.
{'Loop Body': 1}
{'Variable Medium-Range': 1, 'Variable Short-Range': 2}
infilling_python
simplex_method
130
130
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' tableau[i] = [x / pivotDenom for x in tableau[i]]']
['', ' # Zero out the other entries in the pivot column', ' for k,row in enumerate(tableau):', ' if k != i:', ' pivotRowMultiple = [y * tableau[k][j] for y in tableau[i]]', ' tableau[k] = [x - y for x,y in zip(tableau[k], pivotRowMultiple)]', ' print("Tableau after pivot:")'...
[{'reason_category': 'Loop Body', 'usage_line': 130}, {'reason_category': 'List_Comprehension', 'usage_line': 130}]
Variable 'tableau' used at line 130 is defined at line 97 and has a Long-Range dependency. Variable 'i' used at line 130 is defined at line 126 and has a Short-Range dependency. Variable 'x' used at line 130 is part of a List_Comprehension defined at line 130 and has a Short-Range dependency. Variable 'pivotDenom' used...
{'Loop Body': 1, 'List_Comprehension': 1}
{'Variable Long-Range': 1, 'Variable Short-Range': 2, 'Variable List_Comprehension Short-Range': 1}
infilling_python
simplex_method
134
136
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' if k != i:', ' pivotRowMultiple = [y * tableau[k][j] for y in tableau[i]]', ' tableau[k] = [x - y for x,y in zip(tableau[k], pivotRowMultiple)]']
[' print("Tableau after pivot:")', ' for row in tableau:', ' print(row)', ' print()', ' ', ' # Transpose the tableau to make it easier to work with columns', ' columns = transpose(tableau)', '', ' # Identify pivot columns in the tableau. A column is a pivot column if it has a single 1 and...
[{'reason_category': 'Loop Body', 'usage_line': 134}, {'reason_category': 'If Condition', 'usage_line': 134}, {'reason_category': 'Loop Body', 'usage_line': 135}, {'reason_category': 'List_Comprehension', 'usage_line': 135}, {'reason_category': 'If Body', 'usage_line': 135}, {'reason_category': 'Loop Body', 'usage_line...
Variable 'k' used at line 134 is part of a Loop defined at line 133 and has a Short-Range dependency. Variable 'i' used at line 134 is defined at line 126 and has a Short-Range dependency. Variable 'y' used at line 135 is part of a List_Comprehension defined at line 135 and has a Short-Range dependency. Variable 'table...
{'Loop Body': 3, 'If Condition': 1, 'List_Comprehension': 2, 'If Body': 2}
{'Variable Loop Short-Range': 3, 'Variable Short-Range': 6, 'Variable List_Comprehension Short-Range': 3}
infilling_python
simplex_method
143
143
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' columns = transpose(tableau)']
['', ' # Identify pivot columns in the tableau. A column is a pivot column if it has a single 1 and the rest of its entries are 0.', ' indices = [j for j, col in enumerate(columns[:-1]) if isPivotCol(col)]', '', ' # Looking at the rightmost entry (the value part of the tableau row) of the row where the 1 in the p...
[]
Function 'transpose' used at line 143 is defined at line 11 and has a Long-Range dependency. Variable 'tableau' used at line 143 is defined at line 97 and has a Long-Range dependency.
{}
{'Function Long-Range': 1, 'Variable Long-Range': 1}
infilling_python
simplex_method
146
146
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' indices = [j for j, col in enumerate(columns[:-1]) if isPivotCol(col)]']
['', ' # Looking at the rightmost entry (the value part of the tableau row) of the row where the 1 in the pivot column is located.', ' primal_solution = [(colIndex, variableValueForPivotColumn(tableau, columns[colIndex])) for colIndex in indices]', ' ', ' # The last entry of the last row of the tableau gives us...
[{'reason_category': 'List_Comprehension', 'usage_line': 146}]
Variable 'j' used at line 146 is part of a List_Comprehension defined at line 146 and has a Short-Range dependency. Variable 'col' used at line 146 is part of a List_Comprehension defined at line 146 and has a Short-Range dependency. Variable 'columns' used at line 146 is defined at line 143 and has a Short-Range depen...
{'List_Comprehension': 1}
{'Variable List_Comprehension Short-Range': 2, 'Variable Short-Range': 1, 'Function Long-Range': 1}
infilling_python
simplex_method
149
149
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' primal_solution = [(colIndex, variableValueForPivotColumn(tableau, columns[colIndex])) for colIndex in indices]']
[' ', ' # The last entry of the last row of the tableau gives us the negation of the objective function value.', ' objective_value = -(tableau[-1][-1])', '', ' return tableau, primal_solution, objective_value']
[{'reason_category': 'List_Comprehension', 'usage_line': 149}]
Variable 'colIndex' used at line 149 is part of a List_Comprehension defined at line 149 and has a Short-Range dependency. Variable 'indices' used at line 149 is defined at line 146 and has a Short-Range dependency. Function 'variableValueForPivotColumn' used at line 149 is defined at line 19 and has a Long-Range depen...
{'List_Comprehension': 1}
{'Variable List_Comprehension Short-Range': 1, 'Variable Short-Range': 2, 'Function Long-Range': 1, 'Variable Long-Range': 1}
infilling_python
simplex_method
152
152
['import heapq', '# Calculate the dot product of two vectors', 'def dot(a,b):', ' return sum(x*y for x,y in zip(a,b))', '', '# Get a specific column from a 2D list (matrix)', 'def column(A, j):', ' return [row[j] for row in A]', '', '# Transpose a 2D list (matrix)', 'def transpose(A):', ' return [column(A, j) for...
[' objective_value = -(tableau[-1][-1])']
['', ' return tableau, primal_solution, objective_value']
[]
Variable 'tableau' used at line 152 is defined at line 97 and has a Long-Range dependency.
{}
{'Variable Long-Range': 1}
completion_python
Image_Filtering
17
22
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' np.linspace(-3*sigma_y, 3*sigma_y, size_y))', ' ', ' kernel = np.exp(-(x**2 / (2*sigma_x**2) + y**2 / (2*sigma_y**2)))', ' kernel /= 2 * np.pi * sigma_x * sigma_y', ' kernel /= kernel.sum()', ' return kernel']
['', 'def center_crop(image, target_size):', ' image = np.array(image)', ' h, w = image.shape[:2]', '', ' left = (w - target_size[0]) // 2', ' top = (h - target_size[1]) // 2', '', ' right = left + target_size[0]', ' bottom = top + target_size[1]', '', ' cropped_image = image[top:bottom, 0:right]',...
[]
Library 'np' used at line 17 is imported at line 1 and has a Medium-Range dependency. Variable 'sigma_y' used at line 17 is defined at line 10 and has a Short-Range dependency. Variable 'size_y' used at line 17 is defined at line 14 and has a Short-Range dependency. Library 'np' used at line 19 is imported at line 1 an...
{}
{'Library Medium-Range': 3, 'Variable Short-Range': 11}
completion_python
Image_Filtering
19
22
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' kernel = np.exp(-(x**2 / (2*sigma_x**2) + y**2 / (2*sigma_y**2)))', ' kernel /= 2 * np.pi * sigma_x * sigma_y', ' kernel /= kernel.sum()', ' return kernel']
['', 'def center_crop(image, target_size):', ' image = np.array(image)', ' h, w = image.shape[:2]', '', ' left = (w - target_size[0]) // 2', ' top = (h - target_size[1]) // 2', '', ' right = left + target_size[0]', ' bottom = top + target_size[1]', '', ' cropped_image = image[top:bottom, 0:right]',...
[]
Library 'np' used at line 19 is imported at line 1 and has a Medium-Range dependency. Variable 'x' used at line 19 is defined at line 16 and has a Short-Range dependency. Variable 'sigma_x' used at line 19 is defined at line 10 and has a Short-Range dependency. Variable 'y' used at line 19 is defined at line 16 and has...
{}
{'Library Medium-Range': 2, 'Variable Short-Range': 9}
completion_python
Image_Filtering
20
22
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' kernel /= 2 * np.pi * sigma_x * sigma_y', ' kernel /= kernel.sum()', ' return kernel']
['', 'def center_crop(image, target_size):', ' image = np.array(image)', ' h, w = image.shape[:2]', '', ' left = (w - target_size[0]) // 2', ' top = (h - target_size[1]) // 2', '', ' right = left + target_size[0]', ' bottom = top + target_size[1]', '', ' cropped_image = image[top:bottom, 0:right]',...
[]
Variable 'kernel' used at line 20 is defined at line 19 and has a Short-Range dependency. Library 'np' used at line 20 is imported at line 1 and has a Medium-Range dependency. Variable 'sigma_x' used at line 20 is defined at line 10 and has a Short-Range dependency. Variable 'sigma_y' used at line 20 is defined at line...
{}
{'Variable Short-Range': 5, 'Library Medium-Range': 1}
completion_python
Image_Filtering
21
22
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' kernel /= kernel.sum()', ' return kernel']
['', 'def center_crop(image, target_size):', ' image = np.array(image)', ' h, w = image.shape[:2]', '', ' left = (w - target_size[0]) // 2', ' top = (h - target_size[1]) // 2', '', ' right = left + target_size[0]', ' bottom = top + target_size[1]', '', ' cropped_image = image[top:bottom, 0:right]',...
[]
Variable 'kernel' used at line 21 is defined at line 20 and has a Short-Range dependency. Variable 'kernel' used at line 22 is defined at line 21 and has a Short-Range dependency.
{}
{'Variable Short-Range': 2}
completion_python
Image_Filtering
16
22
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' x, y = np.meshgrid(np.linspace(-3*sigma_x, 3*sigma_x, size_x),', ' np.linspace(-3*sigma_y, 3*sigma_y, size_y))', ' ', ' kernel = np.exp(-(x**2 / (2*sigma_x**2) + y**2 / (2*sigma_y**2)))', ' kernel /= 2 * np.pi * sigma_x * sigma_y', ' kernel /= kernel.sum()', ' return kernel']
['', 'def center_crop(image, target_size):', ' image = np.array(image)', ' h, w = image.shape[:2]', '', ' left = (w - target_size[0]) // 2', ' top = (h - target_size[1]) // 2', '', ' right = left + target_size[0]', ' bottom = top + target_size[1]', '', ' cropped_image = image[top:bottom, 0:right]',...
[]
Library 'np' used at line 16 is imported at line 1 and has a Medium-Range dependency. Variable 'sigma_x' used at line 16 is defined at line 10 and has a Short-Range dependency. Variable 'size_x' used at line 16 is defined at line 13 and has a Short-Range dependency. Library 'np' used at line 17 is imported at line 1 an...
{}
{'Library Medium-Range': 4, 'Variable Short-Range': 13}
completion_python
Image_Filtering
31
35
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' right = left + target_size[0]', ' bottom = top + target_size[1]', '', ' cropped_image = image[top:bottom, 0:right]', ' return cropped_image']
['', "img_a = cv2.imread('./marilyn.jpeg')", "img_b = cv2.imread('./einstein.jpeg')", '', '# Part1', '# Reshape to ensure images are same size by center cropping to image with smallest dimension', '# Convert img to grayscale ', 'smallest_dim = min(img_a.shape[0],img_a.shape[1],img_b.shape[1],img_b.shape[1])', 'img_a_gr...
[]
Variable 'left' used at line 31 is defined at line 28 and has a Short-Range dependency. Variable 'target_size' used at line 31 is defined at line 24 and has a Short-Range dependency. Variable 'top' used at line 32 is defined at line 29 and has a Short-Range dependency. Variable 'target_size' used at line 32 is defined ...
{}
{'Variable Short-Range': 9}
completion_python
Image_Filtering
25
35
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' image = np.array(image)', ' h, w = image.shape[:2]', '', ' left = (w - target_size[0]) // 2', ' top = (h - target_size[1]) // 2', '', ' right = left + target_size[0]', ' bottom = top + target_size[1]', '', ' cropped_image = image[top:bottom, 0:right]', ' return cropped_image']
['', "img_a = cv2.imread('./marilyn.jpeg')", "img_b = cv2.imread('./einstein.jpeg')", '', '# Part1', '# Reshape to ensure images are same size by center cropping to image with smallest dimension', '# Convert img to grayscale ', 'smallest_dim = min(img_a.shape[0],img_a.shape[1],img_b.shape[1],img_b.shape[1])', 'img_a_gr...
[]
Library 'np' used at line 25 is imported at line 1 and has a Medium-Range dependency. Variable 'image' used at line 25 is defined at line 24 and has a Short-Range dependency. Variable 'image' used at line 26 is defined at line 25 and has a Short-Range dependency. Variable 'w' used at line 28 is defined at line 26 and h...
{}
{'Library Medium-Range': 1, 'Variable Short-Range': 15}
completion_python
Image_Filtering
61
61
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
['blur_b = cv2.filter2D(img_b_gray, -1, gaussian_kernel_b)']
['', 'a_diff = img_a_gray - blur_a', 'img_c = blur_b + a_diff', 'print(img_c)', '', 'def downsample_image(image, factor):', ' if factor <= 0:', ' raise ValueError("Downsampling factor must be greater than 0.")', ' ', ' height, width = image.shape[:2]', ' new_height = height // factor', ' new_width...
[]
Library 'cv2' used at line 61 is imported at line 2 and has a Long-Range dependency. Variable 'img_b_gray' used at line 61 is defined at line 45 and has a Medium-Range dependency. Variable 'gaussian_kernel_b' used at line 61 is defined at line 58 and has a Short-Range dependency.
{}
{'Library Long-Range': 1, 'Variable Medium-Range': 1, 'Variable Short-Range': 1}
completion_python
Image_Filtering
76
76
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' downsampled_image = np.zeros((new_height, new_width, image.shape[2]), dtype=np.uint8)']
[' else:', ' downsampled_image = np.zeros((new_height, new_width), dtype=np.uint8)', '', ' for i in range(new_height):', ' for j in range(new_width):', ' downsampled_image[i, j] = image[i * factor, j * factor]', ' return downsampled_image', '', 'downsampling_factor = 4', 'downsampled_i...
[{'reason_category': 'If Body', 'usage_line': 76}]
Library 'np' used at line 76 is imported at line 1 and has a Long-Range dependency. Variable 'new_height' used at line 76 is defined at line 72 and has a Short-Range dependency. Variable 'new_width' used at line 76 is defined at line 73 and has a Short-Range dependency. Variable 'image' used at line 76 is defined at li...
{'If Body': 1}
{'Library Long-Range': 1, 'Variable Short-Range': 3}
completion_python
Image_Filtering
78
78
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' downsampled_image = np.zeros((new_height, new_width), dtype=np.uint8)']
['', ' for i in range(new_height):', ' for j in range(new_width):', ' downsampled_image[i, j] = image[i * factor, j * factor]', ' return downsampled_image', '', 'downsampling_factor = 4', 'downsampled_image = downsample_image(img_c, downsampling_factor)', 'print(np.array(downsampled_image))', ''...
[{'reason_category': 'Else Reasoning', 'usage_line': 78}]
Library 'np' used at line 78 is imported at line 1 and has a Long-Range dependency. Variable 'new_height' used at line 78 is defined at line 72 and has a Short-Range dependency. Variable 'new_width' used at line 78 is defined at line 73 and has a Short-Range dependency.
{'Else Reasoning': 1}
{'Library Long-Range': 1, 'Variable Short-Range': 2}
completion_python
Image_Filtering
82
82
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' downsampled_image[i, j] = image[i * factor, j * factor]']
[' return downsampled_image', '', 'downsampling_factor = 4', 'downsampled_image = downsample_image(img_c, downsampling_factor)', 'print(np.array(downsampled_image))', '', '# Part3', '# Computer fourier magnitude for the final image, original grayscale images, ', '# the blurred second image and difference between gra...
[{'reason_category': 'Loop Body', 'usage_line': 82}]
Variable 'downsampled_image' used at line 82 is defined at line 78 and has a Short-Range dependency. Variable 'i' used at line 82 is part of a Loop defined at line 80 and has a Short-Range dependency. Variable 'j' used at line 82 is part of a Loop defined at line 81 and has a Short-Range dependency. Variable 'image' us...
{'Loop Body': 1}
{'Variable Short-Range': 1, 'Variable Loop Short-Range': 2, 'Variable Medium-Range': 2}
completion_python
Image_Filtering
80
83
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' for i in range(new_height):', ' for j in range(new_width):', ' downsampled_image[i, j] = image[i * factor, j * factor]', ' return downsampled_image']
['', 'downsampling_factor = 4', 'downsampled_image = downsample_image(img_c, downsampling_factor)', 'print(np.array(downsampled_image))', '', '# Part3', '# Computer fourier magnitude for the final image, original grayscale images, ', '# the blurred second image and difference between grayscale first image and blurred f...
[{'reason_category': 'Define Stop Criteria', 'usage_line': 80}, {'reason_category': 'Define Stop Criteria', 'usage_line': 81}, {'reason_category': 'Loop Body', 'usage_line': 82}]
Variable 'new_height' used at line 80 is defined at line 72 and has a Short-Range dependency. Variable 'new_width' used at line 81 is defined at line 73 and has a Short-Range dependency. Variable 'downsampled_image' used at line 82 is defined at line 78 and has a Short-Range dependency. Variable 'i' used at line 82 is ...
{'Define Stop Criteria': 2, 'Loop Body': 1}
{'Variable Short-Range': 4, 'Variable Loop Short-Range': 2, 'Variable Medium-Range': 2}
completion_python
Image_Filtering
94
96
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' spectrum = np.abs(np.fft.fftshift(np.fft.fft2(image)))', ' log_spectrum = np.log(1 + spectrum)', ' return log_spectrum']
['', 'spectrum_A = compute_fourier_magnitude(img_a_gray)', 'spectrum_B = compute_fourier_magnitude(img_b_gray)', 'spectrum_blurred_B = compute_fourier_magnitude(blur_b)', 'spectrum_A_blur_A = compute_fourier_magnitude(a_diff)', 'spectrum_C = compute_fourier_magnitude(img_c)', 'print(spectrum_A)', 'print(spectrum_B)', '...
[]
Library 'np' used at line 94 is imported at line 1 and has a Long-Range dependency. Variable 'image' used at line 94 is defined at line 93 and has a Short-Range dependency. Library 'np' used at line 95 is imported at line 1 and has a Long-Range dependency. Variable 'spectrum' used at line 95 is defined at line 94 and h...
{}
{'Library Long-Range': 2, 'Variable Short-Range': 3}
completion_python
Image_Filtering
95
96
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' log_spectrum = np.log(1 + spectrum)', ' return log_spectrum']
['', 'spectrum_A = compute_fourier_magnitude(img_a_gray)', 'spectrum_B = compute_fourier_magnitude(img_b_gray)', 'spectrum_blurred_B = compute_fourier_magnitude(blur_b)', 'spectrum_A_blur_A = compute_fourier_magnitude(a_diff)', 'spectrum_C = compute_fourier_magnitude(img_c)', 'print(spectrum_A)', 'print(spectrum_B)', '...
[]
Library 'np' used at line 95 is imported at line 1 and has a Long-Range dependency. Variable 'spectrum' used at line 95 is defined at line 94 and has a Short-Range dependency. Variable 'log_spectrum' used at line 96 is defined at line 95 and has a Short-Range dependency.
{}
{'Library Long-Range': 1, 'Variable Short-Range': 2}
completion_python
Image_Filtering
119
120
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' G = cv2.pyrDown(G)', ' gpA.append(G)']
['', '# Gaussian pyramid for B', 'G = B.copy()', 'gpB = [G]', 'for i in range(6):', ' G = cv2.pyrDown(G)', ' gpB.append(G)', '', '# Laplacian Pyramid for A and B', 'lpA = [gpA[5]]', 'for i in range(5,0,-1):', ' GE = cv2.pyrUp(gpA[i])', ' L = cv2.subtract(gpA[i-1],GE)', ' lpA.append(L)', '', 'lpB = [gpB[5...
[{'reason_category': 'Loop Body', 'usage_line': 119}, {'reason_category': 'Loop Body', 'usage_line': 120}]
Library 'cv2' used at line 119 is imported at line 2 and has a Long-Range dependency. Variable 'G' used at line 119 is defined at line 116 and has a Short-Range dependency. Variable 'gpA' used at line 120 is defined at line 117 and has a Short-Range dependency. Variable 'G' used at line 120 is defined at line 119 and h...
{'Loop Body': 2}
{'Library Long-Range': 1, 'Variable Short-Range': 3}
completion_python
Image_Filtering
126
127
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' G = cv2.pyrDown(G)', ' gpB.append(G)']
['', '# Laplacian Pyramid for A and B', 'lpA = [gpA[5]]', 'for i in range(5,0,-1):', ' GE = cv2.pyrUp(gpA[i])', ' L = cv2.subtract(gpA[i-1],GE)', ' lpA.append(L)', '', 'lpB = [gpB[5]]', 'for i in range(5,0,-1):', ' GE = cv2.pyrUp(gpB[i])', ' L = cv2.subtract(gpB[i-1],GE)', ' lpB.append(L)', '', '# Add...
[{'reason_category': 'Loop Body', 'usage_line': 126}, {'reason_category': 'Loop Body', 'usage_line': 127}]
Library 'cv2' used at line 126 is imported at line 2 and has a Long-Range dependency. Variable 'G' used at line 126 is defined at line 123 and has a Short-Range dependency. Variable 'gpB' used at line 127 is defined at line 124 and has a Short-Range dependency. Variable 'G' used at line 127 is defined at line 126 and h...
{'Loop Body': 2}
{'Library Long-Range': 1, 'Variable Short-Range': 3}
completion_python
Image_Filtering
132
134
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' GE = cv2.pyrUp(gpA[i])', ' L = cv2.subtract(gpA[i-1],GE)', ' lpA.append(L)']
['', 'lpB = [gpB[5]]', 'for i in range(5,0,-1):', ' GE = cv2.pyrUp(gpB[i])', ' L = cv2.subtract(gpB[i-1],GE)', ' lpB.append(L)', '', '# Add left and right halves of images in each level', 'LS = []', 'for la,lb in zip(lpA,lpB):', ' rows,cols,dpt = la.shape', ' ls = np.hstack((la[:,0:cols//2], lb[:,cols//2...
[{'reason_category': 'Loop Body', 'usage_line': 132}, {'reason_category': 'Loop Body', 'usage_line': 133}, {'reason_category': 'Loop Body', 'usage_line': 134}]
Library 'cv2' used at line 132 is imported at line 2 and has a Long-Range dependency. Variable 'gpA' used at line 132 is defined at line 117 and has a Medium-Range dependency. Variable 'i' used at line 132 is part of a Loop defined at line 131 and has a Short-Range dependency. Library 'cv2' used at line 133 is imported...
{'Loop Body': 3}
{'Library Long-Range': 2, 'Variable Medium-Range': 2, 'Variable Loop Short-Range': 2, 'Variable Short-Range': 3}
completion_python
Image_Filtering
138
140
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' GE = cv2.pyrUp(gpB[i])', ' L = cv2.subtract(gpB[i-1],GE)', ' lpB.append(L)']
['', '# Add left and right halves of images in each level', 'LS = []', 'for la,lb in zip(lpA,lpB):', ' rows,cols,dpt = la.shape', ' ls = np.hstack((la[:,0:cols//2], lb[:,cols//2:]))', ' LS.append(ls)', '', '# Reconstruct', 'ls_ = LS[0]', 'for i in range(1,6):', ' ls_ = cv2.pyrUp(ls_)', ' ls_ = cv2.add(ls...
[{'reason_category': 'Loop Body', 'usage_line': 138}, {'reason_category': 'Loop Body', 'usage_line': 139}, {'reason_category': 'Loop Body', 'usage_line': 140}]
Library 'cv2' used at line 138 is imported at line 2 and has a Long-Range dependency. Variable 'gpB' used at line 138 is defined at line 124 and has a Medium-Range dependency. Variable 'i' used at line 138 is part of a Loop defined at line 137 and has a Short-Range dependency. Library 'cv2' used at line 139 is imported...
{'Loop Body': 3}
{'Library Long-Range': 2, 'Variable Medium-Range': 2, 'Variable Loop Short-Range': 2, 'Variable Short-Range': 3}
completion_python
Image_Filtering
145
147
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' rows,cols,dpt = la.shape', ' ls = np.hstack((la[:,0:cols//2], lb[:,cols//2:]))', ' LS.append(ls)']
['', '# Reconstruct', 'ls_ = LS[0]', 'for i in range(1,6):', ' ls_ = cv2.pyrUp(ls_)', ' ls_ = cv2.add(ls_, LS[i])', '', '# Image with direct connecting each half', 'real = np.hstack((A[:,:cols//2],B[:,cols//2:]))', '', 'blended_rgb = cv2.cvtColor(ls_, cv2.COLOR_BGR2RGB)', 'original_rgb = cv2.cvtColor(real, cv2.CO...
[{'reason_category': 'Loop Body', 'usage_line': 145}, {'reason_category': 'Loop Body', 'usage_line': 146}, {'reason_category': 'Loop Body', 'usage_line': 147}]
Variable 'la' used at line 145 is part of a Loop defined at line 144 and has a Short-Range dependency. Library 'np' used at line 146 is imported at line 1 and has a Long-Range dependency. Variable 'la' used at line 146 is part of a Loop defined at line 144 and has a Short-Range dependency. Variable 'cols' used at line ...
{'Loop Body': 3}
{'Variable Loop Short-Range': 3, 'Library Long-Range': 1, 'Variable Short-Range': 3}
completion_python
Image_Filtering
172
172
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' mask[i, max(0, i - strip_width // 2):min(width, i + strip_width // 2), :] = 1.0']
[' return mask', '', '# Now blend images using the diagonal mask', 'LS = []', 'mask = create_diagonal_mask(A.shape)', 'M = mask.copy()', 'gpmask = [M]', 'for i in range(5):', ' M = cv2.pyrDown(M)', ' gpmask.append(M)', 'gpmask.reverse()', 'for i in range(len(gpmask)):', ' rows, cols, dpt = lpA[i].shape', ' ...
[{'reason_category': 'Loop Body', 'usage_line': 172}]
Variable 'mask' used at line 172 is defined at line 169 and has a Short-Range dependency. Variable 'i' used at line 172 is part of a Loop defined at line 171 and has a Short-Range dependency. Variable 'strip_width' used at line 172 is defined at line 168 and has a Short-Range dependency. Variable 'width' used at line 1...
{'Loop Body': 1}
{'Variable Short-Range': 3, 'Variable Loop Short-Range': 1}
completion_python
Image_Filtering
169
173
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' mask = np.zeros(shape, dtype=np.float32)', ' height, width, _ = mask.shape', ' for i in range(min(height, width)):', ' mask[i, max(0, i - strip_width // 2):min(width, i + strip_width // 2), :] = 1.0', ' return mask']
['', '# Now blend images using the diagonal mask', 'LS = []', 'mask = create_diagonal_mask(A.shape)', 'M = mask.copy()', 'gpmask = [M]', 'for i in range(5):', ' M = cv2.pyrDown(M)', ' gpmask.append(M)', 'gpmask.reverse()', 'for i in range(len(gpmask)):', ' rows, cols, dpt = lpA[i].shape', ' ls = lpA[i] * gp...
[{'reason_category': 'Define Stop Criteria', 'usage_line': 171}, {'reason_category': 'Loop Body', 'usage_line': 172}]
Library 'np' used at line 169 is imported at line 1 and has a Long-Range dependency. Variable 'shape' used at line 169 is defined at line 168 and has a Short-Range dependency. Variable 'mask' used at line 170 is defined at line 169 and has a Short-Range dependency. Variable 'height' used at line 171 is defined at line ...
{'Define Stop Criteria': 1, 'Loop Body': 1}
{'Library Long-Range': 1, 'Variable Short-Range': 8, 'Variable Loop Short-Range': 1}
completion_python
Image_Filtering
181
182
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' M = cv2.pyrDown(M)', ' gpmask.append(M)']
['gpmask.reverse()', 'for i in range(len(gpmask)):', ' rows, cols, dpt = lpA[i].shape', ' ls = lpA[i] * gpmask[i] + lpB[i] * (1 - gpmask[i])', ' LS.append(ls)', '', '# Now reconstruct', 'ls_ = LS[0]', 'for i in range(1, 6):', ' ls_ = cv2.pyrUp(ls_)', ' ls_ = cv2.resize(ls_, (LS[i].shape[1], LS[i].shape[0...
[{'reason_category': 'Loop Body', 'usage_line': 181}, {'reason_category': 'Loop Body', 'usage_line': 182}]
Library 'cv2' used at line 181 is imported at line 2 and has a Long-Range dependency. Variable 'M' used at line 181 is defined at line 178 and has a Short-Range dependency. Variable 'gpmask' used at line 182 is defined at line 179 and has a Short-Range dependency. Variable 'M' used at line 182 is defined at line 181 an...
{'Loop Body': 2}
{'Library Long-Range': 1, 'Variable Short-Range': 3}
completion_python
Image_Filtering
185
187
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' rows, cols, dpt = lpA[i].shape', ' ls = lpA[i] * gpmask[i] + lpB[i] * (1 - gpmask[i])', ' LS.append(ls)']
['', '# Now reconstruct', 'ls_ = LS[0]', 'for i in range(1, 6):', ' ls_ = cv2.pyrUp(ls_)', ' ls_ = cv2.resize(ls_, (LS[i].shape[1], LS[i].shape[0])) ', ' ls_ = cv2.add(ls_, LS[i])', '', '# Image with direct connecting each diagonal half', 'real = np.hstack((A[:, :cols//2], B[:, cols//2:]))', 'ls_rgb = cv2.cvtC...
[{'reason_category': 'Loop Body', 'usage_line': 185}, {'reason_category': 'Loop Body', 'usage_line': 186}, {'reason_category': 'Loop Body', 'usage_line': 187}]
Variable 'lpA' used at line 185 is defined at line 130 and has a Long-Range dependency. Variable 'i' used at line 185 is part of a Loop defined at line 184 and has a Short-Range dependency. Variable 'lpA' used at line 186 is defined at line 130 and has a Long-Range dependency. Variable 'i' used at line 186 is part of a...
{'Loop Body': 3}
{'Variable Long-Range': 3, 'Variable Loop Short-Range': 2, 'Variable Short-Range': 2, 'Variable Medium-Range': 1}
completion_python
Image_Filtering
192
194
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' ls_ = cv2.pyrUp(ls_)', ' ls_ = cv2.resize(ls_, (LS[i].shape[1], LS[i].shape[0])) ', ' ls_ = cv2.add(ls_, LS[i])']
['', '# Image with direct connecting each diagonal half', 'real = np.hstack((A[:, :cols//2], B[:, cols//2:]))', 'ls_rgb = cv2.cvtColor(ls_.astype(np.uint8), cv2.COLOR_BGR2RGB)', 'real_rgb = cv2.cvtColor(real, cv2.COLOR_BGR2RGB)', '', 'print(ls_rgb)', 'print(real_rgb)', 'print(mask)', '', '', '# Task3', '# Part1', '# Re...
[{'reason_category': 'Loop Body', 'usage_line': 192}, {'reason_category': 'Loop Body', 'usage_line': 193}, {'reason_category': 'Loop Body', 'usage_line': 194}]
Library 'cv2' used at line 192 is imported at line 2 and has a Long-Range dependency. Variable 'ls_' used at line 192 is defined at line 190 and has a Short-Range dependency. Library 'cv2' used at line 193 is imported at line 2 and has a Long-Range dependency. Variable 'ls_' used at line 193 is defined at line 192 and ...
{'Loop Body': 3}
{'Library Long-Range': 3, 'Variable Short-Range': 3, 'Variable Medium-Range': 2, 'Variable Loop Short-Range': 2}
completion_python
Image_Filtering
220
221
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)', ' frames.append(frame)']
['', ' cap.release()', ' # Converts to numpy array(T,H,W,C)', ' video = np.stack(frames, axis=0)', ' # (T,H,W,C)->(H,W,C,T)', ' video = np.transpose(video, (1,2,3,0))', ' return frames', '', 'def bandpass_filter(signal, low_cutoff, high_cutoff, fs, order):', ' nyquist = 0.5 * fs', ' low = low_cu...
[{'reason_category': 'Loop Body', 'usage_line': 220}, {'reason_category': 'Loop Body', 'usage_line': 221}]
Library 'cv2' used at line 220 is imported at line 2 and has a Long-Range dependency. Variable 'frame' used at line 220 is defined at line 214 and has a Short-Range dependency. Variable 'frames' used at line 221 is defined at line 212 and has a Short-Range dependency. Variable 'frame' used at line 221 is defined at lin...
{'Loop Body': 2}
{'Library Long-Range': 1, 'Variable Short-Range': 3}
completion_python
Image_Filtering
231
236
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' nyquist = 0.5 * fs', ' low = low_cutoff / nyquist', ' high = high_cutoff / nyquist', " b, a = butter(order, [low, high], btype='band')", ' filtered_signal = filtfilt(b, a, signal)', ' return filtered_signal']
['', "alice = './alice.avi'", 'video_frames = read_video_into_numpy(alice)', 'first_frame = video_frames[0]', '', '# Specify regions of interest', 'cheek_rect = [(220, 250), (320, 350)]', 'forehead_rect = [(220, 10), (500, 174)]', 'cheek_roi = first_frame[cheek_rect[0][1]:cheek_rect[1][1], cheek_rect[0][0]:cheek_rect[1...
[]
Variable 'fs' used at line 231 is defined at line 230 and has a Short-Range dependency. Variable 'low_cutoff' used at line 232 is defined at line 230 and has a Short-Range dependency. Variable 'nyquist' used at line 232 is defined at line 231 and has a Short-Range dependency. Variable 'high_cutoff' used at line 233 is ...
{}
{'Variable Short-Range': 12, 'Library Long-Range': 2}
completion_python
Image_Filtering
235
236
['import numpy as np', 'import cv2', 'import matplotlib.pyplot as plt', 'from scipy.signal import convolve2d', 'from scipy.signal import butter, filtfilt', '', '# Task1', '# Gaussian blurring einstein monroe illusion', 'def gaussian2D(sigma, kernel_size):', ' sigma_x, sigma_y = sigma', ' size_x, size_y = kernel_s...
[' filtered_signal = filtfilt(b, a, signal)', ' return filtered_signal']
['', "alice = './alice.avi'", 'video_frames = read_video_into_numpy(alice)', 'first_frame = video_frames[0]', '', '# Specify regions of interest', 'cheek_rect = [(220, 250), (320, 350)]', 'forehead_rect = [(220, 10), (500, 174)]', 'cheek_roi = first_frame[cheek_rect[0][1]:cheek_rect[1][1], cheek_rect[0][0]:cheek_rect[1...
[]
Library 'filtfilt' used at line 235 is imported at line 5 and has a Long-Range dependency. Variable 'b' used at line 235 is defined at line 234 and has a Short-Range dependency. Variable 'a' used at line 235 is defined at line 234 and has a Short-Range dependency. Variable 'signal' used at line 235 is defined at line 2...
{}
{'Library Long-Range': 1, 'Variable Short-Range': 4}
completion_python
Image_Transformation
29
36
['from PIL import Image', 'import cv2', 'import numpy as np', 'import matplotlib.pyplot as plt', '', '#Task 1:', '#resize two imgs', '#resize imgA with cv2.resize', '#resize imgB via center cropping', '#ensure both resized images are resized to same end_size', '#concatenate the resized imgs via every other row imgA and...
[' x_start = int((img_array.shape[0]-end_size)/2)', ' x_end = x_start + end_size', '', ' y_start = int((img_array.shape[1]-end_size)/2)', ' y_end = y_start + end_size', '', ' img_resized = img_array[x_start:x_end, y_start:y_end, :]', ' return img_resized']
['B_resized = center_crop(B_array, end_size)', 'print(B_resized.shape)', 'C = np.concatenate((A_resized[0:256,0:128,:],B_resized[0:256,128:256,:]),axis = 1)', '', 'D = B_resized[0:1,:,:]', 'for row in range(1,A_resized.shape[0]):', ' if row % 2 == 0:', ' D = np.concatenate((D,B_resized[row:row+1,:,:]), axis=0...
[]
Variable 'img_array' used at line 29 is defined at line 28 and has a Short-Range dependency. Variable 'end_size' used at line 29 is defined at line 28 and has a Short-Range dependency. Variable 'x_start' used at line 30 is defined at line 29 and has a Short-Range dependency. Variable 'end_size' used at line 30 is defin...
{}
{'Variable Short-Range': 14}
completion_python
Image_Transformation
32
36
['from PIL import Image', 'import cv2', 'import numpy as np', 'import matplotlib.pyplot as plt', '', '#Task 1:', '#resize two imgs', '#resize imgA with cv2.resize', '#resize imgB via center cropping', '#ensure both resized images are resized to same end_size', '#concatenate the resized imgs via every other row imgA and...
[' y_start = int((img_array.shape[1]-end_size)/2)', ' y_end = y_start + end_size', '', ' img_resized = img_array[x_start:x_end, y_start:y_end, :]', ' return img_resized']
['B_resized = center_crop(B_array, end_size)', 'print(B_resized.shape)', 'C = np.concatenate((A_resized[0:256,0:128,:],B_resized[0:256,128:256,:]),axis = 1)', '', 'D = B_resized[0:1,:,:]', 'for row in range(1,A_resized.shape[0]):', ' if row % 2 == 0:', ' D = np.concatenate((D,B_resized[row:row+1,:,:]), axis=0...
[]
Variable 'img_array' used at line 32 is defined at line 28 and has a Short-Range dependency. Variable 'end_size' used at line 32 is defined at line 28 and has a Short-Range dependency. Variable 'y_start' used at line 33 is defined at line 32 and has a Short-Range dependency. Variable 'end_size' used at line 33 is defin...
{}
{'Variable Short-Range': 10}
completion_python
Image_Transformation
35
36
['from PIL import Image', 'import cv2', 'import numpy as np', 'import matplotlib.pyplot as plt', '', '#Task 1:', '#resize two imgs', '#resize imgA with cv2.resize', '#resize imgB via center cropping', '#ensure both resized images are resized to same end_size', '#concatenate the resized imgs via every other row imgA and...
[' img_resized = img_array[x_start:x_end, y_start:y_end, :]', ' return img_resized']
['B_resized = center_crop(B_array, end_size)', 'print(B_resized.shape)', 'C = np.concatenate((A_resized[0:256,0:128,:],B_resized[0:256,128:256,:]),axis = 1)', '', 'D = B_resized[0:1,:,:]', 'for row in range(1,A_resized.shape[0]):', ' if row % 2 == 0:', ' D = np.concatenate((D,B_resized[row:row+1,:,:]), axis=0...
[]
Variable 'img_array' used at line 35 is defined at line 28 and has a Short-Range dependency. Variable 'x_start' used at line 35 is defined at line 29 and has a Short-Range dependency. Variable 'x_end' used at line 35 is defined at line 30 and has a Short-Range dependency. Variable 'y_start' used at line 35 is defined a...
{}
{'Variable Short-Range': 6}
completion_python
Image_Transformation
44
44
['from PIL import Image', 'import cv2', 'import numpy as np', 'import matplotlib.pyplot as plt', '', '#Task 1:', '#resize two imgs', '#resize imgA with cv2.resize', '#resize imgB via center cropping', '#ensure both resized images are resized to same end_size', '#concatenate the resized imgs via every other row imgA and...
[' D = np.concatenate((D,B_resized[row:row+1,:,:]), axis=0)']
[' else:', ' D = np.concatenate((D,A_resized[row:row+1,:,:]), axis =0)', 'print(D)', '', '#Task 2:', '#upload picture of multiple peppers each different colors', '#create a mask without the yellow peppers by using range provided', '#do this in rgb and hsv -> note different ranges depending on rgb or hsv', "pe...
[{'reason_category': 'If Body', 'usage_line': 44}, {'reason_category': 'Loop Body', 'usage_line': 44}]
Library 'np' used at line 44 is imported at line 3 and has a Long-Range dependency. Variable 'B_resized' used at line 44 is defined at line 37 and has a Short-Range dependency. Variable 'row' used at line 44 is part of a Loop defined at line 42 and has a Short-Range dependency.
{'If Body': 1, 'Loop Body': 1}
{'Library Long-Range': 1, 'Variable Short-Range': 1, 'Variable Loop Short-Range': 1}
completion_python
Image_Transformation
46
46
['from PIL import Image', 'import cv2', 'import numpy as np', 'import matplotlib.pyplot as plt', '', '#Task 1:', '#resize two imgs', '#resize imgA with cv2.resize', '#resize imgB via center cropping', '#ensure both resized images are resized to same end_size', '#concatenate the resized imgs via every other row imgA and...
[' D = np.concatenate((D,A_resized[row:row+1,:,:]), axis =0)']
['print(D)', '', '#Task 2:', '#upload picture of multiple peppers each different colors', '#create a mask without the yellow peppers by using range provided', '#do this in rgb and hsv -> note different ranges depending on rgb or hsv', "pepper_img = Image.open('./pepper.png')", 'pepper = np.array(pepper_img)', '', 'lowe...
[{'reason_category': 'Loop Body', 'usage_line': 46}, {'reason_category': 'Else Reasoning', 'usage_line': 46}]
Library 'np' used at line 46 is imported at line 3 and has a Long-Range dependency. Variable 'A_resized' used at line 46 is defined at line 26 and has a Medium-Range dependency. Variable 'row' used at line 46 is part of a Loop defined at line 42 and has a Short-Range dependency.
{'Loop Body': 1, 'Else Reasoning': 1}
{'Library Long-Range': 1, 'Variable Medium-Range': 1, 'Variable Loop Short-Range': 1}
completion_python
Image_Transformation
43
46
['from PIL import Image', 'import cv2', 'import numpy as np', 'import matplotlib.pyplot as plt', '', '#Task 1:', '#resize two imgs', '#resize imgA with cv2.resize', '#resize imgB via center cropping', '#ensure both resized images are resized to same end_size', '#concatenate the resized imgs via every other row imgA and...
[' if row % 2 == 0:', ' D = np.concatenate((D,B_resized[row:row+1,:,:]), axis=0)', ' else:', ' D = np.concatenate((D,A_resized[row:row+1,:,:]), axis =0)']
['print(D)', '', '#Task 2:', '#upload picture of multiple peppers each different colors', '#create a mask without the yellow peppers by using range provided', '#do this in rgb and hsv -> note different ranges depending on rgb or hsv', "pepper_img = Image.open('./pepper.png')", 'pepper = np.array(pepper_img)', '', 'lowe...
[{'reason_category': 'Loop Body', 'usage_line': 43}, {'reason_category': 'If Condition', 'usage_line': 43}, {'reason_category': 'If Body', 'usage_line': 44}, {'reason_category': 'Loop Body', 'usage_line': 44}, {'reason_category': 'Loop Body', 'usage_line': 45}, {'reason_category': 'Else Reasoning', 'usage_line': 45}, {...
Variable 'row' used at line 43 is part of a Loop defined at line 42 and has a Short-Range dependency. Library 'np' used at line 44 is imported at line 3 and has a Long-Range dependency. Variable 'B_resized' used at line 44 is defined at line 37 and has a Short-Range dependency. Variable 'row' used at line 44 is part of...
{'Loop Body': 4, 'If Condition': 1, 'If Body': 1, 'Else Reasoning': 2}
{'Variable Loop Short-Range': 3, 'Library Long-Range': 2, 'Variable Short-Range': 1, 'Variable Medium-Range': 1}
completion_python
Image_Transformation
83
84
['from PIL import Image', 'import cv2', 'import numpy as np', 'import matplotlib.pyplot as plt', '', '#Task 1:', '#resize two imgs', '#resize imgA with cv2.resize', '#resize imgB via center cropping', '#ensure both resized images are resized to same end_size', '#concatenate the resized imgs via every other row imgA and...
[' translation_matrix = np.array([[1,0,dx],[0,1,dy],[0,0,1]])', ' return translation_matrix']
['', 'def rotation(angle,radians = True):', ' if radians == False:', ' angle = np.radians(angle)', ' costheta = np.cos(angle)', ' sintheta = np.sin(angle)', ' rotation_matrix = np.array([[costheta, sintheta,0],[-1*sintheta,costheta,0],[0,0,1]])', ' return rotation_matrix', '', 'def similarity_matr...
[]
Library 'np' used at line 83 is imported at line 3 and has a Long-Range dependency. Variable 'dx' used at line 83 is defined at line 82 and has a Short-Range dependency. Variable 'dy' used at line 83 is defined at line 82 and has a Short-Range dependency. Variable 'translation_matrix' used at line 84 is defined at line...
{}
{'Library Long-Range': 1, 'Variable Short-Range': 3}
completion_python
Image_Transformation
88
88
['from PIL import Image', 'import cv2', 'import numpy as np', 'import matplotlib.pyplot as plt', '', '#Task 1:', '#resize two imgs', '#resize imgA with cv2.resize', '#resize imgB via center cropping', '#ensure both resized images are resized to same end_size', '#concatenate the resized imgs via every other row imgA and...
[' angle = np.radians(angle)']
[' costheta = np.cos(angle)', ' sintheta = np.sin(angle)', ' rotation_matrix = np.array([[costheta, sintheta,0],[-1*sintheta,costheta,0],[0,0,1]])', ' return rotation_matrix', '', 'def similarity_matrix(angle, dx, dy, scale_factor,radians=True):', ' if radians == False:', ' angle = np.radians(angl...
[{'reason_category': 'If Body', 'usage_line': 88}]
Library 'np' used at line 88 is imported at line 3 and has a Long-Range dependency.
{'If Body': 1}
{'Library Long-Range': 1}
completion_python
Image_Transformation
87
92
['from PIL import Image', 'import cv2', 'import numpy as np', 'import matplotlib.pyplot as plt', '', '#Task 1:', '#resize two imgs', '#resize imgA with cv2.resize', '#resize imgB via center cropping', '#ensure both resized images are resized to same end_size', '#concatenate the resized imgs via every other row imgA and...
[' if radians == False:', ' angle = np.radians(angle)', ' costheta = np.cos(angle)', ' sintheta = np.sin(angle)', ' rotation_matrix = np.array([[costheta, sintheta,0],[-1*sintheta,costheta,0],[0,0,1]])', ' return rotation_matrix']
['', 'def similarity_matrix(angle, dx, dy, scale_factor,radians=True):', ' if radians == False:', ' angle = np.radians(angle)', ' costheta = np.cos(angle)', ' sintheta = np.sin(angle)', '', ' similarity_matrix = np.array([[scale_factor*costheta,scale_factor*sintheta,dx],', ' ...
[{'reason_category': 'If Condition', 'usage_line': 87}, {'reason_category': 'If Body', 'usage_line': 88}]
Variable 'radians' used at line 87 is defined at line 86 and has a Short-Range dependency. Library 'np' used at line 88 is imported at line 3 and has a Long-Range dependency. Library 'np' used at line 89 is imported at line 3 and has a Long-Range dependency. Variable 'angle' used at line 89 is defined at line 88 and ha...
{'If Condition': 1, 'If Body': 1}
{'Variable Short-Range': 6, 'Library Long-Range': 4}
completion_python
Image_Transformation
96
96
['from PIL import Image', 'import cv2', 'import numpy as np', 'import matplotlib.pyplot as plt', '', '#Task 1:', '#resize two imgs', '#resize imgA with cv2.resize', '#resize imgB via center cropping', '#ensure both resized images are resized to same end_size', '#concatenate the resized imgs via every other row imgA and...
[' angle = np.radians(angle)']
[' costheta = np.cos(angle)', ' sintheta = np.sin(angle)', '', ' similarity_matrix = np.array([[scale_factor*costheta,scale_factor*sintheta,dx],', ' [-1*scale_factor*sintheta, scale_factor*costheta, dy],', ' [0,0,1]])', ' return similarity_matrix...
[{'reason_category': 'If Body', 'usage_line': 96}]
Library 'np' used at line 96 is imported at line 3 and has a Long-Range dependency.
{'If Body': 1}
{'Library Long-Range': 1}
completion_python
Image_Transformation
95
103
['from PIL import Image', 'import cv2', 'import numpy as np', 'import matplotlib.pyplot as plt', '', '#Task 1:', '#resize two imgs', '#resize imgA with cv2.resize', '#resize imgB via center cropping', '#ensure both resized images are resized to same end_size', '#concatenate the resized imgs via every other row imgA and...
[' if radians == False:', ' angle = np.radians(angle)', ' costheta = np.cos(angle)', ' sintheta = np.sin(angle)', '', ' similarity_matrix = np.array([[scale_factor*costheta,scale_factor*sintheta,dx],', ' [-1*scale_factor*sintheta, scale_factor*costheta, dy],', ' ...
['', 'def affine(angle, x, y, scale, ax, ay):', ' scaling = np.array([[scale, 0,0], [0, scale, 0], [0,0,1]])', ' shear = np.array([[1, ax, 0], [ay, 1,0], [0, 0,1]])', ' result = np.array([[0,0,0], [0,0,0], [0,0,0]])', ' result = np.dot(translation(x, y), rotation(angle))', ' result = np.dot(result, scali...
[{'reason_category': 'If Condition', 'usage_line': 95}, {'reason_category': 'If Body', 'usage_line': 96}]
Variable 'radians' used at line 95 is defined at line 94 and has a Short-Range dependency. Library 'np' used at line 96 is imported at line 3 and has a Long-Range dependency. Library 'np' used at line 97 is imported at line 3 and has a Long-Range dependency. Variable 'angle' used at line 97 is defined at line 94 and ha...
{'If Condition': 1, 'If Body': 1}
{'Variable Short-Range': 12, 'Library Long-Range': 4}
completion_python
Image_Transformation
100
103
['from PIL import Image', 'import cv2', 'import numpy as np', 'import matplotlib.pyplot as plt', '', '#Task 1:', '#resize two imgs', '#resize imgA with cv2.resize', '#resize imgB via center cropping', '#ensure both resized images are resized to same end_size', '#concatenate the resized imgs via every other row imgA and...
[' similarity_matrix = np.array([[scale_factor*costheta,scale_factor*sintheta,dx],', ' [-1*scale_factor*sintheta, scale_factor*costheta, dy],', ' [0,0,1]])', ' return similarity_matrix']
['', 'def affine(angle, x, y, scale, ax, ay):', ' scaling = np.array([[scale, 0,0], [0, scale, 0], [0,0,1]])', ' shear = np.array([[1, ax, 0], [ay, 1,0], [0, 0,1]])', ' result = np.array([[0,0,0], [0,0,0], [0,0,0]])', ' result = np.dot(translation(x, y), rotation(angle))', ' result = np.dot(result, scali...
[]
Library 'np' used at line 100 is imported at line 3 and has a Long-Range dependency. Variable 'scale_factor' used at line 100 is defined at line 94 and has a Short-Range dependency. Variable 'costheta' used at line 100 is defined at line 97 and has a Short-Range dependency. Variable 'sintheta' used at line 100 is defin...
{}
{'Library Long-Range': 1, 'Variable Short-Range': 9}
completion_python
Image_Transformation
106
112
['from PIL import Image', 'import cv2', 'import numpy as np', 'import matplotlib.pyplot as plt', '', '#Task 1:', '#resize two imgs', '#resize imgA with cv2.resize', '#resize imgB via center cropping', '#ensure both resized images are resized to same end_size', '#concatenate the resized imgs via every other row imgA and...
[' scaling = np.array([[scale, 0,0], [0, scale, 0], [0,0,1]])', ' shear = np.array([[1, ax, 0], [ay, 1,0], [0, 0,1]])', ' result = np.array([[0,0,0], [0,0,0], [0,0,0]])', ' result = np.dot(translation(x, y), rotation(angle))', ' result = np.dot(result, scaling)', ' result = np.dot(result, shear)', ' ...
['', 'def bilinear_interpolation(image,x,y):', ' x1 = int(x)', ' x2 = x1 + 1', ' y1 = int(y)', ' y2 = y1 + 1', '', ' if x1 < 0 or y1 < 0 or x2 >= image.shape[1] or y2 >= image.shape[0]:', ' return 0', ' else:', ' f11 = image[y1][x1]', ' f12 = image[y1][x2]', ' f21 = image[y...
[]
Library 'np' used at line 106 is imported at line 3 and has a Long-Range dependency. Variable 'scale' used at line 106 is defined at line 105 and has a Short-Range dependency. Library 'np' used at line 107 is imported at line 3 and has a Long-Range dependency. Variable 'ax' used at line 107 is defined at line 105 and h...
{}
{'Library Long-Range': 6, 'Variable Short-Range': 11, 'Function Medium-Range': 2}
completion_python
Image_Transformation
109
112
['from PIL import Image', 'import cv2', 'import numpy as np', 'import matplotlib.pyplot as plt', '', '#Task 1:', '#resize two imgs', '#resize imgA with cv2.resize', '#resize imgB via center cropping', '#ensure both resized images are resized to same end_size', '#concatenate the resized imgs via every other row imgA and...
[' result = np.dot(translation(x, y), rotation(angle))', ' result = np.dot(result, scaling)', ' result = np.dot(result, shear)', ' return result']
['', 'def bilinear_interpolation(image,x,y):', ' x1 = int(x)', ' x2 = x1 + 1', ' y1 = int(y)', ' y2 = y1 + 1', '', ' if x1 < 0 or y1 < 0 or x2 >= image.shape[1] or y2 >= image.shape[0]:', ' return 0', ' else:', ' f11 = image[y1][x1]', ' f12 = image[y1][x2]', ' f21 = image[y...
[]
Library 'np' used at line 109 is imported at line 3 and has a Long-Range dependency. Function 'translation' used at line 109 is defined at line 82 and has a Medium-Range dependency. Variable 'x' used at line 109 is defined at line 105 and has a Short-Range dependency. Variable 'y' used at line 109 is defined at line 10...
{}
{'Library Long-Range': 3, 'Function Medium-Range': 2, 'Variable Short-Range': 8}
completion_python
Image_Transformation
110
112
['from PIL import Image', 'import cv2', 'import numpy as np', 'import matplotlib.pyplot as plt', '', '#Task 1:', '#resize two imgs', '#resize imgA with cv2.resize', '#resize imgB via center cropping', '#ensure both resized images are resized to same end_size', '#concatenate the resized imgs via every other row imgA and...
[' result = np.dot(result, scaling)', ' result = np.dot(result, shear)', ' return result']
['', 'def bilinear_interpolation(image,x,y):', ' x1 = int(x)', ' x2 = x1 + 1', ' y1 = int(y)', ' y2 = y1 + 1', '', ' if x1 < 0 or y1 < 0 or x2 >= image.shape[1] or y2 >= image.shape[0]:', ' return 0', ' else:', ' f11 = image[y1][x1]', ' f12 = image[y1][x2]', ' f21 = image[y...
[]
Library 'np' used at line 110 is imported at line 3 and has a Long-Range dependency. Variable 'scaling' used at line 110 is defined at line 106 and has a Short-Range dependency. Variable 'result' used at line 110 is defined at line 109 and has a Short-Range dependency. Library 'np' used at line 111 is imported at line ...
{}
{'Library Long-Range': 2, 'Variable Short-Range': 5}
completion_python
Image_Transformation
121
121
['from PIL import Image', 'import cv2', 'import numpy as np', 'import matplotlib.pyplot as plt', '', '#Task 1:', '#resize two imgs', '#resize imgA with cv2.resize', '#resize imgB via center cropping', '#ensure both resized images are resized to same end_size', '#concatenate the resized imgs via every other row imgA and...
[' return 0']
[' else:', ' f11 = image[y1][x1]', ' f12 = image[y1][x2]', ' f21 = image[y2][x1]', ' f22 = image[y2][x2]', '', ' w1 = (x2-x)*(y2-y)', ' w2 = (x-x1)*(y2-y)', ' w3 = (x2-x)*(y-y1)', ' w4 = (x-x1)*(y-y1)', '', ' return (w1*f11) + (w2*f12) + (w3*f21) + (w4*f22)'...
[{'reason_category': 'If Body', 'usage_line': 121}]
null
{'If Body': 1}
null
completion_python
Image_Transformation
123
131
['from PIL import Image', 'import cv2', 'import numpy as np', 'import matplotlib.pyplot as plt', '', '#Task 1:', '#resize two imgs', '#resize imgA with cv2.resize', '#resize imgB via center cropping', '#ensure both resized images are resized to same end_size', '#concatenate the resized imgs via every other row imgA and...
[' f11 = image[y1][x1]', ' f12 = image[y1][x2]', ' f21 = image[y2][x1]', ' f22 = image[y2][x2]', '', ' w1 = (x2-x)*(y2-y)', ' w2 = (x-x1)*(y2-y)', ' w3 = (x2-x)*(y-y1)', ' w4 = (x-x1)*(y-y1)']
['', ' return (w1*f11) + (w2*f12) + (w3*f21) + (w4*f22)', '', 'def image_warp(I,T):', ' rows,cols = I.shape[:2]', ' output = np.zeros((rows,cols,3))', ' center = (cols/2, rows/2)', ' T_invert = np.linalg.inv(T)', '', ' for i in range(rows):', ' for j in range(cols):', ' shift_center ...
[{'reason_category': 'Else Reasoning', 'usage_line': 123}, {'reason_category': 'Else Reasoning', 'usage_line': 124}, {'reason_category': 'Else Reasoning', 'usage_line': 125}, {'reason_category': 'Else Reasoning', 'usage_line': 126}, {'reason_category': 'Else Reasoning', 'usage_line': 127}, {'reason_category': 'Else Rea...
Variable 'image' used at line 123 is defined at line 114 and has a Short-Range dependency. Variable 'y1' used at line 123 is defined at line 117 and has a Short-Range dependency. Variable 'x1' used at line 123 is defined at line 115 and has a Short-Range dependency. Variable 'image' used at line 124 is defined at line ...
{'Else Reasoning': 9}
{'Variable Short-Range': 11, 'Variable Medium-Range': 17}
completion_python
Image_Transformation
115
133
['from PIL import Image', 'import cv2', 'import numpy as np', 'import matplotlib.pyplot as plt', '', '#Task 1:', '#resize two imgs', '#resize imgA with cv2.resize', '#resize imgB via center cropping', '#ensure both resized images are resized to same end_size', '#concatenate the resized imgs via every other row imgA and...
[' x1 = int(x)', ' x2 = x1 + 1', ' y1 = int(y)', ' y2 = y1 + 1', '', ' if x1 < 0 or y1 < 0 or x2 >= image.shape[1] or y2 >= image.shape[0]:', ' return 0', ' else:', ' f11 = image[y1][x1]', ' f12 = image[y1][x2]', ' f21 = image[y2][x1]', ' f22 = image[y2][x2]', '', ' ...
['', 'def image_warp(I,T):', ' rows,cols = I.shape[:2]', ' output = np.zeros((rows,cols,3))', ' center = (cols/2, rows/2)', ' T_invert = np.linalg.inv(T)', '', ' for i in range(rows):', ' for j in range(cols):', ' shift_center = np.array([j-center[0],i -center[1],1])', ' coor...
[{'reason_category': 'If Condition', 'usage_line': 120}, {'reason_category': 'If Body', 'usage_line': 121}, {'reason_category': 'Else Reasoning', 'usage_line': 122}, {'reason_category': 'Else Reasoning', 'usage_line': 123}, {'reason_category': 'Else Reasoning', 'usage_line': 124}, {'reason_category': 'Else Reasoning', ...
Variable 'x' used at line 115 is defined at line 114 and has a Short-Range dependency. Variable 'x1' used at line 116 is defined at line 115 and has a Short-Range dependency. Variable 'y' used at line 117 is defined at line 114 and has a Short-Range dependency. Variable 'y1' used at line 118 is defined at line 117 and ...
{'If Condition': 1, 'If Body': 1, 'Else Reasoning': 10}
{'Variable Short-Range': 28, 'Variable Medium-Range': 17}
completion_python
Image_Transformation
120
133
['from PIL import Image', 'import cv2', 'import numpy as np', 'import matplotlib.pyplot as plt', '', '#Task 1:', '#resize two imgs', '#resize imgA with cv2.resize', '#resize imgB via center cropping', '#ensure both resized images are resized to same end_size', '#concatenate the resized imgs via every other row imgA and...
[' if x1 < 0 or y1 < 0 or x2 >= image.shape[1] or y2 >= image.shape[0]:', ' return 0', ' else:', ' f11 = image[y1][x1]', ' f12 = image[y1][x2]', ' f21 = image[y2][x1]', ' f22 = image[y2][x2]', '', ' w1 = (x2-x)*(y2-y)', ' w2 = (x-x1)*(y2-y)', ' w3 = (x2-x)*(...
['', 'def image_warp(I,T):', ' rows,cols = I.shape[:2]', ' output = np.zeros((rows,cols,3))', ' center = (cols/2, rows/2)', ' T_invert = np.linalg.inv(T)', '', ' for i in range(rows):', ' for j in range(cols):', ' shift_center = np.array([j-center[0],i -center[1],1])', ' coor...
[{'reason_category': 'If Condition', 'usage_line': 120}, {'reason_category': 'If Body', 'usage_line': 121}, {'reason_category': 'Else Reasoning', 'usage_line': 122}, {'reason_category': 'Else Reasoning', 'usage_line': 123}, {'reason_category': 'Else Reasoning', 'usage_line': 124}, {'reason_category': 'Else Reasoning', ...
Variable 'x1' used at line 120 is defined at line 115 and has a Short-Range dependency. Variable 'y1' used at line 120 is defined at line 117 and has a Short-Range dependency. Variable 'x2' used at line 120 is defined at line 116 and has a Short-Range dependency. Variable 'image' used at line 120 is defined at line 114...
{'If Condition': 1, 'If Body': 1, 'Else Reasoning': 10}
{'Variable Short-Range': 24, 'Variable Medium-Range': 17}
completion_python
Image_Transformation
143
146
['from PIL import Image', 'import cv2', 'import numpy as np', 'import matplotlib.pyplot as plt', '', '#Task 1:', '#resize two imgs', '#resize imgA with cv2.resize', '#resize imgB via center cropping', '#ensure both resized images are resized to same end_size', '#concatenate the resized imgs via every other row imgA and...
[' shift_center = np.array([j-center[0],i -center[1],1])', ' coordinates = np.dot(T_invert,shift_center)', ' x,y = coordinates[0] + center[0], coordinates [1] + center[1]', ' output[i][j] = bilinear_interpolation(I,x,y)']
[' output = np.array(output, np.uint8)', ' return output', '', "path= './arabella.jpg'", 'arabella = cv2.imread(path)', 'arabella_smol = cv2.resize(arabella, dsize=(256, 192), interpolation=cv2.INTER_AREA)', 'arabella_smol = np.array(arabella_smol)', 'arabella_smol = arabella_smol[:, :, [2, 1, 0]]', '', '#transla...
[{'reason_category': 'Loop Body', 'usage_line': 143}, {'reason_category': 'Loop Body', 'usage_line': 144}, {'reason_category': 'Loop Body', 'usage_line': 145}, {'reason_category': 'Loop Body', 'usage_line': 146}]
Library 'np' used at line 143 is imported at line 3 and has a Long-Range dependency. Variable 'j' used at line 143 is part of a Loop defined at line 142 and has a Short-Range dependency. Variable 'center' used at line 143 is defined at line 138 and has a Short-Range dependency. Variable 'i' used at line 143 is part of ...
{'Loop Body': 4}
{'Library Long-Range': 2, 'Variable Loop Short-Range': 4, 'Variable Short-Range': 8, 'Function Long-Range': 1, 'Variable Medium-Range': 1}
completion_python
Image_Transformation
141
148
['from PIL import Image', 'import cv2', 'import numpy as np', 'import matplotlib.pyplot as plt', '', '#Task 1:', '#resize two imgs', '#resize imgA with cv2.resize', '#resize imgB via center cropping', '#ensure both resized images are resized to same end_size', '#concatenate the resized imgs via every other row imgA and...
[' for i in range(rows):', ' for j in range(cols):', ' shift_center = np.array([j-center[0],i -center[1],1])', ' coordinates = np.dot(T_invert,shift_center)', ' x,y = coordinates[0] + center[0], coordinates [1] + center[1]', ' output[i][j] = bilinear_interpolation(I...
['', "path= './arabella.jpg'", 'arabella = cv2.imread(path)', 'arabella_smol = cv2.resize(arabella, dsize=(256, 192), interpolation=cv2.INTER_AREA)', 'arabella_smol = np.array(arabella_smol)', 'arabella_smol = arabella_smol[:, :, [2, 1, 0]]', '', '#translate images keep params as shown', 't1 = translation(21,25)', 'war...
[{'reason_category': 'Define Stop Criteria', 'usage_line': 141}, {'reason_category': 'Loop Body', 'usage_line': 142}, {'reason_category': 'Define Stop Criteria', 'usage_line': 142}, {'reason_category': 'Loop Body', 'usage_line': 143}, {'reason_category': 'Loop Body', 'usage_line': 144}, {'reason_category': 'Loop Body',...
Variable 'rows' used at line 141 is defined at line 136 and has a Short-Range dependency. Variable 'cols' used at line 142 is defined at line 136 and has a Short-Range dependency. Library 'np' used at line 143 is imported at line 3 and has a Long-Range dependency. Variable 'j' used at line 143 is part of a Loop defined...
{'Define Stop Criteria': 2, 'Loop Body': 5}
{'Variable Short-Range': 12, 'Library Long-Range': 3, 'Variable Loop Short-Range': 4, 'Function Long-Range': 1, 'Variable Medium-Range': 1}
completion_python
Credit_Scoring_Fairness
51
51
['import os', 'import pandas as pd', 'import numpy as np', 'import matplotlib.pyplot as plt', 'import matplotlib.cm as cm', 'from sklearn.model_selection import train_test_split', 'from sklearn.naive_bayes import GaussianNB', 'from sklearn.metrics import confusion_matrix', 'from sklearn.ensemble import RandomForestClas...
['gnb_pred = gnb.fit(x_train, y_train).predict(x_test)']
['', '# Result', 'test_df = x_test.copy()', "test_df['biY'] = y_test", "test_df['pred'] = pd.Series(gnb_pred, index=test_df.index)", "test_df['accurate'] = (test_df['pred'] == test_df['biY'])", '', '', '# Confusion Matrix', "confusion_mat = confusion_matrix(test_df['biY'], test_df['pred'])", "print('confusion_matrix: '...
[]
Variable 'gnb' used at line 51 is defined at line 50 and has a Short-Range dependency. Variable 'x_train' used at line 51 is defined at line 39 and has a Medium-Range dependency. Variable 'y_train' used at line 51 is defined at line 39 and has a Medium-Range dependency. Variable 'x_test' used at line 51 is defined at l...
{}
{'Variable Short-Range': 1, 'Variable Medium-Range': 3}