From 40314f3c4da43c658b8292afe8daa5b88085bc80 Mon Sep 17 00:00:00 2001 From: "J. Michael Burgess" Date: Fri, 28 Apr 2023 12:05:03 +0200 Subject: [PATCH] another exception --- astromodels/functions/function.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/astromodels/functions/function.py b/astromodels/functions/function.py index 3e65ce23..cbcf0a0e 100644 --- a/astromodels/functions/function.py +++ b/astromodels/functions/function.py @@ -2477,7 +2477,6 @@ def get_function(function_name, composite_function_expression=None): instance = EmulatorModel(function_name) - except Exception as e: log.debug(e) @@ -2496,7 +2495,6 @@ def get_function(function_name, composite_function_expression=None): return instance - else: return instance @@ -2673,6 +2671,28 @@ def _parse_function_expression(function_specification): % (unique_function, function_specification) ) + except astromodels.functions.template_model.InvalidTemplateModelFile: + + # It's not a template + + try: + + import netspec + + instance = netspec.EmulatorModel(unique_function) + + except Exception: + + raise UnknownFunction( + "Function %s in expression %s is unknown. If this is a template model, you are " + "probably missing the data file" + % (unique_function, function_specification) + ) + + else: + + instances[complete_function_specification] = instance + else: # It's a template