From addb70b7edecb9b4999e16b9a783d48b2dfcd0a6 Mon Sep 17 00:00:00 2001 From: Sebastian Proost Date: Thu, 25 Jan 2018 05:02:20 +0100 Subject: [PATCH] shorter way to suppress a warning --- conekt/models/expression/profiles.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/conekt/models/expression/profiles.py b/conekt/models/expression/profiles.py index 305b87c..e970a4a 100644 --- a/conekt/models/expression/profiles.py +++ b/conekt/models/expression/profiles.py @@ -1,9 +1,9 @@ from conekt import db -from conekt.models.species import Species from conekt.models.sequences import Sequence from conekt.models.condition_tissue import ConditionTissue import json +import contextlib from collections import defaultdict from statistics import mean from math import log @@ -169,17 +169,11 @@ def get_heatmap(species_id, probes, zlog=True, raw=False): order = data['order'] experiments = data['data'] - try: + with contextlib.suppress(ValueError): not_found.remove(profile.probe.lower()) - except ValueError as _: - # Element not in list - pass - try: + with contextlib.suppress(ValueError): not_found.remove(profile.sequence.name.lower()) - except ValueError as _: - # Element not in list - pass values = {} @@ -205,7 +199,7 @@ def get_heatmap(species_id, probes, zlog=True, raw=False): "shortest_alias":profile.sequence.shortest_alias}) if len(not_found) > 0: - flash("Couldn't fine profile for: %s" % ",".join(not_found), "warning") + flash("Couldn't find profile for: %s" % ",".join(not_found), "warning") return {'order': order, 'heatmap_data': output}