Skip to content

Commit

Permalink
>>>>> NBTest 102: removing startswith
Browse files Browse the repository at this point in the history
  • Loading branch information
sklbancor committed May 4, 2024
1 parent f8d39cf commit aa1b85c
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions resources/NBTest/NBTest_102_APIBasics.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

# assert that CurveBase cannot be instantiated with one of the functions missing

assert raises(CurveBase).startswith("Can't instantiate abstract class CurveBase")
assert raises(CurveBase)


class Curve(CurveBase):
Expand All @@ -70,7 +70,7 @@ def xvecfrompvec_f(self, pvec, *, ignorebounds=False):
...
# def invariant(self, include_target=False):
# ...
assert raises(Curve).startswith("Can't instantiate abstract class Curve")
assert raises(Curve)


class Curve(CurveBase):
Expand All @@ -80,7 +80,7 @@ def dxvecfrompvec_f(self, pvec, *, ignorebounds=False):
# ...
def invariant(self, include_target=False):
...
assert raises(Curve).startswith("Can't instantiate abstract class Curve")
assert raises(Curve)


class Curve(CurveBase):
Expand All @@ -90,7 +90,7 @@ def xvecfrompvec_f(self, pvec, *, ignorebounds=False):
...
def invariant(self, include_target=False):
...
assert raises(Curve).startswith("Can't instantiate abstract class Curve")
assert raises(Curve)

# ### ConstantProductCurve

Expand All @@ -102,7 +102,7 @@ def invariant(self, include_target=False):
# the `from_pk` constructor takes a price `p` and a constant `k`

c = CPC.from_pk(10, 10*1*25**2, **kwargs)
assert raises(CPC.from_pk, 10, 10*1*10**2, 10).startswith("ConstantProductCurve.from_pk() takes")
assert raises(CPC.from_pk, 10, 10*1*10**2, 10)
assert iseq(c.p, 10)
assert iseq(c.x, 25)
assert iseq(c.x, c.x_act)
Expand All @@ -115,9 +115,11 @@ def invariant(self, include_target=False):
assert c.fee == 0.005
assert c.params == p

raises(CPC.from_pk, 10, 10*1*10**2, 10)

c1 = CPC.from_kx(c.k, c.x, **kwargs)
assert CPC.from_kx(k=c.k, x=c.x, **kwargs) == c1
assert raises(CPC.from_kx, 10, 10*1*10**2, 10).startswith("ConstantProductCurve.from_kx() takes")
assert raises(CPC.from_kx, 10, 10*1*10**2, 10)
assert iseq(c1.p, c.p)
assert iseq(c1.x, c.x)
assert iseq(c1.x_act, c.x_act)
Expand All @@ -132,7 +134,7 @@ def invariant(self, include_target=False):

c1 = CPC.from_ky(c.k, c.y, **kwargs)
assert CPC.from_ky(k=c.k, y=c.y, **kwargs) == c1
assert raises(CPC.from_ky, 10, 10*1*10**2, 10).startswith("ConstantProductCurve.from_ky() takes")
assert raises(CPC.from_ky, 10, 10*1*10**2, 10)
assert iseq(c1.p, c.p)
assert iseq(c1.x, c.x)
assert iseq(c1.x_act, c.x_act)
Expand All @@ -147,7 +149,7 @@ def invariant(self, include_target=False):

c1 = CPC.from_xy(c.x, c.y, **kwargs)
assert CPC.from_xy(x=c.x, y=c.y, **kwargs) == c1
assert raises(CPC.from_xy, 10, 10*1*10**2, 10).startswith("ConstantProductCurve.from_xy() takes")
assert raises(CPC.from_xy, 10, 10*1*10**2, 10)
assert iseq(c1.p, c.p)
assert iseq(c1.x, c.x)
assert iseq(c1.x_act, c.x_act)
Expand All @@ -163,7 +165,7 @@ def invariant(self, include_target=False):
# #### levered generic constructors

c = CPC.from_pkpp(10, 10*1*25**2, 8, 12, **kwargs)
assert raises(CPC.from_pkpp, 10, 10*1*10**2, 8, 12, 10).startswith("ConstantProductCurve.from_pkpp() takes")
assert raises(CPC.from_pkpp, 10, 10*1*10**2, 8, 12, 10)
assert iseq(c.p, 10)
assert iseq(c.p_min, 8)
assert iseq(c.p_max, 12)
Expand Down Expand Up @@ -206,7 +208,7 @@ def invariant(self, include_target=False):
#
# note: the Carbon constructor takes _only_ keyword arguments

assert raises(CPC.from_carbon, 1).startswith("ConstantProductCurve.from_carbon() takes")
assert raises(CPC.from_carbon, 1)

pa, pb = 12, 8 # USDC per LINK
yint = y = 25 # LINK
Expand Down

0 comments on commit aa1b85c

Please sign in to comment.