From 1141bb1e3955c7d935b874a2255782b4ae2bc9fb Mon Sep 17 00:00:00 2001 From: Christian Sachs Date: Fri, 6 Apr 2018 13:42:14 +0200 Subject: [PATCH] changed assertion failing on wrong rotations to a warning --- molyso/mm/image.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/molyso/mm/image.py b/molyso/mm/image.py index c5f036a..80d3a7a 100644 --- a/molyso/mm/image.py +++ b/molyso/mm/image.py @@ -7,6 +7,8 @@ from __future__ import division, unicode_literals, print_function import math +import warnings + from ..generic.signal import fit_to_type from ..generic.rotation import find_rotation, apply_rotate_and_cleanup from ..generic.registration import translation_2x1d @@ -125,7 +127,15 @@ def autorotate(self): self.image, self.angle, self.crop_height, self.crop_width = \ apply_rotate_and_cleanup(self.image, self.angle) - assert self.image.size > 0 + if self.image.size == 0: + warnings.warn( + "Autorotation failed. This likely means that the image is unsuitable for use with molyso.", + RuntimeWarning + ) + + self.image = self.original_image.copy() + self.angle = 0.0 + self.crop_height = self.crop_width = 0 # noinspection PyUnresolvedReferences