fork download
  1. import numpy as np
  2.  
  3.  
  4. def get_fix(xs):
  5. res = []
  6. for elem in xs:
  7. if elem >= 0.0:
  8. res += [np.floor(elem)]
  9. else:
  10. res += [np.ceil(elem)]
  11. return res
  12.  
  13. xs = [3.14, -2.718]
  14. res = get_fix(xs)
  15. print(res)
  16.  
Success #stdin #stdout 0.14s 24772KB
stdin
Standard input is empty
stdout
[3.0, -2.0]