<commit_before>import os
import random
import unittest

from laserchicken import compute_neighbors, feature_extractor, keys, read_las, utils
from laserchicken.volume_specification import InfiniteCylinder


class TestExtractEntropy(unittest.TestCase):
    _test_file_name = 'AHN3.las'
    _test_data_source = 'testdata'
    point_cloud = None

    def test_entropy_in_cylinders(self):
        """Test computing of eigenvalues in cylinder."""
        num_all_pc_points = len(self.point_cloud[keys.point]["x"]["data"])
        rand_indices = [random.randint(0, num_all_pc_points)
                        for p in range(20)]
        target_point_cloud = utils.copy_point_cloud(
            self.point_cloud, rand_indices)
        n_targets = len(target_point_cloud[keys.point]["x"]["data"])
        radius = 25
        neighbors = compute_neighbors.compute_cylinder_neighborhood(
            self.point_cloud, target_point_cloud, radius)

        target_idx_base = 0
        for x in neighbors:
            feature_extractor.compute_features(self.point_cloud, x, target_idx_base, target_point_cloud,
                                               ["z_entropy"], InfiniteCylinder(5), layer_thickness=0.1)
            target_idx_base += len(x)

        for i in range(n_targets):
            H = utils.get_attribute_value(target_point_cloud, i, "z_entropy")
            self.assertTrue(H >= 0)
        self.assertEqual("laserchicken.feature_extractor.entropy_feature_extractor",
                         target_point_cloud[keys.provenance][0]["module"])
        self.assertEqual(
            [0.1], target_point_cloud[keys.provenance][0]["parameters"])

    def setUp(self):
        self.point_cloud = read_las.read(os.path.join(<commit_msg>update entropy tests to use new feature key/name<commit_after>import os
import random
import unittest

from laserchicken import compute_neighbors, feature_extractor, keys, read_las, utils
from laserchicken.volume_specification import InfiniteCylinder


class TestExtractEntropy(unittest.TestCase):
    _test_file_name = 'AHN3.las'
    _test_data_source = 'testdata'
    point_cloud = None

    def test_entropy_in_cylinders(self):
        """Test computing of eigenvalues in cylinder."""
        num_all_pc_points = len(self.point_cloud[keys.point]["x"]["data"])
        rand_indices = [random.randint(0, num_all_pc_points)
                        for p in range(20)]
        target_point_cloud = utils.copy_point_cloud(
            self.point_cloud, rand_indices)
        n_targets = len(target_point_cloud[keys.point]["x"]["data"])
        radius = 25
        neighbors = compute_neighbors.compute_cylinder_neighborhood(
            self.point_cloud, target_point_cloud, radius)

        target_idx_base = 0
        for x in neighbors:
            feature_extractor.compute_features(self.point_cloud, x, target_idx_base, target_point_cloud,
                                               ["entropy_z"], InfiniteCylinder(5), layer_thickness=0.1)
            target_idx_base += len(x)

        for i in range(n_targets):
            H = utils.get_attribute_value(target_point_cloud, i, "entropy_z")
            self.assertTrue(H >= 0)
        self.assertEqual("laserchicken.feature_extractor.entropy_z_feature_extractor",
                         target_point_cloud[keys.provenance][0]["module"])
        self.assertEqual(
            [0.1], target_point_cloud[keys.provenance][0]["parameters"])

    def setUp(self):
        self.point_cloud = read_las.read(os.path.join(
{'fraction_non_alphanumeric': 0.0943826632449387, 'fraction_numerical': 0.00855431993156544, 'mean_word_length': 2.9283314669652856, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '375052', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1058, 'n_words': 186}