From: Michael Orlitzky Date: Sun, 4 Nov 2018 04:19:18 +0000 (-0400) Subject: cone/faces.py: use generator expressions where applicable. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=1874c5e8ea340d10df3fb337cd93547c4d7c38ba;p=sage.d.git cone/faces.py: use generator expressions where applicable. --- diff --git a/mjo/cone/faces.py b/mjo/cone/faces.py index 70706a8..5573a97 100644 --- a/mjo/cone/faces.py +++ b/mjo/cone/faces.py @@ -53,7 +53,7 @@ def face_generated_by(K,S): sage: set_random_seed() sage: K = random_cone(max_ambient_dim=8, max_rays=10) - sage: S = [K.random_element() for idx in range(0,5)] + sage: S = ( K.random_element() for idx in range(0,5) ) sage: F = face_generated_by(K, S) sage: F.is_face_of(K) True @@ -62,9 +62,9 @@ def face_generated_by(K,S): sage: set_random_seed() sage: K = random_cone(max_ambient_dim=8, max_rays=10) - sage: S = [K.random_element() for idx in range(0,5)] + sage: S = ( K.random_element() for idx in range(0,5) ) sage: F = face_generated_by(K, S) - sage: all([F.contains(x) for x in S]) + sage: all(F.contains(x) for x in S) True The generators of a proper cone are all extreme vectors of the cone, @@ -75,7 +75,7 @@ def face_generated_by(K,S): ....: max_rays=10, ....: strictly_convex=True, ....: solid=True) - sage: all([face_generated_by(K, [r]) == Cone([r]) for r in K]) + sage: all(face_generated_by(K, [r]) == Cone([r]) for r in K) True For any point ``x`` in ``K`` and any face ``F`` of ``K``, we have @@ -123,7 +123,7 @@ def face_generated_by(K,S): """ face_lattice = K.face_lattice() - candidates = [F for F in face_lattice if all([F.contains(x) for x in S])] + candidates = [F for F in face_lattice if all(F.contains(x) for x in S)] # K itself is a face of K, so unless we were given a set S that # isn't a subset of K, the candidates list will be nonempty. @@ -175,7 +175,7 @@ def dual_face(K,F): sage: set_random_seed() sage: K = random_cone(max_ambient_dim=8, max_rays=10) sage: K_dual = K.dual() - sage: lKd_gens = [ dir*l for dir in [1,-1] for l in K_dual.lines() ] + sage: lKd_gens = ( dir*l for dir in [1,-1] for l in K_dual.lines() ) sage: linspace_K_dual = Cone(lKd_gens, K_dual.lattice()) sage: dual_face(K,K).is_equivalent(linspace_K_dual) True @@ -213,7 +213,7 @@ def dual_face(K,F): sage: def check_prop(K,F): ....: return dual_face(K.dual(), dual_face(K,F)).is_equivalent(F) sage: K = random_cone(max_ambient_dim=8, max_rays=10) - sage: all([check_prop(K,F) for F in K.face_lattice()]) + sage: all(check_prop(K,F) for F in K.face_lattice()) True """ @@ -221,5 +221,5 @@ def dual_face(K,F): if not F.is_face_of(K): raise ValueError("%s is not a face of %s" % (F,K)) - span_F = Cone([c*g for c in [1,-1] for g in F], F.lattice()) + span_F = Cone((c*g for c in [1,-1] for g in F), F.lattice()) return K.dual().intersection(span_F.dual())