Wikipedia:Reference desk/Archives/Computing/2012 June 18
Computing desk | ||
---|---|---|
< June 17 | << May | June | Jul >> | June 19 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
June 18
editList of Ubuntu releases says that Ubuntu releases are named in alphabetical order. How will Ubuntu developers choose codenames when they run out of letters in alphabet? 117.5.4.42 (talk) 04:36, 18 June 2012 (UTC)
- I doubt they're really concerned about it; my guess is they'll start back at the beginning. ¦ Reisio (talk) 04:48, 18 June 2012 (UTC)
- I see your guess and raise you an "Ärgerliche Ähre"! --Stephan Schulz (talk) 12:25, 18 June 2012 (UTC)
- The official reference is here and as you can see no official decision has been made on that question by Ubuntu's sponsor, Canonical, yet. The leading suggestions seem to be to just start over again at "A" or else to use double letters such Aalenian Aal or Aalenian Aardvark. - Ahunt (talk) 14:55, 18 June 2012 (UTC)
- It'd be a mercy if they just did away with them. Most Ubuntu users don't even realize they're in alphabetical order, so what you have is two versions (number based and name based) and tons of (official, even) websites that only use one and not the other. ¦ Reisio (talk) 20:56, 18 June 2012 (UTC)
- A well made point there , Precise Pangolin, oxymoronic oncelot,quixotic (insert some random name) sheesh Virtualpractice (talk) 12:00, 21 June 2012 (UTC)
Hi. I use Google Chrome under Windows 7 and my router is SpeedTouch. What should I do to switch to IPv6? Does my router support IPv6? Do I need any new software or hardware? Is the switch done automatically? Help me, please. --41.129.120.207 (talk) 20:53, 18 June 2012 (UTC)
- Go to http://test-ipv6.com/ to see if you have ipv6 support. If you don't, there's not much you can do except wait for your ISP to update their systems or change to an ISP that supports it. 2002:5CE9:401A:0:0:0:5CE9:401A (talk) 21:46, 18 June 2012 (UTC)
It tells me the following:
Your IPv4 address on the public Internet appears to be 41.129.120.207
Your IPv6 address on the public Internet appears to be 2001:0:4137:9e76:18fa:2c5f:d67e:8730
Your IPv6 service appears to be: Teredo
The World IPv6 Launch day is June 6th, 2012. Good news! Your current browser, on this computer and at this location, are expected to keep working after the Launch. [more info]
You appear to be able to browse the IPv4 Internet only. You will not be able to reach IPv6-only sites.
Your IPv6 connection appears to be using Teredo, a type of IPv4/IPv6 gateway; currently it connects only to direct IP's. Your browser will not be able to go to IPv6 sites by name. This means the current configuration is not useful for browsing IPv6 web sites. [more info]
Your DNS server (possibly run by your ISP) appears to have no access to the IPv6 Internet, or is not configured to use it. This may in the future restrict your ability to reach IPv6-only sites. [more info] Your readiness scores
10/10 for your IPv4 stability and readiness, when publishers offer both IPv4 and IPv6
0/10 for your IPv6 stability and readiness, when publishers are forced to go IPv6 only --41.129.120.207 (talk) 21:55, 18 June 2012 (UTC)
Using Python/Numpy/Scipy and Datetime objects
editSo I have just started learning and using python and I have a question. So I have a text file, something like
1990 10 11 21 15 0.0000
1990 10 11 21 20 0.0000
1990 10 11 21 25 0.0000
1990 10 11 21 30 0.0000
with a lot more rows. The columns are delimited by space representing year, month, day, hour, mins, and seconds. So what I want to do is end up with something like
dtdates = [datetime.datetime(1990,10,11,21,15,0),
datetime.datetime(1990,10,11,21,20,0),
datetime.datetime(1990,10,11,21,25,0),
datetime.datetime(1990,10,11,21,30,0)]
an entire array of datetime objects distributed over rows with the columns being the arguments of datetime. First question, all of the arguments of datetime have to be integers right? I am asking about the seconds because in the ascii text file they are written as floats. Second, what is the fastest way (meaning runtime) to do this in python? I can obviously have a naive double for loop but doesn't seem like a good idea for python. I have thousands of rows to process like this so dtdates at the end will be one giant array consisting datetime objects. Thanks! - Looking for Wisdom and Insight! (talk) 22:50, 18 June 2012 (UTC)
- Try this:
#!/usr/bin/python
import datetime
dtdates = []
for line in open('data','r'):
year,month,day,hour,minute,second = line.split()
second = float(second)
ms = (second-int(second))*1000000
dtdates.append(datetime.datetime(int(year),
int(month),
int(day),
int(hour),
int(minute),
int(second),
int(ms)))
- Incidentally, you can do the above with datetime.datetime.strptime too, but I did it this way so there'd be less "magic" for you to have to read about. -- Finlay McWalterჷTalk 23:19, 18 June 2012 (UTC)
- Which would make the entire loop body read:
dtdates.append(datetime.datetime.strptime(line.strip(), "%Y %m %d %H %M %S.%f"))
- If you have lines that don't perfectly match the format you specified, both versions will probably barf, the latter less intelligibly. -- Finlay McWalterჷTalk 23:28, 18 June 2012 (UTC)
Thanks for being prompt but I just realized two things. First the text file has more columns on the right (a total of like 14 but I only need the first six for time) so I suspect the line split thing may not work. Second, I need to read in all columns (because I need them for more processing later) so now instead of reading the time from the text file and datetiming it, I do the following
mydata = numpy.loadtxt('myfile.txt',delimiter=' ') time = mydata[:,0:6]
I think "time" would be an array of arrays? So now the question is, how to go from this above define "time" variable to "dtdates" defined way above? And lastly, is appending the only way to do it? Seems like there should be a faster more efficient approach? If I am reading the entire file, I can know its length so can't I preallocate an array with enough space to hold all the datetime objects and then fill them in? I just don't know the commands to do all this nicely. Thanks again! - Looking for Wisdom and Insight! (talk) 23:44, 18 June 2012 (UTC)
- split returns a tuple containing however many values it has found (unless you tell it to split fewer); so give it more values to fill - if there are variable numbers of possible fields, you'll need to do some extra work based on the length of the tuple. Your program is IO bound, so worrying about arrays and preallocation (in whatever language you were using) is pointless. -- Finlay McWalterჷTalk 00:04, 19 June 2012 (UTC)
- Is it I/O bound? Assuming 100 bytes per line, a raw read rate of 60 MB/s, and a 3 GHz CPU core, that's 5000 CPU cycles per line. A very quick test suggests that the call to
strptime
alone takes several times longer than that. Also, the input file might be cached in RAM. -- BenRG (talk) 17:39, 19 June 2012 (UTC)
- Is it I/O bound? Assuming 100 bytes per line, a raw read rate of 60 MB/s, and a 3 GHz CPU core, that's 5000 CPU cycles per line. A very quick test suggests that the call to
Oh and looking at the second edit, I would actually prefer the condensed version. So can we modify this condensed version to accomodate the changes I described above? It will be much much faster (I know this from past experience in other languages...classic debate for compiled versus interpretative languages). - Looking for Wisdom and Insight! (talk) 23:47, 18 June 2012 (UTC)
- Don't optimise the performance of a program you haven't got running yet. Neither version works the way its superficial representation might suggest. Premature optimisation is a pointless waste of time. -- Finlay McWalterჷTalk 00:04, 19 June 2012 (UTC)
- For the original problem without the extra columns you could write
with open('data', 'r') as f:
dtdates = [datetime.datetime.strptime(line.strip(), "%Y %m %d %H %M %S.%f")
for line in f]
- However, I would be amazed if this ran measurably faster. The bottleneck here is
strptime
(or maybe I/O, but see above).
- For your problem you can try
dtdates, other_fields = [], []
with open('data', 'r') as f:
for line in f:
year, month, day, hour, minute, second, remainder_of_line = line.split(None, 6)
other_fields.append(remainder_of_line)
# make a datetime object and append it to dtdates, as above
- The second argument to
split
should match the number of commas on the left hand side. Or maybe this:
with open('data', 'r') as f:
for line in f:
col1to6, col7, col8, ..., col14 = line.rsplit(None, 8)
dtdates.append(datetime.datetime.strptime(col1to6.lstrip(), "%Y %m %d %H %M %S.%f"))
# do whatever with the remaining columns
- You might want to benchmark
strptime
against manualdatetime
construction. -- BenRG (talk) 17:39, 19 June 2012 (UTC)
Actually it isn't as bad as I thought. I got it working. Thanks again! - Looking for Wisdom and Insight! (talk) 18:25, 19 June 2012 (UTC)