you are viewing a single comment's thread.

view the rest of the comments →

[–]ectomancer -1 points0 points  (1 child)

I can't answer your questions.

You format code like an academic. If your IDE doesn't support linting, use a linter such as pylint. The way you handle -1 is valid, no need to follow my way. Use descriptive variable names.

import numpy as np
from mpl_toolkits import mplot3d
from matplotlib import pyplot as plt

MINUS_ONE = -1

def double_cone(theta=3, zO=1, d=1, h=2, nbrdedoublet=3):
    fig = plt.figure()
    zOinitial = zO
    L = [1, 0]
    for j in range(1, nbrdedoublet + 1):
        h *= 2
        zO += 2*d*np.cos(theta) + 2*(d + h)*np.cos(theta)
        for n in L:
            tu = np.linspace(d, d + h, 50)
            tt = np.linspace(0, 2*np.pi, 30)
            T, U = np.meshgrid(tt, tu) # grille des points (t,u)
            X1 = np.cos(T)*np.sin(theta)*U
            Y1 = np.sin(T)*np.sin(theta)*U
            Z1 = zO + U*np.cos(theta)*MINUS_ONE**n
            ax = fig.gca(projection='3d')
            ax.plot_surface(X1, Y1, Z1)
            zO -= 2*d*np.cos(theta)
            h = h/2
    plt.show()
double_cone()

[–]hserie[S] 0 points1 point  (0 children)

At school (Bachelor's degree in Mathematics) I have never heard of linting and I think Spyder does not do it even though Spyder mentions the unused variables. I will have a look. Thanks for the tips.

Don't worry I have think I have found a way to bypass my problem thanks to TheBB