Questions tagged [bisect]

the "bisect" subcommand of Git or the "bisect" module of Python

105 questions
1
vote
1 answer

Python: Function doesn't receive a value within a for loop

I'm using the bisection method from the scipy.optimize package within a for loop. The idea is to get a value of "sig" with the bisection method for each element (value) in the "eps_komp" vector. I've coded this much: import numpy as np import…
mcluka
  • 285
  • 1
  • 7
  • 17
1
vote
1 answer

Overriding sorting attribute in class, python

I would like to use bisect (as shown here, in the second answer: Does python have a sorted list?), but instead of using a list of numbers, I have a list of objects. In specific, objects from this class:…
matlabit
  • 838
  • 2
  • 13
  • 31
1
vote
1 answer

(python) Implementing C insort in python

So i'm using insort from bisect to insert strings into a sorted list. It's somehow faster if i use the built in one. **by faster i mean, on average twice as fast (1 millisecond vs 2 millisecond on a 10,000 word list). I run through the unix cmd on a…
user1831680
  • 73
  • 1
  • 8
0
votes
2 answers

Python bisecting a list

I need to write a function that takes a list and bisects it (like the bisect module but I cannot use that). I normally would show what I have done so far but I really do not know how to do it without the module so I am hoping someone can help me…
Neemaximo
  • 20,031
  • 12
  • 32
  • 40
0
votes
1 answer

Python bisect with key occures '<' not supported ... error

I'm asking about how to collectly use key function in bisect on Python3.x. Now I writed code below: import bisect if __name__ == '__main__': Q = [] S = [[1, 2], [5, -8], [2, 0]] for s in S: print(s) i =…
0
votes
1 answer

What does it mean for git bisect to produce a merge base which is both bad and good?

I've just performed a lengthy bisect, and received the following output from git: The merge base ec879c71aa41065af101d1cce61966417e8d53c9 is bad. This means the bug has been fixed between ec879c71aa41065af101d1cce61966417e8d53c9 and…
ash
  • 5,139
  • 2
  • 27
  • 39
0
votes
1 answer

How to write a key function for bisect.bisect_left that compares both the index of two arrays?

I want to write a key function for bisect.bisect_left and my objective is to compare two lists, call one list smaller than the other only if both elements of it are smaller than or equal to the other list's elements. [x1, y1] should be placed before…
Aviral Srivastava
  • 4,058
  • 8
  • 29
  • 81
0
votes
1 answer

How to use "git bisect run" for locating first commit introducing a string into a file which only exists in some commits

Let's say I want to locate the first (oldest) Git revision which adds the line delta to text file file. But I want to use git bisect for this rather than searching the output of git log -p because of performance reasons (huge repository). First…
0
votes
0 answers

Using bisect efficiently with the keys of an OrderedDict

I'm looking for the fastest way to do the following: given a dictionary and a key value, return the lowest key in the dictionary greater than than the value given. Per this question, the natural way would seem to be to create an OrderedDict, then…
Eli Johnson
  • 349
  • 2
  • 10
0
votes
0 answers

BisectonFunctionError Lambda

If I enable Bisect on Function Error on AWS Lambda and lets say I get a batch of 100 records. Lets assume I am looping thru the records and publishing them to SNS topic. Now lets say the 51st record ends up in throwing an exception. Now the batch of…
0
votes
1 answer

Python bisect and Pandas dataframe: KeyError

I am using bisect for finding the first index that is greater than my value: bisect.bisect_left(X['x'].iloc[116:231], x=0.15) X is in ascending order and the first value X['x'].iloc[116] is 0.275. The bisect function above gives me KeyError: 57. I…
Kubra
  • 188
  • 8
0
votes
1 answer

Using Python Bisect on List of Lists Throw Error

I am trying to use Bisect to find where I should insert a new element. The list to search is a list of lists. The inner list has two elements and I want to compare using the first element. In the bisect function documentation, it says that the key…
Major
  • 159
  • 1
  • 7
0
votes
2 answers

How to filter a collection of objects by field value?

How in Python to organize and filter a collection of objects by a field value? I need to filter by being equal to an exact value and by being less than a value. And how to do it effectively? If I store my objects in a list I need to iterate over a…
0
votes
1 answer

How does Python's bisect function use this tuple as an argument?

This is a question arising from a Coursera course on genomics that I'm following. We are currently dealing with search methods, specifically how to detect (align) all occurrences of a shorter DNA sequence (p, a string) within a longer DNA sequence…
0
votes
0 answers

Trying to find the best savings rate using Bisect search

I am trying to find a savings rate (rate_approx in my code) that will result in a savings (current_savings in code) over 36 months that is within $100 of the down payment (down_payment in code). I'm running the for loop each time within the while…
Gwen Di
  • 1
  • 2