<commit_before>from django.db import models
import math

class Neighborhood(models.Model):
    """ Corresponds to a neighborhood that the system will recognize.
        - name -- the human-readable name of the neighborhood
        - radius_to_search -- how far to search for wells in meters
        - lattitude -- the lattitude of the neighborhood
        - longitude -- the longitude of the neighborhood
    """ 
    name = models.CharField(max_length=80)
    radius_to_search = models.IntegerField()
    lattitude = models.FloatField()
    longitude = models.FloatField()
    def __str__(self):
        return self.name

class Source(models.Model):
    """ Corresponds to a source of water.
        - water_quality -- a function that takes test results that haven't expired and
                           returns a water quality score
        - lattitude -- the lattitude of the water source
        - longitude -- the longitude of the water source
        - id -- the id of the source written on the well. Must be unique (serves as the db private key)
        - type -- the type of the source (well, private, tap, private well)
    """
    lattitude = models.FloatField()
    longitude = models.FloatField()
    id = models.IntegerField(primary_key=True)
    WELL = 'W'
    PRIVATE = 'P'
    TAP = 'T'
    PRIVATE_WELL = 'PW'
    TYPE_CHOICES = (
        (WELL, 'Well'),
        (PRIVATE, 'Private'),
        (TAP, 'Tap'),
        (PRIVATE_WELL, 'Private Well'),
    )
    type = models.CharField(max_length=2, choices=TYPE_CHOICES)

    ##### GENERAL FUNCTIONS FOR BOTH TURBIDITY AND FECAL##########
    def xtoy(x,x0,x1,y0,y1):<commit_msg>Implemented distance function to determine distance of a source from a neighborhood<commit_after>from django.db import models
import math

class Neighborhood(models.Model):
    """ Corresponds to a neighborhood that the system will recognize.
        - name -- the human-readable name of the neighborhood
        - radius_to_search -- how far to search for wells in meters
        - lattitude -- the lattitude of the neighborhood
        - longitude -- the longitude of the neighborhood
    """ 
    name = models.CharField(max_length=80)
    radius_to_search = models.IntegerField()
    lattitude = models.FloatField()
    longitude = models.FloatField()
    def distance_to(self, lattitude, longitude):
        """Get the distance from this neighborhood to a lat lon point (eg a water source).
           Uses the haversine formula.
        """
        lat1 = math.radians(self.lattitude)
        lat2 = math.radians(lattitude)
        lon1 = math.radians(self.longitude)
        lon2 = math.radians(longitude)
        delta_lattitude = lat2 - lat1
        delta_longitude = lon2 - lon1
        a = (math.sin(delta_lattitude/2.0))**2 + math.cos(lat1)*math.cos(lat2)*(math.sin(delta_longitude))**2 
        c = 2.0 * math.atan2(math.sqrt(a), math.sqrt(1.0-a))
        earth_radius = 6371000.0
        return earth_radius * c

    def __str__(self):
        return self.name

class Source(models.Model):
    """ Corresponds to a source of water.
        - water_quality -- a function that takes test results that haven't expired and
                           returns a water quality score
        - lattitude -- the lattitude of the water source
        - longitude -- the longitude of the water source
        - id -- the id of the source written on the well. Must be unique (serves as the db private key)
        - type -- the type of the source (well, private, tap, private well)
    """
    lattitude = models.FloatField()
    longitude = models.FloatField()
    id = models.IntegerField(primary_key=True)
    WELL = 'W'
    PRIVATE = 'P'
    TAP = 'T'
    PRIVATE_WELL = 'PW'
    TYPE_CHOICES = (
        (WELL, 'Well'),
        (PRIVATE, 'Private'),
        (TAP, 'Tap'),
        (PRIVATE_WELL, 'Private Well'),
    )
    type = models.CharField(max_length=2, choices=TYPE_CHOICES)

    ##### GENERAL FUNCTIONS FOR BOTH TURBIDITY AND FECAL##########
    def xtoy(x,x0,x1,y0,y1):
{'fraction_non_alphanumeric': 0.10201042442293373, 'fraction_numerical': 0.010176222387689253, 'mean_word_length': 2.510452961672474, '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': '3845158', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1176, 'n_words': 381}