This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Francesco Pelizza
Recipients Francesco Pelizza
Date 2016-01-25.12:57:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1453726637.54.0.637888159754.issue26197@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2016-01-25 12:57:17Francesco Pelizzasetrecipients: + Francesco Pelizza
2016-01-25 12:57:17Francesco Pelizzasetmessageid: <1453726637.54.0.637888159754.issue26197@psf.upfronthosting.co.za>
2016-01-25 12:57:17Francesco Pelizzalinkissue26197 messages
2016-01-25 12:57:15Francesco Pelizzacreate