-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.py
33 lines (25 loc) · 915 Bytes
/
example.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
from random import randint
from typing import List
from featureclass import feature, feature_annotations, feature_names, featureclass
@featureclass
class MyFeatures:
a: int
@feature()
def feature_1(self) -> int:
"""generate random number"""
return randint(0, 10)
@feature()
def feature_2(self) -> int:
"""generate random number"""
return randint(0, 10) + self.feature_1
@feature()
def feature_list(self) -> List[int]:
"""generate random of size 5"""
return [randint(0, 10) + self.feature_1 + self.feature_2 for i in range(5)]
if __name__ == "__main__":
myf = MyFeatures()
print("feature_1", myf.feature_1)
print("cached", myf.feature_1 == myf.feature_1)
print("feature_names:", feature_names(myf))
print("feature_annoations:", feature_annotations(myf))
print("__annotations__:", MyFeatures.__annotations__)