Search Results

Search found 4955 results on 199 pages for 'range'.

Page 84/199 | < Previous Page | 80 81 82 83 84 85 86 87 88 89 90 91  | Next Page >

  • Use string as input to re.compile

    - by williamx
    I want to use a variable in a regex, like this: variables = ['variableA','variableB'] for i in range(len(variables)): regex = r"'('+variables[i]+')[:|=|\(](-?\d+(?:\.\d+)?)(?:\))?'" pattern_variable = re.compile(regex) match = re.search(pattern_variable, line) The problem is that python adds an extra backslash character for each backslash character in my regex string (ipython), and makes my regex invalid: In [76]: regex Out[76]: "'('+variables[i]+')[:|=|\\(](-?\\d+(?:\\.\\d+)?)(?:\\))?'" Any tips on how I can avoid this?

    Read the article

  • UISlider increments

    - by Stan Note
    Hi all, I have a UISlider that slides with a range from 0.0 to 1.0. Out of the box, the slider lets users slide with a really high number of fraction digits, but I only want my users to be able to increment/decrement by .001 for each "tick" up or down of the slider. Is this possible to set up? Thank you!

    Read the article

  • TVirtualStringTree - resetting non-visual nodes and memory comsumption

    - by Remy Lebeau - TeamB
    I have an app that loads records from a binary log file and displays them in a virtual TListView. There are potentially millions of records in a file, and the display can be filtered by the user, so I do not load all of the records in memory at one time, and the ListView item indexes are not a 1-to-1 relation with the file record offsets (List item 1 may be file record 100, for instance). I use the ListView's OnDataHint event to load records for just the items the ListView is actually interested in. As the user scrolls around, the range specified by OnDataHint changes, allowing me to free records that are not in the new range, and allocate new records as needed. This works fine, speed is tolerable, and the memory footprint is very low. I am currently evaluating TVirtualStringTree as a replacement for the TListView, mainly because I want to add the ability to expand/collapse records that span multiple lines (I can fudge it with the TListView by incrementing/decrementing the item count dynamically, but this is not as straight forward as using a real tree). For the most part, I have been able to port the TListView logic and have everything work as I need. I notice that TVirtualStringTree's virtual paridigm is vastly different, though. It does not have the same kind of OnDataHint functionality that TListView does (I can use the OnScroll event to fake it, which allows my memory buffer logic to continue working), and I can use the OnInitializeNode event to associate nodes with records that are allocated. However, once a tree node is initialized, it sees that it remains initialized for the lifetime of the tree. That is not good for me. As the user scrolls around and I remove records from memory, I need to reset those non-visual nodes without removing them from the tree completely, or losing their expand/collapse states. When the user scrolls them back into view, I can re-allocate the records and re-initialize the nodes. Basically, I want to make TVirtualStringTree act as much like TListView as possible, as far as its virtualization is concerned. I have seen that TVirtualStringTree has a ResetNode() method, but I encounter various errors whenever I try to use it. I must be using it wrong. I also thought of just storing a data pointer inside each node to my record buffers, and I allocate and free memory, update those pointers accordingly. The end effect does not work so well, either. Worse, my largest test log file has ~5 million records in it. If I initialize the TVirtualStringTree with that many nodes at one time (when the log display is unfiltered), the tree's internal overhead for its nodes takes up a whopping 260MB of memory (without any records being allocated yet). Whereas with the TListView, loading the same log file and all the memory logic behind it, I can get away with using just a few MBs. Any ideas?

    Read the article

  • Cell value is read as #### in excel

    - by Sathish
    I am reading a cell value from excel using named range in my case sometime the column width is smaller then the value that is present in the cell and hence it is appearing as ##### when it is huge number. when i read this from csharp it is reading as #####. Any fix for this

    Read the article

  • Miller-rabin exception number?

    - by nightcracker
    Hey everyone. This question is about the number 169716931325235658326303. According to http://www.alpertron.com.ar/ECM.HTM it is prime. According to my miller-rabin implementation in python with 7 repetitions is is composite. With 50 repetitions it is still composite. With 5000 repetitions it is STILL composite. I thought, this might be a problem of my implementation. So I tried GNU MP bignum library, which has a miller-rabin primality test built-in. I tested with 1000000 repetitions. Still composite. This is my implementation of the miller-rabin primality test: def isprime(n, precision=7): if n == 1 or n % 2 == 0: return False elif n < 1: raise ValueError("Out of bounds, first argument must be > 0") d = n - 1 s = 0 while d % 2 == 0: d //= 2 s += 1 for repeat in range(precision): a = random.randrange(2, n - 2) x = pow(a, d, n) if x == 1 or x == n - 1: continue for r in range(s - 1): x = pow(x, 2, n) if x == 1: return False if x == n - 1: break else: return False return True And the code for the GMP test: #include <gmp.h> #include <stdio.h> int main(int argc, char* argv[]) { mpz_t test; mpz_init_set_str(test, "169716931325235658326303", 10); printf("%d\n", mpz_probab_prime_p(test, 1000000)); mpz_clear(test); return 0; } As far as I know there are no "exceptions" (which return false positives for any amount of repetitions) to the miller-rabin primality test. Have I stumpled upon one? Is my computer broken? Is the Elliptic Curve Method wrong? What is happening here? EDIT I found the issue, which is http://www.alpertron.com.ar/ECM.HTM. I trusted this applet, I'll contact the author his applet's implementation of the ECM is faulty for this number. Thanks. EDIT2 Hah, the shame! In the end it was something that went wrong with copy/pasting on my side. NOR the applet NOR the miller-rabin algorithm NOR my implementation NOR gmp's implementation of it is wrong, the only thing that's wrong is me. I'm sorry.

    Read the article

  • Python learner needs help spotting an error

    - by Protean
    This piece of code gives a syntax error at the colon of "elif process.loop(i, len(list_i) != 'repeat':" and I can't seem to figure out why. class process: def loop(v1, v2): if v1 < v2 - 1: return 'repeat' def isel(chr_i, list_i): for i in range(len(list_i)): if chr_i == list_i[i]: return list_i[i] elif process.loop(i, len(list_i) != 'repeat': return 'error'()

    Read the article

  • How to parse IP addresses with perl?

    - by Andrey Zentavr
    Hello! I have list of IPs: 238.51.208.96/28 238.51.209.180-199 238.51.209.100-109 238.51.213.2-254 ... How can I easily parse them? I need first and last IP from range. For First line I can use Net::Netmask CPAN module, but what can I do with others lines?

    Read the article

  • How to pass parameters to stored procedure ?

    - by Kumara
    I used SQL Server 2005 for my small web application. I Want pass parameters to SP . But there is one condition. number of parameter that can be change time to time. Think ,this time i pass neme and Address , next time i pass name,sirname,address , this parameter range may be 1-30 , Please send any answer if you have,Thanks

    Read the article

  • How can I detect short phone numbers in iPhone web views?

    - by Pedro
    G'day All Most Australian phone numbers are 10 digits with the 1st 2 optional if they're a local area code. For those setting... viewer.dataDetectorTypes = UIDataDetectorTypePhoneNumber; on a web view works. We also have a range of 6 digit phone numbers (usually written xxx xxx or xx xxxx) which aren't being detected in my app. Is there a way to detect those phone numbers as well? Cheers & TIA, Pedro :)

    Read the article

  • How to use Linq in Mono?

    - by Jader Dias
    I can't make System.Linq (aka. Linq-to-objects) work. I am running MonoDevelop 2.2.1 in Ubuntu 10 Lucid Lynx with Mono 2.4.4. They advertise in their site that they implemented Linq, but I can't even find Enumerable.Range or .ToArray(). What's wrong?

    Read the article

  • .Net Memory limit

    - by Prashant
    I have a .Net application running on a 32 bit box. The application is a windows service. It consistently hovers around 600-800 MB range. Is this a problem. If an application crosses 1 GB, is it a memory issue ?

    Read the article

  • List to CSV in Python

    - by Steve
    Hi, I am creating a CSV from a list of values. CSV File gets created but the csv is formed as a single column. Actually it should be multiple rows with multiple columns, instead it forms as a multiple rows with a single column. I am using the following code from random import choice import csv fileObject = csv.writer(open('Insurance.csv','w'),dialect='excel',delimiter=' ') for i in range(0,175): current_list = list(choice(master_list)) fileObject.writerows(current_list) current_list = [] Thanks

    Read the article

  • iPhone web views - detecting short phone numbers

    - by Pedro
    G'day All Most Australian phone numbers are 10 digits with the 1st 2 optional if they're a local area code. For those setting... viewer.dataDetectorTypes = UIDataDetectorTypePhoneNumber; on a web view works. We also have a range of 6 digit phone numbers (usually written xxx xxx or xx xxxx) which aren't being detected in my app. Is there a way to detect those phone numbers as well? Cheers & TIA, Pedro :)

    Read the article

  • random() in python

    - by Arkapravo
    In python the function random() generates a random float uniformly in the semi-open range [0.0, 1.0). In principle can it ever generate 0.0 (i.e. zero) and 1.0 (i.e. unity)? What is the scenario in practicality?

    Read the article

  • Postgre varchar field between

    - by Anton
    I have an addresses table with ZIP code field which has type VARCHAR. I need to select all addresses form this table using ZIP codes range. If I used next code: select * from address where cast(zip as bigint) between 90210 and 90220 I get an error on fields where ZIP code cann't be cast as bigint. How I can resolve this issue?

    Read the article

  • VS2010 Load Testing - Restricting ports

    - by marks-s
    As per the trouble shooting guide for VS2010 Load Testing (http://social.msdn.microsoft.com/Forums/en/vststest/thread/df043823-ffcf-46a4-9e47-1c4b8854ca13), I'm trying to restrict the range of ports used for client-controller communication. HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\VisualStudio\10.0\EnterpriseTools\QualityTools\ListenPortRange\PortRangeStart HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\VisualStudio\10.0\EnterpriseTools\QualityTools\ListenPortRange\PortRangeEnd I've set these keys on the client as described but according to netstat the client is still listening on random ports. The controller is attempting to communicate on the same random ports as the client. Anyone experienced the same?

    Read the article

  • HLSL tex2d sampler seemingly returning incorrect values; why?

    - by BlueNovember
    Hello all, I have code that needs to render regions of my object differently depending on their location. I am trying to use a colour map to define these regions, then get a value (0-14) representing this region by sampling the texture. The problem is when I sample from my colour map, I get collisions. Ie, two regions with different colours in the colourmap get the same value returned from the sampler. I've tried various formats of my colour map. I set the colours for each region to be "5" apart in each case; Indexed colour RGB, RGBA: region 1 will have RGB 5,5,5. region 2 will have RGB 10,10,10 and so on. HSV Greyscale: region 1 will have HSV 0,0,5. region 2 will have HSV 0,0,10 and so on. The tex2D sampler returns a value [0..1]. To get the "region number" I multiply this by 100 and divide by 5, expecting a number [0..20]. (But currently only using 0-14) I am using Shader Model 2 and FX Composer. //Colour map texture gColourmapTexture < string ResourceName = "Globe_Colourmap_Regions_Greyscale.png"; string ResourceType = "2D"; >; sampler2D gColourmapSampler : register(s1) = sampler_state { Texture = <gColourmapTexture>; #if DIRECT3D_VERSION >= 0xa00 Filter = MIN_MAG_MIP_LINEAR; #else /* DIRECT3D_VERSION < 0xa00 */ MinFilter = Linear; MipFilter = Linear; MagFilter = Linear; #endif /* DIRECT3D_VERSION */ AddressU = Clamp; AddressV = Clamp; }; ... //Then later, in a method float region = tex2D(gColourmapSampler,In.UV).x; //at this point I do not think it matters which of xyz components I pick; even in HSV they're all the same for my image. region *= 100; //Now in range [0..100] region /= 5; //Now in range [0..20] float3 levels[21]; //*Code populating "levels" array with what is essentially colour information * levels[1] = ... levels[2] = ... //Chose which level this region has, by looking up its region number float3 Level = levels[region];

    Read the article

  • iPhone SDK - Comparing characters in string

    - by Karl Daniel
    Basically what I'm trying to do is compare 2 strings one from a plist and one from the user's input. I use a while loop to step through each character and compare it and if true then I increase an integer then once the loop has finished I work out the percentage correct / similarity of the plist answer and the user's answer. I seem to be having a problem however as the only return I'm getting is 0. Below is the code I'm using... The code below is all functioning and the question no longer requires answering... Working code... answerLength = boxAnswer.length; //Gets number of characters of first string. plistLength = plistAnswer.length; //Gets number of characters of second string. characterRange = 0; //Sets the variable for which character to look at. charactersCorrect = 0; //Sets the variable of number of matching characters. unichar answerCharacter; //Declares a unichar for the first string. unichar plistCharacter; //Declares a unichar for the second string. while (answerLength > 0 && plistLength > 0) { answerCharacter = [boxAnswer characterAtIndex:characterRange]; //Gets character of first string at the index of the range integer. plistCharacter = [plistAnswer characterAtIndex:characterRange]; //Gets character of second string at the index of the range integer. answerLength--; //Reduces number of characters left to compare. plistLength--; characterRange++; //Increases integer to tell it to look at next character in string. if (answerCharacter == plistCharacter) { //Checks to see if character of first string and character of second string match. charactersCorrect++; //If true increases the number correct. } } //Works out percentage of matching characters out of the total string. totalChar = plistAnswer.length; totalPercentage = (charactersCorrect/totalChar)*100; percentageCorrect.text = [NSString stringWithFormat:@"%i%%",totalPercentage]; Variable Declarations... int answerLength; int plistLength; int characterRange; double totalChar; double charactersCorrect; int totalPercentage;

    Read the article

  • How to kill main thread from sub thread in Jython

    - by JeffGoetz
    I have a script that creates a thread which after 60 seconds (this thread) needs to kill the main thread. I`m not sure what command I can use to kill the main thread. I'm using Jython 2.5.1 and Thread.interrupt_main doesn't work. Here is the code: import threading def exitFunct(): #exit code here t = threading.Timer(60.0, exitFunct) t.start() for i in range(1, 3000): print i

    Read the article

< Previous Page | 80 81 82 83 84 85 86 87 88 89 90 91  | Next Page >