version control - Manually editing using git add --patch <filename> -


so, i've got file i've been working on in branch a, , i'm ready commit it. however, looking @ diff, think it's better put 2 separate commits (well, in case, 2 separate branches, maybe). i've used git add --patch before stage separate hunks, thought use this. problem is, need split 1 of hunks. running git add --patch sda.py , using e edit problem hunk...

# manual hunk edit mode -- see bottom quick guide @@ -50,13 +50,74 @@ import pil.image im   import constant  + +def exp_range(min=none, max=none, step=none): +    """ +    generate exponentially increasing value scaled , offset such +    covers range (min, max].  behaviour similar +    exp(x), scaled such final value generated equal +    'max'.  'step' defines granularity of exponential +    function.  default value 5, corresponding step-size +    of tau. + +    :type min: float +    :param min: minimum value of range (offset) + +    :type max: float +    :param max: maximum (final) value of range + +    :type step: int +    :param step: number of incremental steps within range +                 (min, max] +     +    """ +    if min none: +        raise stopiteration + +    # 1 input argument (same range(10)) +    if min not none , max none , step none: +        step = min +        min = 0. +        max = 1. +    elif step none: +        step = 5 + +    in xrange(step): +        exp_rate = np.exp(i - (step-1)) +        yield min + (max - min) * exp_rate +    raise stopiteration + +  def norm(input): +    """ +    return norm of vector or row-wise norm of matrix + +    :type input: theano.tensor.tensortype +    :param input: theano array or matrix take norm of. +     +    """      return t.sqrt((input * input).sum(axis=0))    def normalize(vector, scale=1.0, offset=0.5): +    """ +    normalize (zero , scale) vector such it's peak peak +    value equal 'scale', , centered 'offset'. + +    :type vector: numpy.ndarray +    :param vector: vector normalize given parameters. + +    :type scale: float +    :param scale: peak-to-peak range stretch or shrink vector's +                  current peak-to-peak range to. + +    :type offset: float +    :param offset: value @ center peak-to-peak range at. +     +    """      return (vector - vector.min()) * scale / vector.ptp()  + 

that's okay. there's mini-guide on bottom. that. so, want put new function in commit, , documentation other functions commit. according mini-doc: # remove '+' lines, delete them.

# manual hunk edit mode -- see bottom quick guide @@ -50,13 +50,74 @@ import pil.image im   import constant  + +def exp_range(min=none, max=none, step=none): +    """ +    generate exponentially increasing value scaled , offset such +    covers range (min, max].  behaviour similar +    exp(x), scaled such final value generated equal +    'max'.  'step' defines granularity of exponential +    function.  default value 5, corresponding step-size +    of tau. + +    :type min: float +    :param min: minimum value of range (offset) + +    :type max: float +    :param max: maximum (final) value of range + +    :type step: int +    :param step: number of incremental steps within range +                 (min, max] +     +    """ +    if min none: +        raise stopiteration + +    # 1 input argument (same range(10)) +    if min not none , max none , step none: +        step = min +        min = 0. +        max = 1. +    elif step none: +        step = 5 + +    in xrange(step): +        exp_rate = np.exp(i - (step-1)) +        yield min + (max - min) * exp_rate +    raise stopiteration + +  def norm(input):      return t.sqrt((input * input).sum(axis=0))    def normalize(vector, scale=1.0, offset=0.5):      return (vector - vector.min()) * scale / vector.ptp() 

that looks good. let's add puppy...

error: patch failed: sda.py:50 error: sda.py: patch not apply edited hunk not apply. edit again (saying "no" discards!) [y/n]? 

mmkay... git add --interactive "your edited hunk not apply" , how read output git diff? explain have update affected line numbers. this, now, can manually count , "hmm, i've removed 1, 2, 3... 23 lines. editing 74 lines previously, i'm editing... hmm... wish had calculator... .... 51 lines" ('whew, i'm sweaty')

this seems overcomplicated method. still think patch right approach, must doing wrong if need manually update number of affected lines in to-file. have advice on how more , efficiently?

commenting out lines # rather deleting them solves issue. i'm not if behaviour part of emacs, commenting line decrements counter @ top of patch message. feature found useful use s first split hunk, add each 1 independently. in particular example, have been better solution.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -