Skip to content

Commit 27ef6e3

Browse files
committed
Add proper single NMR in array edge case handling
1 parent 19624c0 commit 27ef6e3

File tree

5 files changed

+426
-220
lines changed

5 files changed

+426
-220
lines changed

nmrpy/data_objects.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,24 +388,29 @@ def species(self, species):
388388
@property
389389
def fid_object(self):
390390
try:
391-
self.__fid_object.raw_data = self.data.tolist()
391+
self.__fid_object.raw_data = [str(datum) for datum in self.raw_data]
392+
self.__fid_object.processed_data = [float(datum) for datum in self.data]
392393
except AttributeError:
393-
print('Warning: Fid.data is not yet set. Raw data will not be updated.')
394+
print('Warning: Fid.data is not yet set. Processed data will not be updated.')
395+
if not isinstance(self._params.get('acqtime'), float):
396+
return self.__fid_object
394397
try:
395398
self.__fid_object.nmr_parameters = Parameters(
396-
acquisition_time=self._params['at'],
399+
acquisition_time_period=self._params['at'],
397400
relaxation_time=self._params['d1'],
398401
repetition_time=self._params['rt'],
399402
number_of_transients=self._params['nt'],
400-
acquisition_times_array=self._params['acqtime'],
403+
acquisition_time_point=self._params['acqtime'],
401404
spectral_width_ppm=self._params['sw'],
402405
spectral_width_hz=self._params['sw_hz'],
403406
spectrometer_frequency=self._params['sfrq'],
404407
reference_frequency=self._params['reffrq'],
405408
spectral_width_left=self._params['sw_left'],
406409
)
407410
except AttributeError:
408-
print('Warning: Fid._params is not yet set. NMR parameters will not be updated.')
411+
print('Warning: Fid._params does not yet exist. NMR parameters will not be updated.')
412+
except TypeError:
413+
print('Warning: Fid._params exists but is not yet set. NMR parameters will not be updated.')
409414
return self.__fid_object
410415

411416
@fid_object.setter
@@ -1595,7 +1600,7 @@ def concentrations(self, concentrations):
15951600
if not all(len(concentrations[species]) == len(self.t) for species in concentrations.keys()):
15961601
raise ValueError('Length of concentrations must match length of FID data.')
15971602
for v in concentrations.values():
1598-
if not all(isinstance(i, (in4t, float)) for i in v):
1603+
if not all(isinstance(i, (int, float)) for i in v):
15991604
raise ValueError('Concentrations must be a list of integers or floats.')
16001605
self.__concentrations = concentrations
16011606

0 commit comments

Comments
 (0)