<commit_before>import six

from .cypher import Create, Match, Merge, Exists
from .exceptions import DetachedObjectError
from .shared.objects import GraphObject, SetOnceDescriptor

try:
    str = unicode
except NameError:
    pass


class NodeMeta(type):
    def __init__(cls, class_name, bases, attrs):
        cls.labels = SetOnceDescriptor('labels', type=lambda x: tuple(set(x)))
        cls.type = SetOnceDescriptor('type', type=str)
        super(NodeMeta, cls).__init__(class_name, bases, attrs)


@six.add_metaclass(NodeMeta)
class Node(GraphObject):
    def __init__(self, *labels, **properties):
        var = properties.pop('var', 'node')
        if len(labels) == 1 and isinstance(labels[0], Node):
            node = labels[0]
            properties.update({key: prop.copy() for key, prop in node.items()})
        else:
            node = None
        super(Node, self).__init__(**properties)
        if node is not None:
            self.labels = node.labels
            self.type = node.type
            self.var = node.var
        else:
            self.labels = labels
            self.var = var
            try:
                self.type = labels[-1]
            except IndexError:
                self.type = None

    def copy(self, shallow=False, **properties):
        var = properties.pop('var', self.var)
        if shallow:
            copy = Node(graph=self.graph, var=var, *self.labels)
        else:
            copy = Node(graph=self.graph, var=var, *self.labels,
                        **{key: prop.copy() for key, prop in self.items()})
        if self.is_bound:
            copy.bind(*self.bound_keys)
        for key, value in properties.items():
            copy[key].value = value
        return copy

    @property
    def __node__(self):
        return self

    def pattern(self, inline_props=False):<commit_msg>Fix a bug in copy where type could be wrong<commit_after>import six

from .cypher import Create, Match, Merge, Exists
from .exceptions import DetachedObjectError
from .shared.objects import GraphObject, SetOnceDescriptor

try:
    str = unicode
except NameError:
    pass


class NodeMeta(type):
    def __init__(cls, class_name, bases, attrs):
        cls.labels = SetOnceDescriptor('labels', type=lambda x: tuple(set(x)))
        cls.type = SetOnceDescriptor('type', type=str)
        super(NodeMeta, cls).__init__(class_name, bases, attrs)


@six.add_metaclass(NodeMeta)
class Node(GraphObject):
    def __init__(self, *labels, **properties):
        var = properties.pop('var', 'node')
        if len(labels) == 1 and isinstance(labels[0], Node):
            node = labels[0]
            properties.update({key: prop.copy() for key, prop in node.items()})
        else:
            node = None
        super(Node, self).__init__(**properties)
        if node is not None:
            self.labels = node.labels
            self.type = node.type
            self.var = node.var
        else:
            self.labels = labels
            self.var = var
            try:
                self.type = labels[-1]
            except IndexError:
                self.type = None

    def copy(self, shallow=False, **properties):
        var = properties.pop('var', self.var)
        if shallow:
            copy = Node(self, graph=self.graph, var=var)
        else:
            copy = Node(self, graph=self.graph, var=var,
                        **{key: prop.copy() for key, prop in self.items()})
        if self.is_bound:
            copy.bind(*self.bound_keys)
        for key, value in properties.items():
            copy[key].value = value
        return copy

    @property
    def __node__(self):
        return self

    def pattern(self, inline_props=False):
{'fraction_non_alphanumeric': 0.11308562197092084, 'fraction_numerical': 0.002154011847065159, 'mean_word_length': 2.137668918918919, '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': '4519650', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1051, 'n_words': 290}