From 2c0c1339dda541cf9aee33b9becd03e901841499 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 25 Feb 2021 17:39:52 -0500 Subject: [PATCH] eja: simplify _inner_product_is_associative() code. --- mjo/eja/eja_algebra.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index c6a82ca..ad6cde7 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -448,11 +448,14 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): this algebra was constructed with ``check_axioms=False`` and passed an invalid Jordan or inner-product. """ + R = self.base_ring() - # Used to check whether or not something is zero in an inexact - # ring. This number is sufficient to allow the construction of - # QuaternionHermitianEJA(2, field=RDF) with check_axioms=True. - epsilon = 1e-16 + # Used to check whether or not something is zero. + epsilon = R.zero() + if not R.is_exact(): + # This choice is sufficient to allow the construction of + # QuaternionHermitianEJA(2, field=RDF) with check_axioms=True. + epsilon = 1e-16 for i in range(self.dimension()): for j in range(self.dimension()): @@ -462,12 +465,8 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): z = self.gens()[k] diff = (x*y).inner_product(z) - x.inner_product(y*z) - if self.base_ring().is_exact(): - if diff != 0: - return False - else: - if diff.abs() > epsilon: - return False + if diff.abs() > epsilon: + return False return True -- 2.43.2