@@ -72,8 +72,7 @@ def __init__(self, model, path, parse_args):
72
72
(self .data .dust_size_param () is not None )
73
73
if self .data .get_dust_id () is not None :
74
74
if self .nr_gas_densities > 1 or self .nr_dust_densities > 1 :
75
- raise ValueError (
76
- 'Multiple density distributions and dust_id function defined' )
75
+ raise ValueError ('Multiple density distributions and dust_id function defined' )
77
76
else :
78
77
self .data_length += 1
79
78
@@ -115,34 +114,36 @@ def check_density_arrays(self):
115
114
not isinstance (self .data .get_gas_density_distribution (), (float , int )):
116
115
if len (self .data .get_gas_density_distribution ()[0 ]) != \
117
116
len (self .model .parameter ['gas_mass' ][0 ]):
118
- raise ValueError ("gas_density_distribution does not provide the same array than "
119
- "defined in self.parameter['gas_mass']" )
117
+ raise ValueError (
118
+ 'gas_density_distribution does not provide the same array than '
119
+ 'defined in self.parameter[\' gas_mass\' ]' )
120
120
elif self .nr_gas_densities > 1 :
121
121
for i_gas_dens in range (self .nr_gas_densities ):
122
122
if len (self .data .get_gas_density_distribution ()[i_gas_dens ]) != \
123
123
len (self .model .parameter ['gas_mass' ][i_gas_dens ]):
124
- raise ValueError ("gas_density_distribution does not provide the same array than "
125
- "defined in self.parameter['gas_mass']" )
124
+ raise ValueError (
125
+ 'gas_density_distribution does not provide the same array than '
126
+ 'defined in self.parameter[\' gas_mass\' ]' )
126
127
except :
127
- raise ValueError (
128
- "the gas_density function and the defined gas_mass do not fit!" )
128
+ raise ValueError ('the gas_density function and the defined gas_mass do not fit!' )
129
129
try :
130
130
if self .nr_dust_densities == 1 :
131
131
if self .data .get_dust_density_distribution () is not None and \
132
132
not isinstance (self .data .get_dust_density_distribution (), (float , int )):
133
133
if len (self .data .get_dust_density_distribution ()[0 ]) != \
134
134
len (self .model .parameter ['dust_mass' ][0 ]):
135
- raise ValueError ("dust_density_distribution does not provide the same array than "
136
- "defined in self.parameter['dust_mass']" )
135
+ raise ValueError (
136
+ 'dust_density_distribution does not provide the same array than '
137
+ 'defined in self.parameter[\' dust_mass\' ]' )
137
138
elif self .nr_dust_densities > 1 :
138
139
for i_dust_dens in range (self .nr_dust_densities ):
139
140
if len (self .data .get_dust_density_distribution ()[i_dust_dens ]) != \
140
141
len (self .model .parameter ['dust_mass' ][i_dust_dens ]):
141
- raise ValueError ("dust_density_distribution does not provide the same array than "
142
- "defined in self.parameter['dust_mass']" )
142
+ raise ValueError (
143
+ 'dust_density_distribution does not provide the same array than '
144
+ 'defined in self.parameter[\' dust_mass\' ]' )
143
145
except :
144
- raise ValueError (
145
- "the dust_density function and the defined dust_mass do not fit!" )
146
+ raise ValueError ('the dust_density function and the defined dust_mass do not fit!' )
146
147
147
148
def write_header (self , grid_file , grid_type = '' , num_dens = False , root = None ):
148
149
"""Writes general header to binary file.
@@ -192,7 +193,7 @@ def write_header(self, grid_file, grid_type='', num_dens=False, root=None):
192
193
elif grid_type == 'cylindrical' :
193
194
grid_id = 40
194
195
else :
195
- raise ValueError ('Grid type: ' + str ( grid_type ) + ' is not known!' )
196
+ raise ValueError (f 'Grid type: { grid_type } is not known!' )
196
197
197
198
grid_file .write (struct .pack ('H' , grid_id ))
198
199
grid_file .write (struct .pack ('H' , self .data_length ))
@@ -248,8 +249,7 @@ def write_header(self, grid_file, grid_type='', num_dens=False, root=None):
248
249
grid_file .write (struct .pack ('H' , root .parameter ['is_leaf' ]))
249
250
grid_file .write (struct .pack ('H' , root .parameter ['level' ]))
250
251
else :
251
- raise ValueError (
252
- 'root node has to be defined for writing the grid header!' )
252
+ raise ValueError ('root node has to be defined for writing the grid header!' )
253
253
254
254
def write_node_data (self , grid_file , node , data_type = 'f' , cell_IDs = None , rewrite = False ):
255
255
"""Write data of each node.
@@ -269,8 +269,7 @@ def write_node_data(self, grid_file, node, data_type='f', cell_IDs=None, rewrite
269
269
elif data_type == 'd' :
270
270
data_type_length = 8
271
271
else :
272
- raise ValueError (
273
- 'Do not understand the data type ' + data_type + ' in grid.py!' )
272
+ raise ValueError (f'Do not understand the data type { data_type } in grid.py!' )
274
273
275
274
if rewrite :
276
275
grid_file .seek (- (self .data_length * data_type_length ), 1 )
@@ -347,8 +346,7 @@ def read_write_node_data(self, tmp_file, grid_file, data_type='f'):
347
346
elif data_type == 'd' :
348
347
data_type_length = 8
349
348
else :
350
- raise ValueError (
351
- 'Do not understand the data type ' + data_type + ' in grid.py!' )
349
+ raise ValueError (f'Do not understand the data type { data_type } in grid.py!' )
352
350
353
351
# Calculate normalized density
354
352
for i_gas_dens in range (self .nr_gas_densities ):
@@ -441,7 +439,7 @@ def create_grid(self, grid_file, node, max_tree_level=None, refinement_limit=0.1
441
439
442
440
percentage = 100 * percentage_count / 64
443
441
if percentage - last_percentage > 10 :
444
- stdout .write (f'--- Generate cartesian grid: ' + str ( int (percentage )) + ' % \r ' )
442
+ stdout .write (f'--- Generate cartesian grid: { int (percentage )} % \r ' )
445
443
stdout .flush ()
446
444
last_percentage = percentage
447
445
@@ -706,8 +704,7 @@ def create_grid(self, grid_file, root):
706
704
if sp_param ['sf_r' ] == 0 :
707
705
if sp_param ['radius_list' ][0 ] != sp_param ['inner_radius' ] or \
708
706
sp_param ['radius_list' ][- 1 ] != sp_param ['outer_radius' ]:
709
- raise ValueError (
710
- 'radius_list does not agree with the inner and outer grid borders!' )
707
+ raise ValueError ('radius_list does not agree with the inner and outer grid borders!' )
711
708
radius_list = sp_param ['radius_list' ]
712
709
sp_param ['n_r' ] = len (radius_list ) - 1
713
710
elif sp_param ['sf_r' ] == 1 :
@@ -782,7 +779,7 @@ def create_grid(self, grid_file, root):
782
779
for i_t in range (sp_param ['n_th' ]):
783
780
percentage = 100 * i_node / nr_cells
784
781
if percentage - last_percentage > 10 :
785
- stdout .write (f'--- Generate spherical grid: ' + str ( int (percentage )) + ' % \r ' )
782
+ stdout .write (f'--- Generate spherical grid: { int (percentage )} % \r ' )
786
783
stdout .flush ()
787
784
last_percentage = percentage
788
785
# Calculate the cell midpoint in spherical coordinates
@@ -984,8 +981,7 @@ def create_grid(self, grid_file, root):
984
981
if cy_param ['sf_r' ] == 0 :
985
982
if cy_param ['radius_list' ][0 ] != cy_param ['inner_radius' ] or \
986
983
cy_param ['radius_list' ][- 1 ] != cy_param ['outer_radius' ]:
987
- raise ValueError (
988
- 'radius_list does not agree with the inner and outer grid borders!' )
984
+ raise ValueError ('radius_list does not agree with the inner and outer grid borders!' )
989
985
radius_list = cy_param ['radius_list' ]
990
986
cy_param ['n_r' ] = len (radius_list ) - 1
991
987
elif cy_param ['sf_r' ] == 1 :
@@ -1021,8 +1017,7 @@ def create_grid(self, grid_file, root):
1021
1017
for i_r in range (cy_param ['n_r' ])])
1022
1018
cy_param ['n_ph' ] = [len (phi_list [0 ])- 1 ] * cy_param ['n_r' ]
1023
1019
else :
1024
- raise ValueError (
1025
- 'Cell distriution in phi-direction not understood!' )
1020
+ raise ValueError ('Cell distriution in phi-direction not understood!' )
1026
1021
elif cy_param ['sf_ph' ] == - 1 :
1027
1022
phi_list = [self .math .lin_list (0. , 2. * np .pi , n_ph )
1028
1023
for n_ph in cy_param ['n_ph' ]]
@@ -1035,14 +1030,12 @@ def create_grid(self, grid_file, root):
1035
1030
if len (cy_param ['z_list' ]) > 0 :
1036
1031
if cy_param ['z_list' ][0 ] != - cy_param ['z_max' ] or \
1037
1032
cy_param ['z_list' ][- 1 ] != cy_param ['z_max' ]:
1038
- raise ValueError (
1039
- 'z_list does not agree with the inner and outer grid borders!' )
1033
+ raise ValueError ('z_list does not agree with the inner and outer grid borders!' )
1040
1034
z_list = np .array ([cy_param ['z_list' ]
1041
1035
for i_r in range (cy_param ['n_r' ])])
1042
1036
cy_param ['n_z' ] = len (z_list [0 ]) - 1
1043
1037
else :
1044
- raise ValueError (
1045
- 'Cell distribution in z-direction not understood!' )
1038
+ raise ValueError ('Cell distribution in z-direction not understood!' )
1046
1039
elif cy_param ['sf_z' ] == - 1 :
1047
1040
z_max_tmp = [self .model .get_dz (
1048
1041
radius_list [i_r ]) * cy_param ['n_z' ] / 2. for i_r in range (cy_param ['n_r' ])]
@@ -1101,7 +1094,7 @@ def create_grid(self, grid_file, root):
1101
1094
for i_z in range (cy_param ['n_z' ]):
1102
1095
percentage = 100 * i_node / nr_cells
1103
1096
if percentage - last_percentage > 10 :
1104
- stdout .write ('--- Generate cylindrical grid: ' + str ( int (percentage )) + ' % \r ' )
1097
+ stdout .write (f '--- Generate cylindrical grid: { int (percentage )} % \r ' )
1105
1098
stdout .flush ()
1106
1099
last_percentage = percentage
1107
1100
# Calculate the cell midpoint in cylindrical coordinates
0 commit comments