for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
"""
Calculations.
import math
from collections import defaultdict
from typing import Collection, Dict, Sequence, Set, Tuple
from typeddfs import TypedDfs
from mandos.model.hits import AbstractHit, HitFrame, Pair
SimilarityDf = TypedDfs.typed("DistanceDf").symmetric().build()
class AnalysisUtils:
@classmethod
def elle(cls, x: float) -> float:
This check looks for invalid names for a range of different identifiers.
You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.
If your project includes a Pylint configuration file, the settings contained in that file take precedence.
To find out more about Pylint, please refer to their site.
return math.log10(1 + x)
def hit_multidict(cls, hits: Sequence[AbstractHit], key: str):
x_to_hits = defaultdict(list)
for hit in hits:
x_to_hits[getattr(hit, key)].append(hit)
return x_to_hits
def weights_of_pairs(
cls, hits1: Collection[AbstractHit], hits2: Collection[AbstractHit]
) -> Dict[Pair, Tuple[float, float]]:
Calculates the sum of
union = {h.to_pair for h in hits1}.union({h.to_pair for h in hits2})
return {p: (cls._score(hits1, p), cls._score(hits2, p)) for p in union}
def _score(cls, hits: Collection[AbstractHit], pair: Pair) -> int:
return sum([h.value for h in hits if h.to_pair == pair])
__all__ = ["AnalysisUtils", "SimilarityDf"]