0

I have 2 functions called cornerpoints(dim) and sntx(corners).

If I do:

a = cornerpoints(2)
b = sntx(a)
c = sntx(cornerpoints(2)

print(b == c)

I get as output: False.

Since none of the functions change anything outside of themselves I would expect True as the output.

If I create another function like this:

def d(dim):
    a = cornerpoints(dim)
    b = sntx(a)
    return b

it also breaks down.

(The outputs for dim=2 explicitly are:

print(b)
>>>[\left\{1<=t<=2:\left(2\right)\left(t-1\right)+-1,\left\{t<2:-1,\left\{2<=t<=3:\left(2\right)\left(t-2\right)+-1,\left\{t<3:-1,\left\{t<4:1,0\right\}\right\}\right\}\right\}\right\},

\left\{0<=t<=1:\left(2\right)\left(t-0\right)+-1,\left\{t<2:-1,\left\{t<3:1,\left\{3<=t<=4:\left(2\right)\left(t-3\right)+-1,\left\{t<4:-1,0\right\}\right\}\right\}\right\}\right\}]

and

print(c)
>>>
[\left\{1<=t<=2:\left(2\right)\left(t-1\right)+-1,\left\{3<=t<=4:\left(2\right)\left(t-3\right)+-1,\left\{t<4:-1,\left\{4<=t<=5:\left(2\right)\left(t-4\right)+-1,\left\{6<=t<=7:\left(2\right)\left(t-6\right)+-1,\left\{t<7:-1,\left\{8<=t<=9:\left(-2\right)\left(t-8\right)+1,\left\{t<10:1,\left\{10<=t<=11:\left(-2\right)\left(t-10\right)+1,\left\{t<12:1,\left\{13<=t<=14:\left(2\right)\left(t-13\right)+-1,\left\{t<14:-1,\left\{14<=t<=15:\left(2\right)\left(t-14\right)+-1,\left\{t<15:-1,\left\{t<16:1,0\right\}\right\}\right\}\right\}\right\}\right\}\right\}\right\}\right\}\right\}\right\}\right\}\right\}\right\}\right\},

\left\{0<=t<=1:\left(2\right)\left(t-0\right)+-1,\left\{2<=t<=3:\left(2\right)\left(t-2\right)+-1,\left\{t<4:-1,\left\{5<=t<=6:\left(-2\right)\left(t-5\right)+1,\left\{t<7:1,\left\{7<=t<=8:\left(2\right)\left(t-7\right)+-1,\left\{9<=t<=10:\left(2\right)\left(t-9\right)+-1,\left\{t<10:-1,\left\{11<=t<=12:\left(-2\right)\left(t-11\right)+1,\left\{t<12:1,\left\{12<=t<=13:\left(2\right)\left(t-12\right)+-1,\left\{t<14:-1,\left\{t<15:1,\left\{15<=t<=16:\left(2\right)\left(t-15\right)+-1,\left\{t<16:-1,0\right\}\right\}\right\}\right\}\right\}\right\}\right\}\right\}\right\}\right\}\right\}\right\}\right\}\right\}\right\}]

)

The functions are:

def cornerpoints(dim,x=[],xs=[]):
    
    for i in [-1,1]:
        x.append(i)
        if len(x) == dim:
            xs.append(copy.copy(x))
        else:
            cornerpoints(dim,x,xs)
        x.pop(-1)
    return xs

and

def sntx(a):
    G = nachbarn(a)
    U = indexUnterschied(G,a)

    dim = len(a[0])

    k = [1 for i in range(dim)] # Count of opened Barckets
    n = 0                       # Position of t
    
    s = ["\\left\\{" for sdf in range(dim)]
    for i in range(len(G)):

        for dimension in U[i]:
            # print(dimension,i)
            ind = U[i].index(dimension)
            vecI= G[i][ind]
            s[dimension] += lrp(a[i][dimension], a[vecI][dimension], n) + ",\\left\\{"
            n += 1
            k[dimension] += 1
        for j in range(dim):
            s[j] += f"t<{n}:{ecken[i][j]}" + ",\\left\\{"
            k[j] += 1

    for j in range(dim):
        s[j] = s[j][:-7]
        s[j] += "0"
        for ikj in range(k[j]-1):
            s[j] += "\\right\\}"

    return s

TL:DR for the second one: It's just changing the information into syntax desmos understands, while making no changes to anything but the list of strings "s".

(U and G are just simple nested lists)

  • 1
    Please give a [mre]. Most likely see https://stackoverflow.com/q/1132941/3001761 – jonrsharpe Mar 23 '23 at 17:13
  • 2
    [Using a mutable default value as an argument](https://docs.quantifiedcode.com/python-anti-patterns/correctness/mutable_default_value_as_argument.html) – B Remmelzwaal Mar 23 '23 at 17:13

0 Answers0