<commit_before>#!/usr/bin/python3


import math
import hashlib


import numpy as np

from typing import Any, Optional

from ..exceptions import StrandError, ChromosomeError, MissingLocusError
from .subloci import SubLoci
from .attrs import LocusAttrs


__all__ = ["Locus"]


class Locus:
    def __init__(
        self,
        chromosome: str,
        start: int,
        end: int,
        source: str = "locuspocus",
        feature_type: str = "locus",
        strand: str = "+",
        frame: int = None,
        name: str = None,
        # Extra locus stuff
        attrs: LocusAttrs = None,
        subloci: SubLoci = None,
    ):
        self.chromosome = str(chromosome)
        self.start = int(start)
        self.end = int(end)
        self.source = str(source)
        self.feature_type = str(feature_type)
        self.strand = str(strand)
        self.frame = frame
        self.name = name

        self.attrs = LocusAttrs(attrs)
        self.subloci = SubLoci(subloci)

    def __eq__(self, other):
        if (
            self.chromosome == other.chromosome
            and self.start == other.start
            and self.end == other.end
            and self.source == other.source
            and self.feature_type == other.feature_type
            and self.strand == other.strand
            and self.frame == other.frame
            and self.name == other.name
            and self.attrs == other.attrs
            and self.subloci == other.subloci
        ):
            return True
        else:
            return False<commit_msg>use hash for equality<commit_after>#!/usr/bin/python3


import math
import hashlib


import numpy as np

from typing import Any, Optional

from ..exceptions import StrandError, ChromosomeError, MissingLocusError
from .subloci import SubLoci
from .attrs import LocusAttrs


__all__ = ["Locus"]


class Locus:
    def __init__(
        self,
        chromosome: str,
        start: int,
        end: int,
        source: str = "locuspocus",
        feature_type: str = "locus",
        strand: str = "+",
        frame: int = None,
        name: str = None,
        # Extra locus stuff
        attrs: LocusAttrs = None,
        subloci: SubLoci = None,
    ):
        self.chromosome = str(chromosome)
        self.start = int(start)
        self.end = int(end)
        self.source = str(source)
        self.feature_type = str(feature_type)
        self.strand = str(strand)
        self.frame = frame
        self.name = name

        self.attrs = LocusAttrs(attrs)
        self.subloci = SubLoci(subloci)

    def __eq__(self, other):
        return hash(self) == hash(other)
        if (
            self.chromosome == other.chromosome
            and self.start == other.start
            and self.end == other.end
            and self.source == other.source
            and self.feature_type == other.feature_type
            and self.strand == other.strand
            and self.frame == other.frame
            and self.name == other.name
            and self.attrs == other.attrs
            #and self.subloci == other.subloci
        ):
            return True
        else:
            return False
{'fraction_non_alphanumeric': 0.09329538266919671, 'fraction_numerical': 0.0006325110689437065, 'mean_word_length': 1.789241622574956, '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': '6859916', 'n_tokens_mistral': 963, 'n_tokens_neox': 912, 'n_words': 249}