@@ -0,0 +1,2148 @@
+import beprof.curve%0Aimport beprof.profile%0Aimport numpy as np%0A%0Adef subtract(curve1, curve2, defval=0):%0A    '''%0A    Function calculates difference between curve1 and curve2 and returns new object%0A    which domain is an union of domains of curve1 and curve2%0A%0A    :param curve1: first curve to calculate the difference%0A    :param curve2: second curve to calculate the difference%0A    :param defval: default value for points that cannot be interpolated%0A    :return: new curve object with element-wise difference (using interpolation if necessary)%0A    '''%0A    # domain1 = %5Ba1, b1%5D%0A    # domain2 = %5Ba2, b2%5D%0A    # a1, b1 = np.min(curve1.x), np.max(curve1.x)%0A    # a2, b2 = np.min(curve2.x), np.max(curve2.x)%0A    #%0A    # # mutual position of the domains can be 1 of 3 cases:%0A    # # CASE 1: domains are disjoint:%0A    # if a2 %3E b1 or a1 %3E b2:%0A    #     tmp1 = np.array(curve1.y) - defval        # new values for self.x are correspoding self.y-defval%0A    #     tmp2 = defval - np.array(curve2.y)          # new values for c2.x are corresponding defval - c2.y%0A    #     if a2 %3E b1:     # here we have ------a1%7C%7C%7C%7C%7C%7Cb1-----a2%7C%7C%7C%7C%7Cb2------%3E%0A    #         newX = np.concatenate((curve1.x, curve2.x))        # new X is just an union%0A    #         newY = np.concatenate((tmp1, tmp2))    # into one list%0A    #     else:           # mirrored, just a minor change%0A    #         newX = np.concatenate((curve2.x, curve1.x))        # new X is just an union%0A    #         newY = np.concatenate((tmp2, tmp1))             # into one list%0A    #%0A    #     print('newX: ', newX)%0A    #     print('newY: ', newY)%0A    #     obj = curve.Curve(np.stack((newX, newY), axis=1))  # ADD METADATA HANDLING!%0A    #     return obj%0A    # # CASE 2: one domain includes the other, in this example domain(curve2) is inside domain(curve1)%0A    # elif a1 %3C= a2 and b1 %3E= b2:%0A    set1 = set(curve1.x)%0A    set2 = set(curve2.x)%0A    newX = list(set1 %7C set2)%0A    newX.sort()%0A    print('newX: ', newX)%0A    y1 = curve1.evaluate_at_x(newX, defval)%0A    y2 = curve2.evaluate_at_x(newX, defval)%0A    newY = y1 - y2%0A    obj = curve.Curve(np.stack((newX, newY), axis=1))  # ADD METADATA HANDLING!%0A    return obj%0A

Create functions.py