Skip to content

Commit 91915d9

Browse files
authored
Prepare for NumPy 2.0 (openmc-dev#2845)
1 parent c1b338f commit 91915d9

22 files changed

Lines changed: 74 additions & 72 deletions

‎openmc/data/correlated.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def to_hdf5(self, group):
113113
HDF5 group to write to
114114
115115
"""
116-
group.attrs['type'] = np.string_(self._name)
116+
group.attrs['type'] = np.bytes_(self._name)
117117

118118
dset = group.create_dataset('energy', data=self.energy)
119119
dset.attrs['interpolation'] = np.vstack((self.breakpoints,

‎openmc/data/energy_distribution.py‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def to_hdf5(self, group):
277277
278278
"""
279279

280-
group.attrs['type'] = np.string_('maxwell')
280+
group.attrs['type'] = np.bytes_('maxwell')
281281
group.attrs['u'] = self.u
282282
self.theta.to_hdf5(group, 'theta')
283283

@@ -410,7 +410,7 @@ def to_hdf5(self, group):
410410
411411
"""
412412

413-
group.attrs['type'] = np.string_('evaporation')
413+
group.attrs['type'] = np.bytes_('evaporation')
414414
group.attrs['u'] = self.u
415415
self.theta.to_hdf5(group, 'theta')
416416

@@ -556,7 +556,7 @@ def to_hdf5(self, group):
556556
557557
"""
558558

559-
group.attrs['type'] = np.string_('watt')
559+
group.attrs['type'] = np.bytes_('watt')
560560
group.attrs['u'] = self.u
561561
self.a.to_hdf5(group, 'a')
562562
self.b.to_hdf5(group, 'b')
@@ -728,7 +728,7 @@ def to_hdf5(self, group):
728728
729729
"""
730730

731-
group.attrs['type'] = np.string_('madland-nix')
731+
group.attrs['type'] = np.bytes_('madland-nix')
732732
group.attrs['efl'] = self.efl
733733
group.attrs['efh'] = self.efh
734734
self.tm.to_hdf5(group)
@@ -846,7 +846,7 @@ def to_hdf5(self, group):
846846
847847
"""
848848

849-
group.attrs['type'] = np.string_('discrete_photon')
849+
group.attrs['type'] = np.bytes_('discrete_photon')
850850
group.attrs['primary_flag'] = self.primary_flag
851851
group.attrs['energy'] = self.energy
852852
group.attrs['atomic_weight_ratio'] = self.atomic_weight_ratio
@@ -945,7 +945,7 @@ def to_hdf5(self, group):
945945
946946
"""
947947

948-
group.attrs['type'] = np.string_('level')
948+
group.attrs['type'] = np.bytes_('level')
949949
group.attrs['threshold'] = self.threshold
950950
group.attrs['mass_ratio'] = self.mass_ratio
951951

@@ -1074,7 +1074,7 @@ def to_hdf5(self, group):
10741074
10751075
"""
10761076

1077-
group.attrs['type'] = np.string_('continuous')
1077+
group.attrs['type'] = np.bytes_('continuous')
10781078

10791079
dset = group.create_dataset('energy', data=self.energy)
10801080
dset.attrs['interpolation'] = np.vstack((self.breakpoints,

‎openmc/data/function.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def to_hdf5(self, group, name='xy'):
364364
"""
365365
dataset = group.create_dataset(name, data=np.vstack(
366366
[self.x, self.y]))
367-
dataset.attrs['type'] = np.string_(type(self).__name__)
367+
dataset.attrs['type'] = np.bytes_(type(self).__name__)
368368
dataset.attrs['breakpoints'] = self.breakpoints
369369
dataset.attrs['interpolation'] = self.interpolation
370370

@@ -460,7 +460,7 @@ def to_hdf5(self, group, name='xy'):
460460
461461
"""
462462
dataset = group.create_dataset(name, data=self.coef)
463-
dataset.attrs['type'] = np.string_(type(self).__name__)
463+
dataset.attrs['type'] = np.bytes_(type(self).__name__)
464464

465465
@classmethod
466466
def from_hdf5(cls, dataset):
@@ -592,7 +592,7 @@ def to_hdf5(self, group, name='xy'):
592592
593593
"""
594594
sum_group = group.create_group(name)
595-
sum_group.attrs['type'] = np.string_(type(self).__name__)
595+
sum_group.attrs['type'] = np.bytes_(type(self).__name__)
596596
sum_group.attrs['n'] = len(self.functions)
597597
for i, f in enumerate(self.functions):
598598
f.to_hdf5(sum_group, f'func_{i+1}')

‎openmc/data/kalbach_mann.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ def to_hdf5(self, group):
366366
HDF5 group to write to
367367
368368
"""
369-
group.attrs['type'] = np.string_('kalbach-mann')
369+
group.attrs['type'] = np.bytes_('kalbach-mann')
370370

371371
dset = group.create_dataset('energy', data=self.energy)
372372
dset.attrs['interpolation'] = np.vstack((self.breakpoints,

‎openmc/data/multipole.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ def export_to_hdf5(self, path, mode='a', libver='earliest'):
12731273

12741274
# Open file and write version.
12751275
with h5py.File(str(path), mode, libver=libver) as f:
1276-
f.attrs['filetype'] = np.string_('data_wmp')
1276+
f.attrs['filetype'] = np.bytes_('data_wmp')
12771277
f.attrs['version'] = np.array(WMP_VERSION)
12781278

12791279
g = f.create_group(self.name)

‎openmc/data/nbody.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def to_hdf5(self, group):
9191
HDF5 group to write to
9292
9393
"""
94-
group.attrs['type'] = np.string_('nbody')
94+
group.attrs['type'] = np.bytes_('nbody')
9595
group.attrs['total_mass'] = self.total_mass
9696
group.attrs['n_particles'] = self.n_particles
9797
group.attrs['atomic_weight_ratio'] = self.atomic_weight_ratio

‎openmc/data/neutron.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ def export_to_hdf5(self, path, mode='a', libver='earliest'):
425425

426426
# Open file and write version
427427
with h5py.File(str(path), mode, libver=libver) as f:
428-
f.attrs['filetype'] = np.string_('data_neutron')
428+
f.attrs['filetype'] = np.bytes_('data_neutron')
429429
f.attrs['version'] = np.array(HDF5_VERSION)
430430

431431
# Write basic data

‎openmc/data/photon.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ def export_to_hdf5(self, path, mode='a', libver='earliest'):
764764
"""
765765
with h5py.File(str(path), mode, libver=libver) as f:
766766
# Write filetype and version
767-
f.attrs['filetype'] = np.string_('data_photon')
767+
f.attrs['filetype'] = np.bytes_('data_photon')
768768
if 'version' not in f.attrs:
769769
f.attrs['version'] = np.array(HDF5_VERSION)
770770

‎openmc/data/product.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ def to_hdf5(self, group):
124124
HDF5 group to write to
125125
126126
"""
127-
group.attrs['particle'] = np.string_(self.particle)
128-
group.attrs['emission_mode'] = np.string_(self.emission_mode)
127+
group.attrs['particle'] = np.bytes_(self.particle)
128+
group.attrs['emission_mode'] = np.bytes_(self.emission_mode)
129129
if self.decay_rate > 0.0:
130130
group.attrs['decay_rate'] = self.decay_rate
131131

‎openmc/data/reaction.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -920,9 +920,9 @@ def to_hdf5(self, group):
920920

921921
group.attrs['mt'] = self.mt
922922
if self.mt in REACTION_NAME:
923-
group.attrs['label'] = np.string_(REACTION_NAME[self.mt])
923+
group.attrs['label'] = np.bytes_(REACTION_NAME[self.mt])
924924
else:
925-
group.attrs['label'] = np.string_(self.mt)
925+
group.attrs['label'] = np.bytes_(self.mt)
926926
group.attrs['Q_value'] = self.q_value
927927
group.attrs['center_of_mass'] = 1 if self.center_of_mass else 0
928928
group.attrs['redundant'] = 1 if self.redundant else 0

0 commit comments

Comments
 (0)