@@ -97,17 +97,18 @@ pure function from_lines(lines) result(file_object)
9797
9898end module
9999
100- module hyperparameters_m
101- use julienne_m, only : string_t
100+ module fiats_m
101+ use julienne_m, only : string_t, file_t
102102 implicit none
103103 private
104- public :: hyperparameters_t
104+ public hyperparameters_t
105+ public training_configuration_t
105106
106107 type hyperparameters_t (k)
107108 integer , kind :: k = kind (1 .)
108109 real (k), private :: learning_rate_ = real (1.5 ,k)
109110 contains
110- procedure to_json
111+ procedure hyperparameters_to_json
111112 end type
112113
113114 interface hyperparameters_t
@@ -116,6 +117,17 @@ module hyperparameters_m
116117
117118 character (len=* ), parameter :: learning_rate_key = " learning rate"
118119
120+ type, extends(file_t) :: training_configuration_t(m)
121+ integer , kind :: m = kind (1 .)
122+ type (hyperparameters_t(m)) hyperparameters_
123+ contains
124+ procedure training_configuration_to_json
125+ end type
126+
127+ interface training_configuration_t
128+ module procedure training_configuration_from_components, training_configuration_from_file
129+ end interface
130+
119131contains
120132
121133 pure function hyperparameters_from_components (learning_rate ) result(hyperparameters)
@@ -130,7 +142,7 @@ pure function hyperparameters_from_json(lines) result(hyperparameters)
130142 hyperparameters% learning_rate_ = lines(1 )% get_json_value(string_t(learning_rate_key), mold= 0 .)
131143 end function
132144
133- pure function to_json (self ) result(lines)
145+ pure function hyperparameters_to_json (self ) result(lines)
134146 class(hyperparameters_t), intent (in ) :: self
135147 type (string_t), allocatable :: lines(:)
136148 character (len=* ), parameter :: indent = repeat (" " ,ncopies= 4 )
@@ -141,32 +153,12 @@ pure function to_json(self) result(lines)
141153 lines = [string_t(indent // indent // ' "' // learning_rate_key // ' " : ' // trim (adjustl (learning_rate_string)) // " ," )]
142154 end function
143155
144- end module
145-
146- module training_configuration_m
147- use julienne_m, only : string_t, file_t
148- use hyperparameters_m, only : hyperparameters_t
149- implicit none
150-
151- type, extends(file_t) :: training_configuration_t(m)
152- integer , kind :: m = kind (1 .)
153- type (hyperparameters_t(m)) hyperparameters_
154- contains
155- procedure to_json
156- end type
157-
158- interface training_configuration_t
159- module procedure training_configuration_from_components, training_configuration_from_file
160- end interface
161-
162- contains
163-
164156 pure function training_configuration_from_components (hyperparameters ) result(training_configuration)
165157 type (hyperparameters_t), intent (in ) :: hyperparameters
166158 type (training_configuration_t) training_configuration
167159
168160 training_configuration% hyperparameters_ = hyperparameters
169- training_configuration% file_t = file_t([training_configuration% hyperparameters_% to_json ()])
161+ training_configuration% file_t = file_t([training_configuration% hyperparameters_% hyperparameters_to_json ()])
170162 end function
171163
172164 function training_configuration_from_file (lines ) result(training_configuration)
@@ -177,7 +169,7 @@ function training_configuration_from_file(lines) result(training_configuration)
177169 training_configuration% hyperparameters_ = hyperparameters_t(training_configuration% file_t% lines_)
178170 end function
179171
180- pure function to_json (self ) result(json_lines)
172+ pure function training_configuration_to_json (self ) result(json_lines)
181173 class(training_configuration_t), intent (in ) :: self
182174 type (string_t), allocatable :: json_lines(:)
183175 json_lines = self% lines_
@@ -186,8 +178,7 @@ pure function to_json(self) result(json_lines)
186178end module
187179
188180program test_suite_driver
189- use training_configuration_m, only : training_configuration_t
190- use hyperparameters_m, only : hyperparameters_t
181+ use fiats_m, only : hyperparameters_t, training_configuration_t
191182 use julienne_m, only : string_t
192183 implicit none
193184
0 commit comments