1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
U
P±dÓã@sädZddlZddlmZddlmZddlmZm    Z    m
Z
Gdd„dƒZ Gdd„dƒZ ej  d    ejd
d d gd ded
d d gƒf¡Gdd„dƒƒZGdd„dƒZGdd„dƒZGdd„dƒZdd„Zdd„Zdd„Zdd„Zdd „ZdS)!zE
Tests related to the ``symbol`` attribute of the ABCPolyBase class.
éN)Úarray)Ú assert_equalÚ assert_raisesÚassert_c@sveZdZdZdddgZdd„Zej dde    fd    e    fd
e
fde
ff¡d d „ƒZ ej d d¡dd„ƒZ dd„Z dd„Zd
S)ÚTestInitz5
    Test polynomial creation with symbol kwarg.
    ééécCst |j¡}t|jdƒdS)NÚx©ÚpolyÚ
PolynomialÚcrÚsymbol©ÚselfÚp©rúYd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/polynomial/tests/test_symbol.pyÚtest_default_symbols zTestInit.test_default_symbol)Ú    bad_inputÚ    exceptionÚÚ3Nc    Cs*t |¡tj|j|d}W5QRXdS)N©r)ÚpytestÚraisesr r r)rrrrrrrÚtest_symbol_bad_inputs zTestInit.test_symbol_bad_inputr)r
Zx_1ÚAZxyzuβcCs tj|j|d}t|j|ƒdS)zF
        Values for symbol that should pass input validation.
        rNr )rrrrrrÚtest_valid_symbolss zTestInit.test_valid_symbolsc    Cs0tj|jdd}t t¡ d|_W5QRXdS)z2
        'symbol' attribute is read only.
        r
rÚzN)r r rrrÚAttributeErrorrrrrrÚ test_property-s zTestInit.test_propertycCs0tj|jdd}tj|jdd}t|jdƒdS)NÚyrÚt)r r rZcoefrr)rrÚptrrrÚtest_change_symbol5szTestInit.test_change_symbol)Ú__name__Ú
__module__Ú __qualname__Ú__doc__rrrÚmarkÚ parametrizeÚ
ValueErrorÚ    TypeErrorrrr"r&rrrrr s
ü
 
rc@s@eZdZejdddgddZdd„Zdd    „Zd
d „Zd d „Z    dS)ÚTestUnaryOperatorsrrr    r rcCs|j }t|jdƒdS©Nr ©rrr)rÚnrrrÚtest_neg?szTestUnaryOperators.test_negcCs|jd}t|jdƒdS©Né
r r1©rÚoutrrrÚtest_scalarmulCs
z!TestUnaryOperators.test_scalarmulcCsd|j}t|jdƒdSr4r1r6rrrÚtest_rscalarmulGs
z"TestUnaryOperators.test_rscalarmulcCs|jd}t|jdƒdS)Nr    r r1r6rrrÚtest_powKs
zTestUnaryOperators.test_powN)
r'r(r)r r rr3r8r9r:rrrrr/<s
r/Úrhsééér rc@sdeZdZdZejdddgddZdd„Zd    d
„Zd d „Z    d d„Z
dd„Z dd„Z dd„Z dd„ZdS)ÚTestBinaryOperatorsSameSymbolzc
    Ensure symbol is preserved for numeric operations on polynomials with
    the same symbol
    rrr    r rcCs|j|}t|jdƒdSr0r1©rr;r7rrrÚtest_add^s
z&TestBinaryOperatorsSameSymbol.test_addcCs|j|}t|jdƒdSr0r1r@rrrÚtest_subbs
z&TestBinaryOperatorsSameSymbol.test_subcCs|j|}t|jdƒdSr0r1r@rrrÚ test_polymulfs
z*TestBinaryOperatorsSameSymbol.test_polymulcCs"t|j|ƒD]}t|jdƒq dSr0©Údivmodrrrr@rrrÚ test_divmodjsz)TestBinaryOperatorsSameSymbol.test_divmodcCs||j}t|jdƒdSr0r1r@rrrÚ    test_raddns
z'TestBinaryOperatorsSameSymbol.test_raddcCs||j}t|jdƒdSr0r1r@rrrÚ    test_rsubrs
z'TestBinaryOperatorsSameSymbol.test_rsubcCs||j}t|jdƒdSr0r1r@rrrÚ    test_rmulvs
z'TestBinaryOperatorsSameSymbol.test_rmulcCs"t||jƒD]}t|jdƒq dSr0rDr@rrrÚ test_rdivmodzsz*TestBinaryOperatorsSameSymbol.test_rdivmodN)r'r(r)r*r r rrArBrCrFrGrHrIrJrrrrr?Psr?c@sbeZdZejdddgddZejdddgd    dZejejej    ej
ej fZ e j d
e ¡d d „ƒZd S)Ú"TestBinaryOperatorsDifferentSymbolrrr    r
rr<r=r>r#ÚfcCstt||jƒdS)N)rr-Úother)rrLrrrÚtest_binops_fails„sz4TestBinaryOperatorsDifferentSymbol.test_binops_failsN)r'r(r)r r rrMÚ__add__Ú__sub__Ú__mul__Ú __floordiv__Ú__mod__Úopsrr+r,rNrrrrrKs
 rKc@s0eZdZejdddgddZdd„Zdd    „Zd
S) Ú TestEqualityrrr    r
rcCs&tjdddgdd}t|j|kƒdS)Nrrr    r
r©r r rr©rrMrrrÚtest_eqŒszTestEquality.test_eqcCs(tjdddgdd}t|j|k ƒdS)Nrrr    r#rrVrWrrrÚtest_neqszTestEquality.test_neqN)r'r(r)r r rrXrYrrrrrU‰srUc@s€eZdZdZejddddgddZdd    „Zd
d „Zd d „Z    e
j   ddddgidddgidej if¡dd„ƒZdd„Zdd„ZdS)ÚTestExtraMethodszJ
    Test other methods for manipulating/creating polynomial objects.
    rrr    rr rcCs|j ¡}t|jdƒdSr0)rÚcopyrrrWrrrÚ    test_copy›s
zTestExtraMethods.test_copycCs|j ¡}t|jdƒdSr0)rZtrimrrrWrrrÚ    test_trimŸs
zTestExtraMethods.test_trimcCs|j d¡}t|jdƒdS)Nrr )rÚtruncaterrrWrrrÚ test_truncate£s zTestExtraMethods.test_truncateÚkwargÚdomainiöÿÿÿr5ÚwindowÚkindcCs|jjf|Ž}t|jdƒdSr0)rÚconvertrr)rr`rMrrrÚ test_convert§szTestExtraMethods.test_convertcCs|j ¡}t|jdƒdSr0)rZintegrrrWrrrÚ
test_integ°s
zTestExtraMethods.test_integcCs|j ¡}t|jdƒdSr0)rZderivrrrWrrrÚ
test_deriv´s
zTestExtraMethods.test_derivN)r'r(r)r*r r rr\r]r_rr+r,Z    ChebyshevrerfrgrrrrrZ•s
 
ý
rZcCsDtjdddgdd}tjddddgd    d}||ƒ}|jd    ks@t‚dS)
Nr    rrr$rr=réÿÿÿÿuλ_1)r r rÚAssertionError)rÚqÚrrrrÚtest_composition¹srlcCs6tdƒfd\}}tjj||ddd}t|jdƒdS)Nr5rrr )Údegr)Úranger r Zfitrr)r
r#rrrrÚtest_fitÅsrocCs(ddg}tjj|dd}t|jdƒdS)Néþÿÿÿrr r)r r Z    fromrootsrr)ÚrootsrrrrÚtest_froomrootsËsrrcCs*tjjddgddgdd}t|jdƒdS)Nrhrr=ér )rarbr)r r Úidentityrr©rrrrÚ test_identityÑsrvcCs tjjddd}t|jdƒdS)Nr    r r)r r ZbasisrrrurrrÚ
test_basisÖsrw)r*rZnumpy.polynomialZ
polynomialr Z
numpy.corerZ numpy.testingrrrrr/r+r,r r?rKrUrZrlrorrrvrwrrrrÚ<module>s*  1 þþ(
 $