@@ -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,18 +404,18 @@ 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]+$" )
408
- result_array += test_attr (f , v , "required" , "basePath" , np .string_ , "^\/data\/\%T\/$" )
409
- result_array += test_attr (f , v , "required" , "iterationEncoding" , np .string_ , "^groupBased|fileBased$" )
410
- result_array += test_attr (f , v , "required" , "iterationFormat" , np .string_ )
407
+ result_array += test_attr (f , v , "required" , "openPMD" , np .bytes_ , "^[0-9]+\.[0-9]+\.[0-9]+$" )
408
+ result_array += test_attr (f , v , "required" , "basePath" , np .bytes_ , "^\/data\/\%T\/$" )
409
+ result_array += test_attr (f , v , "required" , "iterationEncoding" , np .bytes_ , "^groupBased|fileBased$" )
410
+ result_array += test_attr (f , v , "required" , "iterationFormat" , np .bytes_ )
411
411
412
412
# optional but required for extensions
413
- result_array += test_attr (f , v , "optional" , "openPMDextension" , np .string_ ,
413
+ result_array += test_attr (f , v , "optional" , "openPMDextension" , np .bytes_ ,
414
414
# allowed are a-Z 0-9 - ; (but no spaces!)
415
415
"^[a-zA-Z0-9\-;]+$" )
416
416
# optional but required for data
417
- result_array += test_attr (f , v , "optional" , "meshesPath" , np .string_ , "^.*\/$" )
418
- result_array += test_attr (f , v , "optional" , "particlesPath" , np .string_ , "^.*\/$" )
417
+ result_array += test_attr (f , v , "optional" , "meshesPath" , np .bytes_ , "^.*\/$" )
418
+ result_array += test_attr (f , v , "optional" , "particlesPath" , np .bytes_ , "^.*\/$" )
419
419
420
420
# groupBased iteration encoding needs to match basePath
421
421
if result_array [0 ] == 0 :
@@ -426,17 +426,17 @@ def check_root_attr(f, v):
426
426
result_array += np .array ([1 ,0 ])
427
427
428
428
# recommended
429
- result_array += test_attr (f , v , "recommended" , "author" , np .string_ )
430
- result_array += test_attr (f , v , "recommended" , "software" , np .string_ )
429
+ result_array += test_attr (f , v , "recommended" , "author" , np .bytes_ )
430
+ result_array += test_attr (f , v , "recommended" , "software" , np .bytes_ )
431
431
result_array += test_attr (f , v , "recommended" ,
432
- "softwareVersion" , np .string_ )
433
- result_array += test_attr (f , v , "recommended" , "date" , np .string_ ,
432
+ "softwareVersion" , np .bytes_ )
433
+ result_array += test_attr (f , v , "recommended" , "date" , np .bytes_ ,
434
434
"^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} [\+|-][0-9]{4}$" )
435
435
436
436
# optional
437
- result_array += test_attr (f , v , "optional" , "softwareDependencies" , np .string_ )
438
- result_array += test_attr (f , v , "optional" , "machine" , np .string_ )
439
- result_array += test_attr (f , v , "optional" , "comment" , np .string_ )
437
+ result_array += test_attr (f , v , "optional" , "softwareDependencies" , np .bytes_ )
438
+ result_array += test_attr (f , v , "optional" , "machine" , np .bytes_ )
439
+ result_array += test_attr (f , v , "optional" , "comment" , np .bytes_ )
440
440
441
441
return (result_array )
442
442
@@ -619,18 +619,18 @@ def check_meshes(f, iteration, v, extensionStates):
619
619
result_array += test_attr (field , v , "required" ,
620
620
"gridUnitDimension" , np .ndarray , np .double )
621
621
result_array += test_attr (field , v , "required" ,
622
- "axisLabels" , np .ndarray , np .string_ )
622
+ "axisLabels" , np .ndarray , np .bytes_ )
623
623
# Specific check for geometry
624
- geometry_test = test_attr (field , v , "required" , "geometry" , np .string_ )
624
+ geometry_test = test_attr (field , v , "required" , "geometry" , np .bytes_ )
625
625
result_array += geometry_test
626
626
# geometryParameters is required when using thetaMode
627
627
if geometry_test [0 ] == 0 and field .attrs ["geometry" ] == b"thetaMode" :
628
628
result_array += test_attr (field , v , "required" ,
629
- "geometryParameters" , np .string_ )
629
+ "geometryParameters" , np .bytes_ )
630
630
# otherwise it is optional
631
631
else :
632
632
result_array += test_attr (field , v , "optional" ,
633
- "geometryParameters" , np .string_ )
633
+ "geometryParameters" , np .bytes_ )
634
634
635
635
# Attributes of the record's components
636
636
if is_scalar_record (field ) : # If the record is a scalar field
@@ -650,45 +650,45 @@ def check_meshes(f, iteration, v, extensionStates):
650
650
if extensionStates ['ED-PIC' ] and len (list_meshes ) > 0 :
651
651
# Check the attributes associated with the field solver
652
652
result_array += test_attr (f [full_meshes_path ], v , "required" ,
653
- "fieldSolver" , np .string_ )
653
+ "fieldSolver" , np .bytes_ )
654
654
valid , field_solver = get_attr (f [full_meshes_path ], "fieldSolver" )
655
655
if (valid == True ) and (field_solver in ["other" , "GPSTD" ]) :
656
656
result_array += test_attr (f [full_meshes_path ], v , "required" ,
657
- "fieldSolverParameters" , np .string_ )
657
+ "fieldSolverParameters" , np .bytes_ )
658
658
659
659
# Check for the attributes associated with the field boundaries
660
660
result_array += test_attr (f [full_meshes_path ], v , "required" ,
661
- "fieldBoundary" , np .ndarray , np .string_ )
661
+ "fieldBoundary" , np .ndarray , np .bytes_ )
662
662
valid , field_boundary = get_attr (f [full_meshes_path ], "fieldBoundary" )
663
663
if (valid == True ) and (np .any (field_boundary == b"other" )) :
664
664
result_array += test_attr (f [full_meshes_path ], v , "required" ,
665
- "fieldBoundaryParameters" , np .ndarray , np .string_ )
665
+ "fieldBoundaryParameters" , np .ndarray , np .bytes_ )
666
666
667
667
# Check the attributes associated with the current smoothing
668
668
result_array += test_attr (f [full_meshes_path ], v , "required" ,
669
- "currentSmoothing" , np .string_ )
669
+ "currentSmoothing" , np .bytes_ )
670
670
valid , current_smoothing = get_attr (f [full_meshes_path ], "currentSmoothing" )
671
671
if (valid == True ) and (current_smoothing != b"none" ) :
672
672
result_array += test_attr (f [full_meshes_path ], v , "required" ,
673
- "currentSmoothingParameters" , np .string_ )
673
+ "currentSmoothingParameters" , np .bytes_ )
674
674
675
675
# Check the attributes associated with the charge conservation
676
676
result_array += test_attr (f [full_meshes_path ], v , "required" ,
677
- "chargeCorrection" , np .string_ )
677
+ "chargeCorrection" , np .bytes_ )
678
678
valid , charge_correction = get_attr (f [full_meshes_path ], "chargeCorrection" )
679
679
if valid == True and charge_correction != b"none" :
680
680
result_array += test_attr (f [full_meshes_path ], v , "required" ,
681
- "chargeCorrectionParameters" , np .string_ )
681
+ "chargeCorrectionParameters" , np .bytes_ )
682
682
683
683
# Check for the attributes of each record
684
684
for field_name in list_meshes :
685
685
field = f [full_meshes_path + field_name .encode ('ascii' )]
686
686
result_array + test_attr (field , v , "required" ,
687
- "fieldSmoothing" , np .string_ )
687
+ "fieldSmoothing" , np .bytes_ )
688
688
valid , field_smoothing = get_attr (field , "fieldSmoothing" )
689
689
if (valid == True ) and (field_smoothing != b"none" ) :
690
690
result_array += test_attr (field ,v , "required" ,
691
- "fieldSmoothingParameters" , np .string_ )
691
+ "fieldSmoothingParameters" , np .bytes_ )
692
692
693
693
# Check the attributes in the SpeciesType extension
694
694
if extensionStates ['SpeciesType' ] :
@@ -697,7 +697,7 @@ def check_meshes(f, iteration, v, extensionStates):
697
697
field = f [full_meshes_path + field_name .encode ('ascii' )]
698
698
# allowed are a-Z 0-9 - ; : (but no spaces!)
699
699
result_array += test_attr (field , v , "optional" ,
700
- "speciesType" , np .string_ ,
700
+ "speciesType" , np .bytes_ ,
701
701
"^[a-zA-Z0-9\-;:]+$" )
702
702
703
703
return (result_array )
@@ -834,33 +834,33 @@ def check_particles(f, iteration, v, extensionStates) :
834
834
result_array += test_attr (species , v , "required" ,
835
835
"particleShape" , [np .single , np .double , np .longdouble ])
836
836
result_array += test_attr (species , v , "required" ,
837
- "currentDeposition" , np .string_ )
837
+ "currentDeposition" , np .bytes_ )
838
838
result_array += test_attr (species , v , "required" ,
839
- "particlePush" , np .string_ )
839
+ "particlePush" , np .bytes_ )
840
840
result_array += test_attr (species , v , "required" ,
841
- "particleInterpolation" , np .string_ )
841
+ "particleInterpolation" , np .bytes_ )
842
842
843
843
# Check for the attributes associated with the particle boundaries
844
844
result_array += test_attr (species , v , "required" ,
845
- "particleBoundary" , np .ndarray , np .string_ )
845
+ "particleBoundary" , np .ndarray , np .bytes_ )
846
846
valid , particle_boundary = get_attr (species , "particleBoundary" )
847
847
if (valid == True ) and (np .any (particle_boundary == b"other" )) :
848
848
result_array += test_attr (species , v , "required" ,
849
- "particleBoundaryParameters" , np .ndarray , np .string_ )
849
+ "particleBoundaryParameters" , np .ndarray , np .bytes_ )
850
850
851
851
# Check for the attributes associated with the particle smoothing
852
852
result_array += test_attr (species , v , "required" ,
853
- "particleSmoothing" , np .string_ )
853
+ "particleSmoothing" , np .bytes_ )
854
854
valid , particle_smoothing = get_attr (species , "particleSmoothing" )
855
855
if valid == True and particle_smoothing != b"none" :
856
856
result_array += test_attr (species , v , "required" ,
857
- "particleSmoothingParameters" , np .string_ )
857
+ "particleSmoothingParameters" , np .bytes_ )
858
858
859
859
# Check the attributes associated with the SpeciesType extension
860
860
if extensionStates ['SpeciesType' ] :
861
861
# allowed are a-Z 0-9 - ; : (but no spaces!)
862
862
result_array += test_attr (species , v , "optional" , "speciesType" ,
863
- np .string_ , "^[a-zA-Z0-9\-;:]+$" )
863
+ np .bytes_ , "^[a-zA-Z0-9\-;:]+$" )
864
864
865
865
# Check attributes of each record of the particle
866
866
for record in list (species .keys ()) :
0 commit comments