-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDimensions.ts
More file actions
125 lines (108 loc) · 4.36 KB
/
Dimensions.ts
File metadata and controls
125 lines (108 loc) · 4.36 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// ----------------------------------------------------------------
// PURPOSE:
// This library implements the Dimensions class.
//
// Models:
// This directory contiains the model of the data of this application.
// ----------------------------------------------------------------
import { SerializedDimensions } from '../serializers/Dimensions'
import { Model } from '../interfaces/Model'
import { Log } from '../utils/Logging'
export class Dimensions implements Model {
private small: number = 8
private normal: number = 11
private title: number = 50
private heading1: number = 28
private heading2: number = 20
private heading3: number = 15
private heading4: number = 13
private margin: number = 70
private avatar: number = 50
private padding: number = 8
// Margin size getter and setter.
getMargin(): number { return this.margin }
setMargin(size: number) { this.margin = size }
// Avatar size getter and setter.
getAvatar(): number { return this.avatar }
setAvatar(size: number) { this.avatar = size }
// Padding size getter and setter.
getPadding(): number { return this.padding }
setPadding(size: number) { this.padding = size }
// Normal size getter and setter.
getNormal(): number { return this.normal }
setNormal(size: number) { this.normal = size }
// Small size getter and setter.
getSmall(): number { return this.small }
setSmall(size: number) { this.small = size }
// Title size getter and setter.
getTitle(): number { return this.title }
setTitle(size: number) { this.title = size }
// Heading size getter and setter.
getHeading1(): number { return this.heading1 }
setHeading1(size: number) { this.heading1 = size }
// Heading size getter and setter.
getHeading2(): number { return this.heading2 }
setHeading2(size: number) { this.heading2 = size }
// Heading size getter and setter.
getHeading3(): number { return this.heading3 }
setHeading3(size: number) { this.heading3 = size }
// Heading size getter and setter.
getHeading4(): number { return this.heading4 }
setHeading4(size: number) { this.heading4 = size }
// String serializers.
public toString(): string {
return `<${(this as any).constructor.name}: ${this.getNormal()}>`
}
// ----------------------------------------------------------------
// PREPROCESSING STEP:
// Preprocessing simply refers to perform series of operations to
// transform or change data and cache the results before actually
// using them. That includes:
// - Data Cleaning.
// - Dimensionality Reduction.
// - Feature Engineering.
// - Sampling Data.
// - Data Transformation.
// - Imbalanced Data.
// ----------------------------------------------------------------
public async build(): Promise<void> {
Log.info('Preprocessing Dimensions', this)
return new Promise((resolve, reject) => resolve())
}
// ----------------------------------------------------------------
// JSON SERIALIZERS:
// The main purpose is to save the state of an object in order to
// be able to recreate it when needed. The reverse process is called
// deserialization
// ----------------------------------------------------------------
public serialise(): SerializedDimensions {
return {
"Type": (this as any).constructor.name,
"Normal": this.getNormal(),
"Small": this.getSmall(),
"Margin": this.getMargin(),
"Avatar": this.getAvatar(),
"Padding": this.getPadding(),
"Title": this.getTitle(),
"Heading1": this.getHeading1(),
"Heading2": this.getHeading2(),
"Heading3": this.getHeading3(),
"Heading4": this.getHeading4(),
}
}
public deserialise(data: SerializedDimensions): void {
if (data) {
Log.info('Unserialising Dimensions', data)
this.setNormal(data.Normal)
this.setSmall(data.Small)
this.setMargin(data.Margin)
this.setPadding(data.Padding)
this.setAvatar(data.Avatar)
this.setTitle(data.Title)
this.setHeading1(data.Heading1)
this.setHeading2(data.Heading2)
this.setHeading3(data.Heading3)
this.setHeading4(data.Heading4)
}
}
}