query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
This test is for the root alone without any children being linked
def test_root_setup assert_not_nil(@root , "Root cannot be nil") assert_nil(@root.parent , "Parent of root node should be nil") assert_not_nil(@root.name , "Name should not be nil") assert_equal("ROOT" , @root.name, "Name should be 'ROOT'") assert_equal("Root Node" , @root.content, "Content should be 'Root Node'") assert(@root.is_root? , "Should identify as root") assert(!@root.has_children? , "Cannot have any children") assert(@root.has_content? , "This root should have content") assert_equal(1 , @root.size, "Number of nodes should be one") assert_equal(0, @root.siblings.length, "This root does not have any children") assert_equal(0, @root.in_degree, "Root should have an in-degree of 0") assert_equal(0, @root.node_height, "Root's height before adding any children is 0") assert_raise(ArgumentError) { Tree::TreeNode.new(nil) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_is_root_eh\n setup_test_tree\n assert(@root.is_root?, \"The ROOT node must respond as the root node\")\n end", "def test_new_tree_empty_root\n assert_equal nil, @tree.root\n end", "def test_root\n setup_test_tree\n\n # TODO: Should probably change this logic. Root's root sh...
[ "0.7407995", "0.7389919", "0.7373433", "0.7280292", "0.7200388", "0.7115901", "0.6971962", "0.695324", "0.69144", "0.68989855", "0.6871652", "0.68547374", "0.68253666", "0.6782645", "0.67319846", "0.6723097", "0.6713372", "0.66674066", "0.6662848", "0.66329324", "0.6630796", ...
0.7034719
6
This test is for the state after the children are linked to the root.
def test_root setup_test_tree # TODO: Should probably change this logic. Root's root should # return nil so that the possibility of a recursive error does not exist # at all. assert_same(@root , @root.root, "Root's root is self") assert_same(@root , @child1.root, "Root should be ROOT") assert_same(@root , @child4.root, "Root should be ROOT") assert_equal(2 , @root.node_height, "Root's height after adding the children should be 2") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_has_children_eh\n setup_test_tree\n assert(@root.has_children?, \"The Root node MUST have children\")\n end", "def setup_test_tree\n @root << @child1\n @root << @child2\n @root << @child3 << @child4\n end", "def test_slide_1\n TaxonName.slide(2, 3)\n assert_equal 6...
[ "0.68895394", "0.683684", "0.67910427", "0.6727221", "0.6662147", "0.66272247", "0.66171277", "0.6581025", "0.6580105", "0.65084946", "0.64351", "0.6410759", "0.63753045", "0.6370954", "0.6313798", "0.62765545", "0.62703997", "0.62565684", "0.625236", "0.6242969", "0.61745644...
0.66355586
5
Test the presence of content in the nodes.
def test_has_content_eh a_node = Tree::TreeNode.new("A Node") assert_nil(a_node.content , "The node should not have content") assert(!a_node.has_content? , "The node should not have content") a_node.content = "Something" assert_not_nil(a_node.content, "The node should now have content") assert(a_node.has_content?, "The node should now have content") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def text_content?\n @node.children.all?(&:text?)\n end", "def text_content?\n @node.children.all? {|c| c.text?}\n end", "def has_content?\n !content.nil?\n end", "def node_contains_content?(node)\n node.name == '#cdata-section'\n end", "def has_content(*e...
[ "0.7626888", "0.7516905", "0.75079936", "0.74425876", "0.6966598", "0.6883407", "0.68198645", "0.68046916", "0.6668258", "0.66450804", "0.6625135", "0.66230035", "0.6603954", "0.6596043", "0.6558029", "0.65354013", "0.6515779", "0.6510004", "0.64987457", "0.6477516", "0.64324...
0.66436774
10
Test the equivalence of size and length methods.
def test_length_is_size setup_test_tree assert_equal(@root.size, @root.length, "Length and size methods should return the same result") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def size(*) end", "def size(*) end", "def size?() end", "def size() end", "def size() end", "def size() end", "def size() end", "def size() end", "def size() end", "def size\n length\n end", "def size; end", "def size; end", "def size; end", "def size; end", "def size; end", "def ...
[ "0.75586134", "0.75586134", "0.74102986", "0.7407792", "0.7407792", "0.7407792", "0.7407792", "0.7407792", "0.7407792", "0.73437035", "0.7316878", "0.7316878", "0.7316878", "0.7316878", "0.7316878", "0.7316878", "0.7316878", "0.7316878", "0.7316878", "0.7316878", "0.7316878",...
0.7759589
0
Test the to_s method. This is probably a little fragile right now.
def test_to_s a_node = Tree::TreeNode.new("A Node", "Some Content") expected_string = "Node Name: A Node Content: Some Content Parent: <None> Children: 0 Total Nodes: 1" assert_equal(expected_string, a_node.to_s, "The string representation should be same") # Now test with a symbol as a key. a_node = Tree::TreeNode.new(:Node_Name, "Some Content") expected_string = "Node Name: Node_Name Content: Some Content Parent: <None> Children: 0 Total Nodes: 1" assert_equal(expected_string, a_node.to_s, "The string representation should be same") # Now test with a symbol as a key and another symbol as the content. a_node = Tree::TreeNode.new(:Node_Name, :Content) expected_string = "Node Name: Node_Name Content: Content Parent: <None> Children: 0 Total Nodes: 1" assert_equal(expected_string, a_node.to_s, "The string representation should be same") # Now test with a symbol as a key, and a hash as the content. a_hash = {:a_key => "Some Value"} a_node = Tree::TreeNode.new(:Node_Name, a_hash) expected_string = "Node Name: Node_Name Content: #{a_hash} Parent: <None> Children: 0 Total Nodes: 1" assert_equal(expected_string, a_node.to_s, "The string representation should be same") # Lets now add a child to the previous node, and test the to_s for the child child_node = Tree::TreeNode.new(:Child_node, "Child Node") a_node << child_node expected_string = "Node Name: Child_node Content: Child Node Parent: Node_Name Children: 0 Total Nodes: 1" assert_equal(expected_string, child_node.to_s, "The string representation should be same") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end"...
[ "0.7174683", "0.7174683", "0.7174683", "0.7174683", "0.7174683", "0.7174683", "0.7174683", "0.7174683", "0.7174683", "0.7174683", "0.7174683", "0.7174683", "0.7174683", "0.7174683", "0.7174683", "0.7174683", "0.7174683", "0.7174683", "0.7109426", "0.7042864", "0.70329475", ...
0.0
-1
Test the first_sibling method.
def test_first_sibling setup_test_tree # TODO: Need to fix the first_sibling method to return nil for nodes with no siblings. assert_same(@root, @root.first_sibling, "Root's first sibling is itself") assert_same(@child1, @child1.first_sibling, "Child1's first sibling is itself") assert_same(@child1, @child2.first_sibling, "Child2's first sibling should be child1") assert_same(@child1, @child3.first_sibling, "Child3's first sibling should be child1") assert_same(@child4, @child4.first_sibling, "Child4's first sibling should be itself") assert_not_same(@child1, @child4.first_sibling, "Child4's first sibling is itself") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_is_first_sibling_eh\n setup_test_tree\n\n assert(@root.is_first_sibling?, \"Root's first sibling is itself\")\n assert( @child1.is_first_sibling?, \"Child1's first sibling is itself\")\n assert(!@child2.is_first_sibling?, \"Child2 is not the first sibling\")\n assert(!@child3.is_f...
[ "0.79009914", "0.7566066", "0.7036902", "0.69206107", "0.6722695", "0.6710509", "0.6663359", "0.6630579", "0.65792525", "0.65449476", "0.63982356", "0.6392025", "0.6339048", "0.63280016", "0.6317552", "0.6300825", "0.62610334", "0.6217274", "0.62068033", "0.62030685", "0.6179...
0.8353498
0
Test the is_first_sibling? method.
def test_is_first_sibling_eh setup_test_tree assert(@root.is_first_sibling?, "Root's first sibling is itself") assert( @child1.is_first_sibling?, "Child1's first sibling is itself") assert(!@child2.is_first_sibling?, "Child2 is not the first sibling") assert(!@child3.is_first_sibling?, "Child3 is not the first sibling") assert( @child4.is_first_sibling?, "Child4's first sibling is itself") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_first_sibling\n setup_test_tree\n\n # TODO: Need to fix the first_sibling method to return nil for nodes with no siblings.\n assert_same(@root, @root.first_sibling, \"Root's first sibling is itself\")\n assert_same(@child1, @child1.first_sibling, \"Child1's first sibling is itself\")\n...
[ "0.8011443", "0.7393663", "0.68509376", "0.67709875", "0.6767636", "0.6628235", "0.6586078", "0.65065676", "0.64640445", "0.6428762", "0.6379756", "0.6361455", "0.63255423", "0.6273904", "0.6273167", "0.62536615", "0.6253361", "0.62115103", "0.61885977", "0.61577463", "0.6157...
0.7982871
1
Test the is_last_sibling? method.
def test_is_last_sibling_eh setup_test_tree assert(@root.is_last_sibling?, "Root's last sibling is itself") assert(!@child1.is_last_sibling?, "Child1 is not the last sibling") assert(!@child2.is_last_sibling?, "Child2 is not the last sibling") assert( @child3.is_last_sibling?, "Child3's last sibling is itself") assert( @child4.is_last_sibling?, "Child4's last sibling is itself") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def last?\n !right_sibling\n end", "def test_last_sibling\n setup_test_tree\n\n assert_same(@root, @root.last_sibling, \"Root's last sibling is itself\")\n assert_same(@child3, @child1.last_sibling, \"Child1's last sibling should be child3\")\n assert_same(@child3, @child2.last_siblin...
[ "0.83869696", "0.76460224", "0.73134035", "0.7301334", "0.7240698", "0.6910003", "0.6863837", "0.6729055", "0.6729055", "0.66619647", "0.6660469", "0.6627207", "0.6570848", "0.6570848", "0.6557216", "0.6557216", "0.65351707", "0.65260994", "0.64273703", "0.64195675", "0.63713...
0.7951246
1
Test the last_sibling method.
def test_last_sibling setup_test_tree assert_same(@root, @root.last_sibling, "Root's last sibling is itself") assert_same(@child3, @child1.last_sibling, "Child1's last sibling should be child3") assert_same(@child3, @child2.last_sibling, "Child2's last sibling should be child3") assert_same(@child3, @child3.last_sibling, "Child3's last sibling should be itself") assert_same(@child4, @child4.last_sibling, "Child4's last sibling should be itself") assert_not_same(@child3, @child4.last_sibling, "Child4's last sibling is itself") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_is_last_sibling_eh\n setup_test_tree\n\n assert(@root.is_last_sibling?, \"Root's last sibling is itself\")\n assert(!@child1.is_last_sibling?, \"Child1 is not the last sibling\")\n assert(!@child2.is_last_sibling?, \"Child2 is not the last sibling\")\n assert( @child3.is_last_sibl...
[ "0.78397834", "0.7777814", "0.75926775", "0.6686773", "0.66590345", "0.6619843", "0.6617082", "0.6594998", "0.6557912", "0.63980746", "0.6383031", "0.63199455", "0.6260094", "0.62564456", "0.6239777", "0.62381005", "0.62360746", "0.6223332", "0.6221834", "0.6216103", "0.62147...
0.80057913
0
Test the siblings method, which is essentially an iterator.
def test_siblings setup_test_tree # Lets first collect the siblings in an array. siblings = [] @child1.siblings { |sibling| siblings << sibling} assert_equal(2, siblings.length, "Should have two siblings") assert(siblings.include?(@child2), "Should have 2nd child as sibling") assert(siblings.include?(@child3), "Should have 3rd child as sibling") siblings.clear siblings = @child1.siblings assert_equal(2, siblings.length, "Should have two siblings") siblings.clear @child4.siblings {|sibling| siblings << sibling} assert(siblings.empty?, "Should not have any siblings") siblings.clear siblings = @root.siblings assert_equal(0, siblings.length, "Root should not have any siblings") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inelastic_siblings\n siblings\n end", "def ppl_many_siblings\n raise NotImplementedError\n end", "def siblings\n without_self self_and_siblings\n end", "def siblings\n self_and_siblings - [self]\n end", "def siblings\n self_and_siblings - [self]\n end...
[ "0.70834196", "0.6983204", "0.6980295", "0.6934281", "0.6934281", "0.6934281", "0.6865605", "0.6863374", "0.6852279", "0.6826814", "0.6826814", "0.68249834", "0.6802441", "0.67338663", "0.67019105", "0.66974765", "0.66627675", "0.6584337", "0.6557576", "0.6557038", "0.6531824...
0.7606843
0
Test the is_only_child? method.
def test_is_only_child_eh setup_test_tree assert( @root.is_only_child? , "Root is an only child") assert(!@child1.is_only_child?, "Child1 is not the only child") assert(!@child2.is_only_child?, "Child2 is not the only child") assert(!@child3.is_only_child?, "Child3 is not the only child") assert( @child4.is_only_child?, "Child4 is an only child") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_only_child?\n return false if parent.nil? # root\n 1 == parent.children.size\n end", "def is_child?\n !is_parent?\n end", "def child?\n false\n end", "def child?\n true\n end", "def is_only_child?\n return call_ancestry_method(:is_only_child?) if use_ancestry?\n\n rel...
[ "0.8115992", "0.80901664", "0.8003854", "0.7896261", "0.788674", "0.7732107", "0.7650381", "0.7649291", "0.7649291", "0.7621647", "0.74487025", "0.741235", "0.741235", "0.741235", "0.7374786", "0.7319415", "0.72612846", "0.71617126", "0.71441275", "0.7141895", "0.7136186", ...
0.8213884
0
Test the next_sibling method.
def test_next_sibling setup_test_tree assert_nil(@root.next_sibling, "Root does not have any next sibling") assert_equal(@child2, @child1.next_sibling, "Child1's next sibling is Child2") assert_equal(@child3, @child2.next_sibling, "Child2's next sibling is Child3") assert_nil(@child3.next_sibling, "Child3 does not have a next sibling") assert_nil(@child4.next_sibling, "Child4 does not have a next sibling") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next_sibling\n\t\treturn next_sibling_of @current_node\n\tend", "def next_sibling\n return @links[:next_sibling]\n end", "def next_sibling_of(node)\n\t\treturn valid(node) ? node.next_sibling : nil\n\tend", "def next_sibling=(other); end", "def assert_next_sibling(id, expected_sibling_id)\n ...
[ "0.76542443", "0.76073545", "0.7462824", "0.7378023", "0.7237333", "0.71161175", "0.70956135", "0.67643636", "0.6759868", "0.6719854", "0.66626745", "0.6623448", "0.654384", "0.65373915", "0.64451945", "0.64451945", "0.6405785", "0.63927156", "0.63911545", "0.6361223", "0.630...
0.7859511
0
Test the previous_sibling method.
def test_previous_sibling setup_test_tree assert_nil(@root.previous_sibling, "Root does not have any previous sibling") assert_nil(@child1.previous_sibling, "Child1 does not have previous sibling") assert_equal(@child1, @child2.previous_sibling, "Child2's previous sibling is Child1") assert_equal(@child2, @child3.previous_sibling, "Child3's previous sibling is Child2") assert_nil(@child4.previous_sibling, "Child4 does not have a previous sibling") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def previous_sibling\n return @links[:previous_sibling]\n end", "def prev_sibling_of(node)\n\t\treturn valid(node) ? node.previous_sibling : nil\n\tend", "def prev_sibling\n\t\treturn prev_sibling_of @current_node\n\tend", "def previous_sibling=(other); end", "def previous_sibling\n return nil...
[ "0.7949191", "0.78544027", "0.77540195", "0.7651189", "0.7334865", "0.73188716", "0.7155193", "0.70268035", "0.7015421", "0.7009322", "0.6913326", "0.6905757", "0.690292", "0.6900668", "0.6895148", "0.6839489", "0.6709548", "0.6701049", "0.6685996", "0.6659306", "0.66137254",...
0.82296556
0
Test the add method.
def test_add assert(!@root.has_children?, "Should not have any children") assert_equal(1, @root.size, "Should have 1 node (the root)") @root.add(@child1) @root << @child2 assert(@root.has_children?, "Should have children") assert_equal(3, @root.size, "Should have three nodes") @root << @child3 << @child4 assert_equal(5, @root.size, "Should have five nodes") assert_equal(2, @child3.size, "Should have two nodes") # Test the addition of a duplicate node (duplicate being defined as a node with the same name). assert_raise(RuntimeError) { @root.add(Tree::TreeNode.new(@child1.name)) } # Test the addition of a nil node. assert_raise(ArgumentError) { @root.add(nil) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add \n end", "def add\n end", "def add\n end", "def add\n\tend", "def test_add\n\t\tassert_raise( RuntimeError ) { @freeid.add(\"Yo\") }\n\t\t@freeid.next\n\t\t@freeid.next\n\t\t@freeid.add(6)\n\t\tassert_equal(6, @freeid.next, \"Add not working\")\n\t\tassert_equal(2, @freeid.next, \"Last not wo...
[ "0.7766352", "0.77309036", "0.77309036", "0.7469937", "0.7372775", "0.7254426", "0.72147036", "0.7109115", "0.6894059", "0.68549937", "0.6822096", "0.67919594", "0.67138296", "0.66925323", "0.66725206", "0.6668689", "0.66252476", "0.6613247", "0.66003686", "0.65780306", "0.65...
0.71688604
7
Test Addition at a specific position
def test_add_at_specific_position assert(!@root.has_children?, "Should not have any children") assert_equal(1, @root.size, "Should have 1 node (the root)") @root.add(@child1) # First Child added at position 0 # Validate that children = [@child1] assert_equal(@child1, @root[0]) @root << @child2 # Second child appended at position 1. # Validate that children = [@child1, @child2] assert_equal(@child1, @root[0]) assert_equal(@child2, @root[1]) assert_equal(2, @root.children.size, "Should have two child nodes") @root.add(@child3, 1) # Third child inserted at position 1 (before @child2) # Validate that children = [@child1, @child3, @child2] assert_equal(@child1, @root[0]) assert_equal(@child3, @root[1]) assert_equal(@child2, @root[2]) assert_equal(3, @root.children.size, "Should have three child nodes") @root.add(@child4, @root.children.size) # Fourth child inserted at the end (equivalent to plain #add(child4) # Validate that children = [@child1, @child3, @child2, @child4] assert_equal(@child1, @root[0]) assert_equal(@child3, @root[1]) assert_equal(@child2, @root[2]) assert_equal(@child4, @root[3]) assert_equal(4, @root.children.size, "Should have four child nodes") # Now, a negative test. We are preventing addition to a position that does not exist. assert_raise(RuntimeError) { @root.add(@child5, @root.children.size + 1) # Fifth child inserted beyond the last position that is valid (at 5th pos). } # Validate that we still have children = [@child1, @child3, @child2, @child4] assert_equal(@child1, @root[0]) assert_equal(@child3, @root[1]) assert_equal(@child2, @root[2]) assert_equal(@child4, @root[3]) assert_nil(@root[4]) assert_equal(4, @root.children.size, "Should have four child nodes") # Another negative test. Lets attempt to add from the end at a position that is not available assert_raise(RuntimeError) { @root.add(@child5, -(@root.children.size+2)) # Fifth child inserted beyond the first position that is valid; i.e. at -6 } assert_nil(@root[-5]) assert_equal(@child1, @root[-4]) assert_equal(@child3, @root[-3]) assert_equal(@child2, @root[-2]) assert_equal(@child4, @root[-1]) assert_equal(4, @root.children.size, "Should have four child nodes") # Lets correctly add the fifth child from the end to effectively prepend the node. @root.add(@child5, -(@root.children.size+1)) # Fifth child inserted beyond the first position; i.e. at -5 assert_nil(@root[-6]) assert_equal(@child5, @root[-5]) assert_equal(@child1, @root[-4]) assert_equal(@child3, @root[-3]) assert_equal(@child2, @root[-2]) assert_equal(@child4, @root[-1]) assert_equal(5, @root.children.size, "Should have five child nodes") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checkAddi(before, after, instruction)\n\ta = instruction[1] #reg\n\tb = instruction[2] #val\n\tc = instruction[3] #reg\n\n\treturn after[c] == before[a] + b\nend", "def test_match\n\t\tassert_equal(2,add(1,1))\n\tend", "def games_won_or_lost(add_one_point)\n if add_one_point > 0\n return\n @points +...
[ "0.653353", "0.6229101", "0.61959153", "0.61586654", "0.6102774", "0.6056856", "0.6015448", "0.60082644", "0.5980176", "0.59594405", "0.5906639", "0.589928", "0.5888202", "0.58585227", "0.585003", "0.5773482", "0.5770864", "0.57688195", "0.57641363", "0.5762516", "0.5760988",...
0.0
-1
Test the remove! and remove_all! methods.
def test_remove_bang @root << @child1 @root << @child2 assert(@root.has_children?, "Should have children") assert_equal(3, @root.size, "Should have three nodes") @root.remove!(@child1) assert_equal(2, @root.size, "Should have two nodes") @root.remove!(@child2) assert(!@root.has_children?, "Should have no children") assert_equal(1, @root.size, "Should have one node") @root << @child1 @root << @child2 assert(@root.has_children?, "Should have children") assert_equal(3, @root.size, "Should have three nodes") @root.remove_all! assert(!@root.has_children?, "Should have no children") assert_equal(1, @root.size, "Should have one node") # Some negative testing @root.remove!(nil) assert(!@root.has_children?, "Should have no children") assert_equal(1, @root.size, "Should have one node") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove!; end", "def remove; end", "def remove; end", "def remove; end", "def remove; end", "def test_remove_errors\n\t\t#test error case\n\t\tassert_raise(IndexError){CheckersGame.new.remove('c','*')}\n\t\tassert_raise(IndexError){CheckersGame.new.remove('*','3')}\n\tend", "def test_remove_songs()\...
[ "0.70570487", "0.6902851", "0.6902851", "0.6902851", "0.6902851", "0.6669141", "0.651382", "0.6474579", "0.6401205", "0.63701934", "0.63241833", "0.63152343", "0.6311091", "0.63098407", "0.6306452", "0.62909275", "0.62614816", "0.625369", "0.6239325", "0.6239103", "0.6233882"...
0.6640408
6
Test the remove_all! method.
def test_remove_all_bang setup_test_tree assert(@root.has_children?, "Should have children") @root.remove_all! assert(!@root.has_children?, "Should have no children") assert_equal(1, @root.size, "Should have one node") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_all\n delete_if { |b| true }\n end", "def _remove_all_method\n :\"_remove_all_#{self[:name]}\"\n end", "def _remove_all_method\n :\"_remove_all_#{self[:name]}\"\n end", "def remove_all()\n @items.clear()\n end", "def destroy_all\n all.each(&:destroy)\...
[ "0.71939343", "0.7176142", "0.7102055", "0.70483047", "0.69953567", "0.6903057", "0.6901647", "0.6871518", "0.6859547", "0.6842449", "0.67936504", "0.6790571", "0.67635554", "0.6745188", "0.67447454", "0.6687549", "0.66753036", "0.6666008", "0.6640039", "0.6639998", "0.659597...
0.7037308
4
Test the remove_from_parent! method.
def test_remove_from_parent_bang setup_test_tree assert(@root.has_children?, "Should have children") assert(!@root.is_leaf?, "Root is not a leaf here") child1 = @root[0] assert_not_nil(child1, "Child 1 should exist") assert_same(@root, child1.root, "Child 1's root should be ROOT") assert(@root.include?(child1), "root should have child1") child1.remove_from_parent! assert_same(child1, child1.root, "Child 1's root should be self") assert(!@root.include?(child1), "root should not have child1") child1.remove_from_parent! assert_same(child1, child1.root, "Child 1's root should still be self") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def removeFromParent\n @parent.remove(self) if @parent\n end", "def remove_parent\n # has to go from parent to child\n self.parent.remove_child(self)\n end", "def remove_parent(selector); end", "def remove_from_parent\n @change_set = ChangeSet.for(resource)\n parent_resource = find...
[ "0.7715611", "0.7382604", "0.7307142", "0.68450654", "0.68401265", "0.6837654", "0.6741294", "0.66547126", "0.6604148", "0.6529854", "0.6482111", "0.6477159", "0.64689726", "0.6445911", "0.64372575", "0.63909924", "0.63823104", "0.6352334", "0.63177717", "0.6310191", "0.62356...
0.7794357
0
Test the children method.
def test_children setup_test_tree assert(@root.has_children?, "Should have children") assert_equal(5, @root.size, "Should have five nodes") assert(@child3.has_children?, "Should have children") assert(!@child3.is_leaf?, "Should not be a leaf") assert_equal(1, @child3.node_height, "The subtree at Child 3 should have a height of 1") for child in [@child1, @child2, @child4] assert_equal(0, child.node_height, "The subtree at #{child.name} should have a height of 0") end children = [] for child in @root.children children << child end assert_equal(3, children.length, "Should have three direct children") assert(!children.include?(@root), "Should not have root") assert(children.include?(@child1), "Should have child 1") assert(children.include?(@child2), "Should have child 2") assert(children.include?(@child3), "Should have child 3") assert(!children.include?(@child4), "Should not have child 4") children.clear children = @root.children assert_equal(3, children.length, "Should have three children") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def children; end", "def children; end", "def children; end", "def children; end", "def children; end", "def children; end", "def children; end", "def children; end", "def children; end", "def children; end", "def children; end", "def children; end", "def children\n raise NotImplemente...
[ "0.7388832", "0.7388832", "0.7388832", "0.7388832", "0.7388832", "0.7388832", "0.7388832", "0.7388832", "0.7388832", "0.7388832", "0.7388832", "0.7388832", "0.71020573", "0.7087898", "0.68895894", "0.68776155", "0.6828522", "0.67999005", "0.67268866", "0.66181093", "0.6600451...
0.7104079
12
Test the first_child method.
def test_first_child setup_test_tree assert_equal(@child1, @root.first_child, "Root's first child is Child1") assert_nil(@child1.first_child, "Child1 does not have any children") assert_equal(@child4, @child3.first_child, "Child3's first child is Child4") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_first_sibling\n setup_test_tree\n\n # TODO: Need to fix the first_sibling method to return nil for nodes with no siblings.\n assert_same(@root, @root.first_sibling, \"Root's first sibling is itself\")\n assert_same(@child1, @child1.first_sibling, \"Child1's first sibling is itself\")\n...
[ "0.7982242", "0.77640253", "0.77415323", "0.73569846", "0.73472583", "0.72539914", "0.6833663", "0.677806", "0.67485505", "0.67452073", "0.6468998", "0.64033115", "0.6375613", "0.6367125", "0.62516266", "0.61623526", "0.61593854", "0.60892355", "0.60821503", "0.60335475", "0....
0.85284865
0
Test the last_child method.
def test_last_child setup_test_tree assert_equal(@child3, @root.last_child, "Root's last child is Child3") assert_nil(@child1.last_child, "Child1 does not have any children") assert_equal(@child4, @child3.last_child, "Child3's last child is Child4") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_last_sibling\n setup_test_tree\n\n assert_same(@root, @root.last_sibling, \"Root's last sibling is itself\")\n assert_same(@child3, @child1.last_sibling, \"Child1's last sibling should be child3\")\n assert_same(@child3, @child2.last_sibling, \"Child2's last sibling should be child3\")...
[ "0.8076884", "0.77156967", "0.7451575", "0.7406189", "0.73204654", "0.69250536", "0.67753804", "0.6684065", "0.66303384", "0.6609797", "0.6565042", "0.6476528", "0.6403612", "0.639643", "0.6366839", "0.6366839", "0.6366839", "0.63501596", "0.632775", "0.632775", "0.6220421", ...
0.8650782
0
Test the find method.
def test_find setup_test_tree found_node = @root.find { |node| node == @child2} assert_same(@child2, found_node, "The node should be Child 2") found_node = @root.find { |node| node == @child4} assert_same(@child4, found_node, "The node should be Child 4") found_node = @root.find { |node| node.name == "Child4" } assert_same(@child4, found_node, "The node should be Child 4") found_node = @root.find { |node| node.name == "NOT PRESENT" } assert_nil(found_node, "The node should not be found") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find; end", "def find\n fail NotImplementedError\n end", "def find\n raise \"Method not implemented\"\n end", "def find(value)\n end", "def find_by()\n\n end", "def test_find\n assert_not_nil @rdigg.user.find(\"kevinrose\")\n end", "def test_0150_find\n @@log.debug ...
[ "0.78023165", "0.77532566", "0.746425", "0.69116193", "0.69103605", "0.68870854", "0.67851675", "0.67456454", "0.67143756", "0.6703975", "0.6683145", "0.66625124", "0.6575091", "0.6570424", "0.65411603", "0.65147233", "0.65147233", "0.64343196", "0.6433345", "0.63966596", "0....
0.69797987
3
Test the parentage method.
def test_parentage setup_test_tree assert_nil(@root.parentage, "Root does not have any parentage") assert_equal([@root], @child1.parentage, "Child1 has Root as its parent") assert_equal([@child3, @root], @child4.parentage, "Child4 has Child3 and Root as ancestors") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_parent_child_test_cases\n \n end", "def child_condition; end", "def parent\n self.sample || self.test_subject\n end", "def override()\n puts \"CHILD override()\"\n end", "def parent; end", "def parent; end", "def parent; end", "def parent; end", "def parent; end", "def...
[ "0.658933", "0.65447915", "0.6414217", "0.6406607", "0.63398546", "0.63398546", "0.63398546", "0.63398546", "0.63398546", "0.63398546", "0.63398546", "0.63398546", "0.63398546", "0.63398546", "0.63398546", "0.63398546", "0.6254013", "0.62044454", "0.61957926", "0.61906064", "...
0.6502638
2
Test the each method.
def test_each setup_test_tree assert(@root.has_children?, "Should have children") assert_equal(5, @root.size, "Should have five nodes") assert(@child3.has_children?, "Should have children") nodes = [] @root.each { |node| nodes << node } assert_equal(5, nodes.length, "Should have FIVE NODES") assert(nodes.include?(@root), "Should have root") assert(nodes.include?(@child1), "Should have child 1") assert(nodes.include?(@child2), "Should have child 2") assert(nodes.include?(@child3), "Should have child 3") assert(nodes.include?(@child4), "Should have child 4") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each(*) end", "def each\n end", "def each\n end", "def each\n end", "def each\n en...
[ "0.7758466", "0.7758466", "0.7758466", "0.7758466", "0.7758466", "0.7758466", "0.7758466", "0.7758466", "0.7758466", "0.7758466", "0.7758466", "0.77246624", "0.7612229", "0.7612229", "0.7612229", "0.7612229", "0.7612229", "0.7612229", "0.75326544", "0.7521627", "0.7521627", ...
0.6459353
88
Test the each_leaf method.
def test_each_leaf setup_test_tree nodes = [] @root.each_leaf { |node| nodes << node } assert_equal(3, nodes.length, "Should have THREE LEAF NODES") assert(!nodes.include?(@root), "Should not have root") assert(nodes.include?(@child1), "Should have child 1") assert(nodes.include?(@child2), "Should have child 2") assert(!nodes.include?(@child3), "Should not have child 3") assert(nodes.include?(@child4), "Should have child 4") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each_leaf!\n raise \"Method not yet written.\"\n\n self.each do |leaf|\n yield(leaf)\n end\n end", "def each_leaf(&block)\n each_leaf_node([], @root, block)\n end", "def each_leaf#:yields: leaf\n leafs.compact!\n \n leafs.each do |leaf|\n yield leaf\n e...
[ "0.80726945", "0.7618389", "0.75051165", "0.73378736", "0.72592145", "0.72518724", "0.72058684", "0.7045499", "0.7045499", "0.6691756", "0.6641135", "0.6595139", "0.6587919", "0.6518978", "0.6484925", "0.6477158", "0.64397836", "0.6378181", "0.6264441", "0.6232343", "0.620719...
0.7992356
1
Test the parent method.
def test_parent setup_test_tree assert_nil(@root.parent, "Root's parent should be nil") assert_equal(@root, @child1.parent, "Parent should be root") assert_equal(@root, @child3.parent, "Parent should be root") assert_equal(@child3, @child4.parent, "Parent should be child3") assert_equal(@root, @child4.parent.parent, "Parent should be root") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def should; super end", "def calls_super # :nodoc:\n false\n end", "def super_method; end", "def expected_method; end", "def altered()\n puts \"CHILD, BEFORE PARENT altered()\" # change to altered() before calling the base class instance method with same name\n super() # base method with name n...
[ "0.71102375", "0.66954154", "0.6500565", "0.64474654", "0.644199", "0.64055", "0.6377932", "0.63137424", "0.6306183", "0.6255243", "0.6233944", "0.6233944", "0.6193677", "0.618211", "0.617468", "0.617468", "0.617468", "0.617468", "0.61691517", "0.6139561", "0.6122296", "0.6...
0.0
-1
Test the [] method.
def test_indexed_access setup_test_tree assert_equal(@child1, @root[0], "Should be the first child") assert_equal(@child4, @root[2][0], "Should be the grandchild") assert_nil(@root["TEST"], "Should be nil") assert_nil(@root[99], "Should be nil") assert_raise(ArgumentError) { @root[nil] } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def [](*)\n raise NotImplementedError, '`#[]` method must be implemented'\n end", "def [](index); end", "def [](index)\n end", "def [](index)\n end", "def [](*) end", "def [](index) # i.e. array style index lookup.\n end", "def [](index); @data[index]; end", "def [](value); end", "de...
[ "0.7014241", "0.70027465", "0.69269663", "0.69269663", "0.68697435", "0.68673015", "0.6831208", "0.6826385", "0.6795721", "0.6762816", "0.6737938", "0.67096496", "0.6708499", "0.6708499", "0.6702766", "0.66576606", "0.66186357", "0.6604641", "0.6604641", "0.6590126", "0.65901...
0.0
-1
Test the print_tree method.
def test_print_tree setup_test_tree #puts #@root.print_tree end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_tree\n ''\n end", "def print_tree\n if root.children\n puts \" - root : #{root.children.length} - \"\n root.children.each(&:print_node)\n puts ''\n end\n end", "def printTree(options = {})\n # Set defaults\n options[:name] ||= true\n options[:content] ||= false\n ...
[ "0.7902457", "0.7844856", "0.76276535", "0.76085335", "0.7580548", "0.75174874", "0.73933315", "0.7332164", "0.7263764", "0.72026175", "0.71303356", "0.71237785", "0.71031094", "0.7033289", "0.70139384", "0.69903165", "0.6978808", "0.69728065", "0.69462276", "0.67919517", "0....
0.9064362
0
Tests the binary dumping mechanism with an Object content node
def test_marshal_dump # Setup Test Data test_root = Tree::TreeNode.new("ROOT", "Root Node") test_content = {"KEY1" => "Value1", "KEY2" => "Value2" } test_child = Tree::TreeNode.new("Child", test_content) test_content2 = ["AValue1", "AValue2", "AValue3"] test_grand_child = Tree::TreeNode.new("Grand Child 1", test_content2) test_root << test_child << test_grand_child # Perform the test operation data = Marshal.dump(test_root) # Marshal new_root = Marshal.load(data) # And unmarshal # Test the root node assert_equal(test_root.name, new_root.name, "Must identify as ROOT") assert_equal(test_root.content, new_root.content, "Must have root's content") assert(new_root.is_root?, "Must be the ROOT node") assert(new_root.has_children?, "Must have a child node") # Test the child node new_child = new_root[test_child.name] assert_equal(test_child.name, new_child.name, "Must have child 1") assert(new_child.has_content?, "Child must have content") assert(new_child.is_only_child?, "Child must be the only child") new_child_content = new_child.content assert_equal(Hash, new_child_content.class, "Class of child's content should be a hash") assert_equal(test_child.content.size, new_child_content.size, "The content should have same size") # Test the grand-child node new_grand_child = new_child[test_grand_child.name] assert_equal(test_grand_child.name, new_grand_child.name, "Must have grand child") assert(new_grand_child.has_content?, "Grand-child must have content") assert(new_grand_child.is_only_child?, "Grand-child must be the only child") new_grand_child_content = new_grand_child.content assert_equal(Array, new_grand_child_content.class, "Class of grand-child's content should be an Array") assert_equal(test_grand_child.content.size, new_grand_child_content.size, "The content should have same size") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_be_fully_dumped?(object)\n begin\n Marshal.dump(object)\n true\n rescue TypeError, IOError\n false\n end\n end", "def dump(object)\n raise NotImplementedError, \"#{self.class} must implement #dump\"\n end", "def structure_dump() end", "def marshal_dump; end", "def _...
[ "0.6263297", "0.61053145", "0.6102183", "0.6070473", "0.6068636", "0.606498", "0.6060673", "0.603301", "0.60080266", "0.5982621", "0.5982621", "0.59586066", "0.5907594", "0.58899474", "0.58816576", "0.5851618", "0.58489805", "0.58051205", "0.5704244", "0.57041013", "0.5695208...
0.6296182
0
Test the collect method from the mixedin Enumerable functionality.
def test_collect setup_test_tree collect_array = @root.collect do |node| node.content = "abc" node end collect_array.each {|node| assert_equal("abc", node.content, "Should be 'abc'")} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_collect_transforms_elements_of_an_array\n array = [1, 2, 3]\n new_array = array.collect { |item| item + 10 }\n assert_equal [11, 12, 13], new_array\n\n # NOTE: 'map' is another name for the 'collect' operation\n another_array = array.map { |item| item + 10 }\n assert_equal [11, 12, 13], ...
[ "0.7641104", "0.7519661", "0.7514939", "0.74053234", "0.7126162", "0.7126018", "0.7092514", "0.6817597", "0.66804314", "0.66524094", "0.6643883", "0.656589", "0.63235676", "0.62671983", "0.62116736", "0.6147768", "0.6137684", "0.6104986", "0.60806155", "0.60591465", "0.604867...
0.6561504
12
Test freezing the tree
def test_freeze_tree_bang setup_test_tree @root.content = "ABC" assert_equal("ABC", @root.content, "Content should be 'ABC'") @root.freeze_tree! # Note: The error raised here depends on the Ruby version. # For Ruby > 1.9, RuntimeError is raised # For Ruby ~ 1.8, TypeError is raised assert_raise(RuntimeError, TypeError) {@root.content = "123"} assert_raise(RuntimeError, TypeError) {@root[0].content = "123"} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cheap_wait; end", "def test_should_block_recursion_in_tree\n group = Group.find @greeks_group.id\n\n assert_raises(RecursionInTree) { group.parent = Group.find @cretes_group.id }\n end", "def test_save_tree\n end", "def test_cyclic\n end", "def test_breadth_each\n j = Tree::TreeNode.new(\...
[ "0.5896011", "0.5835977", "0.5793127", "0.56592774", "0.5588644", "0.5534555", "0.55041546", "0.5460143", "0.54390097", "0.5420358", "0.54201794", "0.54101765", "0.5403881", "0.5403881", "0.53922224", "0.5389457", "0.5378399", "0.5378399", "0.5378399", "0.5332773", "0.5303974...
0.7029016
0
Test whether the content is accesible
def test_content pers = Person::new("John", "Doe") @root.content = pers assert_same(pers, @root.content, "Content should be the same") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_access?\n true\n end", "def has_access?\n true\n end", "def can_read_content?(user)\n released_for_student?(user) || can_edit?(user)\n end", "def publicly_available?\n return false unless access_rights.present?\n\n access_rights.none? do |value|\n value == 'deny' || %w[allow:ic...
[ "0.7377797", "0.7377797", "0.71611613", "0.7152097", "0.7019996", "0.6942628", "0.69218874", "0.68518776", "0.6823548", "0.6812201", "0.6762285", "0.674089", "0.67158216", "0.6711801", "0.6688084", "0.6686559", "0.66835994", "0.66764975", "0.66746205", "0.6665309", "0.6663134...
0.0
-1
Test the depth computation algorithm. Note that this is an incorrect computation and actually returns height+1 instead of depth. This method has been deprecated in this release and may be removed in the future.
def test_depth begin require 'structured_warnings' assert_warn(DeprecatedMethodWarning) { do_deprecated_depth } rescue LoadError # Since the structued_warnings package is not present, we revert to good old Kernel#warn behavior. do_deprecated_depth end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_depth\n raise \"Not implemented\"\n end", "def depth()\n #This is a stub, used for indexing\n end", "def depth\n @traversal_position.depth\n end", "def depth\n n = 0\n p, q = lftp, lftq\n while p != 0\n x = p.inve...
[ "0.72374964", "0.6954031", "0.68363124", "0.6725244", "0.6662514", "0.66375756", "0.65993387", "0.6531998", "0.6505338", "0.6462455", "0.6452357", "0.6449738", "0.6422739", "0.640122", "0.639568", "0.63855505", "0.6373602", "0.6330523", "0.63191706", "0.6300117", "0.6266125",...
0.0
-1
Run the assertions for the deprecated depth method.
def do_deprecated_depth assert_equal(1, @root.depth, "A single node's depth is 1") @root << @child1 assert_equal(2, @root.depth, "This should be of depth 2") @root << @child2 assert_equal(2, @root.depth, "This should be of depth 2") @child2 << @child3 assert_equal(3, @root.depth, "This should be of depth 3") assert_equal(2, @child2.depth, "This should be of depth 2") @child3 << @child4 assert_equal(4, @root.depth, "This should be of depth 4") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_depth\n begin\n require 'structured_warnings'\n assert_warn(DeprecatedMethodWarning) { do_deprecated_depth }\n rescue LoadError\n # Since the structued_warnings package is not present, we revert to good old Kernel#warn behavior.\n do_deprecated_depth\n end\n e...
[ "0.77921015", "0.55722946", "0.5520603", "0.54864395", "0.5477407", "0.5471653", "0.54617983", "0.5444409", "0.54002744", "0.5350991", "0.5350007", "0.53381425", "0.5314139", "0.5314139", "0.52814263", "0.5274706", "0.5245313", "0.5232082", "0.5204234", "0.5113039", "0.508011...
0.72621274
1
Test the height computation algorithm
def test_node_height assert_equal(0, @root.node_height, "A single node's height is 0") @root << @child1 assert_equal(1, @root.node_height, "This should be of height 1") assert_equal(0, @child1.node_height, "This should be of height 0") @root << @child2 assert_equal(1, @root.node_height, "This should be of height 1") assert_equal(0, @child2.node_height, "This should be of height 0") @child2 << @child3 assert_equal(2, @root.node_height, "This should be of height 2") assert_equal(1, @child2.node_height, "This should be of height 1") assert_equal(0, @child3.node_height, "This should be of height 0") @child3 << @child4 assert_equal(3, @root.node_height, "This should be of height 3") assert_equal(2, @child2.node_height, "This should be of height 2") assert_equal(1, @child3.node_height, "This should be of height 1") assert_equal(0, @child4.node_height, "This should be of height 0") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def height(input)\n process(:height, input)\n end", "def height\n return 0 if @root.nil?\n return hegiht_helper(@root)\n end", "def get_height(*params); raise('Stub or mock required.') end", "def height!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __m...
[ "0.6804894", "0.66909003", "0.66903865", "0.66596335", "0.6650588", "0.66208225", "0.6558609", "0.6541876", "0.65319586", "0.649235", "0.649235", "0.6458327", "0.6458327", "0.64481395", "0.6440195", "0.64302826", "0.64302826", "0.6368589", "0.6316633", "0.6289489", "0.6283935...
0.6244528
27
Test the depth computation algorithm. Note that this is the correct depth computation. The original Tree::TreeNodedepth was incorrectly computing the height of the node instead of its depth.
def test_node_depth assert_equal(0, @root.node_depth, "A root node's depth is 0") setup_test_tree for child in [@child1, @child2, @child3] assert_equal(1, child.node_depth, "Node #{child.name} should have depth 1") end assert_equal(2, @child4.node_depth, "Child 4 should have depth 2") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_depth_of_method\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n tree.insert(40, \"movie c\")\n tree.insert(35, \"movie d\")\n assert_equal 3, tree.depth_of(35)\n end", "def depth\n if empty?\n 0\n else\n if @left==nil || @r...
[ "0.6864693", "0.6757938", "0.6713219", "0.6686807", "0.6681568", "0.6674517", "0.65427613", "0.6526818", "0.65262014", "0.6513792", "0.64473724", "0.64045507", "0.63973296", "0.6364339", "0.6276778", "0.6271265", "0.6258746", "0.62341547", "0.6209124", "0.6202515", "0.6086186...
0.74402314
0
Test the level method. Since this is an alias of node_depth, we just test for equivalence
def test_level assert_equal(0, @root.level, "A root node's level is 0") assert_equal(@root.node_depth, @root.level, "Level and depth should be the same") setup_test_tree for child in [@child1, @child2, @child3] assert_equal(1, child.level, "Node #{child.name} should have level 1") assert_equal(@root.node_depth, @root.level, "Level and depth should be the same") end assert_equal(2, @child4.level, "Child 4 should have level 2") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_depth_two_levels\n @tree.insert(\"a\")\n @tree.insert(\"b\")\n assert_equal 1, @tree.depth_of?(\"b\")\n end", "def test_node_depth\n assert_equal(0, @root.node_depth, \"A root node's depth is 0\")\n\n setup_test_tree\n\n for child in [@child1, @child2, @child3]\n assert_e...
[ "0.6713321", "0.64925057", "0.64134645", "0.63959444", "0.63704574", "0.63364893", "0.6289961", "0.62431514", "0.6223875", "0.6188657", "0.6180239", "0.61747295", "0.61284477", "0.6109462", "0.6109462", "0.6109462", "0.6109462", "0.6109462", "0.6109462", "0.6109397", "0.61064...
0.74802727
0
Test the breadth computation algorithm
def test_breadth assert_equal(1, @root.breadth, "A single node's breadth is 1") @root << @child1 assert_equal(1, @root.breadth, "This should be of breadth 1") @root << @child2 assert_equal(2, @child1.breadth, "This should be of breadth 2") assert_equal(2, @child2.breadth, "This should be of breadth 2") @root << @child3 assert_equal(3, @child1.breadth, "This should be of breadth 3") assert_equal(3, @child2.breadth, "This should be of breadth 3") @child3 << @child4 assert_equal(1, @child4.breadth, "This should be of breadth 1") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_breadth_each\n j = Tree::TreeNode.new(\"j\")\n f = Tree::TreeNode.new(\"f\")\n k = Tree::TreeNode.new(\"k\")\n a = Tree::TreeNode.new(\"a\")\n d = Tree::TreeNode.new(\"d\")\n h = Tree::TreeNode.new(\"h\")\n z = Tree::TreeNode.new(\"z\")\n\n # The expected order of r...
[ "0.6748863", "0.6638496", "0.6524973", "0.64008266", "0.6240808", "0.62361646", "0.6219844", "0.6144744", "0.61364985", "0.61242646", "0.60998636", "0.6016119", "0.60131943", "0.60131943", "0.60131943", "0.60131943", "0.60131943", "0.60131943", "0.60131943", "0.60131943", "0....
0.66878647
1
Test the breadth for each
def test_breadth_each j = Tree::TreeNode.new("j") f = Tree::TreeNode.new("f") k = Tree::TreeNode.new("k") a = Tree::TreeNode.new("a") d = Tree::TreeNode.new("d") h = Tree::TreeNode.new("h") z = Tree::TreeNode.new("z") # The expected order of response expected_array = [j, f, k, a, h, z, d] # Create the following Tree # j <-- level 0 (Root) # / \ # f k <-- level 1 # / \ \ # a h z <-- level 2 # \ # d <-- level 3 j << f << a << d f << h j << k << z # Create the response result_array = Array.new j.breadth_each { |node| result_array << node.detached_copy } expected_array.each_index do |i| assert_equal(expected_array[i].name, result_array[i].name) # Match only the names. end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_breadth\n assert_equal(1, @root.breadth, \"A single node's breadth is 1\")\n\n @root << @child1\n assert_equal(1, @root.breadth, \"This should be of breadth 1\")\n\n @root << @child2\n assert_equal(2, @child1.breadth, \"This should be of breadth 2\")\n assert_equal(2, @child2...
[ "0.68890536", "0.6702945", "0.64721006", "0.6361148", "0.619658", "0.6179271", "0.6152221", "0.61176646", "0.6109527", "0.6078409", "0.6042431", "0.604147", "0.6034782", "0.60049886", "0.5931217", "0.59139794", "0.5910914", "0.5906268", "0.5904258", "0.5873253", "0.58702934",...
0.7331208
0
Test the preordered_each method.
def test_preordered_each j = Tree::TreeNode.new("j") f = Tree::TreeNode.new("f") k = Tree::TreeNode.new("k") a = Tree::TreeNode.new("a") d = Tree::TreeNode.new("d") h = Tree::TreeNode.new("h") z = Tree::TreeNode.new("z") # The expected order of response expected_array = [j, f, a, d, h, k, z] # Create the following Tree # j <-- level 0 (Root) # / \ # f k <-- level 1 # / \ \ # a h z <-- level 2 # \ # d <-- level 3 j << f << a << d f << h j << k << z result_array = [] j.preordered_each { |node| result_array << node.detached_copy} expected_array.each_index do |i| # Match only the names. assert_equal(expected_array[i].name, result_array[i].name) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each(&block)\n\t\t\t@ordered.each(&block)\n\t\tend", "def each(&block)\n @ordered_elements.each(&block)\n end", "def each order=:preorder, &block\n # I know, I know. SGF is only preorder. Well, it's implemented, ain't it?\n # Stop complaining.\n case order\n when :preorder\n ...
[ "0.64636976", "0.644502", "0.6233939", "0.60754436", "0.59109217", "0.5780458", "0.5622207", "0.55871916", "0.5566852", "0.55113477", "0.55030495", "0.54603636", "0.5453088", "0.53986776", "0.53867394", "0.5367764", "0.5332064", "0.53297645", "0.531629", "0.5304872", "0.52816...
0.7615955
0
test the detached_copy method.
def test_detached_copy setup_test_tree assert(@root.has_children?, "The root should have children") copy_of_root = @root.detached_copy assert(!copy_of_root.has_children?, "The copy should not have children") assert_equal(@root.name, copy_of_root.name, "The names should be equal") # Try the same test with a child node assert(!@child3.is_root?, "Child 3 is not a root") assert(@child3.has_children?, "Child 3 has children") copy_of_child3 = @child3.detached_copy assert(copy_of_child3.is_root?, "Child 3's copy is a root") assert(!copy_of_child3.has_children?, "Child 3's copy does not have children") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_detached_subtree_copy\n setup_test_tree\n\n assert(@root.has_children?, \"The root should have children.\")\n tree_copy = @root.detached_subtree_copy\n\n assert_equal(@root.name, tree_copy.name, \"The names should be equal.\")\n assert_not_equal(@root.object_id, tree_copy.object_i...
[ "0.700882", "0.6117217", "0.5791448", "0.55092436", "0.54721403", "0.53427446", "0.5323102", "0.53072613", "0.5289093", "0.5273171", "0.5242975", "0.5192002", "0.5188811", "0.51586384", "0.5153594", "0.51498854", "0.51441985", "0.5126331", "0.5114862", "0.5114246", "0.5114246...
0.7740094
0
Test the detached_subtree_copy method.
def test_detached_subtree_copy setup_test_tree assert(@root.has_children?, "The root should have children.") tree_copy = @root.detached_subtree_copy assert_equal(@root.name, tree_copy.name, "The names should be equal.") assert_not_equal(@root.object_id, tree_copy.object_id, "Object_ids should differ.") assert(tree_copy.is_root?, "Copied root should be a root node.") assert(tree_copy.has_children?, "Copied tree should have children.") assert_equal(tree_copy.children.count, @root.children.count, "Copied tree and the original tree should have same number of children.") assert_equal(tree_copy[0].name, @child1.name, "The names of Child1 (original and copy) should be same.") assert_not_equal(tree_copy[0].object_id, @child1.object_id, "Child1 Object_ids (original and copy) should differ.") assert(!tree_copy[0].is_root?, "Child1 copied should not be root.") assert(!tree_copy[0].has_children?, "Child1 copied should not have children.") assert_equal(tree_copy[1].name, @child2.name, "The names of Child2 (original and copy) should be same.") assert_not_equal(tree_copy[1].object_id, @child2.object_id, "Child2 Object_ids (original and copy) should differ.") assert(!tree_copy[1].is_root?, "Child2 copied should not be root.") assert(!tree_copy[1].has_children?, "Child2 copied should not have children.") assert_equal(tree_copy[2].name, @child3.name, "The names of Child3 (original and copy) should be same.") assert_not_equal(tree_copy[2].object_id, @child3.object_id, "Child3 Object_ids (original and copy) should differ.") assert(!tree_copy[2].is_root?, "Child3 copied should not be root.") assert(tree_copy[2].has_children?, "Child3 copied should have children.") assert_equal(tree_copy[2][0].name, @child4.name, "The names of Child4 (original and copy) should be same.") assert_not_equal(tree_copy[2][0].object_id, @child4.object_id, "Child4 Object_ids (original and copy) should differ.") assert(!tree_copy[2][0].is_root?, "Child4 copied should not be root.") assert(!tree_copy[2][0].has_children?, "Child4 copied should not have children.") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_detached_copy\n setup_test_tree\n\n assert(@root.has_children?, \"The root should have children\")\n copy_of_root = @root.detached_copy\n assert(!copy_of_root.has_children?, \"The copy should not have children\")\n assert_equal(@root.name, copy_of_root.name, \"The names should be ...
[ "0.8262548", "0.55862147", "0.55859387", "0.5510041", "0.5429278", "0.54041034", "0.5393935", "0.51875526", "0.5151589", "0.5133615", "0.51270664", "0.5110476", "0.5052661", "0.5042424", "0.50371915", "0.50181377", "0.5002533", "0.5002492", "0.4940325", "0.49332863", "0.49327...
0.8244235
1
Test the has_children? method.
def test_has_children_eh setup_test_tree assert(@root.has_children?, "The Root node MUST have children") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_children?\n false\n end", "def has_children?\n !children.empty?\n end", "def has_children?\n children.size > 0\n end", "def has_children?\n children.size > 0\n end", "def has_children?\n self.children.size > 0\n end", "def has_children?\n self.children.size > 0\n e...
[ "0.8574548", "0.8568535", "0.85664934", "0.85664934", "0.85439277", "0.85439277", "0.85439277", "0.85439277", "0.8538637", "0.8538637", "0.85172266", "0.85172266", "0.85172266", "0.85172266", "0.84925646", "0.8484526", "0.84638", "0.84638", "0.84638", "0.84638", "0.84638", ...
0.7956138
44
test the is_leaf? method.
def test_is_leaf_eh setup_test_tree assert(!@child3.is_leaf?, "Child 3 is not a leaf node") assert(@child4.is_leaf?, "Child 4 is a leaf node") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_leaf\n true\n end", "def is_leaf\n true\n end", "def is_leaf\n return @left == nil\n end", "def leaf?\n true\n end", "def leaf?\n !node?\n end", "def is_a_leaf?\n self.left_child.nil? && self.right_child.nil?\n end", "def is_leaf?\n self.children_count.ze...
[ "0.87861156", "0.87861156", "0.8582141", "0.8375332", "0.82717794", "0.82253176", "0.81750053", "0.81031686", "0.80189276", "0.80012417", "0.7976427", "0.79656833", "0.79433405", "0.7925012", "0.7893264", "0.78806865", "0.78794503", "0.78500605", "0.78383994", "0.7787532", "0...
0.8251714
5
Test the is_root? method.
def test_is_root_eh setup_test_tree assert(@root.is_root?, "The ROOT node must respond as the root node") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_root?\n false\n end", "def root?\n root == self\n end", "def has_root?\n @root != nil\n end", "def root?\n root\n end", "def root?\n true\n end", "def root?\n true\n end", "def root?\n true\n end", "def is_root?\n \troot == id\n end", ...
[ "0.82637626", "0.81894755", "0.8150901", "0.81488985", "0.805424", "0.8050058", "0.8050058", "0.8029191", "0.7975747", "0.7963455", "0.7958967", "0.7940238", "0.77978915", "0.7666345", "0.76224166", "0.7549867", "0.7534729", "0.7499187", "0.7497382", "0.7497382", "0.7478093",...
0.83728653
0
Test the content= method.
def test_content_equals @root.content = nil assert_nil(@root.content, "Root's content should be nil") @root.content = "ABCD" assert_equal("ABCD", @root.content, "Root's content should now be 'ABCD'") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def content=(content)\n @content = content\n end", "def setContent(content)\r\n\t\t\t\t\t@content = content\r\n\t\t\t\tend", "def setContent(content)\r\n\t\t\t\t\t@content = content\r\n\t\t\t\tend", "def set_content(content)\n @content = content\n end", "def content= (new_content)\n @content = n...
[ "0.74305713", "0.73660016", "0.73660016", "0.7365818", "0.73488307", "0.73015845", "0.73015845", "0.73015845", "0.73015845", "0.73015845", "0.73015845", "0.71943", "0.710825", "0.710825", "0.70657825", "0.7027108", "0.70021707", "0.69263816", "0.67569983", "0.675478", "0.6722...
0.65447176
44
Test the size method.
def test_size assert_equal(1, @root.size, "Root's size should be 1") setup_test_tree assert_equal(5, @root.size, "Root's size should be 5") assert_equal(2, @child3.size, "Child 3's size should be 2") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def size() end", "def size() end", "def size() end", "def size() end", "def size() end", "def size() end", "def size(*) end", "def size(*) end", "def size\n end", "def size\n end", "def size\n end", "def size\n\n end", "def size; end", "def size; end", "def size; end", "de...
[ "0.78845096", "0.78845096", "0.78845096", "0.78845096", "0.78845096", "0.78845096", "0.785843", "0.785843", "0.78399026", "0.78399026", "0.78399026", "0.78007126", "0.77779907", "0.77779907", "0.77779907", "0.77779907", "0.77779907", "0.77779907", "0.77779907", "0.77779907", ...
0.76174635
48
Test the << method.
def test_lt2 # Test the << method @root << @child1 @root << @child2 @root << @child3 << @child4 assert_not_nil(@root['Child1'], "Child 1 should have been added to Root") assert_not_nil(@root['Child2'], "Child 2 should have been added to Root") assert_not_nil(@root['Child3'], "Child 3 should have been added to Root") assert_not_nil(@child3['Child4'], "Child 4 should have been added to Child3") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def <<(x) end", "def <<(x) end", "def <<\n end", "def <<\n end", "def <<\n end", "def <<(value); end", "def <<(arg); end", "def <<(data); end", "def <<(data); end", "def <<(data); end", "def <<(data); end", "def <<(data)\n end", "def <<(arg0)\n end", "def <<(arg0)\n end", "def <...
[ "0.70901245", "0.70901245", "0.7074061", "0.7074061", "0.7074061", "0.6902383", "0.6901677", "0.67635036", "0.67635036", "0.67635036", "0.67635036", "0.6688614", "0.6573168", "0.6573168", "0.6573168", "0.6573168", "0.64573646", "0.64489645", "0.639959", "0.63786876", "0.63700...
0.6294255
24
Test the [] method.
def test_index # Test the [] method assert_raise(ArgumentError) {@root[nil]} @root << @child1 @root << @child2 assert_equal(@child1.name, @root['Child1'].name, "Child 1 should be returned") assert_equal(@child1.name, @root[0].name, "Child 1 should be returned") assert_equal(@child1.name, @root[-2].name, "Child 1 should be returned") # Negative access also works assert_equal(@child1.name, @root[-(@root.children.size)].name, "Child 1 should be returned") # Negative access also works assert_equal(@child2.name, @root['Child2'].name, "Child 2 should be returned") assert_equal(@child2.name, @root[1].name, "Child 2 should be returned") assert_equal(@child2.name, @root[-1].name, "Child 2 should be returned") # Negative access also works assert_nil(@root['Some Random Name'], "Should return nil") assert_nil(@root[99], "Should return nil") assert_nil(@root[-(@root.children.size+1)], "Should return nil") assert_nil(@root[-3], "Should return nil") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def [](*)\n raise NotImplementedError, '`#[]` method must be implemented'\n end", "def [](index); end", "def [](index)\n end", "def [](index)\n end", "def [](*) end", "def [](index) # i.e. array style index lookup.\n end", "def [](index); @data[index]; end", "def [](value); end", "de...
[ "0.7014241", "0.70027465", "0.69269663", "0.69269663", "0.68697435", "0.68673015", "0.6831208", "0.6826385", "0.6795721", "0.6762816", "0.6737938", "0.67096496", "0.6708499", "0.6708499", "0.6702766", "0.66576606", "0.66186357", "0.6604641", "0.6604641", "0.6590126", "0.65901...
0.61459357
35
Test the in_degree method.
def test_in_degree setup_test_tree assert_equal(0, @root.in_degree, "Root's in-degree should be zero") assert_equal(1, @child1.in_degree, "Child 1's in-degree should be 1") assert_equal(1, @child2.in_degree, "Child 2's in-degree should be 1") assert_equal(1, @child3.in_degree, "Child 3's in-degree should be 1") assert_equal(1, @child4.in_degree, "Child 4's in-degree should be 1") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def degree(v) in_degree(v); end", "def in_degree(vertex)\n\tend", "def degree\n self.in_degree + self.out_degree\n end", "def test_out_degree\n setup_test_tree\n\n assert_equal(3, @root.out_degree, \"Root's out-degree should be 3\")\n assert_equal(0, @child1.out_degree, \"Child 1's out-...
[ "0.7368912", "0.6845612", "0.6654296", "0.6463978", "0.63506055", "0.61380655", "0.6129609", "0.6096297", "0.609111", "0.6089261", "0.60667974", "0.59744346", "0.59245294", "0.58623236", "0.58312917", "0.58229214", "0.58207643", "0.57796717", "0.5744778", "0.56702095", "0.564...
0.7744613
0
Test the out_degree method.
def test_out_degree setup_test_tree assert_equal(3, @root.out_degree, "Root's out-degree should be 3") assert_equal(0, @child1.out_degree, "Child 1's out-degree should be 0") assert_equal(0, @child2.out_degree, "Child 2's out-degree should be 0") assert_equal(1, @child3.out_degree, "Child 3's out-degree should be 1") assert_equal(0, @child4.out_degree, "Child 4's out-degree should be 0") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def degree\n self.in_degree + self.out_degree\n end", "def out_degree(vertex)\n\tend", "def out_degree\n @out_edges.length\n end", "def out_degree(v)\n r = 0\n each_adjacent(v) { |u| r += 1 }\n r\n end", "def out_degree(node)\n @adj[node].length\n end", "def out_degree(n...
[ "0.6726331", "0.67059845", "0.6697559", "0.65575594", "0.653462", "0.6340498", "0.6224677", "0.61898947", "0.60682994", "0.60337806", "0.6027786", "0.597832", "0.5760423", "0.5600363", "0.5587584", "0.5559842", "0.5537469", "0.54718786", "0.54524803", "0.5435376", "0.5410193"...
0.780635
0
Test the new JSON serialization method.
def test_json_serialization setup_test_tree expected_json = { "name" => "ROOT", "content" => "Root Node", JSON.create_id => "Tree::TreeNode", "children" => [ {"name" => "Child1", "content" => "Child Node 1", JSON.create_id => "Tree::TreeNode"}, {"name" => "Child2", "content" => "Child Node 2", JSON.create_id => "Tree::TreeNode"}, { "name" => "Child3", "content" => "Child Node 3", JSON.create_id => "Tree::TreeNode", "children" => [ {"name" => "Child4", "content" => "Grand Child 1", JSON.create_id => "Tree::TreeNode"} ] } ] }.to_json assert_equal(expected_json, @root.to_json) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_serialization\n # TODO: test serialization methods\n end", "def json_serialize\n end", "def test_json_object_child\n obj = { 'child' => Jeez.new(true, 58) }\n assert_equal('{\"child\":{\"json_class\":\"CompatJuice::Jeez\",\"x\":true,\"y\":58}}', Oj.dump(obj))\n end", "def serializer;...
[ "0.7805911", "0.69619346", "0.6739729", "0.66873354", "0.6620401", "0.6599065", "0.65728134", "0.6468269", "0.6407441", "0.6369593", "0.6353084", "0.6353084", "0.6339046", "0.6292706", "0.6286541", "0.628575", "0.6185708", "0.61709976", "0.6147885", "0.60945326", "0.6090455",...
0.6708164
3
Test the old CamelCase method names
def test_old_camelCase_method_names setup_test_tree meth_names_to_test = %w{isRoot? isLeaf? hasContent? hasChildren? setAsRoot! firstChild lastChild firstSibling isFirstSibling? lastSibling isLastSibling? isOnlyChild? nextSibling previousSibling nodeHeight nodeDepth createDumpRep removeFromParent! removeAll! freezeTree! } require 'structured_warnings' DeprecatedMethodWarning.disable do assert(@root.isRoot?) # Test if the original method is really called end meth_names_to_test.each do |meth_name| assert_warn(DeprecatedMethodWarning) {@root.send(meth_name)} end # Special Case for printTree to avoid putting stuff on the STDOUT during the unit test. begin require 'stringio' $stdout = StringIO.new assert_warn(DeprecatedMethodWarning) { @root.send('printTree') } ensure $stdout = STDOUT end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_camel_case\n raise NotImplementedError, 'Undecided as to whether to check camel case or not'\n end", "def test_Method_InstanceMethods_meth\n\t\tmethod = \"cat\".method(:upcase)\n\t\tassert_equal(\"upcase\", method.name.to_s)\n\tend", "def camel_case_method?\n method_name.to_s =~ /\\A[A-Z]/\n ...
[ "0.8006875", "0.74762756", "0.74658036", "0.7402534", "0.73579395", "0.73183393", "0.72632813", "0.7260595", "0.7260355", "0.725124", "0.7186343", "0.7172299", "0.71242326", "0.71216244", "0.7116901", "0.7079842", "0.70731884", "0.7030736", "0.7020418", "0.6991513", "0.691132...
0.6928734
20
Test usage of integers as node names
def test_integer_node_names require 'structured_warnings' assert_warn(StandardWarning) do @n_root = Tree::TreeNode.new(0, "Root Node") @n_child1 = Tree::TreeNode.new(1, "Child Node 1") @n_child2 = Tree::TreeNode.new(2, "Child Node 2") @n_child3 = Tree::TreeNode.new("three", "Child Node 3") end @n_root << @n_child1 @n_root << @n_child2 @n_root << @n_child3 # Node[n] is really accessing the nth child with a zero-base assert_not_equal(@n_root[1].name, 1) # This is really the second child assert_equal(@n_root[0].name, 1) # This will work, as it is the first child assert_equal(@n_root[1, true].name, 1) # This will work, as the flag is now enabled # Sanity check for the "normal" string name cases. Both cases should work. assert_equal(@n_root["three", false].name, "three") StandardWarning.disable assert_equal(@n_root["three", true].name, "three") # Also ensure that the warning is actually being thrown StandardWarning.enable assert_warn(StandardWarning) {assert_equal(@n_root["three", true].name, "three") } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nodetype2num(x)\n @nodetypes.find_index(x)\nend", "def visit_node(n); end", "def gen_node_key(num)\n \"node#{num}\".to_sym\nend", "def test_access_feature_name\n assert_equal 'krung go', @one_to_nine.child_node.name\n assert_equal 'ཀྲུང་གོ', @one_to_nine.parent_node.name\n end", "def test_acce...
[ "0.5880383", "0.57831836", "0.576323", "0.5723512", "0.5706851", "0.54743654", "0.5442897", "0.54287714", "0.53955", "0.53803945", "0.53787047", "0.5362258", "0.5346841", "0.5346841", "0.53371245", "0.533357", "0.533357", "0.5321807", "0.52802956", "0.5262876", "0.526039", ...
0.75187016
0
Test the addition of a node to itself as a child
def test_add_node_to_self_as_child root = Tree::TreeNode.new("root") # Lets check the direct parentage scenario assert_raise(ArgumentError) {root << root} # And now a scenario where the node addition is done down the hierarchy # @todo This scenario is not yet fixed. child = Tree::TreeNode.new("child") root << child << root # puts root # This will throw a stack trace end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def just_add_child(node)\n return if @children.member?(node)\n @children << node\n node.parent = self\n update_boxes \n end", "def add(child); end", "def child_node; end", "def test_add\n assert(!@root.has_children?, \"Should not have any children\")\n\n assert_equal(1, @root.size, ...
[ "0.74029994", "0.72090757", "0.69931376", "0.69070613", "0.686713", "0.6851359", "0.6851359", "0.6785406", "0.67298084", "0.6728562", "0.6685328", "0.6662659", "0.6607456", "0.65953904", "0.6593382", "0.65564173", "0.65564173", "0.65564173", "0.652232", "0.6496561", "0.647320...
0.74339324
0
Test whether the tree_leaf method works correctly
def test_single_node_becomes_leaf setup_test_tree leafs = @root.each_leaf parents = leafs.collect {|leaf| leaf.parent } leafs.each {|leaf| leaf.remove_from_parent!} parents.each {|parent| assert(parent.is_leaf?) if not parent.has_children?} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_leaf\n true\n end", "def is_leaf\n true\n end", "def test_is_leaf_eh\n setup_test_tree\n assert(!@child3.is_leaf?, \"Child 3 is not a leaf node\")\n assert(@child4.is_leaf?, \"Child 4 is a leaf node\")\n end", "def is_leaf\n return @left == nil\n end", "def leaf?\n ...
[ "0.84353673", "0.84353673", "0.83431554", "0.8100705", "0.806321", "0.7953672", "0.7895372", "0.77505195", "0.76434004", "0.7642754", "0.7638584", "0.7498978", "0.73904014", "0.7389269", "0.73611826", "0.7336549", "0.7325284", "0.73150194", "0.72899014", "0.72705096", "0.7258...
0.7808975
7
Second, implement the highest_prime_number_under method below. It should accept a number as an argument and return the highest prime number under that number. For example, the highest prime number under 10 is 7.
def highest_prime_number_under(number) prime = number - 1 counter = 1 until is_prime?(prime) prime -= 1 end return prime end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def highest_prime_number_under(number)\n start = number - 1\n start.downto(1) do |num|\n if is_prime?(num)\n return num\n end\n end\n end", "def highest_prime_number_under(number)\n\nend", "def highest_prime_number_under(number)\n until is_prime?(number)\n number -= 1\n end\n n...
[ "0.84532905", "0.8345327", "0.834144", "0.8112479", "0.805265", "0.79949474", "0.7853941", "0.76582015", "0.7296592", "0.723168", "0.7223145", "0.72068954", "0.71572", "0.7149735", "0.71105057", "0.7074159", "0.7051469", "0.7044985", "0.70053464", "0.70033205", "0.6993876", ...
0.8340299
3
FIXME: Default to first TodoList until TodoLists CRUD is supported.
def todo_list TodoList.find_by(user_id: current_user['sub']) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def first\n @todo.first! if @todo.may_first?\n redirect_to root_path\n end", "def set_todolist\n @todolists = Todolist.find(params[:id])\n end", "def set_todo_list\n @todo_list = TodoList.find(params[:id])\n end", "def set_todo_list\n @todo_list = TodoList.find(params[:id])\n end",...
[ "0.6672769", "0.65580666", "0.65246356", "0.65246356", "0.65246356", "0.6517467", "0.6502787", "0.6447455", "0.64415413", "0.6424842", "0.6406425", "0.6404615", "0.6388647", "0.63870126", "0.63340926", "0.63278043", "0.627213", "0.6262549", "0.6233896", "0.6195576", "0.616224...
0.6411786
10
STEPS: 1. save something in mb as visitor 2. OAuth login with Facebook VIA mobile path 3. confirm UGC merge on my book
def test_visitor_merge_through_facebook @user.email = @fb_user['email'] # Step 1 assign_http(Config["panda"]["host"]) # convert to search params = { 'type' => { 'shortcuts' => ['gas'] }, 'vrid' => @user.vrid } post '/mb/preferences', params assert_response(@response, :success) # Step 2 params = { 'vrid' => @user.vrid, 'merge_history' => true } assign_http(Config["turtle"]["host"]) get '/auth/facebook', params assert_response(@response, 302) assert_match(/https:\/\/www\.facebook\.com/, @response['location']) login_fb_user!(@fb_user, @user) # Step 3 assign_http(Config["panda"]["host"]) params = { 'type' => 'shortcuts', 'user_id' => @parsed_response['id'] } get '/mb/preferences', params assert_response(@response, :success) assert_equal(1, @parsed_response['Shortcuts'].size) assert_equal('gas', @parsed_response['Shortcuts'].first['Name']) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_unverified_user_fb_sign_up_ugc_merge\n # Step 1\n @user.email = @fb_user['email']\n turtle_response = @user.register\n assert_response(turtle_response, :success)\n assert(@user.id)\n @user.login_oauth\n assert(@user.oauth_token)\n\n # Step 2\n assign_http(Config[\"panda\"][\"hos...
[ "0.64715683", "0.6243314", "0.6169844", "0.6080056", "0.60709566", "0.6019965", "0.5974508", "0.59318626", "0.5923659", "0.5895076", "0.58888006", "0.58883613", "0.58746284", "0.58703685", "0.5864117", "0.58496326", "0.5842658", "0.58064723", "0.5797942", "0.57765114", "0.577...
0.5986124
6
STEPS: 1. login on turtle using facebook account 2. search for listing 3. upload image to listing 4. check image 5. hide image
def test_fb_sign_up_and_upload_monkey_image # Step 1 @user.email = @fb_user['email'] login_fb_user!(@fb_user, @user) # Step 2 assign_http(Config["panda"]["host"]) opts = { 'vrid' => @user.vrid } get_consumer_search_resp('ramen', 'glendale, ca', opts) assert_response(@response, :success) listing = @parsed_response['SearchResult']['BusinessListings'].first int_xxid = listing['Int_Xxid'] # Step 3 assign_http(Config["monkey"]["host"]) headers = { 'Content-Type' => 'image/jpg' } params = { 'api_key' => Config["monkey"]["api_key"], 'oauth_token' => @user.oauth_token, 'metadata' => { 'user_type' => 'xx' } } put_file "/b_image", params, generate_random_image, headers assert_response(@response, :success) sha1 = @parsed_response['id'] params = { 'ext_type' => 'int_xxid', 'ext_id' => int_xxid, 'oauth_token' => @user.oauth_token, 'api_key' => Config["monkey"]["api_key"], 'metadata' => { 'user_type' => 'xx' } } post "/b_image/#{sha1}", params assert_response(@response, :success) # Step 4 assert_image_in_consumer_business(sha1, listing) assert_image_in_profile(sha1, @user) # Step 5 assign_http(Config["monkey"]["host"]) params = { 'ext_type' => 'int_xxid', 'ext_id' => int_xxid, 'oauth_token' => @user.oauth_token, 'api_key' => Config["monkey"]["api_key"], 'reason' => 6 } post "/b_image/#{sha1}/int_xxid/#{int_xxid}/report", params assert_response(@response, :success) params = { 'api_key' => Config["monkey"]["api_key"] } get "/business/images/#{int_xxid}", params assert_response(@response, :success) refute_empty(@parsed_response[int_xxid], "Expected response for int_xxid #{int_xxid} to not be empty: #{@parsed_response}") refute(@parsed_response[int_xxid].map { |images| images['id'] }.include?(sha1), "Expected image removed from list after delete: #{sha1}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def atest_ID_25836_edit_profile_pic_03\n login_as_user1\n go_to_edit_profile_page\n verify_user_able_to_close_photo_upload_dialog\n end", "def uploading_pictures\n end", "def atest_ID_25836_edit_profile_pic_02\n login_as_user1\n go_to_edit_profile_page\n verify_unable_to_upload_non_image_fi...
[ "0.5973723", "0.5827267", "0.58178514", "0.58116597", "0.5743193", "0.57244116", "0.5716951", "0.5665135", "0.56402797", "0.5595061", "0.558402", "0.5533642", "0.55262864", "0.55206966", "0.551238", "0.5486385", "0.5484302", "0.5481954", "0.5470436", "0.5465468", "0.5462275",...
0.5998476
0
STEPS: 1. sign up and login on turtle with same email as fb 2. search for listing 3. upload image to listing 4. check image in profile, but not in mip 5. login via fb of same email 6. check image in mip and profile 7. hide image
def test_unverified_user_fb_sign_up_ugc_merge # Step 1 @user.email = @fb_user['email'] turtle_response = @user.register assert_response(turtle_response, :success) assert(@user.id) @user.login_oauth assert(@user.oauth_token) # Step 2 assign_http(Config["panda"]["host"]) opts = { 'vrid' => @user.vrid } get_consumer_search_resp('ramen', 'glendale, ca', opts) assert_response(@response, :success) listing = @parsed_response['SearchResult']['BusinessListings'].first int_xxid = listing['Int_Xxid'] # Step 3 assign_http(Config["monkey"]["host"]) headers = { 'Content-Type' => 'image/jpg' } params = { 'api_key' => Config["monkey"]["api_key"], 'oauth_token' => @user.oauth_token, 'metadata' => { 'user_type' => 'xx' } } put_file "/b_image", params, generate_random_image, headers assert_response(@response, :success) sha1 = @parsed_response['id'] params = { 'ext_type' => 'int_xxid', 'ext_id' => int_xxid, 'oauth_token' => @user.oauth_token, 'api_key' => Config["monkey"]["api_key"], 'metadata' => { 'user_type' => 'xx' } } post "/b_image/#{sha1}", params assert_response(@response, :success) # Step 4 refute_image_in_consumer_business(sha1, listing) assert_image_in_profile(sha1, @user) # Step 5 login_fb_user!(@fb_user, @user) # Step 6 assert_image_in_consumer_business(sha1, listing) assert_image_in_profile(sha1, @user) # Step 7 assign_http(Config["monkey"]["host"]) params = { 'ext_type' => 'int_xxid', 'ext_id' => int_xxid, 'oauth_token' => @user.oauth_token, 'api_key' => Config["monkey"]["api_key"], 'reason' => 6 } post "/b_image/#{sha1}/int_xxid/#{int_xxid}/report", params assert_response(@response, :success) params = { 'api_key' => Config["monkey"]["api_key"] } get "/business/images/#{int_xxid}", params assert_response(@response, :success) refute_empty(@parsed_response[int_xxid], "Expected response for int_xxid #{int_xxid} to not be empty: #{@parsed_response}") refute(@parsed_response[int_xxid].map { |images| images['id'] }.include?(sha1), "Expected image removed from list after delete: #{sha1}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def atest_ID_25836_edit_profile_pic_02\n login_as_user1\n go_to_edit_profile_page\n verify_unable_to_upload_non_image_file \"PDFDocument\"\n end", "def atest_ID_25836_edit_profile_pic_03\n login_as_user1\n go_to_edit_profile_page\n verify_user_able_to_close_photo_upload_dialog\n end", "def ...
[ "0.659132", "0.64810014", "0.6393637", "0.61355555", "0.6072024", "0.60481954", "0.6043239", "0.6020203", "0.5940387", "0.592949", "0.59072995", "0.58556306", "0.5845191", "0.5756754", "0.57445323", "0.57061285", "0.5693826", "0.562336", "0.56181234", "0.55981034", "0.5579436...
0.6069787
5
STEPS: 1. Login user though facebook 2. Logout user (clear access token for sanity check) 3. Sign up with same email should prompt password reset link 4. Login with same email should prompt password reset link
def test_user_fb_sign_up_web_login_register_password_prompt # Step 1 @user.email = @fb_user['email'] login_fb_user!(@fb_user, @user) # Step 2 turtle_response = @user.logout assert_response(turtle_response, :redirect) # Step 3 turtle_response = @user.register(true, false) # web view assert_response(turtle_response, 302) assert_match(/\/register/, turtle_response['location']) session = CGI::Cookie.parse(turtle_response['set-cookie'])['rack.session'].first refute_nil(session) headers = { 'Cookie' => "rack.session=#{CGI.escape(session)}" } assign_http(Config["turtle"]["host"]) get '/register', {}, headers assert_response(@response, :success) assert_match(/new_password_confirmation/, @response.body) # Step 4 turtle_response = @user.login(true, false) # web view assert_response(turtle_response, 302) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_fb_user_signup_then_login_logout_multiple_times\n @user.email = @fb_user['email']\n\n # Step 1\n params = {\n 'vrid' => @user.vrid,\n 'merge_history' => true\n }\n\n assign_http(Config[\"turtle\"][\"host\"])\n\n get '/auth/facebook', params\n assert_response(@response, 3...
[ "0.6433499", "0.6302646", "0.62398446", "0.62214303", "0.6214542", "0.6193085", "0.616618", "0.6164569", "0.61562043", "0.6122677", "0.6119641", "0.6072862", "0.6065", "0.605457", "0.6027739", "0.60267144", "0.60233295", "0.60183394", "0.6012812", "0.60090154", "0.59970546", ...
0.60404855
14
AS6487 | Facebook Account added to Dragon User Steps: 1. Verify successful facebook authentication & login 2. Confirm information for user form Dragon API 3. User logs out, and confirm user from Dragon API 4. Verify successful facebook authentication & login
def test_fb_user_signup_then_login_logout_multiple_times @user.email = @fb_user['email'] # Step 1 params = { 'vrid' => @user.vrid, 'merge_history' => true } assign_http(Config["turtle"]["host"]) get '/auth/facebook', params assert_response(@response, 302) assert_match(/https:\/\/www\.facebook\.com/, @response['location']) login_fb_user!(@fb_user, @user) assert(@user.oauth_token) lookup_user_by_id(@user.id) fb_uid = @parsed_response['facebook_uid'] # Step 2 get_user_info(@user.oauth_token) assert(@parsed_response['accounts'].length >= 1, @parsed_response) fb_account = @parsed_response['accounts'].first assert_equal('FacebookAccount', fb_account['type'], fb_account) assert(fb_account['identifier'], fb_account) get_dragon_user(@user.id) assert_response(@response, :success) assert(@parsed_response['facebook_uid'], @parsed_response) assert_equal(fb_uid, @parsed_response['facebook_uid'], @parsed_response) # Step 3 turtle_response = @user.logout assert_response(turtle_response, :redirect) get_dragon_user(@user.id) assert_response(@response, :success) assert(@parsed_response['facebook_uid'], @parsed_response) assert_equal(fb_uid, @parsed_response['facebook_uid'], @parsed_response) # Step 4 params = { 'vrid' => @user.vrid, 'merge_history' => true } assign_http(Config["turtle"]["host"]) get '/auth/facebook', params assert_response(@response, 302) assert_match(/https:\/\/www\.facebook\.com/, @response['location']) login_fb_user!(@fb_user, @user) assert(@user.oauth_token) get_user_info(@user.oauth_token) assert(@parsed_response['accounts'].length >= 1, @parsed_response) fb_account = @parsed_response['accounts'].first assert_equal('FacebookAccount', fb_account['type'], fb_account) assert(fb_account['identifier'], fb_account) get_dragon_user(@user.id) assert_response(@response, :success) assert(@parsed_response['facebook_uid'], @parsed_response) assert_equal(fb_uid, @parsed_response['facebook_uid'], @parsed_response) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def facebook\n @user = User.find_for_facebook_oauth(request.env[\"omniauth.auth\"], current_user)\n\n if @user.persisted?\n @user\n sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated\n set_flash_message(:notice, :success, :kind => \"Facebook\") if ...
[ "0.679115", "0.6735726", "0.6609625", "0.6596209", "0.6591692", "0.6583103", "0.65577483", "0.6554772", "0.65363556", "0.65348667", "0.65310067", "0.6510138", "0.6482514", "0.6436525", "0.6419062", "0.64186287", "0.64052296", "0.63961077", "0.6390426", "0.6379573", "0.6371273...
0.63679475
21
Returns the list of partition types supported by the Device
def partition_types_ext ptr1 = MemoryPointer::new( :size_t, 1) error = OpenCL.clGetDeviceInfo(self, PARTITION_TYPES_EXT, 0, nil, ptr1) error_check(error) ptr2 = MemoryPointer::new( ptr1.read_size_t ) error = OpenCL.clGetDeviceInfo(self, PARTITION_TYPES_EXT, ptr1.read_size_t, ptr2, nil) error_check(error) arr = ptr2.get_array_of_cl_device_partition_property_ext(0, ptr1.read_size_t/ OpenCL.find_type(:cl_device_partition_property_ext).size) arr.reject! { |e| e == 0 } return arr.collect { |e| PartitionEXT::new(e.to_i) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_partitions_with_size_and_type # by nelsongs. => list: partition size type\n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{if ($2==\"*\") print $1\":\"$5\":\"$6;else print $1\":\"$4\":\"$5}' | sed s/+//g`.split\nend", "def list_partitions #by nelsongs\n\treturn `fdisk -l | grep /dev | grep -v Disk...
[ "0.7248117", "0.63458914", "0.62699544", "0.6232824", "0.61675614", "0.6139866", "0.60773873", "0.6015134", "0.59679866", "0.59332496", "0.58867615", "0.5861007", "0.58582693", "0.58413965", "0.5800998", "0.5777511", "0.5731578", "0.56630963", "0.56233054", "0.56147826", "0.5...
0.75209886
0
Returns the parent Device if it exists
def parent_device_ext ptr = MemoryPointer::new( Device ) error = OpenCL.clGetDeviceInfo(self, PARENT_DEVICE_EXT, Device.size, ptr, nil) error_check(error) return nil if ptr.null? return Device::new(ptr.read_pointer) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parent_whole_disk\n Device.new('/dev/' + self['ParentWholeDisk'])\n end", "def parent_object\n if has_parent?\n actual_class = parent_class_name.camelize.constantize\n actual_class.find(parent_id)\n else\n nil\n end\n end", "def get_parent child_path\n parent_maj_min =...
[ "0.69526756", "0.6830269", "0.6823165", "0.67923945", "0.6683053", "0.6677846", "0.666579", "0.6550104", "0.6542374", "0.64039856", "0.637274", "0.6357295", "0.6278255", "0.62720096", "0.62618977", "0.6219054", "0.6180903", "0.6165943", "0.6160411", "0.61377126", "0.612947", ...
0.6999914
0
Complete the method which accepts an array of integers, and returns one of the following: "yes, ascending" if the numbers in the array are sorted in an ascending order "yes, descending" if the numbers in the array are sorted in a descending order "no" otherwise You can assume the array will always be valid, and there will always be one correct answer.
def is_sorted_and_how(numbers) if numbers.sort == numbers "yes, ascending" elsif numbers.sort.reverse == numbers "yes, descending" else "no" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_sorted_and_how(arr)\n if arr == arr.sort \n return 'yes, ascending'\n elsif arr == arr.sort.reverse \n return 'yes, descending' \n else\n return 'no'\n end\nend", "def is_sorted_and_how(arr)\n arr == arr.sort ? \"yes, ascending\" : arr == arr.sort.reverse ? \"yes, descending\" : \"no\"\nen...
[ "0.7304954", "0.71570307", "0.6782844", "0.65234137", "0.6510752", "0.65092766", "0.64166933", "0.6411729", "0.6399094", "0.6358728", "0.63401425", "0.63190717", "0.6258218", "0.6256327", "0.6219555", "0.6219555", "0.6194703", "0.61894", "0.61864525", "0.6185327", "0.6181142"...
0.6843163
2
human readable description of modeling approach
def modeler_description return "Purging objects like space types, schedules, and constructions requires a specific sequence to be most effective. This measure will first remove unused space types, then load defs, schedules sets, schedules, construction sets, constructions, and then materials. A space type having a construction set assign, will show that construction set as used even if no spaces are assigned to that space type. That is why order is important." end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def modeler_description\n return 'Gather orientation and story specific construction, fenestration (including overhang) specific information'\n end", "def modeler_description\n return \"Example use case is adding special loads like an elevator to a model as part of an analysis workflow\"\n end", "def m...
[ "0.7710149", "0.76145315", "0.75934714", "0.74018747", "0.7299891", "0.7296635", "0.727943", "0.71912926", "0.71912926", "0.7191264", "0.7100944", "0.70977926", "0.70629936", "0.7045383", "0.7044268", "0.70413125", "0.7040473", "0.7032938", "0.70267737", "0.70182866", "0.6987...
0.0
-1
define the arguments that the user will input
def arguments(model) args = OpenStudio::Ruleset::OSArgumentVector.new # bool to remove unused remove_unused_space_types remove_unused_space_types = OpenStudio::Ruleset::OSArgument::makeBoolArgument("remove_unused_space_types",true) remove_unused_space_types.setDisplayName("Remove Unused Space Types") remove_unused_space_types.setDefaultValue(false) args << remove_unused_space_types # bool to remove unused remove_unused_load_defs remove_unused_load_defs = OpenStudio::Ruleset::OSArgument::makeBoolArgument("remove_unused_load_defs",true) remove_unused_load_defs.setDisplayName("Remove Unused Load Definitions") remove_unused_load_defs.setDefaultValue(false) args << remove_unused_load_defs # bool to remove unused remove_unused_schedules remove_unused_schedules = OpenStudio::Ruleset::OSArgument::makeBoolArgument("remove_unused_schedules",true) remove_unused_schedules.setDisplayName("Remove Unused Schedules Sets and Schedules") remove_unused_schedules.setDefaultValue(false) args << remove_unused_schedules # bool to remove unused constructions remove_unused_constructions = OpenStudio::Ruleset::OSArgument::makeBoolArgument("remove_unused_constructions",true) remove_unused_constructions.setDisplayName("Remove Unused Construction Sets, Constructions, and Materials") remove_unused_constructions.setDefaultValue(false) args << remove_unused_constructions return args end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def arguments; end", "def arguments; end", "def arguments; end", "def arguments\n \"\"\n end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end...
[ "0.73753476", "0.73753476", "0.73753476", "0.70890766", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301",...
0.0
-1
define what happens when the measure is run
def run(model, runner, user_arguments) super(model, runner, user_arguments) # use the built-in error checking if !runner.validateUserArguments(arguments(model), user_arguments) return false end # assign the user inputs to variables remove_unused_space_types = runner.getBoolArgumentValue("remove_unused_space_types",user_arguments) remove_unused_load_defs = runner.getBoolArgumentValue("remove_unused_load_defs",user_arguments) remove_unused_schedules = runner.getBoolArgumentValue("remove_unused_schedules",user_arguments) remove_unused_constructions = runner.getBoolArgumentValue("remove_unused_constructions",user_arguments) # report initial condition of model runner.registerInitialCondition("The model started with #{model.numObjects.to_s} objects.") # remove orphan space infiltration objects orphan_flag = false model.getSpaceInfiltrationDesignFlowRates.sort.each do |instance| if instance.spaceType.is_initialized == false and instance.space.is_initialized == false runner.registerInfo("Removing orphan space infiltration object named #{instance.name}") instance.remove orphan_flag = true end end if not orphan_flag runner.registerInfo("No orphan space infiltration objects were found") end # todo - add section to remove orphan effective leakage # remove orphan design spec oa objects orphan_flag = false model.getDesignSpecificationOutdoorAirs.sort.each do |instance| if instance.directUseCount == 0 runner.registerInfo("Removing orphan design specification outdoor air object named #{instance.name}") instance.remove orphan_flag = true end end if not orphan_flag runner.registerInfo("No orphan design specification outdoor air objects were found") end # remove orphan load instances orphan_flag = false model.getSpaceLoadInstances.sort.each do |instance| if instance.spaceType.is_initialized == false and instance.space.is_initialized == false # extra check for water use equipment. They may or may not have space. But they should have a water use connection if instance.to_WaterUseEquipment.is_initialized and instance.to_WaterUseEquipment.get.waterUseConnections.is_initialized next end runner.registerInfo("Removing orphan load instance object named #{instance.name}") instance.remove orphan_flag = true end end if not orphan_flag runner.registerInfo("No orphan load instance objects were found") end # remove orphan surfaces orphan_flag = false model.getSurfaces.sort.each do |surface| if not surface.space.is_initialized runner.registerInfo("Removing orphan base surface named #{surface.name}") surface.remove orphan_flag = true end end if not orphan_flag runner.registerInfo("No orphan base surfaces were found") end # remove orphan subsurfaces orphan_flag = false model.getSubSurfaces.sort.each do |subsurface| if not subsurface.surface.is_initialized runner.registerInfo("Removing orphan sub surface named #{subsurface.name}") subsurface.remove orphan_flag = true end end if not orphan_flag runner.registerInfo("No orphan sub surfaces were found") end # remove orphan shading surfaces orphan_flag = false model.getShadingSurfaces.sort.each do |surface| if not surface.shadingSurfaceGroup.is_initialized runner.registerInfo("Removing orphan shading surface named #{surface.name}") surface.remove orphan_flag = true end end if not orphan_flag runner.registerInfo("No orphan shading surfaces were found") end # remove orphan interior partition surfaces orphan_flag = false model.getInteriorPartitionSurfaces.sort.each do |surface| if not surface.interiorPartitionSurfaceGroup.is_initialized runner.registerInfo("Removing orphan interior partition surface named #{surface.name}") surface.remove orphan_flag = true end end if not orphan_flag runner.registerInfo("No orphan interior partition surfaces were found") end # find and remove orphan LifeCycleCost objects lcc_objects = model.getObjectsByType("OS:LifeCycleCost".to_IddObjectType) #make an array to store the names of the orphan LifeCycleCost objects orphaned_lcc_objects = Array.new #loop through all LifeCycleCost objects, checking for missing Item Name lcc_objects.each do |lcc_object| if lcc_object.isEmpty(4) orphaned_lcc_objects << lcc_object.handle puts "**(removing object)#{lcc_object.name} is not connected to any model object" runner.registerInfo("Removing orphan lifecycle cost named #{lcc_object.name}") lcc_object.remove end end #summarize the results if not orphaned_lcc_objects.length > 0 runner.registerInfo("no orphaned LifeCycleCost objects were found") end # todo - remove surfaces that would trigger error in E+ (less than 3 vertices or too small.) # todo - remove empty shading and interior partition groups. Don't think we would want to do this to spaces, since they may contain space types or loads # remove unused space types if remove_unused_space_types unused_flag_counter = 0 model.getSpaceTypes.sort.each do |resource| if resource.spaces.size == 0 unused_flag_counter += 1 resource.remove end end runner.registerInfo("Removed #{unused_flag_counter} unused space types") end # remove unused load defs if remove_unused_load_defs unused_flag_counter = 0 model.getSpaceLoadDefinitions.sort.each do |resource| if resource.directUseCount == 0 unused_flag_counter += 1 resource.remove end end runner.registerInfo("Removed #{unused_flag_counter} unused load definitions") end # remove unused default schedule sets if remove_unused_schedules unused_flag_counter = 0 model.getDefaultScheduleSets.sort.each do |resource| if resource.directUseCount == 0 unused_flag_counter += 1 resource.remove end end runner.registerInfo("Removed #{unused_flag_counter} unused default schedules sets") end # remove unused default schedules if remove_unused_schedules unused_flag_counter = 0 model.getSchedules.sort.each do |resource| if resource.directUseCount == 0 unused_flag_counter += 1 resource.remove end end runner.registerInfo("Removed #{unused_flag_counter} unused schedules") end # remove unused default schedule sets if remove_unused_constructions unused_flag_counter = 0 model.getDefaultConstructionSets.sort.each do |resource| if resource.directUseCount == 0 unused_flag_counter += 1 resource.remove end end runner.registerInfo("Removed #{unused_flag_counter} unused default construction sets") # remove default surface and sub surface constructions, but dont' report # these are typically hidden from users and reporting it may be more confusing that helpful unused_flag_counter = 0 model.getDefaultSurfaceConstructionss.sort.each do |resource| if resource.directUseCount == 0 unused_flag_counter += 1 resource.remove end end #runner.registerInfo("Removed #{unused_flag_counter} unused default surface constructions") unused_flag_counter = 0 model.getDefaultSubSurfaceConstructionss.sort.each do |resource| if resource.directUseCount == 0 unused_flag_counter += 1 resource.remove end end #runner.registerInfo("Removed #{unused_flag_counter} unused default sub surface constructions") # remove default constructions unused_flag_counter = 0 model.getConstructions.sort.each do |resource| if resource.directUseCount == 1 # still don't understand why this is 1 not 0 unused_flag_counter += 1 resource.remove else # this was just put in for testing ot understand why directUseCount isn't 0 #puts "" #puts "Name #{resource.name}" #puts "directUseCount = #{resource.nonResourceObjectUseCount}" #puts "nonResourceObjectUseCount = #{resource.nonResourceObjectUseCount}" #puts "targets.size = #{resource.targets.size}" #puts "sources.size = #{resource.sources.size}" end end runner.registerInfo("Removed #{unused_flag_counter} unused constructions") # remove unused materials unused_flag_counter = 0 model.getMaterials.sort.each do |resource| if resource.directUseCount == 0 unused_flag_counter += 1 resource.remove end end runner.registerInfo("Removed #{unused_flag_counter} unused materials") end # report final condition of model runner.registerFinalCondition("The model finished with #{model.numObjects.to_s} objects.") return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def measure; end", "def measure=(_arg0); end", "def measure\n\t\t1\n\tend", "def measure(*args, &b)\n end", "def communicate_measure_result(_ = nil, _ = nil); end", "def communicate_measure_result(_ = nil, _ = nil); end", "def called\n self.measurement.called\n end", "def measure\n ...
[ "0.79848564", "0.7639647", "0.76355976", "0.7170129", "0.66926914", "0.66926914", "0.66718984", "0.66311747", "0.6599127", "0.65870225", "0.65324444", "0.6481582", "0.6405596", "0.64028287", "0.6333309", "0.6283632", "0.6283632", "0.6283632", "0.6281165", "0.6269874", "0.6242...
0.0
-1
checks if the identity is ready to be further processed e.g. all preconditions are fullfilled to start the oauth dance
def processable? return true if self.user && !self.user.new_record? # clean error on accept_terms self.errors.delete(:accept_terms) # check if terms of use have been accepted self.errors.add(:accept_terms, :accepted) if self.accept_terms.to_i.zero? self.errors.blank? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ready?\n config and\n config.authorization_url and\n tokens and\n tokens.access_token and\n tokens.refresh_token\n end", "def is_ready_to_start?\n self.is_owner? ? self.ack_get_started_owner : ack_get_started_user\n end", "def ready?\n self.class.ready?(@cloud_id, c...
[ "0.6451269", "0.63725257", "0.63293195", "0.6221577", "0.61388314", "0.60509247", "0.60039926", "0.5998415", "0.5983313", "0.5946791", "0.5944305", "0.5934631", "0.59164494", "0.5915563", "0.58971393", "0.58752996", "0.5862322", "0.585778", "0.5850673", "0.5850673", "0.584922...
0.0
-1
Access the classes for the '' element. If a block is given, this invocation is being used to accumulate CSS class names; otherwise this invocation is being used to emit the CSS classes for inclusion in the '' element definition.
def page_classes if block_given? set_page_classes(*yield) else emit_page_classes end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def css_classes\n classes= [\"row\"]\n unless @element.content_by_name(:classi_css).essence.body.nil?\n classes << @element.content_by_name(:classi_css).essence.body\n end\n classes #todo estrapolare valori da options\n end", "def dom_class\n node['class']\n end", "def class_n...
[ "0.64221454", "0.6237864", "0.61898285", "0.61824834", "0.6174134", "0.6143465", "0.6015646", "0.58767366", "0.58746195", "0.5846111", "0.5824157", "0.5803588", "0.58028924", "0.579065", "0.5775611", "0.5730014", "0.5634122", "0.56323886", "0.5612594", "0.5611201", "0.556757"...
0.5748805
15
Set the classes for the '' element, eliminating any previous value.
def set_page_classes(*values) @page_classes = [] @page_classes += values @page_classes += Array.wrap(yield) if block_given? @page_classes end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_classes(class_names)\n self.attr['class'] = ''\n class_names.each { |e| add_class(e) }\n end", "def remove_class c\n each do |q|\n str = q.get_attribute(\"class\")\n\n str = str.split(\" \").find_all do |n|\n n != c.to_s\n end.join(\" \")\n \n q...
[ "0.7085044", "0.6880239", "0.6760475", "0.66856855", "0.66591895", "0.6648968", "0.65733975", "0.62743205", "0.6263523", "0.6229792", "0.62095803", "0.6204296", "0.5989905", "0.5984917", "0.59698254", "0.596821", "0.5905442", "0.5840728", "0.57988435", "0.5798677", "0.5788581...
0.5630128
29
Add to the classes for the '' element.
def append_page_classes(*values) @page_classes ||= default_page_classes @page_classes += values @page_classes += Array.wrap(yield) if block_given? @page_classes end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_class class_name\n each do |el|\n next unless el.respond_to? :get_attribute\n classes = el.get_attribute('class').to_s.split(\" \")\n el.set_attribute('class', classes.push(class_name).uniq.join(\" \"))\n end\n self\n end", "def add_class c\n each do |q|\n ...
[ "0.7722148", "0.74526757", "0.70900846", "0.70900846", "0.70598644", "0.70598644", "0.70283186", "0.70261085", "0.6987524", "0.6928194", "0.69225484", "0.6858269", "0.6824207", "0.67648685", "0.64623404", "0.64436597", "0.642449", "0.6420374", "0.6416678", "0.63925755", "0.63...
0.5861112
50
Emit the CSS classes for inclusion in the '' element definition.
def emit_page_classes @page_classes ||= default_page_classes @page_classes.flatten! @page_classes.compact_blank! @page_classes.map! { |c| c.to_s.gsub(/[^a-z_0-9-]/i, '_') } @page_classes.uniq! @page_classes.join(' ') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def css_classes\n classes= [\"row\"]\n unless @element.content_by_name(:classi_css).essence.body.nil?\n classes << @element.content_by_name(:classi_css).essence.body\n end\n classes #todo estrapolare valori da options\n end", "def comp_class\n @xml += '<class> '\n while @i < ...
[ "0.6809233", "0.6532971", "0.6450472", "0.6357284", "0.63551396", "0.6306282", "0.6257774", "0.619884", "0.6198387", "0.6197295", "0.61258864", "0.61211944", "0.611239", "0.611239", "0.60921395", "0.6091575", "0.6088885", "0.60771734", "0.6056501", "0.6045831", "0.60227454", ...
0.65412295
1
GET /euclid_users/1 GET /euclid_users/1.json
def show @euclid_user = EuclidUser.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @euclid_user } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_one_user_data\n get_url(\"/api/v1/users/#{@filter}\")\n end", "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response ...
[ "0.6822484", "0.6801907", "0.65722764", "0.6542782", "0.64431804", "0.6437672", "0.6422124", "0.64149046", "0.6385286", "0.63612884", "0.6361115", "0.6361115", "0.63608205", "0.63596237", "0.63580936", "0.6351446", "0.635084", "0.6350172", "0.6340591", "0.6300943", "0.6299135...
0.7289374
0
GET /euclid_users/new GET /euclid_users/new.json
def new @euclid_user = EuclidUser.new respond_to do |format| format.html # new.html.erb format.json { render json: @euclid_user } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @newuser = Newuser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newuser }\n end\n end", "def new\n @user = user.new\n\t\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n ...
[ "0.7714887", "0.77041", "0.7681287", "0.7508355", "0.7479379", "0.7457338", "0.74127156", "0.7396769", "0.73927766", "0.7378929", "0.73718935", "0.7359137", "0.73421896", "0.73421896", "0.72694767", "0.7265147", "0.7265147", "0.7265147", "0.7261225", "0.7261225", "0.7261225",...
0.78537786
0
POST /euclid_users POST /euclid_users.json
def create @euclid_user = EuclidUser.new(params[:euclid_user]) @euclid_user.proximity = "distant"; respond_to do |format| if @euclid_user.save format.html { redirect_to @euclid_user, notice: 'Euclid user was successfully created.' } format.json { render json: @euclid_user, status: :created, location: @euclid_user } else format.html { render action: "new" } format.json { render json: @euclid_user.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end", "def create_user(params:)\n parse(JSON.parse(connection.post(\"users\", params.to_json).body))\n end", "def new\n @euclid_user = ...
[ "0.6259141", "0.62283283", "0.6210158", "0.61411136", "0.6134746", "0.6126794", "0.61217546", "0.6099993", "0.60931695", "0.60412914", "0.60357714", "0.6026509", "0.6025068", "0.600273", "0.5993673", "0.5958619", "0.5947786", "0.59270746", "0.5915842", "0.5915638", "0.5915366...
0.6727144
0
PUT /euclid_users/1 PUT /euclid_users/1.json
def update @euclid_user = EuclidUser.find(params[:id]) respond_to do |format| if @euclid_user.update_attributes(params[:euclid_user]) format.html { redirect_to @euclid_user, notice: 'Euclid user was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @euclid_user.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def updateUser\n options = {\n :body => params.to_json,\n :headers => {\n 'Content-Type' => 'application/json',\n 'Authorization' => request.headers['Authorization']\n }\n }\n results = HTTParty.put(\"http://192.168.99.101:4051/users/\"+@current_user[\"id\"].to_s, ...
[ "0.67932063", "0.6774995", "0.6708661", "0.6584418", "0.65644723", "0.6553645", "0.6550216", "0.6545514", "0.6471925", "0.646046", "0.6438865", "0.64369965", "0.64322716", "0.6414681", "0.6414681", "0.6402894", "0.64004993", "0.63678604", "0.63527614", "0.63241565", "0.632415...
0.71763444
0
DELETE /euclid_users/1 DELETE /euclid_users/1.json
def destroy @euclid_user = EuclidUser.find(params[:id]) @euclid_user.destroy respond_to do |format| format.html { redirect_to euclid_users_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end", "def delete_user_for_tenant(args = {}) \n delete(\"/tenants.json/#{args[:tenantId]}/users/#{args[:userId]}\", args)\nend", "def user_management_delete_user id\n # the base uri for api requests\...
[ "0.72144127", "0.7078144", "0.7068458", "0.70267", "0.7009003", "0.69466496", "0.6919501", "0.6901847", "0.6868615", "0.68578565", "0.6841119", "0.6840021", "0.6832048", "0.68235826", "0.6821509", "0.6820895", "0.6800377", "0.6786589", "0.6784441", "0.6784441", "0.6781281", ...
0.76037097
0
GET /quandaries GET /quandaries.json
def index @quandaries = Quandary.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @enquiries = @product.enquiries\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @enquiries }\n end\n end", "def index\n @qandas = Qanda.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:...
[ "0.61279315", "0.6097457", "0.6088066", "0.6036146", "0.6034176", "0.60301036", "0.60092074", "0.59902686", "0.5989661", "0.5957071", "0.59337425", "0.5905685", "0.59052444", "0.59038985", "0.590354", "0.5884594", "0.5883558", "0.5877946", "0.585553", "0.5842793", "0.5827917"...
0.7351676
0
GET /quandaries/1 GET /quandaries/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @quandaries = Quandary.all\n end", "def show\n @quiniela = Quiniela.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quiniela }\n end\n end", "def show\n @qu = Qu.find(params[:id])\n\n respond_to do |format|\n ...
[ "0.6961569", "0.6517356", "0.644197", "0.64323044", "0.64267725", "0.64141005", "0.63896364", "0.63785464", "0.6346586", "0.6204286", "0.6171063", "0.6140138", "0.60529745", "0.6052364", "0.60214853", "0.5986348", "0.5982835", "0.5974955", "0.59725136", "0.5959132", "0.594075...
0.0
-1
POST /quandaries POST /quandaries.json
def create @quandary= current_user.quandaries.build(quandary_params) respond_to do |format| if @quandary.save format.html { redirect_to @quandary, notice: 'Quandary was successfully created.' } format.json { render :show, status: :created, location: @quandary } else format.html { render :new } format.json { render json: @quandary.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @qu = Qu.new(params[:qu])\n\n respond_to do |format|\n if @qu.save\n format.html { redirect_to @qu, :notice => 'Qu was successfully created.' }\n format.json { render :json => @qu, :status => :created, :location => @qu }\n else\n format.html { render :action => \"n...
[ "0.62389404", "0.62389404", "0.6151092", "0.61087877", "0.6073034", "0.6004367", "0.593869", "0.5891279", "0.58522236", "0.5834811", "0.58176064", "0.57938856", "0.5793638", "0.57666874", "0.57587105", "0.575488", "0.57460207", "0.57189983", "0.56820595", "0.5674164", "0.5650...
0.7157882
0
PATCH/PUT /quandaries/1 PATCH/PUT /quandaries/1.json
def update respond_to do |format| if @quandary.update(quandary_params) format.html { redirect_to @quandary, notice: 'Quandary was successfully updated.' } format.json { render :show, status: :ok, location: @quandary } else format.html { render :edit } format.json { render json: @quandary.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @qu = Qu.find(params[:id])\n respond_to do |format|\n if @qu.update_attributes(params[:qu])\n format.html { redirect_to @qu, :notice => 'Qu was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n ...
[ "0.6535625", "0.6535625", "0.6463256", "0.6404475", "0.6357032", "0.6356482", "0.63205767", "0.63128835", "0.6258589", "0.6254157", "0.62235", "0.61985064", "0.6196127", "0.6118855", "0.6104543", "0.60871434", "0.6069321", "0.606445", "0.6039602", "0.60374117", "0.60209024", ...
0.69665366
0
DELETE /quandaries/1 DELETE /quandaries/1.json
def destroy @quandary.destroy respond_to do |format| format.html { redirect_to quandaries_url, notice: 'Quandary was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @quatum.destroy\n respond_to do |format|\n format.html { redirect_to quata_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @qu = Qu.find(params[:id])\n @qu.destroy\n\n respond_to do |format|\n format.html { redirect_to qus_url }\n format....
[ "0.71185946", "0.7070663", "0.70522606", "0.7052003", "0.69715416", "0.69682944", "0.6847839", "0.68292654", "0.6829206", "0.68079275", "0.6757404", "0.6745749", "0.6730558", "0.6705325", "0.6683369", "0.6668477", "0.6653593", "0.6652635", "0.6635347", "0.66319096", "0.662888...
0.7315046
0
Use callbacks to share common setup or constraints between actions.
def set_quandary @quandary = Quandary.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def quandary_params params.require(:quandary).permit(:title, :description, :rating, :image) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
Formats a CarbonDate::Date with year precision as a string Returns: A humanreadable string representing the Date
def year(date) y = date.year.abs.to_s return [y, BCE_SUFFIX].join(' ') if (date.year <= -1) y end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_year(year)\n \"#{year}-#{year+1}\"\n end", "def zt_date date\n if date.year == Time.now.year\n l date, format: :short\n else\n l date, format: :long\n end\n end", "def year\n date&.strftime('%Y')\n end", "def w_year\n @obj.date.strftime(\"%G\")\n end", ...
[ "0.7263901", "0.70944643", "0.70578635", "0.68968964", "0.6865473", "0.6822611", "0.68086827", "0.68062824", "0.680387", "0.6730236", "0.6712811", "0.6666544", "0.6627725", "0.66246295", "0.6560978", "0.64972436", "0.6484851", "0.64819336", "0.64819336", "0.6473761", "0.64682...
0.6805639
8
Formats a CarbonDate::Date with month precision as a string Returns: A humanreadable string representing the Date
def month(date) [MONTHS[date.month - 1], year(date)].join(', ') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def month_format(date)\n return nil if date.blank?\n date.strftime('%b')\n end", "def month_format(date)\n return nil if date.blank?\n date.strftime('%b')\n end", "def month\n @month.to_s.rjust(2, '0')\n end", "def month_str\n ret = Datet.months(:trans => true)[@t_month]\n if args...
[ "0.70175797", "0.70175797", "0.6908569", "0.68976855", "0.67848736", "0.67848736", "0.67518467", "0.6716134", "0.6712761", "0.6684678", "0.66814077", "0.66467375", "0.66138846", "0.6593557", "0.65671486", "0.65501297", "0.65374804", "0.6481884", "0.6475689", "0.64270544", "0....
0.6518905
17
Formats a CarbonDate::Date with day precision as a string Returns: A humanreadable string representing the Date
def day(date) [date.day.ordinalize.to_s, month(date)].join(' ') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def formatted_date\n \"#{self.day.date.strftime(\"%A, %B %e, %Y\")}\"\n end", "def to_s\n CarbonDate::Date.formatter.date_to_string(self)\n end", "def format_date\n chars = @date.split('')\n chars.pop(6)\n chars.join('')\n end", "def format_date_nicely(date)\nend", "def to_s\n da...
[ "0.7418952", "0.6998934", "0.6885781", "0.681611", "0.67580223", "0.6754108", "0.67494404", "0.67186266", "0.6626139", "0.6626139", "0.6566078", "0.65371704", "0.6524665", "0.65231633", "0.652215", "0.65159845", "0.6490641", "0.64803797", "0.64725554", "0.64614254", "0.644637...
0.59504145
90
Formats a CarbonDate::Date with hour precision as a string Returns: A humanreadable string representing the Date
def hour(date) h = date.minute >= 30 ? date.hour + 1 : date.hour time = [pad(h.to_s), '00'].join(':') [time, day(date)].join(' ') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_formatted_hour\n start_on.strftime(\"%H:%M\")\n end", "def format_date(date)\n year, month, day, day_name, hour = [\n date.year,\n Date::MONTHNAMES[date.month],\n date.day.ordinalize,\n date.strftime(\"%A\"),\n convert_hour(date.hour, 'standard')\n ]\n\n \"#{day_...
[ "0.68358004", "0.6781176", "0.6676465", "0.6548966", "0.6546911", "0.6520813", "0.651328", "0.648706", "0.6472163", "0.6292472", "0.62876934", "0.62299997", "0.62299997", "0.6177343", "0.61736315", "0.61465746", "0.6122212", "0.6104503", "0.6080567", "0.6074086", "0.60721505"...
0.6031681
25
Formats a CarbonDate::Date with minute precision as a string Returns: A humanreadable string representing the Date
def minute(date) time = [pad(date.hour.to_s), pad(date.minute.to_s)].join(':') [time, day(date)].join(' ') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def formatted_date(date)\n return '' if date.nil?\n sprintf('%d/%d/%d alle %d:%d', date.day, date.month, date.year,\n date.hour, date.min)\n end", "def format_datetime(date, format = :long)\n date.to_formatted_s(format)\n end", "def start_time_string\n date_component = self.start_tim...
[ "0.65942013", "0.61959046", "0.59428924", "0.59124947", "0.5905701", "0.5872843", "0.5849906", "0.5840041", "0.58203125", "0.5809602", "0.57933164", "0.57621205", "0.57257676", "0.57216126", "0.5713124", "0.5702826", "0.56995213", "0.5685221", "0.5661887", "0.56459457", "0.56...
0.63774943
1
Formats a CarbonDate::Date with second precision as a string Returns: A humanreadable string representing the Date
def second(date) time = [pad(date.hour.to_s), pad(date.minute.to_s), pad(date.second.to_s)].join(':') [time, day(date)].join(' ') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n CarbonDate::Date.formatter.date_to_string(self)\n end", "def format_date_nicely(date)\nend", "def formatDate(date, options={})\n if (options[:dateOnly]==true)\n return date.localtime().strftime(\"%d.%m.%Y\")\n else\n if (options[:showSeconds]==false)\n return date.loca...
[ "0.6484579", "0.6476181", "0.6469141", "0.646061", "0.62972987", "0.62581277", "0.62081", "0.6193074", "0.615616", "0.6139488", "0.6139488", "0.6138897", "0.6071379", "0.5993085", "0.5993085", "0.59857273", "0.59679365", "0.5956938", "0.595501", "0.5930252", "0.59277177", "...
0.60055274
13
Formats a CarbonDate::Date with decade precision Returns: A humanreadable string representing the Date
def decade(date) d = ((date.year.abs.to_i / 10) * 10).to_s + 's' return [d, BCE_SUFFIX].join(' ') if (date.year <= -1) d end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_date\n chars = @date.split('')\n chars.pop(6)\n chars.join('')\n end", "def pretty_date(input_date)\n return input_date.strftime(\"%d %B %Y\")\n end", "def format_date_nicely(date)\nend", "def to_s\n CarbonDate::Date.formatter.date_to_string(self)\n end", "def date_formatte...
[ "0.67224425", "0.6532047", "0.64644957", "0.64226294", "0.63994473", "0.6208132", "0.61918914", "0.6159244", "0.6159244", "0.6119847", "0.6119847", "0.6119847", "0.6091613", "0.607432", "0.60601646", "0.60582453", "0.6048835", "0.60484886", "0.6047693", "0.6029764", "0.602296...
0.6248774
5
Formats a CarbonDate::Date with century precision Returns: A humanreadable string representing the Date
def century(date) c = ((date.year.abs.to_i / 100) + 1).ordinalize + ' century' return [c, BCE_SUFFIX].join(' ') if (date.year <= -1) c end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_str_for_century\n return unless orig_date_str\n return if orig_date_str =~ /B\\.C\\./\n\n century_str_matches = orig_date_str.match(CENTURY_WORD_REGEXP)\n return century_str_matches.to_s if century_str_matches\n\n century_matches = orig_date_str.match(CENTURY_4CHAR_RE...
[ "0.6688998", "0.6508177", "0.63961935", "0.63858837", "0.63814676", "0.63205165", "0.63205165", "0.6317557", "0.6222274", "0.62221074", "0.62148434", "0.6214128", "0.6212795", "0.6190952", "0.6176208", "0.6171632", "0.614571", "0.61113495", "0.6083428", "0.6071608", "0.607016...
0.68591857
0
Formats a CarbonDate::Date with millennium precision Returns: A humanreadable string representing the Date
def millennium(date) m = ((date.year.abs.to_i / 1000) + 1).ordinalize + ' millennium' return [m, BCE_SUFFIX].join(' ') if (date.year <= -1) m end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_date_nicely(date)\nend", "def pretty_date(input_date)\n return input_date.strftime(\"%d %B %Y\")\n end", "def date_formatted\n date.strftime(\"%A %B %d, %Y\")\n end", "def expected_note_short_date_format(date)\n (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d') ...
[ "0.6249519", "0.62080973", "0.601992", "0.59677535", "0.5927565", "0.5911778", "0.5910613", "0.5882393", "0.5877799", "0.5851", "0.58409035", "0.58233577", "0.5756727", "0.57434565", "0.57348484", "0.5720722", "0.57056326", "0.565787", "0.56289965", "0.56255573", "0.5574238",...
0.57560164
13
Formats a CarbonDate::Date with ten_thousand_years precision Returns: A humanreadable string representing the Date
def ten_thousand_years(date) coarse_precision(date.year, 10e3.to_i) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ten_million_years(date)\n coarse_precision(date.year, 10e6.to_i)\n end", "def hundred_thousand_years(date)\n coarse_precision(date.year, 100e3.to_i)\n end", "def hundred_million_years(date)\n coarse_precision(date.year, 100e6.to_i)\n end", "def billion_years(date)\n coarse_pr...
[ "0.6480022", "0.62412304", "0.6012005", "0.59666866", "0.5856101", "0.5848344", "0.5779537", "0.5720695", "0.5717529", "0.5710835", "0.5669659", "0.565364", "0.56508756", "0.56508756", "0.56446445", "0.56200486", "0.55205345", "0.55137295", "0.5507825", "0.54464793", "0.54361...
0.681807
0
Formats a CarbonDate::Date with hundred_thousand_years precision Returns: A humanreadable string representing the Date
def hundred_thousand_years(date) coarse_precision(date.year, 100e3.to_i) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ten_thousand_years(date)\n coarse_precision(date.year, 10e3.to_i)\n end", "def hundred_million_years(date)\n coarse_precision(date.year, 100e6.to_i)\n end", "def billion_years(date)\n coarse_precision(date.year, 1e9.to_i)\n end", "def ten_million_years(date)\n coarse_precisio...
[ "0.65144795", "0.6489899", "0.6168684", "0.6153184", "0.6072605", "0.60651904", "0.60636854", "0.60636854", "0.60246164", "0.5978676", "0.5938752", "0.58899736", "0.5809043", "0.5778706", "0.57681113", "0.57350665", "0.57097524", "0.57077795", "0.56959915", "0.5690208", "0.56...
0.6821243
0
Formats a CarbonDate::Date with million_years precision Returns: A humanreadable string representing the Date
def million_years(date) coarse_precision(date.year, 1e6.to_i) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ten_million_years(date)\n coarse_precision(date.year, 10e6.to_i)\n end", "def hundred_million_years(date)\n coarse_precision(date.year, 100e6.to_i)\n end", "def billion_years(date)\n coarse_precision(date.year, 1e9.to_i)\n end", "def format_date_nicely(date)\nend", "def ten_thou...
[ "0.64051497", "0.63893443", "0.62808996", "0.6013068", "0.5954019", "0.59120136", "0.5871082", "0.58656216", "0.5839477", "0.58277667", "0.58230555", "0.5721606", "0.57044834", "0.57044834", "0.56823957", "0.56441736", "0.56210005", "0.56068146", "0.56017363", "0.55892205", "...
0.65519065
0
Formats a CarbonDate::Date with ten_million_years precision Returns: A humanreadable string representing the Date
def ten_million_years(date) coarse_precision(date.year, 10e6.to_i) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ten_thousand_years(date)\n coarse_precision(date.year, 10e3.to_i)\n end", "def hundred_million_years(date)\n coarse_precision(date.year, 100e6.to_i)\n end", "def million_years(date)\n coarse_precision(date.year, 1e6.to_i)\n end", "def billion_years(date)\n coarse_precision(da...
[ "0.6353445", "0.6072817", "0.6047292", "0.6042898", "0.5839487", "0.5815037", "0.57690495", "0.57598335", "0.5718243", "0.5715554", "0.56648076", "0.56621873", "0.5647103", "0.5595492", "0.5591696", "0.5591696", "0.5563381", "0.5522932", "0.5522932", "0.5477907", "0.54554003"...
0.6582434
0
Formats a CarbonDate::Date with hundred_million_years precision Returns: A humanreadable string representing the Date
def hundred_million_years(date) coarse_precision(date.year, 100e6.to_i) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hundred_thousand_years(date)\n coarse_precision(date.year, 100e3.to_i)\n end", "def ten_million_years(date)\n coarse_precision(date.year, 10e6.to_i)\n end", "def million_years(date)\n coarse_precision(date.year, 1e6.to_i)\n end", "def billion_years(date)\n coarse_precision(da...
[ "0.6489859", "0.6457484", "0.6398476", "0.639723", "0.6288928", "0.6007059", "0.5962666", "0.5959947", "0.5928867", "0.58949167", "0.5890696", "0.5890696", "0.58042276", "0.57296354", "0.56888074", "0.56431854", "0.5635764", "0.562886", "0.56057197", "0.5601694", "0.5569729",...
0.6697717
0