Questions tagged [bisect]

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

105 questions
1
vote
1 answer

'only length-1 arrays can be converted to Python scalars' error

I have such Python code import numpy as np import matplotlib.pyplot as plt import math from scipy import optimize as opt def func1(x): f1 = math.exp(x-2)+x**3-x return f1 solv1_bisect = opt.bisect(func1, -1.5, 1.5) x1 =…
Y Yen
  • 13
  • 3
1
vote
1 answer

I want to change all of the number in my array into ABCD scoring system using python

I want to change all the number in my array into ABCD scoring system. I have 100 X 1 array of scores, my array is put under total_score. I tried using def grade(score): if 91 <= score <= 100: return 'A' if 81 <= score <= 90.99: …
1
vote
1 answer

Is the state of previous git bisect "sessions" stored somewhere in git?

Some time ago I used git bisect to identify a bad commit, which I managed to. I then closed the git bisect "session" with git bisect reset. However, my process to identify whether a commit is good/bad is rather complex, and I may have made a…
bbercz
  • 180
  • 1
  • 11
1
vote
1 answer

kernel: bisect merge commits to find non-merge first bad

I bisected problem in kernel and the first bad commit is merge commit: 2b90506a8186 ("Merge tag 'arm-defconfig-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc"). Parents of 2b90506a8186 (both are good): 01d713689441 ("Merge tag…
pevik
  • 4,523
  • 3
  • 33
  • 44
1
vote
2 answers

Python bisect_left

Can someone please explain me what the bisect_left function from the bisect library actually does? Example: import bisect bisect.bisect_left([1,2,3], 2) This code will print '1'. But what is the rule for this printing? Is '2' inserted in the list,…
Ciprian
  • 33
  • 6
1
vote
1 answer

function count_numbers that accepts a sorted list of unique integers

Implement function count_numbers that accepts a sorted list of unique integers and, efficiently with respect to time used, counts the number of list elements that are less than the parameter less_than. For example, count_numbers([1, 3, 5, 7], 4)…
1
vote
2 answers

How can I change code within a commit to help find a bug?

I am trying to track down a specific bug in my code, but the trouble is the bug appeared somewhere in a block of commits where the only way to check if the commit breaks is commented out, so I can't see which commit it is. I need to change one line…
Mild Fuzz
  • 29,463
  • 31
  • 100
  • 148
1
vote
1 answer

python3 bisect sequence association

I'm struggling to understand how Python makes the association between the breakpoints sequence and the grades sequence. def grade(score, breakpoints=[60, 70, 80, 90], grades='FDCBA'): i = bisect.bisect(breakpoints, score) return…
Adwald
  • 13
  • 2
1
vote
1 answer

Equivalent of 'git bisect run' for mercurial?

git bisect run conveniently bisects a given range of revisions with a script run on each revision whose exit status is used to determine whether it is good, bad or broken. hg bisect does not seem to offer this automatic ability. I need to manually…
Simon
  • 593
  • 2
  • 13
1
vote
1 answer

Why does this solution have O(nlogn) complexity?

Given an array of integers, return a new array where each element in the new array is the number of smaller elements to the right of that element in the original input array. For example, given the array [3, 4, 9, 6, 1], return [1, 1, 2, 1,…
1
vote
1 answer

using boost::bisect on a series of equations

I just started using boost today and found this post to be extremely helpful. I am attempting to use boost::bisect to solve a parametric equation for a series of values. The following works if I want to solve for a value of 0.8: #include…
gmculp
  • 135
  • 1
  • 10
1
vote
0 answers

Cython build with bisect fails for python 3

I am trying to build a cython module that uses the bisect module. When compiling with python-2 the import works flawlessly, but when compiled for python-3 I get a strange recursion error. Here is an example test and setup script: ##…
christopherlovell
  • 3,800
  • 4
  • 19
  • 26
1
vote
0 answers

Is there a way to get rspec --bisect to work with jruby?

I thought I'd try using rspec --bisect to figure out which combinations of tests caused a failure, but it turns out that this doesn't work with JRuby, or at least, not when launching org.jruby.Main via java, which is how all our automated tests are…
Hakanai
  • 12,010
  • 10
  • 62
  • 132
1
vote
1 answer

scipy.optimise.bisect on a numpy array

I have a numpy array of floats which when printed look like this: The red circles are the original values, the blue crosses are a linear interpolation using numpy.interp. I would like to find the abscissa of the zero crossing of this numpy array…
gregory
  • 413
  • 4
  • 12
1
vote
1 answer

Find Item lower or equal to value in list

I have a sorted csv file with multiple columns and I want to return the value or the index of an item in column 1. This csv file has around 300.000 to 400.000 values so I'm trying to avoid any min function since it would propably take to long and I…
Max
  • 13
  • 5