<commit_before># -*- coding: utf-8 -*-
from django.db import models
from place import Place
from django.contrib.auth.models import User
from math import exp


class UserPlaceManager(models.Manager):

    def for_user_and_map(self, user, map_place):
        return self.filter(
            user=user,
            place__in=map_place.related_places.all()
        ).select_related('place').order_by('place__name')

    def from_user_and_place(self, user, place):
        try:
            user_place = self.get(user=user, place=place)
        except UserPlace.DoesNotExist:
            user_place = UserPlace(
                user=user,
                place=place,
            )
        return user_place


class UserPlace(models.Model):

    dummy_id = models.CharField(primary_key=True, max_length=40)
    user = models.ForeignKey(User)
    place = models.ForeignKey(Place)
    elo_skill = models.FloatField(default=0)

    objects = UserPlaceManager()

    def to_serializable(self):
        ret = self.place.to_serializable()
        ret.update({
            'skill': self.elo_skill,
            'probability': 1.0 / (1 + exp(-self.skill)),
            'certainty': 1
        })
        return ret

    class Meta:
        app_label = 'geography'
        managed = False

    """ READ ONLY MODEL """
    def save(self, **kwargs):
        raise NotImplementedError<commit_msg>fix usage of elo_skill in user's place<commit_after># -*- coding: utf-8 -*-
from django.db import models
from place import Place
from django.contrib.auth.models import User
from math import exp


class UserPlaceManager(models.Manager):

    def for_user_and_map(self, user, map_place):
        return self.filter(
            user=user,
            place__in=map_place.related_places.all()
        ).select_related('place').order_by('place__name')

    def from_user_and_place(self, user, place):
        try:
            user_place = self.get(user=user, place=place)
        except UserPlace.DoesNotExist:
            user_place = UserPlace(
                user=user,
                place=place,
            )
        return user_place


class UserPlace(models.Model):

    dummy_id = models.CharField(primary_key=True, max_length=40)
    user = models.ForeignKey(User)
    place = models.ForeignKey(Place)
    elo_skill = models.FloatField(default=0)

    objects = UserPlaceManager()

    def to_serializable(self):
        ret = self.place.to_serializable()
        ret.update({
            'skill': self.elo_skill,
            'probability': 1.0 / (1 + exp(-self.elo_skill)),
            'certainty': 1
        })
        return ret

    class Meta:
        app_label = 'geography'
        managed = False

    """ READ ONLY MODEL """
    def save(self, **kwargs):
        raise NotImplementedError
{'fraction_non_alphanumeric': 0.104638619201726, 'fraction_numerical': 0.005753326141675656, 'mean_word_length': 2.331736526946108, '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': '2549193', 'n_tokens_mistral': 844, 'n_tokens_neox': 811, 'n_words': 181}