File tree 1 file changed +10
-2
lines changed
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -276,7 +276,12 @@ def checkfield(self, field):
276
276
raise ValueError ('Subelements of the ' + field + ' field must not contain tabs or newlines' )
277
277
278
278
elif field == 'sample' :
279
- sampdiffs = np .concatenate (([self .sample [0 ]], np .diff (self .sample )))
279
+ if len (self .sample ) == 1 :
280
+ sampdiffs = np .array ([self .sample [0 ]])
281
+ elif len (self .sample ) > 1 :
282
+ sampdiffs = np .concatenate (([self .sample [0 ]], np .diff (self .sample )))
283
+ else :
284
+ raise ValueError ("The 'sample' field must be a numpy array with length greater than 0" )
280
285
if min (self .sample ) < 0 :
281
286
raise ValueError ("The 'sample' field must only contain non-negative integers" )
282
287
if min (sampdiffs ) < 0 :
@@ -621,7 +626,10 @@ def calc_core_bytes(self):
621
626
Convert all used annotation fields into bytes to write
622
627
"""
623
628
# The difference sample to write
624
- sampdiff = np .concatenate (([self .sample [0 ]], np .diff (self .sample )))
629
+ if len (self .sample ) == 1 :
630
+ sampdiff = np .array ([self .sample [0 ]])
631
+ else :
632
+ sampdiff = np .concatenate (([self .sample [0 ]], np .diff (self .sample )))
625
633
626
634
# Create a copy of the annotation object with a
627
635
# compact version of fields to write
You can’t perform that action at this time.
0 commit comments