@@ -239,7 +239,7 @@ def test_attr(f, v, request, name, is_type=None, type_format=None):
239
239
240
240
type_format: (numpy or python) data type
241
241
Used with is_type to specify numpy ndarray dtypes or a
242
- base np.string_ format regex. Can be a list of data types
242
+ base np.bytes_ format regex. Can be a list of data types
243
243
for ndarrays where at least one data type must match.
244
244
245
245
Returns
@@ -257,7 +257,7 @@ def test_attr(f, v, request, name, is_type=None, type_format=None):
257
257
# test type
258
258
if is_type is not None :
259
259
type_format_names = None
260
- if not type_format is None and not is_type is np .string_ and \
260
+ if not type_format is None and not is_type is np .bytes_ and \
261
261
not isinstance (type_format , Iterable ):
262
262
type_format = [type_format ]
263
263
type_format_names = map (lambda x : x .__name__ , type_format )
@@ -266,8 +266,8 @@ def test_attr(f, v, request, name, is_type=None, type_format=None):
266
266
is_type_names = "' or '" .join (map (lambda x : str (x .__name__ ), is_type ))
267
267
# add for each type in is_type -> wrong, need to add this at the comparison level!
268
268
if type (value ) in is_type :
269
- # np.string_ format or general ndarray dtype text
270
- if type (value ) is np .string_ and type_format is not None :
269
+ # np.bytes_ format or general ndarray dtype text
270
+ if type (value ) is np .bytes_ and type_format is not None :
271
271
regEx = re .compile (type_format ) # Python3 only: re.ASCII
272
272
if regEx .match (value .decode ()) :
273
273
result_array = np .array ([0 ,0 ])
@@ -404,15 +404,15 @@ def check_root_attr(f, v):
404
404
405
405
# STANDARD.md
406
406
# required
407
- result_array += test_attr (f , v , "required" , "openPMD" , np .string_ , "^[0-9]+\.[0-9]+\.[0-9]+$" )
407
+ result_array += test_attr (f , v , "required" , "openPMD" , np .bytes_ , "^[0-9]+\.[0-9]+\.[0-9]+$" )
408
408
result_array += test_attr (f , v , "required" , "openPMDextension" , np .uint32 )
409
- result_array += test_attr (f , v , "required" , "basePath" , np .string_ , "^\/data\/\%T\/$" )
410
- result_array += test_attr (f , v , "required" , "iterationEncoding" , np .string_ , "^groupBased|fileBased$" )
411
- result_array += test_attr (f , v , "required" , "iterationFormat" , np .string_ )
409
+ result_array += test_attr (f , v , "required" , "basePath" , np .bytes_ , "^\/data\/\%T\/$" )
410
+ result_array += test_attr (f , v , "required" , "iterationEncoding" , np .bytes_ , "^groupBased|fileBased$" )
411
+ result_array += test_attr (f , v , "required" , "iterationFormat" , np .bytes_ )
412
412
413
413
# optional but required for data
414
- result_array += test_attr (f , v , "optional" , "meshesPath" , np .string_ , "^.*\/$" )
415
- result_array += test_attr (f , v , "optional" , "particlesPath" , np .string_ , "^.*\/$" )
414
+ result_array += test_attr (f , v , "optional" , "meshesPath" , np .bytes_ , "^.*\/$" )
415
+ result_array += test_attr (f , v , "optional" , "particlesPath" , np .bytes_ , "^.*\/$" )
416
416
417
417
# groupBased iteration encoding needs to match basePath
418
418
if result_array [0 ] == 0 :
@@ -423,17 +423,17 @@ def check_root_attr(f, v):
423
423
result_array += np .array ([1 ,0 ])
424
424
425
425
# recommended
426
- result_array += test_attr (f , v , "recommended" , "author" , np .string_ )
427
- result_array += test_attr (f , v , "recommended" , "software" , np .string_ )
426
+ result_array += test_attr (f , v , "recommended" , "author" , np .bytes_ )
427
+ result_array += test_attr (f , v , "recommended" , "software" , np .bytes_ )
428
428
result_array += test_attr (f , v , "recommended" ,
429
- "softwareVersion" , np .string_ )
430
- result_array += test_attr (f , v , "recommended" , "date" , np .string_ ,
429
+ "softwareVersion" , np .bytes_ )
430
+ result_array += test_attr (f , v , "recommended" , "date" , np .bytes_ ,
431
431
"^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} [\+|-][0-9]{4}$" )
432
432
433
433
# optional
434
- result_array += test_attr (f , v , "optional" , "softwareDependencies" , np .string_ )
435
- result_array += test_attr (f , v , "optional" , "machine" , np .string_ )
436
- result_array += test_attr (f , v , "optional" , "comment" , np .string_ )
434
+ result_array += test_attr (f , v , "optional" , "softwareDependencies" , np .bytes_ )
435
+ result_array += test_attr (f , v , "optional" , "machine" , np .bytes_ )
436
+ result_array += test_attr (f , v , "optional" , "comment" , np .bytes_ )
437
437
438
438
return (result_array )
439
439
@@ -614,20 +614,20 @@ def check_meshes(f, iteration, v, extensionStates):
614
614
result_array += test_attr (field , v , "required" ,
615
615
"gridUnitSI" , np .float64 )
616
616
result_array += test_attr (field , v , "required" ,
617
- "dataOrder" , np .string_ )
617
+ "dataOrder" , np .bytes_ )
618
618
result_array += test_attr (field , v , "required" ,
619
- "axisLabels" , np .ndarray , np .string_ )
619
+ "axisLabels" , np .ndarray , np .bytes_ )
620
620
# Specific check for geometry
621
- geometry_test = test_attr (field , v , "required" , "geometry" , np .string_ )
621
+ geometry_test = test_attr (field , v , "required" , "geometry" , np .bytes_ )
622
622
result_array += geometry_test
623
623
# geometryParameters is required when using thetaMode
624
624
if geometry_test [0 ] == 0 and field .attrs ["geometry" ] == b"thetaMode" :
625
625
result_array += test_attr (field , v , "required" ,
626
- "geometryParameters" , np .string_ )
626
+ "geometryParameters" , np .bytes_ )
627
627
# otherwise it is optional
628
628
else :
629
629
result_array += test_attr (field , v , "optional" ,
630
- "geometryParameters" , np .string_ )
630
+ "geometryParameters" , np .bytes_ )
631
631
632
632
# Attributes of the record's components
633
633
if is_scalar_record (field ) : # If the record is a scalar field
@@ -647,53 +647,53 @@ def check_meshes(f, iteration, v, extensionStates):
647
647
if extensionStates ['ED-PIC' ] and len (list_meshes ) > 0 :
648
648
# Check the attributes associated with the field solver
649
649
result_array += test_attr (f [full_meshes_path ], v , "required" ,
650
- "fieldSolver" , np .string_ )
650
+ "fieldSolver" , np .bytes_ )
651
651
valid , field_solver = get_attr (f [full_meshes_path ], "fieldSolver" )
652
652
if (valid == True ) and (field_solver in ["other" , "GPSTD" ]) :
653
653
result_array += test_attr (f [full_meshes_path ], v , "required" ,
654
- "fieldSolverParameters" , np .string_ )
654
+ "fieldSolverParameters" , np .bytes_ )
655
655
656
656
# Check for the attributes associated with the field boundaries
657
657
result_array += test_attr (f [full_meshes_path ], v , "required" ,
658
- "fieldBoundary" , np .ndarray , np .string_ )
658
+ "fieldBoundary" , np .ndarray , np .bytes_ )
659
659
valid , field_boundary = get_attr (f [full_meshes_path ], "fieldBoundary" )
660
660
if (valid == True ) and (np .any (field_boundary == b"other" )) :
661
661
result_array += test_attr (f [full_meshes_path ], v , "required" ,
662
- "fieldBoundaryParameters" , np .ndarray , np .string_ )
662
+ "fieldBoundaryParameters" , np .ndarray , np .bytes_ )
663
663
664
664
# Check for the attributes associated with the field boundaries
665
665
result_array += test_attr (f [full_meshes_path ], v , "required" ,
666
- "particleBoundary" , np .ndarray , np .string_ )
666
+ "particleBoundary" , np .ndarray , np .bytes_ )
667
667
valid , particle_boundary = get_attr (f [full_meshes_path ], "particleBoundary" )
668
668
if (valid == True ) and (np .any (particle_boundary == b"other" )) :
669
669
result_array += test_attr (f [full_meshes_path ], v , "required" ,
670
- "particleBoundaryParameters" , np .ndarray , np .string_ )
670
+ "particleBoundaryParameters" , np .ndarray , np .bytes_ )
671
671
672
672
# Check the attributes associated with the current smoothing
673
673
result_array += test_attr (f [full_meshes_path ], v , "required" ,
674
- "currentSmoothing" , np .string_ )
674
+ "currentSmoothing" , np .bytes_ )
675
675
valid , current_smoothing = get_attr (f [full_meshes_path ], "currentSmoothing" )
676
676
if (valid == True ) and (current_smoothing != b"none" ) :
677
677
result_array += test_attr (f [full_meshes_path ], v , "required" ,
678
- "currentSmoothingParameters" , np .string_ )
678
+ "currentSmoothingParameters" , np .bytes_ )
679
679
680
680
# Check the attributes associated with the charge conservation
681
681
result_array += test_attr (f [full_meshes_path ], v , "required" ,
682
- "chargeCorrection" , np .string_ )
682
+ "chargeCorrection" , np .bytes_ )
683
683
valid , charge_correction = get_attr (f [full_meshes_path ], "chargeCorrection" )
684
684
if valid == True and charge_correction != b"none" :
685
685
result_array += test_attr (f [full_meshes_path ], v , "required" ,
686
- "chargeCorrectionParameters" , np .string_ )
686
+ "chargeCorrectionParameters" , np .bytes_ )
687
687
688
688
# Check for the attributes of each record
689
689
for field_name in list_meshes :
690
690
field = f [full_meshes_path + field_name .encode ('ascii' )]
691
691
result_array + test_attr (field , v , "required" ,
692
- "fieldSmoothing" , np .string_ )
692
+ "fieldSmoothing" , np .bytes_ )
693
693
valid , field_smoothing = get_attr (field , "fieldSmoothing" )
694
694
if (valid == True ) and (field_smoothing != b"none" ) :
695
695
result_array += test_attr (field ,v , "required" ,
696
- "fieldSmoothingParameters" , np .string_ )
696
+ "fieldSmoothingParameters" , np .bytes_ )
697
697
return (result_array )
698
698
699
699
@@ -827,19 +827,19 @@ def check_particles(f, iteration, v, extensionStates) :
827
827
result_array += test_attr (species , v , "required" ,
828
828
"particleShape" , [np .single , np .double , np .longdouble ])
829
829
result_array += test_attr (species , v , "required" ,
830
- "currentDeposition" , np .string_ )
830
+ "currentDeposition" , np .bytes_ )
831
831
result_array += test_attr (species , v , "required" ,
832
- "particlePush" , np .string_ )
832
+ "particlePush" , np .bytes_ )
833
833
result_array += test_attr (species , v , "required" ,
834
- "particleInterpolation" , np .string_ )
834
+ "particleInterpolation" , np .bytes_ )
835
835
836
836
# Check for the attributes associated with the particle smoothing
837
837
result_array += test_attr (species , v , "required" ,
838
- "particleSmoothing" , np .string_ )
838
+ "particleSmoothing" , np .bytes_ )
839
839
valid , particle_smoothing = get_attr (species , "particleSmoothing" )
840
840
if valid == True and particle_smoothing != b"none" :
841
841
result_array += test_attr (species , v , "required" ,
842
- "particleSmoothingParameters" , np .string_ )
842
+ "particleSmoothingParameters" , np .bytes_ )
843
843
844
844
# Check attributes of each record of the particle
845
845
for record in list (species .keys ()) :
0 commit comments