Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 finding the closest floating point number in a list
#11
(Sep-15-2019, 04:16 AM)Skaperen Wrote: i'm going to need to find some extra time to learn numpy.
Definitely, i actually can´t believe you didn´t learn it so far.
Maybe this vid is helpful.
Introduction to Numerical Computing with NumPy | SciPy 2019 Tutorial
Gribouillis likes this post
Quote
#12
i learn things when i need them. things stay with me better that way. i haven't needed numpy, yet. of course, the disadvantage is that i won't know there's a solution in there. but i won't know that if i never use it, either. so i wait until i have a real need or at least a way to use it in my current project. i remember a new friend a few years ago told me i should try python, and that i'd love it. my next project was a script to login to the main router and pull down the configuration. so i tried it in python using the pexpect module. my friend was right.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote
#13
At least you can become familiar with what the most used Python's modules are used for and what they are capable. That way when you start a project you will know that there are alternative/different way to do something and you can do deeper research about it. And eventually, use it. Numpy is fast. Really fast.

I don't know NumPy and I have never used it but because of this topic, I google it just a bit to make an example. I just know that it's fast. So here is how much.

In [1]: import math

In [2]: nums = list(range(2, 100001))

In [3]: def power_it(numbers):
   ...:     return [math.pow(num, 5) for num in numbers]
   ...:

In [4]: %timeit power_it(nums)
22.6 ms ± 2.65 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

In [5]: import numpy as np

In [6]: def np_pow(numbers):
   ...:     return np.power(numbers, 5)
   ...:

In [7]: %timeit np_pow(nums)
4.89 ms ± 14.9 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

In [8]: l = np.array(nums)

In [9]: %timeit np_pow(l)
258 µs ± 1.39 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
I have to thank you for that because I'm planning to use it constantly now. I am surpriced Sick
Consider I have opened two browsers Chrome and Firefox with 118 and 499 tabs. ;)
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Quote
#14
499 tabs????? and it didn't crash or cry?
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote
#15
I don't believe it either but it's in front of my eyes :D
Two windows 499 tabs both.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Quote
#16
and i really also need to understand the depths of things. for example, i need to look at processing a tar file. the compression layer, i know, is not an issue. but can i change things in an incoming tarball and put it all in an outgoing tarball at the same time handling file contents chunk-by-chunk so i don't need to extract it all before putting it in a new outgoing tarball? this case needs to change metadata in the tarball, like file owner or file name. in the future i might even need to change file content on the fly, or change between tar and cpio format. that's why i actually need to go have a look at that module, real soon.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote
#17
Well, actually the window 1 has opened 336 tabs FF window 2 has opened 499. In along with Chrome with its own 116 tabs.
But! I see that both browsers are loading pages when their tabs are clicked. The Task manager tells me that FF has 6 processes running and Chrome 15. This is why they don't crash. Or the machine.

I don't learn anything until I need it. Just like you. But I think this is a mistake. I am glad that I did this with NumPy for the simple example above. I'm going to use it instead of a regular for loop when I deal with numbers. Yesterday I realised that I can use it with my old project which I put on hold because I stuck. It involves heavy computations with really, really big numbers. It was too slow. If I knew NumPy perhaps I would have finished it by now.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Quote
#18
both windows are FF? one process? that would be 835 tabs, total. yikes! they probably coded with inf in mind like GNU did make. all programs should be like that. let people scale up to how much memory they install.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  adding elements to a list that are more than a specific number Olavv 2 122 Mar-19-2020, 06:05 PM
Last Post: Olavv
  Adding elements to a list by number Olavv 4 186 Mar-08-2020, 11:16 AM
Last Post: ndc85430
  counting items in a list of number combinations Dixon 2 129 Feb-19-2020, 07:06 PM
Last Post: Dixon
  connecting the first point to the last point Matplotlib omar_mohsen 0 104 Jan-15-2020, 01:23 PM
Last Post: omar_mohsen
  'Get closest value array in array of arrays.' follow up help. DreamingInsanity 10 511 Dec-05-2019, 06:30 PM
Last Post: DreamingInsanity
  Finding MINIMUM number in a random list is not working Mona 5 267 Nov-18-2019, 07:27 PM
Last Post: ThomasL
  Complex floating issue arshad 2 474 Nov-05-2019, 03:26 PM
Last Post: arshad
  floating point arithmetic exDeveloper 2 229 Sep-25-2019, 04:33 PM
Last Post: DeaD_EyE
  finding the next higher representable floating point value Skaperen 0 443 Sep-13-2019, 11:16 PM
Last Post: Skaperen
  Checking number in a list to see if they are beside each other Allaye 5 382 Aug-26-2019, 07:15 AM
Last Post: perfringo

Forum Jump:


Users browsing this thread: 1 Guest(s)