Search Results

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

Page 136/199 | < Previous Page | 132 133 134 135 136 137 138 139 140 141 142 143  | Next Page >

  • Python list comprehension overriding value

    - by Joschua
    Hi, folks have a look at the following piece of code, which shows a list comprehension.. >>> i = 6 >>> s = [i * i for i in range(100)] >>> print(i) When you execute the code example in Python 2.6 it prints 99, but when you execute it in Python 3.x it prints 6. What were the reason for changing the behaviour and why is the output 6 in Python 3.x? Thank you in advance!

    Read the article

  • T-SQL Operations on a Calculated Date Field

    - by firedrawndagger
    Can I do WHERE operations on a calculated date field? I have a lookup field, which has been written badly in SQL and unfortunately I can't change it. But basically it stores dates as characters such as "July-2010" or "June-2009" (along with other non date data). I want to extract the dates first (which I did using a LIKE opertor) and then extract data based on a date range. SELECT BusinessUnit, Lookup, ReleaseDate FROM ( SELECT TOP 10 LookupColumn As Lookup, BU as BusinessUnit, CONVERT(DATETIME, REPLACE(LookupColumn,'-',' ')) as ReleaseDate FROM [dbo].[LookupTable] WHERE LookupColumn LIKE N'%-2010' ) MyTable ORDER BY ReleaseDate WHERE ReleaseDate = '2010-02-01' I'm having issues with WHERE operator. I would assume creating a subquery to encapsulate the calculated field would allow me to do operations with it such as WHERE but maybe I'm wrong. Bottom line is it possible to do operations on calculated fields?

    Read the article

  • What's wrong with this addProximity code?

    - by Pentium10
    I have this code: private void setupProximity() { Intent intent = new Intent(this, viewContacts.class); PendingIntent sender = PendingIntent.getBroadcast(this, 0, intent, 0); LocationUtils.addProximity(this, -37.40, 144.55, 1000, 1000000, sender); } public static void addProximity(Context ctx,double lat, double lon, float rad,long exp, PendingIntent pintent) { LocationManager lm = (LocationManager) ctx.getSystemService(Context.LOCATION_SERVICE); lm.addProximityAlert(lat, lon, rad, exp, pintent); } Why I don't get the class to fire up? I am in the range of the zone.

    Read the article

  • How can this code be made more Pythonic?

    - by usethedeathstar
    This next part of code does exactly what I want it to do. dem_rows and dem_cols contain float values for a number of things i can identify in an image, but i need to get the nearest pixel for each of them, and than to make sure I only get the unique points, and no duplicates. The problem is that this code is ugly and as far as I get it, as unpythonic as it gets. If there would be a pure-numpy-solution (without for-loops) that would be even better. # next part is to make sure that we get the rounding done correctly, and than to get the integer part out of it # without the annoying floatingpoint-error, and without duplicates fielddic={} for i in range(len(dem_rows)): # here comes the ugly part: abusing the fact that i overwrite dictionary keys if I get duplicates fielddic[int(round(dem_rows[i]) + 0.1), int(round(dem_cols[i]) + 0.1)] = None # also very ugly: to make two arrays of integers out of the first and second part of the keys field_rows = numpy.zeros((len(fielddic.keys())), int) field_cols = numpy.zeros((len(fielddic.keys())), int) for i, (r, c) in enumerate(fielddic.keys()): field_rows[i] = r field_cols[i] = c

    Read the article

  • A faster alternative to Pandas `isin` function

    - by user3576212
    I have a very large data frame df that looks like: ID Value1 Value2 1345 3.2 332 1355 2.2 32 2346 1.0 11 3456 8.9 322 And I have a list that contains a subset of IDs ID_list. I need to have a subset of df for the ID contained in ID_list. Currently, I am using df_sub=df[df.ID.isin(ID_list)] to do it. But it takes a lot time. IDs contained in ID_list doesn't have any pattern, so it's not within certain range. (And I need to apply the same operation to many similar dataframes. I was wondering if there is any faster way to do this. Will it help a lot if make ID as the index? Thanks!

    Read the article

  • Store previous search criteria using ASP.NET

    - by thatuxguy
    I have created a web application which returns a list of products. On this page it allows users to search for a range of different search criteria. Once a user searches and the results are returned to the table on the page a user can then edit a product. However upon returning to the product listing page the page just reloads, and shows all products again. I would like to know what the best way would be to keep the search results, and upon returning to the search page it keeps the previous criteria. I have found a few posts on stack exchange - Best way to store previous search criteria in ASP.NET - is probaly one of the better ones. Does any one know how i could go about keeping the search criteria, so when a user returns to the search page, the previous search criteria and results stay the same. Many thanks.

    Read the article

  • Linked lists in Java - Help with writing methods

    - by user368241
    Representation of a string in linked lists In every intersection in the list there will be 3 fields : The letter itself. The number of times it appears consecutively. A pointer to the next intersection in the list. The following class CharNode represents a intersection in the list : public class CharNode { private char _data; private int _value; private charNode _next; public CharNode (char c, int val, charNode n) { _data = c; _value = val; _next = n; } public charNode getNext() { return _next; } public void setNext (charNode node) { _next = node; } public int getValue() { return _value; } public void setValue (int v) { value = v; } public char getData() { return _data; } public void setData (char c) { _data = c; } } The class StringList represents the whole list : public class StringList { private charNode _head; public StringList() { _head = null; } public StringList (CharNode node) { _head = node; } } Add methods to the class StringList according to the details : (I will add methods gradually according to my specific questions) (Pay attention, these are methods from the class String and we want to fulfill them by the representation of a string by a list as explained above) Pay attention to all the possible error cases. Write what is the time complexity and space complexity of every method that you wrote. Make sure the methods you wrote are effective. It is NOT allowed to use ready classes of Java. It is NOT allowed to move to string and use string operations. 1) public int indexOf (int ch) - returns the index in the string it is operated on of the first appeareance of the char "ch". If the char "ch" doesn't appear in the string, returns -1. If the value of fromIndex isn't in the range, returns -1. Here is my try : public int indexOf (int ch) { int count = 0; charNode pos = _head; if (pos == null ) { return -1; } for (pos = _head; pos!=null && pos.getData()!=ch; pos = pos.getNext()) { count = count + pos.getValue(); } if (pos==null) return -1; return count; } Time complexity = O(N) Space complexity = O(1) EDIT : I have a problem. I tested it in BlueJ and if the char ch doesn't appear it returns -1 but if it does, it always returns 0 and I don't understand why... I am confused. How can the compiler know that the value is the number of times the letter appears consecutively? Can I assume this because its given on the question or what? If it's true and I can assume this, then my code should be correct right? Ok I just spoke with my instructor and she said it isn't required to write it in the exercise but in order for me to test that it indeed works, I need to open a new class and write a code for making a list so that the the value of every node is the number of times the letter appears consecutively. Can someone please assist me? So I will copy+paste to BlueJ and this way I will be able to test all the methods. Meanwhile I am moving on to the next methods. 2) public int indexOf (int ch, int fromIndex) - returns the index in the string it is operated on of the first appeareance of the char "ch", as the search begins in the index "fromIndex". If the char "ch" doesn't appear in the string, returns -1. If the value of fromIndex doesn't appear in the range, returns -1. Here is my try: public int indexOf (int ch, int fromIndex) { int count = 0, len=0, i; charNode pos = _head; CharNode cur = _head; for (pos = _head; pos!=null; pos = pos.getNext()) { len = len+1; } if (fromIndex<0 || fromIndex>=len) return -1; for (i=0; i<fromIndex; i++) { cur = cur.getNext(); } if (cur == null ) { return -1; } for (cur = _head; cur!=null && cur.getData()!=ch; cur = cur.getNext()) { count = count + cur.getValue(); } if (cur==null) return -1; return count; } Time complexity = O(N) ? Space complexity = O(1) 3) public StringList concat (String str) - returns a string that consists of the string that it is operated on and in its end the string "str" is concatenated. Here is my try : public StringList concat (String str) { String str = ""; charNode pos = _head; if (str == null) return -1; for (pos = _head; pos!=null; pos = pos.getNext()) { str = str + pos.getData(); } str = str + "str"; return str; } Time complexity = O(N) Space complexity = O(1)

    Read the article

  • Infor PM (Business Intelligence solution)

    - by Andrew
    We are currently implementing the commercial Infor PM (Performance Management) package as a business intelligence tool. Infor PM website It is apparently used by over 1,000 companies around the world, but I have found scant information about it on the net except for what's on their own website. It covers the whole range of data warehousing and BI functions with: an OLAP environment an ETL tool a report writer (called Application Studio) an add-on to Excel to connect to the data in the cubes through a pivot table etc Does anyone have any experience with using this package? How does it compare to the big players in BI (Cognos, Microsoft SSAS, Business Objects, etc). Any pitfalls I should know about? On the other hand, does it do anything better than its competitors?

    Read the article

  • Permutations in python 2.5.2

    - by flpgdt
    Hi, I have a list of numbers for input, e.g. 671.00 1,636.00 436.00 9,224.00 and I want to generate all possible sums with a way to id it for output, e.g.: 671.00 + 1,636.00 = 2,307.00 671.00 + 436.00 = 1,107.00 671.00 + 9,224.00 = 9,224.00 671.00 + 1,636.00 + 436.00 = 2,743.00 ... and I would like to do it in Python My current constrains are: a) I'm just learning python now (that's part of the idea) b) I will have to use Python 2.5.2 (no intertools) I think I have found a piece of code that may help: def all_perms(str): if len(str) <=1: yield str else: for perm in all_perms(str[1:]): for i in range(len(perm)+1): #nb str[0:1] works in both string and list contexts yield perm[:i] + str[0:1] + perm[i:] ( from these guys ) But I'm not sure how to use it in my propose. Could someone trow some tips and pieces of code of help? cheers, f.

    Read the article

  • Efficient way to combine results of two database queries.

    - by ensnare
    I have two tables on different servers, and I'd like some help finding an efficient way to combine and match the datasets. Here's an example: From server 1, which holds our stories, I perform a query like: query = """SELECT author_id, title, text FROM stories ORDER BY timestamp_created DESC LIMIT 10 """ results = DB.getAll(query) for i in range(len(results)): #Build a string of author_ids, e.g. '1314,4134,2624,2342' But, I'd like to fetch some info about each author_id from server 2: query = """SELECT id, avatar_url FROM members WHERE id IN (%s) """ values = (uid_list) results = DB.getAll(query, values) Now I need some way to combine these two queries so I have a dict that has the story as well as avatar_url and member_id. If this data were on one server, it would be a simple join that would look like: SELECT * FROM members, stories WHERE members.id = stories.author_id But since we store the data on multiple servers, this is not possible. What is the most efficient way to do this? Thanks.

    Read the article

  • Microphone input

    - by George
    I'm trying to build a gadget that detects pistol shots using Android. It's a part of a training aid for pistol shooters that tells how the shots are distributed in time and I use a HTC Tattoo for testing. I use the MediaRecorder and its getMaxAmplitude method to get the highest amplitude during the last 1/100 s but it does not work as expected; speech gives me values from getMaxAmplitude in the range from 0 to about 25000 while the pistol shots (or shouting!) only reaches about 15000. With a sampling frequency of 8kHz there should be some samples with considerably high level. Anyone who knows how these things work? Are there filters that are applied before registering the max amplitude. If so, is it hardware or software? Thanks, /George

    Read the article

  • Insert objects into a collection with LINQ based on a property of the existing objects in the collection

    - by DavidS
    Hi, I've got a collection of object which contains data as follows: FromTime Duration 2010-12-28 24.0000 2010-12-29 24.0000 2010-12-30 24.0000 2010-12-31 22.0000 2011-01-02 1.9167 2011-01-03 24.0000 2011-01-04 24.0000 2011-01-05 24.0000 2011-01-06 24.0000 2011-01-07 22.0000 2011-01-09 1.9167 2011-01-10 24.0000 In the "FromTime" column, there are data "gaps" i.e. 2011-01-01 and 2011-01-08 are "missing". So what I'd like to do is to loop through a range of dates (in this instance 2010-12-28 to 2011-01-10) and "fill in" the "missing" data with a duration of 0. As I've just started with LINQ, I feel that it should be "fairly" easy but I can't quite get it right. I'm reading the book "LINQ in Action" but feel that I'm still quite a way off before I can resolve this particular issue. So any help would be much appreciated. David

    Read the article

  • Online Game programming in Google App Engine: AI

    - by Hortinstein
    I am currently in the planning stages of a game for google app engine, but cannot wrap my head around how I am going to handle AI. I intend to have persistant NPCs that will move about the map, but short of writing a program that generates the same XML requests I use to control player actions, than run it on another server I am stuck on how to do it. I have looked at the Task Queue feature, but due to long running processes not being an option on the App engine, I am a little stuck. I intend to run multiple server instances with 200+ persistant NPC entities that I will need to update. Most action is slowly roaming around based on player movements/concentrations, and attacking close range players(you can probably guess the type of game im developing)

    Read the article

  • Validate decimal number in (known) national format

    - by Álvaro G. Vicario
    PHP has many built-in functions to validate numbers but they all expect input in computer format: 1234.56. I need to validate stuff like 1,234.56 (English) or 1.234,56 (Spanish), together with some typical attributes (accepted range, max number of decimals, etc.). I started writing my own function but I soon got lost. It's easy to read the user input into a float variable but I want to be able to detect numbers with invalid formats like 1,23456.7 or 1..25. Do you have any recommendation on the subject? (Decimal and thousand characters are known beforehand and it's okay to hard-code digit groups as three, there's no need to cover Indian number format.)

    Read the article

  • change available checkboxes after select[html] changed - Zend Framework

    - by Lormitto
    Hi, Could you please help me rosolve my troubling matter. I used Zend_Form to create what I needed. However as I have relations many to many i decided to present multiple choices via checkboxes. Unfortunately range of these checkboxes depends on select field available in form. I would like to change visible/availabe checkboxes depending on select option choosen. I found that it should be possible to use javascript however I've got no idea how to take advantege of it in form based on Zend_Form. Could you suggest possible solution? Thank you in advance. Kind Regards,

    Read the article

  • how to draw a Bitmap to a Canvas with a variable alpha

    - by steelbytes
    Hi, I'm trying to draw a Bitmap to a Canvas with a variable amount of alpha. But I only get nothing (when alpha<255) or the 'full' bitmap (when alpha==255). Have also tried loading as a Drawable, and using drawable.setAlpha, but that gave the same result. my init BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inScaled = false; opts.inSampleSize = 1; Bitmap img = BitmapFactory.decodeResource(getResources(),R.drawable.sample,opts); my onDraw() Paint p = new Paint(Paint.ANTI_ALIAS_FLAG|Paint.FILTER_BITMAP_FLAG); p.setColor((alpha<<24)+0xffffff); // alpha in range 0..255 canvas.drawBitmap(img, null, imgRect, p);

    Read the article

  • Ranged integers in .NET (or C#)

    - by Mal Ross
    Am I being blind, or does the .NET framework not provide any kind of ranged integer class? That is, a type that would prevent you setting a value outside some given bounds that are not the full range of the basic data type. For example, an integer type that would restrict its values to between 1 and 100. Showing my age here, but back in '93, I remember using that sort of thing in Modula-2 (eeek!), but I've not seen explicit framework / language support for it since. Am I just missing something, or is it a case of "it's so simple to make your own that the framework doesn't bother"? Cheers.

    Read the article

  • How to obtain multiple lines in a single density plot, with a corrected scale?

    - by user1677055
    I have recently started working with microarray datasets and am trying to get my hands on R. I wish to make some plots out of my result data, but however I am stuck at the following. I have the following data (myData), cpg samp1 samp2 samp3 cpg1 0.43 0.32 0.21 cpg2 0.43 0.22 1.00 cpg3 0.11 0.99 0.78 cpg4 0.65 0.32 0.12 cpg5 0.11 0.43 0.89 And I wish to obtain a density plot for this, I did the following, plot (density(MyData$samp1), col="red") lines (density(MyData$samp2), col="green") lines (density(MyData$samp3), col="blue") But doing this does not give me correct plots, because not all sample curves fit within the plot limits. I did try looking for answers, but honestly i am still not able to work this out. Can you help me know how do i set my scale for the above? Or what additional should I do to the above code, so that all the curves are in range?? I have got many samples, so i need a something that could also automatically assign a different colour curve for each of my sample, after scaling it right. Thanks in advance..

    Read the article

  • c style thread creation in python

    - by chandank
    Hi I am new to python and want to create multiple threads in a loop something like (in C style) for (;i < 10; i++) thread[i]= pthread_create(&thread[i],&attr,func) I am not sure how to do the same in python? Basically I want have that thread[] variable as global will create all thread at once and then will start then in once. I have written a similar python program that does it but I think having it in above style will be better. def thread_create(thread_number): command_string = "Thread-" + "%d" %thread_number thread = myThread(thread_number, command_string) thread.start() # Start new Threads for i in range(5): thread_create(i)

    Read the article

  • Connecting data to a GUI - OOP

    - by tau
    I have an application with several graphs and tables on it. I worked fast and just made classes like Graph and Table that each contained a request object (pseudo-code): class Graph { private request; public function setDateRange(dateRange) { request.setDateRange(dateRange); } public function refresh() { request.getData(function() { //refresh the display }); } } Upon a GUI event (say, someone changes the date range dropdown), I'd just call the setters on the Graph instance and then refresh it. Well, when I added other GUI elements like tables and whatnot, they all basically had similar methods (setDateRange and other things common to the request). What are some more elegant OOP ways of doing this? The application is very simple and I don't want to over-architect it, but I also don't want to have a bunch of classes with basically the same methods that are just routing to a request object. I also don't want to set up each GUI class as inheriting from the request class, but I'm open to any ideas really.

    Read the article

  • Transponse the data from vertical to horizondal using vba

    - by raam
    I wants to popualte the data in MS-Access into Excel for this i am using VBA This is my code varConnection = "ODBC; DSN=MS Access Database;DBQ=D:\sample\table.accdb; Driver={Driver do Microsoft Access (*.accdb)}" varSQL = "SELECT * FROM LeftPanes" With ActiveSheet.QueryTables.Add(Connection:=varConnection, Destination:=ActiveSheet.Range("B4")) .CommandText = varSQL .Name = "Query-39008" .Refresh BackgroundQuery:=False End With Its working Properly it retrive data and display in the correct sheet my problem is that this code display the retrived date in vertically view i needs horizondal view. it is possible to display in horizondal view please any one guide me . Thanks in advance

    Read the article

  • Floating point innacuracies

    - by Greg
    While writing a function which will perform some operation with each number in a range I ran into some problems with floating point inaccuracies. The problem can be seen in the code below: #include <iostream> using namespace std; int main() { double start = .99999, end = 1.00001, inc = .000001; int steps = (end - start) / inc; for(int i = 0; i <= steps; ++i) { cout << (start + (inc * i)) << endl; } } The problem is that the numbers the above program outputs look like this: 0.99999 0.999991 0.999992 0.999993 0.999994 0.999995 0.999996 0.999997 0.999998 0.999999 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 They only appear to be correct up to the first 1. What is the proper way to solve this problem?

    Read the article

  • Can the below function be improve?(C#3.0)

    - by Newbie
    I have the below function public static List<DateTime> GetOnlyFridays(DateTime endDate, int weeks, bool isIncludeBaseDate) { //Get only the fridays from the date range List<DateTime> dtlist = new List<DateTime>(); List<DateTime> tempDtlist = (from dtFridays in GetDates(endDate, weeks) where dtFridays.DayOfWeek == DayOfWeek.Friday select dtFridays).ToList(); if (isIncludeBaseDate) { dtlist = tempDtlist.Skip(1).ToList(); dtlist.Add(endDate); } else { dtlist = tempDtlist; } return dtlist; } What basically I am doing is getting the datelist using the GetDates function and then depending on the isIncludeBaseDate bool value(if true) skipping the last date and adding the Base Date It is working fine but can this program can be improve? I am using C#3.0 and Framework 3.5 Thanks

    Read the article

  • How do I all the registered users on a day report

    - by Nadal
    I have a table called users where I have two columns: name and created_at. created_at column column is of type datetime and it stores the datetime when this user was created. I need to know the number of users created for a given date range. Let's say I ask give me user report between 1-nov-2010 and 30-nov-2010 . I need something like this 1-nov-2010: 2 2-nov-2010: 5 The problem I am running into is that created_at data has value upto second. How do I check if a created_at date falls within a given date. Any help in solving this problem is appreciated. I am using mysql5.

    Read the article

  • R.matlab/readMat : Error in readTag(this)

    - by Megan
    I am trying to read a matlab file into R using R.matlab but am encountering this error: require(R.matlab) r <- readMat("file.mat", verbose=T) Trying to read MAT v5 file stream... Error in readTag(this) : Unknown data type. Not in range [1,19]: 18569 In addition: Warning message: In readMat5Header(this, firstFourBytes = firstFourBytes) : Unknown MAT version tag: 512. Will assume version 5. How can this issue be solved or is there an alternative way to load matlab files? I can use hdf5load but have heard this can mess with the data. Thanks!

    Read the article

< Previous Page | 132 133 134 135 136 137 138 139 140 141 142 143  | Next Page >