<commit_before># ----------------------------------------------------------------------------
# Copyright (c) 2013--, scikit-bio development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
# ----------------------------------------------------------------------------

from __future__ import absolute_import, division, print_function
from future.utils.six import StringIO

import unittest

from skbio import TreeNode
from skbio.io import NewickFormatError
from skbio.io.newick import (_newick_to_tree_node, _tree_node_to_newick,
                             _newick_sniffer)


class TestNewick(unittest.TestCase):
    def _invert_tree(self, tree):
        tree.children = [self._invert_tree(child) for child
                         in reversed(tree.children)]
        return tree

    def _is_node_equal(self, n1, n2):
        self.assertEqual(n1.name, n2.name)
        self.assertEqual(n1.length, n2.length)
        self.assertEqual(len(n1.children), len(n2.children))
        return True

    def _is_equal(self, n1, n2):
        name = lambda x: (x.name, x.length, len(x.children))
        if self._is_node_equal(n1, n2):
            for c1, c2 in zip(sorted(n1.children, key=name),
                              sorted(n2.children, key=name)):
                self.assertTrue(c1.parent is n1)
                self.assertTrue(c2.parent is n2)
                if not self._is_equal(c1, c2):
                    return False
            return True<commit_msg>TST: fixed python3 in test_newick.py<commit_after># ----------------------------------------------------------------------------
# Copyright (c) 2013--, scikit-bio development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
# ----------------------------------------------------------------------------

from __future__ import absolute_import, division, print_function
from future.utils.six import StringIO

import unittest

from skbio import TreeNode
from skbio.io import NewickFormatError
from skbio.io.newick import (_newick_to_tree_node, _tree_node_to_newick,
                             _newick_sniffer)


class TestNewick(unittest.TestCase):
    def _invert_tree(self, tree):
        tree.children = [self._invert_tree(child) for child
                         in reversed(tree.children)]
        return tree

    def _is_node_equal(self, n1, n2):
        self.assertEqual(n1.name, n2.name)
        self.assertEqual(n1.length, n2.length)
        self.assertEqual(len(n1.children), len(n2.children))
        return True

    def _is_equal(self, n1, n2):
        name = lambda x: (x.name, x.length, len(x.children))
        if self._is_node_equal(n1, n2):
            for c1, c2 in zip(sorted(n1.children if n1.children else [],
                                     key=name),
                              sorted(n2.children if n1.children else [],
                                     key=name)):
                self.assertTrue(c1.parent is n1)
                self.assertTrue(c2.parent is n2)
                if not self._is_equal(c1, c2):
                    return False
            return True
{'fraction_non_alphanumeric': 0.17263544536271808, 'fraction_numerical': 0.016835016835016835, 'mean_word_length': 1.6569105691056911, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4201971', 'n_tokens_mistral': 921, 'n_tokens_neox': 894, 'n_words': 237}