Ask Your Question

Unbrackable blanck

asked 2020-10-26 18:21:08 +0200

Cyrille gravatar image

updated 2020-10-26 18:21:51 +0200

In the following code I am obliged to insert / to inside my fonction to obtain the desired result.

nl=3 #nombre de contraintes
nc=4  #nombre de variables

### code ####
def simplex_tableau_sf(A, b, c,cond=1) :
    # A matrice des contraintes
    # b vecteur des contraintes
    # c vecteur des paramètres de l'objectif
    # 1 (défaut) tableau

    z1=vector([0 for i in range(n+1)])
    rows = list(L)
    hr=['$x_{}$'.format(i) for i in range(0,nc+nl)]
    hc=list('xc2')+['$x_{}$'.format(i) for i in range(4,7)]
    t = table(rows, header_row=hr, header_column=hc, frame=True)
    if cond == 1 :
        return t
    elif cond != 1 :
        return L

So is there a blank which can be used as a string

edit retag flag offensive close merge delete


Can you clarify? It is not clear what you are asking. In Python, ' ' is a blank string. In LaTeX, '~' is a blank.

John Palmieri gravatar imageJohn Palmieri ( 2020-10-26 22:47:33 +0200 )edit

John look the difference when I use hr=list('/')+list(hr)+list('b'), hr=list(' ')+list(hr)+list('b') and hr=list('/')+list(hr)+list('b'). The only case where I obtain a correct result is the first and I want to have a blanc space not a \.

Cyrille gravatar imageCyrille ( 2020-10-28 19:17:27 +0200 )edit

What happens if you use ' ' rather than ''?

John Palmieri gravatar imageJohn Palmieri ( 2020-10-28 19:56:39 +0200 )edit

Sorry John, I send the wrong code. I have changed it in the question. I hope now it is correct. My problem is only with the /. Now with ' ', it works. I don't know why earlier, I have a wrong result.

Cyrille gravatar imageCyrille ( 2020-11-01 12:21:42 +0200 )edit

Quick comment: you can replace elif cond != 1 : with else:

John Palmieri gravatar imageJohn Palmieri ( 2020-11-02 19:57:16 +0200 )edit

1 Answer

Sort by » oldest newest most voted

answered 2020-10-28 20:03:25 +0200

Here is a screenshot of what your code produces for me (using Sage 9.2):

image description

If I change '' to '/', it adds an extra column to the header row, so that the column "b" has nothing beneath it. Is that really what you want?

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-10-26 18:21:08 +0200

Seen: 67 times

Last updated: Oct 28 '20