Calculate the bin index for a given complexity value using feature scaling. Args: complexity: The complexity value (code length) Returns: Bin index in range [0, self.feature_bins - 1]
(self, complexity: int)
| 906 | return coords |
| 907 | |
| 908 | def _calculate_complexity_bin(self, complexity: int) -> int: |
| 909 | """ |
| 910 | Calculate the bin index for a given complexity value using feature scaling. |
| 911 | |
| 912 | Args: |
| 913 | complexity: The complexity value (code length) |
| 914 | |
| 915 | Returns: |
| 916 | Bin index in range [0, self.feature_bins - 1] |
| 917 | """ |
| 918 | # Update feature statistics |
| 919 | self._update_feature_stats("complexity", float(complexity)) |
| 920 | |
| 921 | # Scale the value using configured method |
| 922 | scaled_value = self._scale_feature_value("complexity", float(complexity)) |
| 923 | |
| 924 | # Get number of bins for this dimension |
| 925 | num_bins = self.feature_bins_per_dim.get("complexity", self.feature_bins) |
| 926 | |
| 927 | # Convert to bin index |
| 928 | bin_idx = int(scaled_value * num_bins) |
| 929 | |
| 930 | # Ensure bin index is within valid range |
| 931 | bin_idx = max(0, min(num_bins - 1, bin_idx)) |
| 932 | |
| 933 | return bin_idx |
| 934 | |
| 935 | def _calculate_diversity_bin(self, diversity: float) -> int: |
| 936 | """ |
no test coverage detected