A little clarification with int type in openseespy docs

Forum for asking and answering questions related to use of the OpenSeesPy module

Moderators: silvia, selimgunay, Moderators

Post Reply
GJoe
Posts: 2
Joined: Sat Apr 27, 2019 9:31 pm
Location: Unmsm

A little clarification with int type in openseespy docs

Post by GJoe »

Hey there, GJoe here, I want to share a bit of my experience:

I was doing an rc static analysis in openseespy module, I imported Geometry to pandas dataframe and then I converted it to numpy int , but I got an error. After some time I found np.int_ and python int are not quite the same. Woosh, I guess you learn a little everyday.

Code: Select all

#Vigas
data2= pd.read_excel('data.xlsx',sheet_name='elementos')
vigas=data2.to_numpy(dtype=np.int_)
print(type(vigas[0][0]))
print(type(int(vigas[0][0])))

for idx, vigai in enumerate(vigas):
    ops.element('elasticBeamColumn',idx+37,vigas[idx][0],int(vigas[idx][1]),Av,E,G,Jxxv,Iyv,Izv,BTransform,'-mass',ρ*Av*10**-8)
Here, last line will fail because vigas[idx][0] is <class 'numpy.int32'>, it should be <class 'int'> like int(vigas[idx][1]). To fix it, replace vigas[idx][0] with int(vigas[idx][0])

Lesson of the day:
1) If docs says int , it really means int (int python type not numpy int) and nothing more

See ya folks, until next time
Post Reply