Skip to content

Instantly share code, notes, and snippets.

@ivanjr0
ivanjr0 / multiple_options_field.py
Created April 1, 2012 15:14
Django - MultipleOptionsField - A set of boolean options stored in a positive integer field.
from django.db.models import SubfieldBase
from django.db.models.fields import PositiveIntegerField
class MultipleOptions(object):
def __init__(self, options, value=None):
self.options = options
try:
self._value = int(value)
def enem2ufmg(nota):
if 0 <= nota <= 118.2600:
resultado = 0.005306951 * nota
elif 118.2600 < nota < 936.1355:
resultado = 0.0
resultado += -1.7988096645 * nota
resultado += (4.18317311423 / 10 ** 2) * nota ** 2
resultado -= (4.01229829463 / 10 ** 4) * nota ** 3