You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Not empty samplesassert (train_df.shape[0] !=0), "No samples!"# Sequences of proper lengthsample=train_df.values[0]
word_0_vec=sample[0]
assert (len(word_0_vec) ==seq_len), "Sample length is not specified seq_len"# Data is of proper typeassert (isinstance(word_0_vec[0], int)), "Sample is improper data type"assert (word_0_vec[0] >-1andword_0_vec[0] <1), "Sample value is out of range"
Exceptions
Conditions that should NEVER occur
Conditions that originate from OUTSIDE the program
network (requests, boto3)
hardware (gpu grabbing)
try:
print('in try')
# int(2.0)int('string')
exceptValueErrorase:
print('in except')
print(' -->', e)
else:
print("in else")
print(' --> continues operations after the try statement')
print(' this is done to localize the single excepted line')
print(' to be the only thing inside the `try`')
finally:
print('in finally')
print(' --> always executes')
# Network exampleimportrequeststry:
r=requests.get('http://www.google.com/nothere')
r.raise_for_status()
exceptrequests.exceptions.HTTPErrorase:
print(e)
sys.exit(1)