pepflow 0.1.2__py3-none-any.whl → 0.1.3a1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pepflow/function.py +17 -0
- pepflow/pep_context.py +6 -2
- pepflow/point.py +11 -0
- pepflow/scalar.py +11 -0
- {pepflow-0.1.2.dist-info → pepflow-0.1.3a1.dist-info}/METADATA +1 -1
- {pepflow-0.1.2.dist-info → pepflow-0.1.3a1.dist-info}/RECORD +9 -9
- {pepflow-0.1.2.dist-info → pepflow-0.1.3a1.dist-info}/WHEEL +0 -0
- {pepflow-0.1.2.dist-info → pepflow-0.1.3a1.dist-info}/licenses/LICENSE +0 -0
- {pepflow-0.1.2.dist-info → pepflow-0.1.3a1.dist-info}/top_level.txt +0 -0
pepflow/function.py
CHANGED
@@ -347,3 +347,20 @@ class SmoothConvexFunction(Function):
|
|
347
347
|
self.smooth_convex_interpolability_constraints(i, j)
|
348
348
|
)
|
349
349
|
return interpolation_constraints
|
350
|
+
|
351
|
+
def interpolate_ineq(
|
352
|
+
self, p1_tag: str, p2_tag: str, pep_context: pc.PEPContext | None = None
|
353
|
+
) -> pt.Scalar:
|
354
|
+
"""Generate the interpolation inequality scalar by tags."""
|
355
|
+
if pep_context is None:
|
356
|
+
pep_context = pc.get_current_context()
|
357
|
+
if pep_context is None:
|
358
|
+
raise RuntimeError("Did you forget to specify a context?")
|
359
|
+
# TODO: we definitely need a more robust tag system
|
360
|
+
x1 = pep_context.get_by_tag(p1_tag)
|
361
|
+
x2 = pep_context.get_by_tag(p2_tag)
|
362
|
+
f1 = pep_context.get_by_tag(f"{self.tag}({p1_tag})")
|
363
|
+
f2 = pep_context.get_by_tag(f"{self.tag}({p2_tag})")
|
364
|
+
g1 = pep_context.get_by_tag(f"gradient_{self.tag}({p1_tag})")
|
365
|
+
g2 = pep_context.get_by_tag(f"gradient_{self.tag}({p2_tag})")
|
366
|
+
return f2 - f1 + g2 * (x1 - x2) + 1 / 2 * (g1 - g2) ** 2
|
pepflow/pep_context.py
CHANGED
@@ -52,6 +52,10 @@ class PEPContext:
|
|
52
52
|
self.triplets: dict[Function, list[Triplet]] = defaultdict(list)
|
53
53
|
self.opt_conditions: dict[Function, list[Constraint]] = defaultdict(list)
|
54
54
|
|
55
|
+
def set_as_current(self) -> PEPContext:
|
56
|
+
set_current_context(self)
|
57
|
+
return self
|
58
|
+
|
55
59
|
def add_point(self, point: Point):
|
56
60
|
self.points.append(point)
|
57
61
|
|
@@ -66,10 +70,10 @@ class PEPContext:
|
|
66
70
|
|
67
71
|
def get_by_tag(self, tag: str) -> Point | Scalar:
|
68
72
|
for p in self.points:
|
69
|
-
if
|
73
|
+
if tag in p.tags:
|
70
74
|
return p
|
71
75
|
for s in self.scalars:
|
72
|
-
if
|
76
|
+
if tag in s.tags:
|
73
77
|
return s
|
74
78
|
raise ValueError("Cannot find the point or scalar of given tag")
|
75
79
|
|
pepflow/point.py
CHANGED
@@ -212,3 +212,14 @@ class Point:
|
|
212
212
|
if not isinstance(other, Point):
|
213
213
|
return NotImplemented
|
214
214
|
return self.uid == other.uid
|
215
|
+
|
216
|
+
def eval(self, ctx: pc.PEPContext | None = None) -> np.ndarray:
|
217
|
+
from pepflow.expression_manager import ExpressionManager
|
218
|
+
|
219
|
+
# Note this can be inefficient.
|
220
|
+
if ctx is None:
|
221
|
+
ctx = pc.get_current_context()
|
222
|
+
if ctx is None:
|
223
|
+
raise RuntimeError("Did you forget to create a context?")
|
224
|
+
em = ExpressionManager(ctx)
|
225
|
+
return em.eval_point(self).vector
|
pepflow/scalar.py
CHANGED
@@ -247,3 +247,14 @@ class Scalar:
|
|
247
247
|
|
248
248
|
def eq(self, other, name: str) -> ctr.Constraint:
|
249
249
|
return ctr.Constraint(self - other, comparator=utils.Comparator.EQ, name=name)
|
250
|
+
|
251
|
+
def eval(self, ctx: pc.PEPContext | None = None) -> EvaluatedScalar:
|
252
|
+
from pepflow.expression_manager import ExpressionManager
|
253
|
+
|
254
|
+
# Note this can be inefficient.
|
255
|
+
if ctx is None:
|
256
|
+
ctx = pc.get_current_context()
|
257
|
+
if ctx is None:
|
258
|
+
raise RuntimeError("Did you forget to create a context?")
|
259
|
+
em = ExpressionManager(ctx)
|
260
|
+
return em.eval_scalar(self)
|
@@ -2,21 +2,21 @@ pepflow/__init__.py,sha256=tLnOlZ1y_mIodRl5Fr5HMLPP5M7h_ad76s4in5OgiHE,1930
|
|
2
2
|
pepflow/constants.py,sha256=t29CDRE8kw773zgKS0ZZCYGegwagaDDdLfpSaeDpK14,871
|
3
3
|
pepflow/constraint.py,sha256=n-01dcQplvsXB7V4fceJBImbwSr-Wa9k9tE7ZcVmi3o,1153
|
4
4
|
pepflow/expression_manager.py,sha256=64FbdMjcUrIqtbFZyJoxoDZ42j1bl1CeGxhJnKcGTD8,5222
|
5
|
-
pepflow/function.py,sha256=
|
5
|
+
pepflow/function.py,sha256=dTEGK65JGTYyKzb7sD4TbbcfTNdDclkl4M_OJr5boXk,13423
|
6
6
|
pepflow/function_test.py,sha256=947Jv0i7HtQ-LOi9-Hd7YsIGbX6BjnHsW3N4Q9HZE-A,4833
|
7
7
|
pepflow/interactive_constraint.py,sha256=HMwAo80tJyCKwWKryxNGk1LAh-qlnQk5OeULLwKZUOQ,9826
|
8
8
|
pepflow/pep.py,sha256=IKrYW6DBIekKOjGfL7rc6t1xU06VJEyL_gxj1sH_m_Q,5824
|
9
|
-
pepflow/pep_context.py,sha256=
|
9
|
+
pepflow/pep_context.py,sha256=RmEPMLqzP3o5wdqE-jGYV36STYb5ssqTaKd_ucw3VdA,4544
|
10
10
|
pepflow/pep_context_test.py,sha256=1kFkmG56JVkmjaT9ic9byV-F9WOs9ZNQz5P1P5v5lLw,3092
|
11
11
|
pepflow/pep_test.py,sha256=aWwP3CqXNJzQUhJqC5sNcsM83i_asJaZewpGNqC1G7M,2504
|
12
|
-
pepflow/point.py,sha256=
|
12
|
+
pepflow/point.py,sha256=sVQ8txNTNvLDEAIXXgH4bBnsE66s-b5nn3Ns5Vjkp8A,7125
|
13
13
|
pepflow/point_test.py,sha256=jwbvjfwHP_9oY7KLp4UE_uSEbAVlDTXAQjr8d0z-eME,12602
|
14
|
-
pepflow/scalar.py,sha256=
|
14
|
+
pepflow/scalar.py,sha256=Dj-kQlXHLhQopTkleFBTanTCQImHXFjGrEJx-RJjEEA,8259
|
15
15
|
pepflow/solver.py,sha256=WzeN_IWNBs9IpE212jenhYMWFuuwH890h0vaFmJRM6I,4312
|
16
16
|
pepflow/solver_test.py,sha256=BC37ggL_S8NDtnq8nPwRR2xItMCYMLs-n931u7f34YE,2414
|
17
17
|
pepflow/utils.py,sha256=tYcpOOWAieNay5Ly7v7dRll69RPYCUGMEuW-Bwp2z68,1321
|
18
|
-
pepflow-0.1.
|
19
|
-
pepflow-0.1.
|
20
|
-
pepflow-0.1.
|
21
|
-
pepflow-0.1.
|
22
|
-
pepflow-0.1.
|
18
|
+
pepflow-0.1.3a1.dist-info/licenses/LICENSE,sha256=na5oVXAps-5f1hLGG4SYnwFdavQeXgYUeN-E3MxOA_s,11361
|
19
|
+
pepflow-0.1.3a1.dist-info/METADATA,sha256=0XSqgCb63395I2lgwMPAwKbX17oHOQLsloc0utws0eQ,1436
|
20
|
+
pepflow-0.1.3a1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
21
|
+
pepflow-0.1.3a1.dist-info/top_level.txt,sha256=0YEPCZQQa6yIAIwMumzDg4pj7AME8aXu2sXkuq8xM6M,8
|
22
|
+
pepflow-0.1.3a1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|