<commit_before>from __future__ import unicode_literals

from django.db.models.indexes import Index

__all__ = ['BrinIndex', 'GinIndex']


class BrinIndex(Index):
    suffix = 'brin'

    def __init__(self, fields=[], name=None, pages_per_range=None):
        if pages_per_range is not None and not (isinstance(pages_per_range, int) and pages_per_range > 0):
            raise ValueError('pages_per_range must be None or a positive integer for BRIN indexes')
        self.pages_per_range = pages_per_range
        return super(BrinIndex, self).__init__(fields, name)

    def __repr__(self):
        if self.pages_per_range is not None:
            return '<%(name)s: fields=%(fields)s, pages_per_range=%(pages_per_range)s>' % {
                'name': self.__class__.__name__,
                'fields': "'{}'".format(', '.join(self.fields)),
                'pages_per_range': self.pages_per_range,
            }
        else:
            return super(BrinIndex, self).__repr__()

    def deconstruct(self):
        path, args, kwargs = super(BrinIndex, self).deconstruct()
        kwargs['pages_per_range'] = self.pages_per_range
        return path, args, kwargs

    def get_sql_create_template_values(self, model, schema_editor, using):<commit_msg>Refs #25809 -- Prefered imports from django.db.models.<commit_after>from __future__ import unicode_literals

from django.db.models import Index

__all__ = ['BrinIndex', 'GinIndex']


class BrinIndex(Index):
    suffix = 'brin'

    def __init__(self, fields=[], name=None, pages_per_range=None):
        if pages_per_range is not None and not (isinstance(pages_per_range, int) and pages_per_range > 0):
            raise ValueError('pages_per_range must be None or a positive integer for BRIN indexes')
        self.pages_per_range = pages_per_range
        return super(BrinIndex, self).__init__(fields, name)

    def __repr__(self):
        if self.pages_per_range is not None:
            return '<%(name)s: fields=%(fields)s, pages_per_range=%(pages_per_range)s>' % {
                'name': self.__class__.__name__,
                'fields': "'{}'".format(', '.join(self.fields)),
                'pages_per_range': self.pages_per_range,
            }
        else:
            return super(BrinIndex, self).__repr__()

    def deconstruct(self):
        path, args, kwargs = super(BrinIndex, self).deconstruct()
        kwargs['pages_per_range'] = self.pages_per_range
        return path, args, kwargs

    def get_sql_create_template_values(self, model, schema_editor, using):
{'fraction_non_alphanumeric': 0.11233740638549468, 'fraction_numerical': 0.0027591643673630273, 'mean_word_length': 3.1402936378466557, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6626572', 'n_tokens_mistral': 796, 'n_tokens_neox': 773, 'n_words': 184}