From 2e91e150e1976ff1374821e84264aa6ab1b4b6c7 Mon Sep 17 00:00:00 2001 From: Drew Camron Date: Mon, 13 Nov 2023 20:34:41 -0700 Subject: [PATCH] Use operator in comparison dict --- src/metpy/testing.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/metpy/testing.py b/src/metpy/testing.py index 8d9c5f6a0f6..5505dab25ca 100644 --- a/src/metpy/testing.py +++ b/src/metpy/testing.py @@ -10,6 +10,7 @@ import contextlib import functools from importlib.metadata import metadata, version +import operator as op import re import numpy as np @@ -42,9 +43,9 @@ def module_version_check(version_spec): bool : Whether the installed package validates against the provided specification """ comparison_operators = { - '==': lambda x, y: x == y, '=': lambda x, y: x == y, '!=': lambda x, y: x != y, - '<': lambda x, y: x < y, '<=': lambda x, y: x <= y, - '>': lambda x, y: x > y, '>=': lambda x, y: x >= y, + '==': op.eq, '=': op.eq, '!=': op.ne, + '<': op.lt, '<=': op.le, + '>': op.gt, '>=': op.ge, } # Match version_spec for groups of module name,