search

Algorithm: Polygon max element in O(log n)

Algorithm: Polygon max element in O(log n) Question: I want to find the vertice in convex polygon, which has the greatest x axis value. The polygon is convex and random. Its vertices are represented in array as tuples: (x,y). The vertices from cartesian coordinate system to array are ordered in counterclockwise order. The most left …

Total answers: 1

Search and replace is adding not replacing

Search and replace is adding not replacing Question: I am trying to find this string in a file: /home/pi/dew-heater/get-temp.py And replace it with #/home/pi/dew-heater/get-temp.py But there are cases where it already reads #/home/pi/dew-heater/get-temp.py. So my program is replacing it with a double ## so it looks like this: ##/home/pi/dew-heater/get-temp.py How can I prevent the double …

Total answers: 1

Web Search Automation with Python/Selenium

Web Search Automation with Python/Selenium Question: I’m trying to access a search box on a website and I keep getting a ‘not JSON serializable’ error. Not quite sure what I am doing wrong should be pretty simple, can anyone spot the issue, is it because I haven’t set a specific file path for ‘webdriver.Chrome()’ or …

Total answers: 1

Fastest Algorithm/Software for MST and Searching on Large Sparse Graphs

Fastest Algorithm/Software for MST and Searching on Large Sparse Graphs Question: I’ve developed a graph clustering model for assigning destinations to vehicle routes, but my implementation is very slow. It takes about two days to process a graph with 400k nodes. My current implementation in Python is as follows: Input data is a sparse graph: …

Total answers: 1

How to avoid a double serch and replace

How to avoid a double serch and replace Question: I have the following code: I need to rem out a line by placing a # at the begining. It works great. Problem is if the line is already remarked out by a #, and the query is run again. it places a second # in …

Total answers: 2

Check if strings from list A exist in list B (by regex)

Check if strings from list A exist in list B (by regex) Question: listA = [‘Leonardo_da_Vinci’, ‘Napoleon’, ‘Cao_Cao’, ‘Elton_John’] listB = [‘123_Leonardo_da_Vinci_abc.csv’, ‘456_Cao_Cao_def.csv’] listC = [‘Napoleon’, ‘Elton_John’] I would like to check if the items in listB contain the values in listA, and returns listC (i.e. the list that is missing in listB). For this …

Total answers: 1

Vectorize a For Loop that search for elements in another array

Vectorize a For Loop that search for elements in another array Question: I have two arrays that look like this: Array 1 (locs_array) is a 2D array containing pairs of values I call lon and lat e.g. array([[-122.463425, 47.195741], [-122.498139, 47.190166]]) Array 2 (parents_array) is also a 2D array containing the following columns [id, centerlon, …

Total answers: 1

Is is still considered a BFS algorithm if I modify it A little bit?

Is is still considered a BFS algorithm if I modify it A little bit? Question: So I’m trying to create a program that finds the shortest path from nodeA to nodeB, however, I want to block certain nodes so that it would find another path. I’m not really aiming for an optimal code here I’m …

Total answers: 1

Image search on Marqo is returning random results – how can I fix this?

Image search on Marqo is returning random results – how can I fix this? Question: I configured a marqo index for image search as follows: settings = { "treat_urls_and_pointers_as_images":True, # allows us to find an image file and index it "model":"ViT-L/14" } response = mq.create_index("my-multimodal-index", **settings) I then added some documents: mq.index("my-multimodal-index").add_documents( [ {"image": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSBgKtI0_GMZMd1Zm4UGRO4E5RL5bN9kBO0FA&usqp=CAU", …

Total answers: 1

list in list, search in an another list

list in list, search in an another list Question: I have a first list, containing string lists and a second list containing strings. I want that when a string from the first list is found in the second, the string from the second is returned and the search resumes at the next string from the …

Total answers: 3