-
Notifications
You must be signed in to change notification settings - Fork 17
/
score.py
57 lines (48 loc) · 1.6 KB
/
score.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from sqlalchemy import Float
from sqlalchemy import Column
from sqlalchemy import String
from sqlalchemy import Integer
from sqlalchemy import Boolean
from .base import Model
__all__ = ['ScoreType']
# XXX: Should probably be addressed at some point?
# Deprecated: score types are now defined in problem.py.
# EventScoreType.score_type should be deleted then DB migrated.
class ScoreType(Model):
"""ScoreType table.
Parameters
----------
name : str
The name of the score.
is_lower_the_better : bool
Whether a lower score is better.
minimum : float
The minimum possible score.
maximum : float
The maximum possible score.
Attributes
----------
id : int
The ID of the row table.
is_lower_the_better : bool
Whether a lower score is better.
minimum : float
The minimum possible score.
maximum : float
The maximum possible score.
events : list of :class:`ramp_database.model.EventScoreType`
A back-reference to the event using the score.
"""
__tablename__ = 'score_types'
id = Column(Integer, primary_key=True)
name = Column(String, nullable=False, unique=True)
is_lower_the_better = Column(Boolean, nullable=False)
minimum = Column(Float, nullable=False)
maximum = Column(Float, nullable=False)
def __init__(self, name, is_lower_the_better, minimum, maximum):
self.name = name
self.is_lower_the_better = is_lower_the_better
self.minimum = minimum
self.maximum = maximum
def __repr__(self):
return 'ScoreType(name={})'.format(self.name)