<commit_before>#!/usr/bin/env python

from nodes import Node

class BitXOR(Node):
    args = 2
    results = 1
    char = ".^"
    
    def prepare(self, stack):
        if len(stack) == 0:
            self.add_arg(stack)
        if isinstance(stack[0], Node.sequence):
                self.args = 1
            
    @Node.test_func([4,5], [1])
    def func(self, a:int,b:int):
        """a^b"""
        return a^b

    @Node.test_func(["Test.", "Te"], [1])
    @Node.test_func(["Test.", "?"], [0])
    @Node.test_func(["Test.", "T"], [1])
    def startswith(self, string:str, suffix:str):
        """Does string start with suffix?"""
        return int(string.startswith(suffix))
    
    def xor_seq(self, seqs:Node.sequence):
        """Setwise xor of sequences"""
        if len(seqs)==0: return seqs
        rtn = []
        for seq in seqs:
            for i in seq:
                if i not in rtn:
                    rtn.append(i)
                else:
                    rtn.remove(i)
        return [rtn]<commit_msg>bit_xor works with 1 dimensional seqs<commit_after>#!/usr/bin/env python

from nodes import Node

class BitXOR(Node):
    args = 2
    results = 1
    char = ".^"
    
    def prepare(self, stack):
        if len(stack) == 0:
            self.add_arg(stack)
        if isinstance(stack[0], Node.sequence):
                self.args = 1
            
    @Node.test_func([4,5], [1])
    def func(self, a:int,b:int):
        """a^b"""
        return a^b

    @Node.test_func(["Test.", "Te"], [1])
    @Node.test_func(["Test.", "?"], [0])
    @Node.test_func(["Test.", "T"], [1])
    def startswith(self, string:str, suffix:str):
        """Does string start with suffix?"""
        return int(string.startswith(suffix))
    
    def xor_seq(self, seqs:Node.sequence):
        """Setwise xor of sequences"""
        if len(seqs)==0: return seqs
        rtn = []
        for seq in seqs:
            if isinstance(seq, Node.sequence):
                for i in seq:
                    if i not in rtn:
                        rtn.append(i)
                    else:
                        rtn.remove(i)
            else:
                if seq in rtn:
                    rtn.append(seq)
                else:
                    rtn.remove(seq)
        return [rtn]

{'fraction_non_alphanumeric': 0.14666084679179398, 'fraction_numerical': 0.010912265386294195, 'mean_word_length': 1.5666293393057111, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4844022', 'n_tokens_mistral': 767, 'n_tokens_neox': 735, 'n_words': 179}