Python cmath.rect() Examples
The following are 30
code examples of cmath.rect().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
cmath
, or try the search function
.
Example #1
Source File: module.py From PynPoint with GNU General Public License v3.0 | 6 votes |
def angle_average(angles: np.ndarray) -> float: """ Function to calculate the average value of a list of angles. Parameters ---------- angles : numpy.ndarray Parallactic angles (deg). Returns ------- float Average angle (deg). """ cmath_rect = sum(cmath.rect(1, math.radians(ang)) for ang in angles) cmath_phase = cmath.phase(cmath_rect/len(angles)) return math.degrees(cmath_phase)
Example #2
Source File: color15.py From micropython-nano-gui with MIT License | 6 votes |
def clock(x): print('Clock test.') refresh(ssd, True) # Clear any prior image lbl = Label(wri, 5, 85, 'Clock') dial = Dial(wri, 5, 5, height = 75, ticks = 12, bdcolor=None, label=50) # Border in fg color hrs = Pointer(dial) mins = Pointer(dial) hrs.value(0 + 0.7j, RED) mins.value(0 + 0.9j, YELLOW) dm = cmath.rect(1, -cmath.pi/30) # Rotate by 1 minute (CW) dh = cmath.rect(1, -cmath.pi/1800) # Rotate hours by 1 minute for n in range(x): refresh(ssd) utime.sleep_ms(200) mins.value(mins.value() * dm, YELLOW) hrs.value(hrs.value() * dh, RED) dial.text('ticks: {}'.format(n)) lbl.value('Done')
Example #3
Source File: nanogui.py From micropython-nano-gui with MIT License | 6 votes |
def arrow(dev, origin, vec, lc, color, ccw=cmath.exp(3j * cmath.pi/4), cw=cmath.exp(-3j * cmath.pi/4)): length, theta = cmath.polar(vec) uv = cmath.rect(1, theta) # Unit rotation vector start = -vec if length > 3 * lc: # If line is long ds = cmath.rect(lc, theta) start += ds # shorten to allow for length of tail chevrons chev = lc + 0j polar(dev, origin, vec, color) # Origin to tip polar(dev, origin, start, color) # Origin to tail polar(dev, origin + conj(vec), chev*ccw*uv, color) # Tip chevron polar(dev, origin + conj(vec), chev*cw*uv, color) if length > lc: # Confusing appearance of very short vectors with tail chevron polar(dev, origin + conj(start), chev*ccw*uv, color) # Tail chevron polar(dev, origin + conj(start), chev*cw*uv, color) # If a (framebuf based) device is passed to refresh, the screen is cleared. # None causes pending widgets to be drawn and the result to be copied to hardware. # The pend mechanism enables a displayable object to postpone its renedering # until it is complete: efficient for e.g. Dial which may have multiple Pointers
Example #4
Source File: vtest.py From micropython-tft-gui with MIT License | 6 votes |
def aclock(dial, lbldate, lbltim): uv = lambda phi : rect(1, phi) # Return a unit vector of phase phi days = ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday') months = ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December') hrs = Pointer(dial) mins = Pointer(dial) secs = Pointer(dial) hstart = 0 + 0.7j # Pointer lengths. Position at top. mstart = 0 + 1j sstart = 0 + 1j while True: t = time.localtime() hrs.value(hstart * uv(-t[3] * pi/6 - t[4] * pi / 360), CYAN) mins.value(mstart * uv(-t[4] * pi/30), CYAN) secs.value(sstart * uv(-t[5] * pi/30), RED) lbltim.value('{:02d}.{:02d}.{:02d}'.format(t[3], t[4], t[5])) lbldate.value('{} {} {} {}'.format(days[t[6]], t[2], months[t[1] - 1], t[0])) await asyncio.sleep(1)
Example #5
Source File: fplot.py From micropython-nano-gui with MIT License | 6 votes |
def show(self): super().show() # Clear working area ssd = self.device x0 = self.x0 y0 = self.y0 radius = self.radius adivs = self.adivs rdivs = self.rdivs diam = 2 * radius if rdivs > 0: for r in range(1, rdivs + 1): circle(ssd, self.xp_origin, self.yp_origin, round(radius * r / rdivs), self.gridcolor) if adivs > 0: v = complex(1) m = rect(1, pi / adivs) for _ in range(adivs): self.cline(-v, v, self.gridcolor) v *= m ssd.vline(x0 + radius, y0, diam, self.fgcolor) ssd.hline(x0, y0 + radius, diam, self.fgcolor)
Example #6
Source File: plot.py From micropython-tft-gui with MIT License | 6 votes |
def show(self): tft = self.tft x0 = self.x0 y0 = self.y0 radius = self.radius diam = 2 * radius if self.rdivs > 0: for r in range(1, self.rdivs + 1): tft.draw_circle(self.xp_origin, self.yp_origin, int(radius * r / self.rdivs), self.gridcolor) if self.adivs > 0: v = complex(1) m = rect(1, pi / self.adivs) for _ in range(self.adivs): self.cline(-v, v, self.gridcolor) v *= m tft.draw_vline(x0 + radius, y0, diam, self.fgcolor) tft.draw_hline(x0, y0 + radius, diam, self.fgcolor) for curve in self.curves: curve.show()
Example #7
Source File: internal.py From curve_cad with GNU General Public License v3.0 | 6 votes |
def bezierLength(points, beginT=0, endT=1, samples=1024): # https://en.wikipedia.org/wiki/Arc_length#Finding_arc_lengths_by_integrating vec = [points[1]-points[0], points[2]-points[1], points[3]-points[2]] dot = [vec[0]@vec[0], vec[0]@vec[1], vec[0]@vec[2], vec[1]@vec[1], vec[1]@vec[2], vec[2]@vec[2]] factors = [ dot[0], 4*(dot[1]-dot[0]), 6*dot[0]+4*dot[3]+2*dot[2]-12*dot[1], 12*dot[1]+4*(dot[4]-dot[0]-dot[2])-8*dot[3], dot[0]+dot[5]+2*dot[2]+4*(dot[3]-dot[1]-dot[4]) ] # https://en.wikipedia.org/wiki/Trapezoidal_rule length = 0 prev_value = math.sqrt(factors[4]+factors[3]+factors[2]+factors[1]+factors[0]) for index in range(0, samples+1): t = beginT+(endT-beginT)*index/samples # value = math.sqrt(factors[4]*(t**4)+factors[3]*(t**3)+factors[2]*(t**2)+factors[1]*t+factors[0]) value = math.sqrt((((factors[4]*t+factors[3])*t+factors[2])*t+factors[1])*t+factors[0]) length += (prev_value+value)*0.5 prev_value = value return length*3/samples # https://en.wikipedia.org/wiki/Root_of_unity # cubic_roots_of_unity = [cmath.rect(1, i/3*2*math.pi) for i in range(0, 3)]
Example #8
Source File: newclock.py From micropython-epaper with Apache License 2.0 | 6 votes |
def ticks(hrs, length): vs = rect(RADIUS, PHI) # Coords relative to arc origin ve = rect(RADIUS - length, PHI) # Short tick ve1 = rect(RADIUS - 1.5 * length, PHI) # Long tick ve2 = rect(RADIUS - 2.0 * length, PHI) # Extra long tick rv = rect(1, -5 * RV) # Rotation vector for 5 minutes (about OR) rot = rect(1, (3 - hrs) * pi / 6) # hrs rotation (about [0,0]) for n in range(13): # Translate to 0, 0 if n == 6: # Overdrawn by hour pointer: visually cleaner if we skip yield elif n % 3 == 0: yield ((vs + XLT) * rot, (ve2 + XLT) * rot) # Extra Long elif n % 2 == 0: yield ((vs + XLT) * rot, (ve1 + XLT) * rot) # Long else: yield ((vs + XLT) * rot, (ve + XLT) * rot) # Short vs *= rv ve *= rv ve1 *= rv ve2 *= rv # Generate vectors for the hour chevron
Example #9
Source File: pt.py From micropython-tft-gui with MIT License | 5 votes |
def populate(self, curve, rot): def f(theta): return rect(1.15*sin(5 * theta), theta)*rot # complex nmax = 150 for n in range(nmax + 1): theta = 2 * pi * n / nmax curve.point(f(theta)) # Simple Cartesian plot with asymmetric axis and two curves.
Example #10
Source File: test_cmath.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_rect(self): self.assertCEqual(rect(0, 0), (0, 0)) self.assertCEqual(rect(1, 0), (1., 0)) self.assertCEqual(rect(1, -pi), (-1., 0)) self.assertCEqual(rect(1, pi/2), (0, 1.)) self.assertCEqual(rect(1, -pi/2), (0, -1.))
Example #11
Source File: test_cmath.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_rect(self): self.assertCEqual(rect(0, 0), (0, 0)) self.assertCEqual(rect(1, 0), (1., 0)) self.assertCEqual(rect(1, -pi), (-1., 0)) self.assertCEqual(rect(1, pi/2), (0, 1.)) self.assertCEqual(rect(1, -pi/2), (0, -1.))
Example #12
Source File: Transform.py From hyperbolic with MIT License | 5 votes |
def rotation(rad=None, deg=None, vec=None): assert (rad is None) + (deg is None) + (vec is None) == 2 if vec is not None: z = complex(*vec) e = z / abs(z) else: if deg is not None: rad = math.radians(deg) e = cmath.rect(1, rad) return Transform(1,0,0,1,e)
Example #13
Source File: test_cmath.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_rect(self): self.assertCEqual(rect(0, 0), (0, 0)) self.assertCEqual(rect(1, 0), (1., 0)) self.assertCEqual(rect(1, -pi), (-1., 0)) self.assertCEqual(rect(1, pi/2), (0, 1.)) self.assertCEqual(rect(1, -pi/2), (0, -1.))
Example #14
Source File: newclock.py From micropython-epaper with Apache License 2.0 | 5 votes |
def arc(hrs, angle=60, mul=1.0): vs = rect(RADIUS * mul, PHI) # Coords relative to arc origin ve = rect(RADIUS * mul, PHI) pe = PHI - angle * RV + TV rv = rect(1, -RV) # Rotation vector for 1 minute (about OR) rot = rect(1, (3 - hrs) * pi / 6) # hrs rotation (about [0,0]) while phase(vs) > pe: ve *= rv # Translate to 0, 0 yield ((vs + XLT) * rot, (ve + XLT) * rot) vs *= rv # Currently unused. Draw the unit circle in a way which may readily be # ported to other displays.
Example #15
Source File: newclock.py From micropython-epaper with Apache License 2.0 | 5 votes |
def circle(): segs = 60 phi = 2 * pi / segs rv = rect(1, phi) vs = 1 + 0j ve = vs for _ in range(segs): ve *= rv yield vs, ve vs *= rv # Generate vectors for the minutes ticks
Example #16
Source File: newclock.py From micropython-epaper with Apache License 2.0 | 5 votes |
def hour(hrs): vs = -1 + 0j ve = 0.96 + 0j rot = rect(1, (3 - hrs) * pi / 6) # hrs rotation (about [0,0]) yield (vs * rot, ve * rot) vs = 0.85 + 0.1j yield (vs * rot, ve * rot) vs = 0.85 - 0.1j yield (vs * rot, ve * rot) # Draw a vector scaling it for display and converting to integer x, y # BEWARE unconventional Y coordinate on Pervasive Displays EPD.
Example #17
Source File: comp_angle.py From CogAlg with MIT License | 5 votes |
def lateral_comp(P_): # horizontal comparison between pixels at distance == rng derts__ = [] for P in P_: x0 = P[1] derts_ = P[-1] new_derts_ = [] # new derts buffer _derts = derts_[0] gd, dx, dy, _ = _derts[-1] # comp_angle always follows comp_gradient or hypot_g _a = complex(dx, dy) # to complex number: _a = dx + dyj _a /= abs(_a) # normalize _a so that abs(_a) == 1 (hypot() from real and imaginary part of _a == 1) _a_radian = phase(_a) # angular value of _a in radian: _a_radian in (-pi, pi) _dax, _ncomp = 0j, 0 # init ncomp, dx(complex) buffers for derts in derts_[1:]: # compute angle: g, dx, dy, _ = derts[-1] # derts_ and new_derts_ are separate a = complex(dx, dy) # to complex number: a = dx + dyj a /= abs(a) # normalize a so that abs(a) == 1 (hypot() from real and imaginary part of a == 1) a_radian = phase(a) # angular value of a in radian: aa in (-pi, pi) da = rect(1, a_radian - _a_radian) # convert bearing difference into complex form (rectangular coordinate) # complex d doesn't need to correct angle diff: if d > pi: d -= 255; elif d < -127: d += 255 dx = da _dax += da # bilateral accumulation _ncomp += 1 # bilateral accumulation new_derts_.append(_derts + [(_a, _a_radian), (0j, _dax, _ncomp)]) # return a and _dy = 0 + 0j in separate tuples _derts = derts # buffer derts _a, _aa, _dx, _ncomp = a, a_radian, dx, 1 # buffer last ncomp and dx new_derts_.append(_derts + [(_a, _a_radian), (0j, _dax, _ncomp)]) # return last derts derts__.append((x0, new_derts_)) # new line of P derts_ appended with new_derts_ return derts__ # ---------- lateral_comp() end -----------------------------------------------------------------------------------------
Example #18
Source File: canvas.py From tk_tools with MIT License | 5 votes |
def set_value(self, number: (float, int)): """ Sets the value of the graphic :param number: the number (must be between 0 and \ 'max_range' or the scale will peg the limits :return: None """ self.canvas.delete('all') self.canvas.create_image(0, 0, image=self.image, anchor='nw') number = number if number <= self.max_value else self.max_value number = 0.0 if number < 0.0 else number radius = 0.9 * self.size/2.0 angle_in_radians = (2.0 * cmath.pi / 3.0) \ + number / self.max_value * (5.0 * cmath.pi / 3.0) center = cmath.rect(0, 0) outer = cmath.rect(radius, angle_in_radians) if self.needle_thickness == 0: line_width = int(5 * self.size / 200) line_width = 1 if line_width < 1 else line_width else: line_width = self.needle_thickness self.canvas.create_line( *self.to_absolute(center.real, center.imag), *self.to_absolute(outer.real, outer.imag), width=line_width, fill=self.needle_color ) self.readout['text'] = '{}{}'.format(number, self.unit)
Example #19
Source File: canvas.py From tk_tools with MIT License | 5 votes |
def _draw_background(self, divisions: int = 10): """ Draws the background of the dial :param divisions: the number of divisions between 'ticks' shown on the dial :return: None """ self.canvas.create_arc(2, 2, self.size-2, self.size-2, style=tk.PIESLICE, start=-60, extent=30, fill='red') self.canvas.create_arc(2, 2, self.size-2, self.size-2, style=tk.PIESLICE, start=-30, extent=60, fill='yellow') self.canvas.create_arc(2, 2, self.size-2, self.size-2, style=tk.PIESLICE, start=30, extent=210, fill='green') # find the distance between the center and the inner tick radius inner_tick_radius = int(self.size * 0.4) outer_tick_radius = int(self.size * 0.5) for tick in range(divisions): angle_in_radians = (2.0 * cmath.pi / 3.0) \ + tick/divisions * (5.0 * cmath.pi / 3.0) inner_point = cmath.rect(inner_tick_radius, angle_in_radians) outer_point = cmath.rect(outer_tick_radius, angle_in_radians) self.canvas.create_line( *self.to_absolute(inner_point.real, inner_point.imag), *self.to_absolute(outer_point.real, outer_point.imag), width=1 )
Example #20
Source File: canvas.py From tk_tools with MIT License | 5 votes |
def draw_axes(self): """ Removes all existing series and re-draws the axes. :return: None """ self.canvas.delete('all') rect = 50, 50, self.w - 50, self.h - 50 self.canvas.create_rectangle(rect, outline="black") for x in self.frange(0, self.x_max - self.x_min + 1, self.x_tick): value = Decimal(self.x_min + x) if self.x_min <= value <= self.x_max: x_step = (self.px_x * x) / self.x_tick coord = 50 + x_step, self.h - 50, 50 + x_step, self.h - 45 self.canvas.create_line(coord, fill="black") coord = 50 + x_step, self.h - 40 label = round(Decimal(self.x_min + x), 1) self.canvas.create_text(coord, fill="black", text=label) for y in self.frange(0, self.y_max - self.y_min + 1, self.y_tick): value = Decimal(self.y_max - y) if self.y_min <= value <= self.y_max: y_step = (self.px_y * y) / self.y_tick coord = 45, 50 + y_step, 50, 50 + y_step self.canvas.create_line(coord, fill="black") coord = 35, 50 + y_step label = round(value, 1) self.canvas.create_text(coord, fill="black", text=label)
Example #21
Source File: round_trk.py From RF-tools-KiCAD with GNU General Public License v3.0 | 5 votes |
def create_round_segments(pcb,sp,a1,ep,a2,cntr,rad,layer,width,Nn,N_SEGMENTS): start_point = sp end_point = ep pos = sp next_pos = ep a1 = getAngleRadians(cntr,sp) a2 = getAngleRadians(cntr,ep) wxLogDebug('a1:'+str(math.degrees(a1))+' a2:'+str(math.degrees(a2))+' a2-a1:'+str(math.degrees(a2-a1)),debug) if (a2-a1) > 0 and abs(a2-a1) > math.radians(180): deltaA = -(math.radians(360)-(a2-a1))/N_SEGMENTS wxLogDebug('deltaA reviewed:'+str(math.degrees(deltaA)),debug) elif (a2-a1) < 0 and abs(a2-a1) > math.radians(180): deltaA = (math.radians(360)-abs(a2-a1))/N_SEGMENTS wxLogDebug('deltaA reviewed2:'+str(math.degrees(deltaA)),debug) else: deltaA = (a2-a1)/N_SEGMENTS delta=deltaA wxLogDebug('delta:'+str(math.degrees(deltaA))+' radius:'+str(ToMM(rad)),debug) points = [] #import round_trk; import importlib; importlib.reload(round_trk) for ii in range (N_SEGMENTS+1): #+1): points.append(pos) #t = create_Track(pos,pos) prv_pos = pos #pos = pos + fraction_delta #posPolar = cmath.polar(pos) #(rad) * cmath.exp(math.radians(deltaA)*1j) #cmath.rect(r, phi) : Return the complex number x with polar coordinates r and phi. #pos = wxPoint(posPolar.real+sp.x,posPolar.imag+sp.y) pos = rotatePoint(rad,a1,delta,cntr) delta=delta+deltaA wxLogDebug("pos:"+str(ToUnits(prv_pos.x))+":"+str(ToUnits(prv_pos.y))+";"+str(ToUnits(pos.x))+":"+str(ToUnits(pos.y)),debug) for i, p in enumerate(points): #if i < len (points)-1: if i < len (points)-2: t = create_Track(pcb,p,points[i+1],layer,width,Nn,True) #adding ts code to segments t = create_Track(pcb,points[-2],ep,layer,width,Nn,True) #avoiding rounding on last segment return points[-1] #
Example #22
Source File: test_cmath.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_rect(self): self.assertCEqual(rect(0, 0), (0, 0)) self.assertCEqual(rect(1, 0), (1., 0)) self.assertCEqual(rect(1, -pi), (-1., 0)) self.assertCEqual(rect(1, pi/2), (0, 1.)) self.assertCEqual(rect(1, -pi/2), (0, -1.))
Example #23
Source File: test_cmath.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_rect(self): self.assertCEqual(rect(0, 0), (0, 0)) self.assertCEqual(rect(1, 0), (1., 0)) self.assertCEqual(rect(1, -pi), (-1., 0)) self.assertCEqual(rect(1, pi/2), (0, 1.)) self.assertCEqual(rect(1, -pi/2), (0, -1.))
Example #24
Source File: color15.py From micropython-nano-gui with MIT License | 5 votes |
def compass(x): print('Compass test.') refresh(ssd, True) # Clear any prior image dial = Dial(wri, 5, 5, height = 75, bdcolor=None, label=50, style = Dial.COMPASS) bearing = Pointer(dial) bearing.value(0 + 1j, RED) dh = cmath.rect(1, -cmath.pi/30) # Rotate by 6 degrees CW for n in range(x): utime.sleep_ms(200) bearing.value(bearing.value() * dh, RED) refresh(ssd)
Example #25
Source File: nanogui.py From micropython-nano-gui with MIT License | 5 votes |
def show(self): wri = self.writer dev = self.device dev.fill_rect(self.col, self.row, self.width, self.height, self.bgcolor) if isinstance(self.bdcolor, bool): # No border if self.has_border: # Border exists: erase it dev.rect(self.col - 2, self.row - 2, self.width + 4, self.height + 4, self.bgcolor) self.has_border = False elif self.bdcolor: # Border is required dev.rect(self.col - 2, self.row - 2, self.width + 4, self.height + 4, self.bdcolor) self.has_border = True
Example #26
Source File: fpt.py From micropython-nano-gui with MIT License | 5 votes |
def polar_clip(): print('Test of polar data clipping.') def populate(rot): f = lambda theta : cmath.rect(1.15 * math.sin(5 * theta), theta) * rot # complex nmax = 150 for n in range(nmax + 1): yield f(2 * cmath.pi * n / nmax) # complex z refresh(ssd, True) # Clear any prior image g = PolarGraph(wri, 2, 2, fgcolor=WHITE, gridcolor=LIGHTGREEN) curve = PolarCurve(g, YELLOW, populate(1)) curve1 = PolarCurve(g, RED, populate(cmath.rect(1, cmath.pi/5),)) refresh(ssd)
Example #27
Source File: fpt.py From micropython-nano-gui with MIT License | 5 votes |
def rt_polar(): print('Simulate realtime polar data acquisition.') refresh(ssd, True) # Clear any prior image g = PolarGraph(wri, 2, 2, fgcolor=WHITE, gridcolor=LIGHTGREEN) curvey = PolarCurve(g, YELLOW) curver = PolarCurve(g, RED) for x in range(100): curvey.point(cmath.rect(x/100, -x * cmath.pi/30)) curver.point(cmath.rect((100 - x)/100, -x * cmath.pi/30)) utime.sleep_ms(60) refresh(ssd)
Example #28
Source File: aclock.py From micropython-nano-gui with MIT License | 5 votes |
def aclock(): uv = lambda phi : cmath.rect(1, phi) # Return a unit vector of phase phi pi = cmath.pi days = ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday') months = ('Jan', 'Feb', 'March', 'April', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec') # Instantiate CWriter CWriter.set_textpos(ssd, 0, 0) # In case previous tests have altered it wri = CWriter(ssd, arial10, GREEN, BLACK, verbose=False) wri.set_clip(True, True, False) # Instantiate displayable objects dial = Dial(wri, 2, 2, height = 75, ticks = 12, bdcolor=None, label=120, pip=False) # Border in fg color lbltim = Label(wri, 5, 85, 35) hrs = Pointer(dial) mins = Pointer(dial) secs = Pointer(dial) hstart = 0 + 0.7j # Pointer lengths and position at top mstart = 0 + 0.92j sstart = 0 + 0.92j while True: t = utime.localtime() hrs.value(hstart * uv(-t[3]*pi/6 - t[4]*pi/360), YELLOW) mins.value(mstart * uv(-t[4] * pi/30), YELLOW) secs.value(sstart * uv(-t[5] * pi/30), RED) lbltim.value('{:02d}.{:02d}.{:02d}'.format(t[3], t[4], t[5])) dial.text('{} {} {} {}'.format(days[t[6]], t[2], months[t[1] - 1], t[0])) refresh(ssd) utime.sleep(1)
Example #29
Source File: test_cmath.py From BinderFilter with MIT License | 5 votes |
def test_rect(self): self.assertCEqual(rect(0, 0), (0, 0)) self.assertCEqual(rect(1, 0), (1., 0)) self.assertCEqual(rect(1, -pi), (-1., 0)) self.assertCEqual(rect(1, pi/2), (0, 1.)) self.assertCEqual(rect(1, -pi/2), (0, -1.))
Example #30
Source File: test_cmath.py From oss-ftp with MIT License | 5 votes |
def test_rect(self): self.assertCEqual(rect(0, 0), (0, 0)) self.assertCEqual(rect(1, 0), (1., 0)) self.assertCEqual(rect(1, -pi), (-1., 0)) self.assertCEqual(rect(1, pi/2), (0, 1.)) self.assertCEqual(rect(1, -pi/2), (0, -1.))