fix bug if injection amplitude is float
This commit is contained in:
parent
d3d16afbcf
commit
2bc6989ab8
1 changed files with 10 additions and 1 deletions
|
@ -77,7 +77,16 @@ class SinInjection(Injection):
|
|||
|
||||
def to_hdf5(self, store: File | Group) -> Group | File:
|
||||
store.attrs["type"] = "sin"
|
||||
store.attrs["amplitude"] = self.amplitude.to_string()
|
||||
if type(self.amplitude) is Quantity:
|
||||
store.attrs["amplitude"] = self.amplitude.to_string()
|
||||
elif type(self.amplitude) is float: # allowed (dimensionless)
|
||||
store.attrs["amplitude"] = self.amplitude
|
||||
else:
|
||||
raise ValueError(
|
||||
"amplitude must be a dimensionless quantity, not {}".format(
|
||||
type(self.amplitude)
|
||||
)
|
||||
)
|
||||
store.attrs["frequency"] = self.frequency.to_string()
|
||||
return store
|
||||
|
||||
|
|
Loading…
Reference in a new issue