New submission from Francesco Pelizza:

arange from numpy is a function to generate list of floats from a start to an 
end number with a defined float number.

The "arange" function works fine for some cases, but in my case where I have to 
generate numbers that constitute parameters in a Quantum Mechanical 
calculation, numbers can be missing or be more than what I want, since many 
time each number is calculated in a couple of days or more. I need to avoid 
extra numbers or missing numbers to avoid loss of data. And sometimes the 
script will pass to a cycle function wrong numbers for start and stop, or the 
same number as starting and ending point, but I can not avoid this because they 
are numbers coming from Quantum World, and I need a function that sort out 
anything on its own because is inserted in for loops and things like that.

Also arange function does not take the "stop" number as the last number of the 
list, but it will terminate before, so to have the last wanted number in the 
list you have to use the formulae  arange(start,stop+inc,inc) or 
arange(start,stop+n,inc) where n allows is bigger than zero.

Some cases that give me problems are the following:
Defective lists of numbers:
1) arange(1,10+0.0000001,0.00000001) some numbers are missing
2) arange(1,10+0.0000001,1) generate float without any decimal after the point
3) arange(1,10,0.0000001) some numbers are missing
4) ...other combination gives problems

Empty lists of numbers:
1) arange(1,10,-1)
2) arange(1,-10,1)
3) arange(1,1,1)
4) arange(1,1,0.5)
5) arange(1,-10,0.005)
6) so on....

I made a python function that goes across any of these problems, taking account 
of using the absolute value of the given incremental step number.

Numbers can be float or integers, any exception of number ordering is kept 
under control to generate anyway at least a list of one number, if the stop 
number is bigger than the starting one, they get switched to generate anyway a 
list of numbers. And it can go down until 14 decimal places of incremental 
steps without generating wrong numbers due to the binary conversion of floats!
Some use of this function are eventually weird or really exotic, but in using 
python as a code to deal with computation without crashing for silly numbers 
ordering from the quantum world, is essential.

Do you agree with the improvements I put in this function called "CYCLE" can be 
of help?

I would like to share it with the community.

Here attached the function I made

----------
components: Library (Lib)
files: CYCLE.py
messages: 258899
nosy: Francesco Pelizza
priority: normal
severity: normal
status: open
title: arange from numpy function has some limits....I propose a python 
function that overcome
type: enhancement
versions: Python 2.7
Added file: http://bugs.python.org/file41707/CYCLE.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26197>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to