This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from matplotlib import pyplot | |
import numpy as np | |
def scale(x, k=1.0, func="log"): | |
k = max(1e-9, abs(k)) | |
if func == "log": | |
return np.sign(x) * np.log(k*np.abs(x)+1) / k | |
elif func == "sqrt": | |
return np.sign(x) * (np.sqrt(k*np.abs(x)+1) * 2 - 2) / k | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object PoiMapping { | |
type Poi = Int | |
type Grade = Int | |
case class MatchResult(poi: Poi, grade: Grade) | |
private def searchMatchingCandidates(poi: Poi): Seq[Poi] = 1 to 300 by 3 | |
private def evaluateMatching(p: Poi, c: Poi): Grade = (p - c).abs |