back soft

مطالب مرتبط با «python list of functions» در back soft | نویسنده: استخدام کار

Python list of lists filled with duplicate rows after writing each entry

Vote count: 0 I am iterating over each entry of a list of lists and filling it with some unique number but the final list of lists contains identical rows. Here's a MWE: x = [1,2,3,4] y = [3,6,9,12] Here I set up a list of lists filled with zeros. m = [[0]*len(x)]*len(y) And I print it to make sure it looks right. [print(i) for i in m] Now I iterate through each row and again through each item in the row and put the result of some calculation in each spot. for i,ii in enumerate(y): for j,jj in e...

ادامه مطلب

For two lists, l1 and l2, how to check that for all e1 ∈ l1, ∃p(e1,e2) where e2 is some element in l2, efficiently in python?

Vote count: 0 Ok, not sure if that was the best title, but I have two python lists. L1 and L2 which both have elements of type T and do not have the same length. I have a function p(T,T) which is a predicate checking a property about two elements of type T. I would like to check that for all elements e in L1, p(e,e') holds, where e' is SOME element in L2. so basically for each element in L1 I go over the second list, and check if the predicate holds for any of the elements. But I also want to ch...

ادامه مطلب

wxPython: ListBox not selectable/clickable when used with ComboCtrl

Vote count: 0 I am trying to couple wx.ListBox with wx.combo.Comboctrl. A sample code is below. For some reason, the items in the ListBox are not clickable/selectable. I wonder how I can make it work. Thanks! import wx, wx.combo class MainFrame(wx.Frame): def __init__(self, parent): wx.Frame.__init__(self, parent, title="", size=(300, 100)) gbs = wx.GridBagSizer() ComboCtrlBox = wx.combo.ComboCtrl(self) ComboCtrlPopup = ListBoxComboPopup() ComboCtrlBox.SetPopupControl(ComboCtrlPopup) ComboCtrlPo...

ادامه مطلب

Android - Passing an ArrayList of Custom Objects to Another Activity

Vote count: 0 So, I've been struggling on this for a while and have searched on here for hours without finding anything that really helped. I have a custom class Streak. When the user creates a new Streak in my Main Activity, I want for that streak to be added to a list of total streaks, which I would then access from an AllStreaks activity. I have tried using Gson, but received errors. What I have below is working for the time being, but since my global variable has to be declared as new. I don...

ادامه مطلب

Why the mmap of Python is much slower than C++'s?

Vote count: 0 C++ code: #include #include #include #include #include using namespace std; #define FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) int main() { timeval tv1, tv2, tv3, tve; gettimeofday(&tv1, 0); int size = 0x1000000; int fd = open("data", O_RDWR | O_CREAT | O_TRUNC, FILE_MODE); ftruncate(fd, size); char *data = (char *) mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); for(int i = 0; i < size; i++) { data[i] = 'S'; } munmap(data, size); close(fd); gettimeofday(&tv2, 0); ...

ادامه مطلب

How to get the Average of a specific category via Python

Vote count: 0 I was wondering how I could calculate the average of a specific category via Python? I have a csv file called demo.csv import pandas as pd import numpy as np #loading the data into data frame X = pd.read_csv('demo.csv') the two columns of interest are the "Category" and "Totals" column: Category Totals estimates 2 2777 0.43 4 1003 0.26 4 3473 0.65 4 2638 0.17 1 2855 0.74 0 2196 0.13 0 2630 0.91 2 2714 0.39 3 2472 0.51 0 1090 0.12 I'm interested in finding the average for the Totals...

ادامه مطلب

Shape of numpy array comparison with empty list

Vote count: 0 I have some problems understanding how python/numpy is casting array shapes when comparing to an empty list - which as far as I understand - is an implicit (element wise) comparison with False. In the following example the shape decreases by one in the last dimension, if it is not greater than 1. z = N.zeros((2,2,1)) z == [] >> array([], shape=(2, 2, 0), dtype=bool) z2 = N.zeros((2,2,2)) z2 ==[] >> False If, however, I compare with False directly, I get the expected output. z = N.z...

ادامه مطلب

ec2-describe-images how to list the creation date of ami for all the AMI's created by specific owner

Vote count: 0 I am using AWS CLI to get the list of AMI's created by specific owner however I want to get the creation date of the AMI along with the size of the AMI The command I am using is below. ec2-describe-images --filter "is-public=false" --filter "architecture=x86_64" --filter "owner-id=xxxxxxx" Please guide me. asked 23 secs agoNarendra522 Let's block ads!...

ادامه مطلب

Python - Having user sort list smallest to biggest

Vote count: 0 So I'm making a code where it asks the user to to swap two places on the list until the list is from smallest to biggest. So it should look like this: Hello: Your current list is [6, 7, 8, 2 , 9, 10, 12, 15, 16, 17] Please pick your first location -> 4 Please pick your second location -> 2 Your new list is [6, 2, 8, 7 , 9, 10, 12, 15, 16, 17] I've gotten to this part but I am currently unable to figure out how to get the USER to do the sorting and not the code. Your list is not sor...

ادامه مطلب

Python combine 2 lists of strings for CSV

Vote count: 0 I have two lists that I want to combine for csv output. alist = ['a', 'b', 'c'] blist = ['d', 'e', 'f'] However, I want the output for the csv to format like this: clist = ['a', 'b', 'c', 'd' 'e' 'f'] such that the last entry extended of the list contains the list of "blist", but will not be comma separated. Unfortunately, what I have been trying instead gives me: clist = ['a', 'b', 'c', 'def'] asked 1 min agoArca Let's block ads!...

ادامه مطلب

Need an excel macro that which can select data from drop down list and copy the contents of the entire sheet into a new work book

Vote count: 0 I have a dashboard which contains many formulas that change depending on the value on the drop down list. Is there any macro which can run a loop for all the values in the drop down list, copy the contents of the entire sheet and paste it into a new workbook? asked 31 secs agoadithya viswanathan Let's block ads!...

ادامه مطلب

Generate different totals of an image using a checkboxlist and user input

Vote count: 0 I have a barcode generator that takes information stored in a database and generates a barcode from a databound checkboxlist selection. There are different check boxes, the user checks the boxes of the items they want and enter a universal total. protected void btnGenerate_Click(object sender, EventArgs e) { int n; int i = Int32.Parse(BatchNumText.Text); for (n = 1; n...

ادامه مطلب

In C#, Rotate a List to The Right by the specified numbers of places without using LINQ?

Vote count: 0 I am trying to rotate a List of items to the right by the specified numbers of places without using LINQ, how am I able to do this? I think I am not understanding how to approach/solve this problem in particular. Here's what I have tried so far. public void Test(List items, int places) { items.RemoveAt(places); items.Add(places); } asked 1 min agoZerox Let's block ads!...

ادامه مطلب

Generate a vector of functions

Vote count: 0 I have a function of a single variable, and various parameters. For each value of one of the parameters (the others are fixed) there is a single root of the function. From a vector of the parameter I would like to generate a vector of the roots (using uniroot). The actual example I'm working on is a bit messy, but I'll give it. Here are the fixed parameters: eta_inf = -0.0139 eta_0 = 178.5 lambda = 2.4954 m = 0.83094 Here is the function: crossFnc...

ادامه مطلب

I have a column of functions in an excel workbook that i want to be executed after a minute. How can i do this?

Vote count: 0 In my excel file, I have a column with about 100 functions that run continuously. I want to time them to run once every minute or so, and then save the file. Can someone please help me out with this? asked 27 secs agoEdmond Let's block ads!...

ادامه مطلب

How to create a list of record to mongoDb using expressJs

Vote count: 0 I want to create a array of object to mongoDb using expressJs (restful API ) . I have a array like this : [ { name: 'java', _id: 578c81ea7d5940501419e819, articles: [] }, { name: 'C#', _id: 578c81ea7d5940501419e81a, articles: [] }, { name: 'C++', _id: 578c81ea7d5940501419e81b, articles: [] }, { name: 'cloud', _id: 578c81ea7d5940501419e81c, articles: [] } ] How can I insert this array to mongoDB by only one function ? thanks for any help . asked just nowTrần Dương Let's block ads!...

ادامه مطلب

Python List of Strings to Tuple Paris

Vote count: 0 I am having some difficulty coming up with an efficient way of taking a list of strings and converting it to tuple pairs. I have a list similar to: listOfNames = ['red-l','blue-l','green-s','red-s','blue-s'] Every color in this example (red, blue, and green) has either a '-l' or '-s' entry or both. I need to convert this list of strings into tuple pairs such as: tupleOfNames = [('red-l','red-s'),(None,'green-s'),('blue-l','blue-s')] I think regular expressions is needed but I am no...

ادامه مطلب

python import of GdkPixBuf says "introspection typelib not found"

Vote count: 0 I have some imports : gi.require_version('Gtk', '3.0') from gi.repository import Gtk from gi.repository import Gdk, GdkPixBuf An error (maybe 2) is raised : WAING **: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files Traceback (most recent call last): File "", line 2158, in _find_spec AttributeError: 'DynamicImporter' object has no attribute 'find_spec' During handling of the above exc...

ادامه مطلب

Get value in list on python

Vote count: 0 See the code mult = [lambda x, i=i:x*i for i in range(4)] for v in mult: print(v) But my retu value is: can i get a real value? asked 42 secs agoGuilherme Almeida Let's block ads!...

ادامه مطلب

scrapy python code to list urls not appears to work as hoped

Vote count: 0 I am trying to write some code to scrap the website of a UK housebuilder to record a list of houses for sale. I am starting on the page http://www.persimmonhomes.com/sitemap and I have written one part of the code to list all the urls of the housebuilder developments and then the second part of the code to scrap from each of the urls to record prices etc. I know the second part works and I know that the first part lists out all the urls. But for some reason the urls listed by the f...

ادامه مطلب