11import { ComponentFixture , TestBed , waitForAsync } from '@angular/core/testing' ;
2-
2+ import { CommonModule } from '@angular/common' ;
3+ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner' ;
4+ import { NgxEchartsModule } from 'ngx-echarts' ;
35import { TrialsGraphEchartsComponent } from './trials-graph-echarts.component' ;
6+ import { BrowserAnimationsModule } from '@angular/platform-browser/animations' ;
7+ import { SimpleChange } from '@angular/core' ;
48
59describe ( 'TrialsGraphEchartsComponent' , ( ) => {
610 let component : TrialsGraphEchartsComponent ;
@@ -9,6 +13,14 @@ describe('TrialsGraphEchartsComponent', () => {
913 beforeEach (
1014 waitForAsync ( ( ) => {
1115 TestBed . configureTestingModule ( {
16+ imports : [
17+ CommonModule ,
18+ BrowserAnimationsModule ,
19+ MatProgressSpinnerModule ,
20+ NgxEchartsModule . forRoot ( {
21+ echarts : ( ) => import ( 'echarts' ) ,
22+ } ) ,
23+ ] ,
1224 declarations : [ TrialsGraphEchartsComponent ] ,
1325 } ) . compileComponents ( ) ;
1426 } ) ,
@@ -17,10 +29,144 @@ describe('TrialsGraphEchartsComponent', () => {
1729 beforeEach ( ( ) => {
1830 fixture = TestBed . createComponent ( TrialsGraphEchartsComponent ) ;
1931 component = fixture . componentInstance ;
32+ component . experimentTrialsCsv =
33+ 'trialName,Status,Validation-accuracy,Train-accuracy,lr,num-layers,optimizer\nbayesian-optimization-52d66cfb,Succeeded,0.113854,0.112390,0.010342079129038503,5,ftrl\nbayesian-optimization-5837197b,Succeeded,0.979100,0.994220,0.024782287934498225,2,sgd' ;
34+ component . experiment = {
35+ spec : {
36+ objective : {
37+ type : 'maximize' ,
38+ goal : 0.99 ,
39+ objectiveMetricName : 'Validation-accuracy' ,
40+ additionalMetricNames : [ 'Train-accuracy' ] ,
41+ metricStrategies : [
42+ { name : 'Validation-accuracy' , value : 'max' } ,
43+ { name : 'Train-accuracy' , value : 'max' } ,
44+ ] ,
45+ } ,
46+ parameters : [ ] ,
47+ } ,
48+ } ;
49+ component . ngOnChanges ( {
50+ experimentTrialsCsv : new SimpleChange (
51+ null ,
52+ component . experimentTrialsCsv ,
53+ false ,
54+ ) ,
55+ } ) ;
56+
2057 fixture . detectChanges ( ) ;
2158 } ) ;
2259
23- it ( 'should create' , ( ) => {
24- expect ( component ) . toBeTruthy ( ) ;
60+ it ( 'should create dataToDisplay' , ( ) => {
61+ expect ( component . dataToDisplay ) . toEqual ( [
62+ [ '0.010342079129038503' , '5' , 'ftrl' , '0.112390' , '0.113854' , '0.113854' ] ,
63+ [ '0.024782287934498225' , '2' , 'sgd' , '0.994220' , '0.979100' , '0.979100' ] ,
64+ ] ) ;
65+ } ) ;
66+
67+ it ( 'should create parallelAxis' , ( ) => {
68+ expect ( component . parallelAxis ) . toEqual ( [
69+ {
70+ dim : 0 ,
71+ name : 'lr' ,
72+ max : 0.027260516727948048 ,
73+ axisLabel : { showMaxLabel : false } ,
74+ } ,
75+ {
76+ dim : 1 ,
77+ name : 'num layers' ,
78+ max : 5.5 ,
79+ axisLabel : { showMaxLabel : false } ,
80+ } ,
81+ {
82+ dim : 2 ,
83+ name : 'optimizer' ,
84+ max : NaN ,
85+ axisLabel : { showMaxLabel : false } ,
86+ } ,
87+ {
88+ dim : 3 ,
89+ name : 'train accuracy' ,
90+ max : 1.093642 ,
91+ axisLabel : { showMaxLabel : false } ,
92+ } ,
93+ {
94+ dim : 4 ,
95+ name : 'validation accuracy' ,
96+ max : 1.07701 ,
97+ axisLabel : { showMaxLabel : false } ,
98+ } ,
99+ {
100+ dim : 5 ,
101+ max : 1.07701 ,
102+ axisTick : { show : false } ,
103+ axisLine : { show : false } ,
104+ axisLabel : { align : 'right' , margin : 1000000 } ,
105+ } ,
106+ ] ) ;
107+ } ) ;
108+
109+ it ( 'should create color' , ( ) => {
110+ expect ( component . color ) . toEqual ( [ '#1a2a6c' , '#b21f1f' , '#fdbb2d' ] ) ;
111+ } ) ;
112+
113+ it ( 'should create dataAllInfo' , ( ) => {
114+ expect ( component . dataAllInfo ) . toEqual ( [
115+ [
116+ 'bayesian-optimization-52d66cfb' ,
117+ 'Succeeded' ,
118+ '0.010342079129038503' ,
119+ '5' ,
120+ 'ftrl' ,
121+ '0.112390' ,
122+ '0.113854' ,
123+ '0.113854' ,
124+ ] ,
125+ [
126+ 'bayesian-optimization-5837197b' ,
127+ 'Succeeded' ,
128+ '0.024782287934498225' ,
129+ '2' ,
130+ 'sgd' ,
131+ '0.994220' ,
132+ '0.979100' ,
133+ '0.979100' ,
134+ ] ,
135+ ] ) ;
136+ } ) ;
137+
138+ it ( 'should create tooltipDataToDisplay' , ( ) => {
139+ expect ( component . tooltipDataToDisplay ) . toEqual ( [
140+ [
141+ 'bayesian-optimization-52d66cfb' ,
142+ 'Succeeded' ,
143+ '0.113854' ,
144+ '0.112390' ,
145+ '0.010342079129038503' ,
146+ '5' ,
147+ 'ftrl' ,
148+ ] ,
149+ [
150+ 'bayesian-optimization-5837197b' ,
151+ 'Succeeded' ,
152+ '0.979100' ,
153+ '0.994220' ,
154+ '0.024782287934498225' ,
155+ '2' ,
156+ 'sgd' ,
157+ ] ,
158+ ] ) ;
159+ } ) ;
160+
161+ it ( 'should create tooltipHeaders' , ( ) => {
162+ expect ( component . tooltipHeaders ) . toEqual ( [
163+ 'trialName' ,
164+ 'Status' ,
165+ 'Validation-accuracy' ,
166+ 'Train-accuracy' ,
167+ 'lr' ,
168+ 'num-layers' ,
169+ 'optimizer' ,
170+ ] ) ;
25171 } ) ;
26172} ) ;
0 commit comments