PyPyNum 1.16.1__py3-none-any.whl → 1.16.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyPyNum
3
- Version: 1.16.1
3
+ Version: 1.16.2
4
4
  Summary: PyPyNum is a Python library for math & science computations, covering algebra, calculus, stats, with data structures like matrices, vectors, tensors. It offers numerical tools, programs, and supports computational ops, functions, processing, simulation, & visualization in data science & ML, crucial for research, engineering, & data processing.
5
5
  Home-page: https://github.com/PythonSJL/PyPyNum
6
6
  Author: Shen Jiayi
@@ -234,7 +234,7 @@ processing.</font><font color = red>[Python>=3.4]</font>
234
234
  [![Downloads](https://static.pepy.tech/badge/pypynum/month)](https://pepy.tech/project/pypynum)
235
235
  [![Downloads](https://static.pepy.tech/badge/pypynum/week)](https://pepy.tech/project/pypynum)
236
236
 
237
- ## PyPyNum | Version -> 1.16.1 | PyPI -> https://pypi.org/project/PyPyNum/ | Gitee -> https://www.gitee.com/PythonSJL/PyPyNum | GitHub -> https://github.com/PythonSJL/PyPyNum
237
+ ## Version -> 1.16.2 | PyPI -> https://pypi.org/project/PyPyNum/ | Gitee -> https://www.gitee.com/PythonSJL/PyPyNum | GitHub -> https://github.com/PythonSJL/PyPyNum
238
238
 
239
239
  ![LOGO](PyPyNum.png)
240
240
 
@@ -247,6 +247,15 @@ The logo cannot be displayed on PyPI, it can be viewed in Gitee or GitHub.
247
247
  + Update versions periodically to add more practical features
248
248
  + If you need to contact, please add QQ number 2261748025 (Py𝙿𝚢𝚝𝚑𝚘𝚗-水晶兰), or through my email 2261748025@qq.com
249
249
 
250
+ ```
251
+ +++++++++++++++++++++++++++++++++++++++++
252
+ + Tip: +
253
+ + Have suggestions or feature requests? +
254
+ + Feel free to share them with us. +
255
+ + Your feedback is highly appreciated! +
256
+ +++++++++++++++++++++++++++++++++++++++++
257
+ ```
258
+
250
259
  ### Name and Function Introduction of Submodules
251
260
 
252
261
  | Submodule Name | Function Introduction |
@@ -327,79 +336,69 @@ Python interpreter and run it!
327
336
  ```
328
337
  !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
329
338
 
330
- Fixed and improved the basic
331
- operation function of 'Array'.
332
-
333
- !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
334
-
335
- We will remove 'Tensor' in
336
- future versions. Because its
337
- computational functions have
338
- already been implemented in
339
- 'Array'. The current version
340
- will throw 'FutureWarning' as a
341
- warning.
342
-
343
- !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
344
-
345
- Fixed the calculation error of
346
- 'mp_euler_gamma', which was
347
- caused when modifying the
348
- iteration stop condition
349
- previously.
350
-
351
- !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
352
-
353
339
  <<< Here are the newly added functions >>>
354
340
 
355
341
 
356
- cos_sim(seq1: Union[list, tuple, str], seq2: Union[list, tuple, str], is_vector: bool = False) -> float
342
+ kmp_table(pattern: Union[list, tuple, str]) -> list
357
343
  Introduction
358
344
  ==========
359
- Calculate the cosine similarity between two sequences.
345
+ Generate the KMP (Knuth-Morris-Pratt) table for a given pattern.
360
346
 
361
- The cosine similarity is a measure of similarity between two non-zero vectors. It is defined as the cosine of the
362
- angle between them, which is computed as the dot product of the vectors divided by the product of their magnitudes.
363
- This function supports both numerical vectors and frequency distributions of sequences.
347
+ The KMP table is used to efficiently find occurrences of a pattern within a sequence by avoiding unnecessary
348
+ comparisons after a mismatch. This table determines how many characters can be skipped after a mismatch.
364
349
 
365
350
  Example
366
- ==========
367
- >>> cos_sim("hello world", "world hello")
368
- 0.9999999999999998
351
+ ========
352
+ >>> kmp_table("AGCTGATCGTACGTAAGCTAGCTA")
353
+ [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 2, 3, 4, 1, 2, 3, 4, 1]
369
354
  >>>
370
- :param seq1: First sequence to compare.
371
- :param seq2: Second sequence to compare.
372
- :param is_vector: A boolean indicating whether the input sequences are numerical vectors. Default is False.
373
- :return: The cosine similarity between the two sequences, ranging from -1 to 1.
355
+ :param pattern: The pattern for which to generate the KMP table.
356
+ :return: A list representing the KMP table for the given pattern.
374
357
 
375
358
 
376
- replace(seq: Union[list, tuple], old: Union[list, tuple], new: Union[list, tuple], count: int = -1) -> Union[list, tuple]
359
+ findall(seq: Union[list, tuple, str], pat: Union[list, tuple, str]) -> list
377
360
  Introduction
378
361
  ==========
379
- Replace occurrences of the subsequence 'old' in 'seq' with 'new'.
362
+ Find all indices of the subsequence 'pat' in 'seq'.
380
363
 
381
- This function is designed to handle sequences such as lists or tuples and replace specified subsequences
382
- with new ones. It also allows limiting the number of replacements.
364
+ This function is designed to handle sequences such as lists, tuples, or strings and find all indices
365
+ of specified subsequences. It allows overlapping matches.
383
366
 
384
367
  Example
385
- ==========
386
- >>> replace([1, 2, 3, 4, 2, 3], [2, 3], [5, 6])
387
- [1, 5, 6, 4, 5, 6]
368
+ ========
369
+ >>> findall([2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2])
370
+ [1, 3]
388
371
  >>>
389
- :param seq: The sequence in which to replace the subsequence.
390
- :param old: The subsequence to be replaced.
391
- :param new: The subsequence to replace with.
392
- :param count: The maximum number of replacements to perform. Default is -1 (unlimited).
393
- :return: The modified sequence with replacements.
372
+ :param seq: The sequence in which to find the subsequence.
373
+ :param pat: The subsequence to be found.
374
+ :return: A list of starting indices where the subsequence is found.
375
+
376
+
377
+ ---------------------------------------------------------------------------------------
378
+ | q-functions generalize classical math functions by introducing parameter q. |
379
+ | They are key in combinatorics and special functions, widely applied. |
380
+ | As q approaches 1, they revert to classical forms. |
381
+ | Examples include q-factorials, q-binomial coefficients, Jackson q-Bessel functions. |
382
+ | These functions are crucial in fractals, chaotic systems, quantum groups. |
383
+ | They provide tools for solving complex mathematical challenges effectively. |
384
+ ---------------------------------------------------------------------------------------
385
+
386
+
387
+ Here are the 12 new q-functions added in the current version (adding the previous 4 makes a total of 16):
394
388
 
395
- !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
396
389
 
397
- Other functions and classes have
398
- also undergone certain
399
- modifications, such as adding a
400
- "reduce" parameter to the "qr"
401
- function to determine whether to
402
- crop the matrix.
390
+ qbeta(a: Union[int, float, complex], b: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
391
+ qcos_large(x: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
392
+ qcos_small(x: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
393
+ qcosh_large(x: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
394
+ qcosh_small(x: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
395
+ qexp_large(z: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
396
+ qexp_small(z: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
397
+ qpi(q: Union[int, float, complex]) -> Union[int, float, complex]
398
+ qsin_large(x: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
399
+ qsin_small(x: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
400
+ qsinh_large(x: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
401
+ qsinh_small(x: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
403
402
 
404
403
  !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
405
404
  ```
@@ -500,7 +499,7 @@ PyPyNum
500
499
  │ ├── gamma_pdf(x: Any, shape: Any, scale: Any) -> Any
501
500
  │ ├── geometric_pmf(k: Any, p: Any) -> Any
502
501
  │ ├── hypergeom_pmf(k: Any, mg: Any, n: Any, nt: Any) -> Any
503
- │ ├── inv_gauss_pdf(x: Any, mu: Any, lambda_: Any, alpha: Any) -> Any
502
+ │ ├── invgauss_pdf(x: Any, mu: Any, lambda_: Any, alpha: Any) -> Any
504
503
  │ ├── levy_pdf(x: Any, c: Any) -> Any
505
504
  │ ├── log_logistic_cdf(x: Any, alpha: Any, beta: Any) -> Any
506
505
  │ ├── log_logistic_pdf(x: Any, alpha: Any, beta: Any) -> Any
@@ -646,7 +645,7 @@ PyPyNum
646
645
  │ ├── cosh(x: typing.Union[int, float]) -> typing.Union[int, float]
647
646
  │ ├── cot(x: typing.Union[int, float]) -> typing.Union[int, float]
648
647
  │ ├── coth(x: typing.Union[int, float]) -> typing.Union[int, float]
649
- │ ├── cov(x: typing.Union[list, tuple], y: typing.Union[list, tuple], dof: int) -> typing.Union[int, float, complex]
648
+ │ ├── cov(x: typing.Union[list, tuple], y: typing.Union[list, tuple], ddof: int) -> typing.Union[int, float, complex]
650
649
  │ ├── crt(n: typing.Union[list, tuple], a: typing.Union[list, tuple]) -> int
651
650
  │ ├── csc(x: typing.Union[int, float]) -> typing.Union[int, float]
652
651
  │ ├── csch(x: typing.Union[int, float]) -> typing.Union[int, float]
@@ -694,13 +693,13 @@ PyPyNum
694
693
  │ ├── sinh(x: typing.Union[int, float]) -> typing.Union[int, float]
695
694
  │ ├── skew(data: typing.Union[list, tuple]) -> float
696
695
  │ ├── square_mean(numbers: typing.Union[list, tuple]) -> typing.Union[int, float, complex]
697
- │ ├── std(numbers: typing.Union[list, tuple], dof: int) -> typing.Union[int, float, complex]
696
+ │ ├── std(numbers: typing.Union[list, tuple], ddof: int) -> typing.Union[int, float, complex]
698
697
  │ ├── sumprod(arrays: typing.Union[list, tuple]) -> typing.Union[int, float, complex]
699
698
  │ ├── tan(x: typing.Union[int, float]) -> typing.Union[int, float]
700
699
  │ ├── tanh(x: typing.Union[int, float]) -> typing.Union[int, float]
701
700
  │ ├── totient(n: int) -> int
702
701
  │ ├── upper_gamma(s: typing.Union[int, float, complex], x: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
703
- │ ├── var(numbers: typing.Union[list, tuple], dof: int) -> typing.Union[int, float, complex]
702
+ │ ├── var(numbers: typing.Union[list, tuple], ddof: int) -> typing.Union[int, float, complex]
704
703
  │ ├── xlogy(x: typing.Union[int, float, complex], y: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
705
704
  │ └── zeta(alpha: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
706
705
  ├── matrices
@@ -847,10 +846,22 @@ PyPyNum
847
846
  │ ├── hyp1f1(a0: typing.Union[int, float, complex], b0: typing.Union[int, float, complex], z: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
848
847
  │ ├── hyp2f1(a0: typing.Union[int, float, complex], a1: typing.Union[int, float, complex], b0: typing.Union[int, float, complex], z: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
849
848
  │ ├── hyppfq(a: typing.Union[list, tuple], b: typing.Union[list, tuple], z: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
849
+ │ ├── qbeta(a: typing.Union[int, float, complex], b: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
850
850
  │ ├── qbinomial(n: typing.Union[int, float, complex], m: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
851
+ │ ├── qcos_large(x: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
852
+ │ ├── qcos_small(x: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
853
+ │ ├── qcosh_large(x: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
854
+ │ ├── qcosh_small(x: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
855
+ │ ├── qexp_large(z: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
856
+ │ ├── qexp_small(z: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
851
857
  │ ├── qfactorial(n: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
852
858
  │ ├── qgamma(n: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
853
- └── qpochhammer(a: typing.Union[int, float, complex], q: typing.Union[int, float, complex], n: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
859
+ ├── qpi(q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
860
+ │ ├── qpochhammer(a: typing.Union[int, float, complex], q: typing.Union[int, float, complex], n: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
861
+ │ ├── qsin_large(x: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
862
+ │ ├── qsin_small(x: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
863
+ │ ├── qsinh_large(x: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
864
+ │ └── qsinh_small(x: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
854
865
  ├── stattest
855
866
  │ ├── CLASS
856
867
  │ └── FUNCTION
@@ -883,8 +894,10 @@ PyPyNum
883
894
  │ ├── cos_sim(seq1: typing.Union[list, tuple, str], seq2: typing.Union[list, tuple, str], is_vector: bool) -> float
884
895
  │ ├── dedup(iterable: typing.Union[list, tuple, str]) -> typing.Union[list, tuple, str]
885
896
  │ ├── fast_pow(a: typing.Any, n: int, init: typing.Any, mul: typing.Callable) -> typing.Any
897
+ │ ├── findall(seq: typing.Union[list, tuple, str], pat: typing.Union[list, tuple, str]) -> list
886
898
  │ ├── frange(start: typing.Union[int, float], stop: typing.Union[int, float], step: float) -> list
887
899
  │ ├── geomspace(start: typing.Union[int, float], stop: typing.Union[int, float], number: int) -> list
900
+ │ ├── kmp_table(pattern: typing.Union[list, tuple, str]) -> list
888
901
  │ ├── lcsubseq(x: typing.Union[list, tuple, str], y: typing.Union[list, tuple, str]) -> list
889
902
  │ ├── lcsubstr(x: typing.Union[list, tuple, str], y: typing.Union[list, tuple, str]) -> list
890
903
  │ ├── levenshtein(x: typing.Union[list, tuple, str], y: typing.Union[list, tuple, str]) -> int
@@ -1,13 +1,13 @@
1
1
  pypynum/PyPyNum.png,sha256=t96tJPWfHxT8kcXm_qZI2z5W36TgOqjCU9qdgbmlFws,11623
2
- pypynum/README.md,sha256=y4JBXggitGZ9Gy0b9fmCo4sZbLJ064DqYZ29J0lbVi8,83919
3
- pypynum/__init__.py,sha256=3ozuifHA8CK2c6h9uFuZo3xkTsYgixL4VZesQMeObkw,2640
4
- pypynum/arrays.py,sha256=GpU_smZ-9Bw897tWDGTTPMThQ_VfCvjfrIq6OGpuiDI,15492
5
- pypynum/chars.py,sha256=6XNmH0zYsv0pfadW3KoevrR8xQPIkles9oGikjS6R1I,2181
2
+ pypynum/README.md,sha256=RQ25LQM5-mWR-7bvwgUn2TzuklWLomSeDABoL0QeN2A,87008
3
+ pypynum/__init__.py,sha256=BqVO2tFYX-UWMao6Uy1Zl8snL6H2_GxNM6Chestl02Q,2640
4
+ pypynum/arrays.py,sha256=81dlyUn1xNs1f4enpfQjXEJurjEMfQqaQMfMC3quR8U,15793
5
+ pypynum/chars.py,sha256=HIqTmWl58GypJgVIlgSFVc2icI01NczfbRyu5QmuHz0,2178
6
6
  pypynum/ciphers.py,sha256=kC7wZk3FF-MCCvn2-1YxiaRa4ImDKxyyihJYc6Dyf5E,10008
7
7
  pypynum/consts.py,sha256=enetPwJevWgYXuGEasAb-tXMHpvL2xWKUe-B1gTwInk,8416
8
8
  pypynum/crandom.py,sha256=44GZ7o6y5PwgL-cZLkXUZaAUfiW6aadyRNfMdxTnH30,5111
9
9
  pypynum/dataproc.py,sha256=bJ2a1-S7TQj8V8vzXZ3ooP32fBe99NQU0orPGprEIdg,9231
10
- pypynum/dists.py,sha256=SGxZ08n4mRaqegHILoaJNH4jzPzk-fsE7kvN-EmegPQ,29697
10
+ pypynum/dists.py,sha256=fz7hZZfHFWDHnxo7Li9eNkaj7cQtE6SuYGaitSRwHKc,29695
11
11
  pypynum/equations.py,sha256=_oywKzbrOPOOhD4yu83qqNiIOKQPbJJs6SghdkGbqUw,561
12
12
  pypynum/fft.py,sha256=AtG0tESykzEs4gDsXhcizW7qhQnmw0gjcWcXefBqzhs,1401
13
13
  pypynum/files.py,sha256=iLtTc5UTtUUWoh2sDJl5Yyy_rT8-Vi0pby5c2J95EqE,3397
@@ -18,7 +18,7 @@ pypynum/images.py,sha256=DPpsW_qdoKSrXz3w6DWaQDj9Y_u5l_JYWbNt47taJbs,12157
18
18
  pypynum/interp.py,sha256=wNMa6M_IRpSe026tuRxXfr244oBtgHOpCpYlGd4eyhA,4920
19
19
  pypynum/kernels.py,sha256=GMwWnjLWEprFXSEAIN8d6GZrC2KDx6qhJdbcLBoYOTg,15869
20
20
  pypynum/logics.py,sha256=EwvWFNND14__oWx7o-_oYIUubmVhp3DrvBcnRCWW8vc,10999
21
- pypynum/maths.py,sha256=McuOXRktbjcjZpTfWEoHnmFkeeQVacMoHyThqTIC27E,32808
21
+ pypynum/maths.py,sha256=Q8TX1o3j5g-0VKS2kHiaxMKkvWXa20vGi1jhIuaJsXw,32820
22
22
  pypynum/matrices.py,sha256=useh4_Hlk3YBRTSTJK6SsErTRnDVblsqB0a7iw1mB_k,22439
23
23
  pypynum/multiprec.py,sha256=LCaj0pkZIXmPKodm2Jt5RdyTg20Q6Js-n7PGBzqMXhk,20111
24
24
  pypynum/networks.py,sha256=iSOvC9JW1h4AFGokGGOTkKie5hAYN_YT9H4f3apI9b8,3275
@@ -29,21 +29,21 @@ pypynum/pprinters.py,sha256=Qt9-V5SUyoOqC3lsUU5D5zSSM-MmcnFCUyUtLxhS4pE,2514
29
29
  pypynum/quats.py,sha256=tn1ZogMiV8FGYucZ3u8ynG6SFpPjhFAachVHxgBdDZk,8000
30
30
  pypynum/random.py,sha256=fGaJfwS0QUWV-qb8hldXpRUYJ-79n7Al0gEmPJMAwJc,2254
31
31
  pypynum/regs.py,sha256=mV1r1KkXAv07FmcTntaBF0rcwHBXUyXPvC9h6UOkhE0,2042
32
- pypynum/seqs.py,sha256=Hch8ebCrVFHUfKig54CVGzf3xXkVJlVbLsE0e7flOX4,11666
33
- pypynum/special.py,sha256=58pRacza__MwnovWFRemVglszF1wdUwgA4uyS25M47w,11643
32
+ pypynum/seqs.py,sha256=Y60nSV32wcuY3zyY8h_l185BURkCJoa82BhZVgI3AMY,11681
33
+ pypynum/special.py,sha256=cuucF1Z6CPRaBiffRKKbStfWaZkbOEqLPTIg7zRXLFQ,19748
34
34
  pypynum/stattest.py,sha256=nCAqFjaHVa9EOaWcmgWrhPuBoyLdoypkz6_YeM_AOd8,5511
35
35
  pypynum/symbols.py,sha256=u-Dig3OLs6qoLzxMpTAYJGq5uSWDMvgU13TAHKLyjMY,2768
36
36
  pypynum/tensors.py,sha256=F87npY9VbaCAr0OvTwsW1GAhEQPQAQTVlJzeVuf4zSg,3418
37
37
  pypynum/test.py,sha256=HY6TiQr9-wIadRoXElu8TJkVWKMxcahisyWBtew8B9c,8730
38
38
  pypynum/this.py,sha256=wT7DwodxqOQ7LoDaUtvskMkAb8CODL_56mtXPy12P54,3411
39
- pypynum/tools.py,sha256=PWE4eHVHcFrbKTz-ohiRPc1xo2_FvQj3LpfDvWe8mh0,23035
39
+ pypynum/tools.py,sha256=bxIoWjjnjlasEYnhrk_2nItKGRndwPrk_f2lK7SLUQ4,25422
40
40
  pypynum/trees.py,sha256=b02t69vBjc3ibKaUAkWfBvMDdsugF4DpGC2-q4RsgEU,39779
41
41
  pypynum/types.py,sha256=v1lGIL_p0xgxL6mGX7uBQBHBa7UScKCsgPkW8Q6nzlk,3348
42
42
  pypynum/ufuncs.py,sha256=Lmr_ZVsswQqbGo2MB8gjd_lijRBOZIy2q2wQBOHvYxM,3549
43
43
  pypynum/utils.py,sha256=BhH_iSU44bS6tC3MMrDfIfGhIsQg9nMVlp6fl0-KcRA,21001
44
- pypynum/vectors.py,sha256=GGVk0YSLVm-hzJjm068W7tNRYu8NqPgOKtWHIOTn9yY,3212
45
- pypynum/zh_cn.py,sha256=YBmTCO0h-xMDEo9pfpaR1qvh0qaL811psoZDdBniuzE,13818
46
- PyPyNum-1.16.1.dist-info/METADATA,sha256=CjPWR4mVYBqmVNqYNTXXnA0dhosQvbClUg614eNIzZM,98298
47
- PyPyNum-1.16.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
48
- PyPyNum-1.16.1.dist-info/top_level.txt,sha256=4wW_Xb4bRglmiMsdPAe9f75MkXhNpuN88H17g_Cr5u8,8
49
- PyPyNum-1.16.1.dist-info/RECORD,,
44
+ pypynum/vectors.py,sha256=ANvmI1ftLZPIxO871YLuXUzV6CtvHXrGBf5YIqN_qUE,3390
45
+ pypynum/zh_cn.py,sha256=raTXV7sa9zob3ZtnT263kNFL7NDm-0ZhTrqZIcc88Tk,13812
46
+ PyPyNum-1.16.2.dist-info/METADATA,sha256=K1E_AqE4v-FaRxqCJB8fd4Z_O9jFBlMoPony-pEt_Fc,101387
47
+ PyPyNum-1.16.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
48
+ PyPyNum-1.16.2.dist-info/top_level.txt,sha256=4wW_Xb4bRglmiMsdPAe9f75MkXhNpuN88H17g_Cr5u8,8
49
+ PyPyNum-1.16.2.dist-info/RECORD,,
pypynum/README.md CHANGED
@@ -20,7 +20,7 @@ processing.</font><font color = red>[Python>=3.4]</font>
20
20
  [![Downloads](https://static.pepy.tech/badge/pypynum/month)](https://pepy.tech/project/pypynum)
21
21
  [![Downloads](https://static.pepy.tech/badge/pypynum/week)](https://pepy.tech/project/pypynum)
22
22
 
23
- ## PyPyNum | Version -> 1.16.1 | PyPI -> https://pypi.org/project/PyPyNum/ | Gitee -> https://www.gitee.com/PythonSJL/PyPyNum | GitHub -> https://github.com/PythonSJL/PyPyNum
23
+ ## Version -> 1.16.2 | PyPI -> https://pypi.org/project/PyPyNum/ | Gitee -> https://www.gitee.com/PythonSJL/PyPyNum | GitHub -> https://github.com/PythonSJL/PyPyNum
24
24
 
25
25
  ![LOGO](PyPyNum.png)
26
26
 
@@ -33,6 +33,15 @@ The logo cannot be displayed on PyPI, it can be viewed in Gitee or GitHub.
33
33
  + Update versions periodically to add more practical features
34
34
  + If you need to contact, please add QQ number 2261748025 (Py𝙿𝚢𝚝𝚑𝚘𝚗-水晶兰), or through my email 2261748025@qq.com
35
35
 
36
+ ```
37
+ +++++++++++++++++++++++++++++++++++++++++
38
+ + Tip: +
39
+ + Have suggestions or feature requests? +
40
+ + Feel free to share them with us. +
41
+ + Your feedback is highly appreciated! +
42
+ +++++++++++++++++++++++++++++++++++++++++
43
+ ```
44
+
36
45
  ### Name and Function Introduction of Submodules
37
46
 
38
47
  | Submodule Name | Function Introduction |
@@ -113,79 +122,69 @@ Python interpreter and run it!
113
122
  ```
114
123
  !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
115
124
 
116
- Fixed and improved the basic
117
- operation function of 'Array'.
118
-
119
- !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
120
-
121
- We will remove 'Tensor' in
122
- future versions. Because its
123
- computational functions have
124
- already been implemented in
125
- 'Array'. The current version
126
- will throw 'FutureWarning' as a
127
- warning.
128
-
129
- !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
130
-
131
- Fixed the calculation error of
132
- 'mp_euler_gamma', which was
133
- caused when modifying the
134
- iteration stop condition
135
- previously.
136
-
137
- !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
138
-
139
125
  <<< Here are the newly added functions >>>
140
126
 
141
127
 
142
- cos_sim(seq1: Union[list, tuple, str], seq2: Union[list, tuple, str], is_vector: bool = False) -> float
128
+ kmp_table(pattern: Union[list, tuple, str]) -> list
143
129
  Introduction
144
130
  ==========
145
- Calculate the cosine similarity between two sequences.
131
+ Generate the KMP (Knuth-Morris-Pratt) table for a given pattern.
146
132
 
147
- The cosine similarity is a measure of similarity between two non-zero vectors. It is defined as the cosine of the
148
- angle between them, which is computed as the dot product of the vectors divided by the product of their magnitudes.
149
- This function supports both numerical vectors and frequency distributions of sequences.
133
+ The KMP table is used to efficiently find occurrences of a pattern within a sequence by avoiding unnecessary
134
+ comparisons after a mismatch. This table determines how many characters can be skipped after a mismatch.
150
135
 
151
136
  Example
152
- ==========
153
- >>> cos_sim("hello world", "world hello")
154
- 0.9999999999999998
137
+ ========
138
+ >>> kmp_table("AGCTGATCGTACGTAAGCTAGCTA")
139
+ [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 2, 3, 4, 1, 2, 3, 4, 1]
155
140
  >>>
156
- :param seq1: First sequence to compare.
157
- :param seq2: Second sequence to compare.
158
- :param is_vector: A boolean indicating whether the input sequences are numerical vectors. Default is False.
159
- :return: The cosine similarity between the two sequences, ranging from -1 to 1.
141
+ :param pattern: The pattern for which to generate the KMP table.
142
+ :return: A list representing the KMP table for the given pattern.
160
143
 
161
144
 
162
- replace(seq: Union[list, tuple], old: Union[list, tuple], new: Union[list, tuple], count: int = -1) -> Union[list, tuple]
145
+ findall(seq: Union[list, tuple, str], pat: Union[list, tuple, str]) -> list
163
146
  Introduction
164
147
  ==========
165
- Replace occurrences of the subsequence 'old' in 'seq' with 'new'.
148
+ Find all indices of the subsequence 'pat' in 'seq'.
166
149
 
167
- This function is designed to handle sequences such as lists or tuples and replace specified subsequences
168
- with new ones. It also allows limiting the number of replacements.
150
+ This function is designed to handle sequences such as lists, tuples, or strings and find all indices
151
+ of specified subsequences. It allows overlapping matches.
169
152
 
170
153
  Example
171
- ==========
172
- >>> replace([1, 2, 3, 4, 2, 3], [2, 3], [5, 6])
173
- [1, 5, 6, 4, 5, 6]
154
+ ========
155
+ >>> findall([2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2])
156
+ [1, 3]
174
157
  >>>
175
- :param seq: The sequence in which to replace the subsequence.
176
- :param old: The subsequence to be replaced.
177
- :param new: The subsequence to replace with.
178
- :param count: The maximum number of replacements to perform. Default is -1 (unlimited).
179
- :return: The modified sequence with replacements.
158
+ :param seq: The sequence in which to find the subsequence.
159
+ :param pat: The subsequence to be found.
160
+ :return: A list of starting indices where the subsequence is found.
161
+
162
+
163
+ ---------------------------------------------------------------------------------------
164
+ | q-functions generalize classical math functions by introducing parameter q. |
165
+ | They are key in combinatorics and special functions, widely applied. |
166
+ | As q approaches 1, they revert to classical forms. |
167
+ | Examples include q-factorials, q-binomial coefficients, Jackson q-Bessel functions. |
168
+ | These functions are crucial in fractals, chaotic systems, quantum groups. |
169
+ | They provide tools for solving complex mathematical challenges effectively. |
170
+ ---------------------------------------------------------------------------------------
171
+
172
+
173
+ Here are the 12 new q-functions added in the current version (adding the previous 4 makes a total of 16):
180
174
 
181
- !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
182
175
 
183
- Other functions and classes have
184
- also undergone certain
185
- modifications, such as adding a
186
- "reduce" parameter to the "qr"
187
- function to determine whether to
188
- crop the matrix.
176
+ qbeta(a: Union[int, float, complex], b: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
177
+ qcos_large(x: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
178
+ qcos_small(x: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
179
+ qcosh_large(x: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
180
+ qcosh_small(x: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
181
+ qexp_large(z: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
182
+ qexp_small(z: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
183
+ qpi(q: Union[int, float, complex]) -> Union[int, float, complex]
184
+ qsin_large(x: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
185
+ qsin_small(x: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
186
+ qsinh_large(x: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
187
+ qsinh_small(x: Union[int, float, complex], q: Union[int, float, complex]) -> Union[int, float, complex]
189
188
 
190
189
  !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
191
190
  ```
@@ -286,7 +285,7 @@ PyPyNum
286
285
  │ ├── gamma_pdf(x: Any, shape: Any, scale: Any) -> Any
287
286
  │ ├── geometric_pmf(k: Any, p: Any) -> Any
288
287
  │ ├── hypergeom_pmf(k: Any, mg: Any, n: Any, nt: Any) -> Any
289
- │ ├── inv_gauss_pdf(x: Any, mu: Any, lambda_: Any, alpha: Any) -> Any
288
+ │ ├── invgauss_pdf(x: Any, mu: Any, lambda_: Any, alpha: Any) -> Any
290
289
  │ ├── levy_pdf(x: Any, c: Any) -> Any
291
290
  │ ├── log_logistic_cdf(x: Any, alpha: Any, beta: Any) -> Any
292
291
  │ ├── log_logistic_pdf(x: Any, alpha: Any, beta: Any) -> Any
@@ -432,7 +431,7 @@ PyPyNum
432
431
  │ ├── cosh(x: typing.Union[int, float]) -> typing.Union[int, float]
433
432
  │ ├── cot(x: typing.Union[int, float]) -> typing.Union[int, float]
434
433
  │ ├── coth(x: typing.Union[int, float]) -> typing.Union[int, float]
435
- │ ├── cov(x: typing.Union[list, tuple], y: typing.Union[list, tuple], dof: int) -> typing.Union[int, float, complex]
434
+ │ ├── cov(x: typing.Union[list, tuple], y: typing.Union[list, tuple], ddof: int) -> typing.Union[int, float, complex]
436
435
  │ ├── crt(n: typing.Union[list, tuple], a: typing.Union[list, tuple]) -> int
437
436
  │ ├── csc(x: typing.Union[int, float]) -> typing.Union[int, float]
438
437
  │ ├── csch(x: typing.Union[int, float]) -> typing.Union[int, float]
@@ -480,13 +479,13 @@ PyPyNum
480
479
  │ ├── sinh(x: typing.Union[int, float]) -> typing.Union[int, float]
481
480
  │ ├── skew(data: typing.Union[list, tuple]) -> float
482
481
  │ ├── square_mean(numbers: typing.Union[list, tuple]) -> typing.Union[int, float, complex]
483
- │ ├── std(numbers: typing.Union[list, tuple], dof: int) -> typing.Union[int, float, complex]
482
+ │ ├── std(numbers: typing.Union[list, tuple], ddof: int) -> typing.Union[int, float, complex]
484
483
  │ ├── sumprod(arrays: typing.Union[list, tuple]) -> typing.Union[int, float, complex]
485
484
  │ ├── tan(x: typing.Union[int, float]) -> typing.Union[int, float]
486
485
  │ ├── tanh(x: typing.Union[int, float]) -> typing.Union[int, float]
487
486
  │ ├── totient(n: int) -> int
488
487
  │ ├── upper_gamma(s: typing.Union[int, float, complex], x: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
489
- │ ├── var(numbers: typing.Union[list, tuple], dof: int) -> typing.Union[int, float, complex]
488
+ │ ├── var(numbers: typing.Union[list, tuple], ddof: int) -> typing.Union[int, float, complex]
490
489
  │ ├── xlogy(x: typing.Union[int, float, complex], y: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
491
490
  │ └── zeta(alpha: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
492
491
  ├── matrices
@@ -633,10 +632,22 @@ PyPyNum
633
632
  │ ├── hyp1f1(a0: typing.Union[int, float, complex], b0: typing.Union[int, float, complex], z: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
634
633
  │ ├── hyp2f1(a0: typing.Union[int, float, complex], a1: typing.Union[int, float, complex], b0: typing.Union[int, float, complex], z: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
635
634
  │ ├── hyppfq(a: typing.Union[list, tuple], b: typing.Union[list, tuple], z: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
635
+ │ ├── qbeta(a: typing.Union[int, float, complex], b: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
636
636
  │ ├── qbinomial(n: typing.Union[int, float, complex], m: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
637
+ │ ├── qcos_large(x: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
638
+ │ ├── qcos_small(x: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
639
+ │ ├── qcosh_large(x: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
640
+ │ ├── qcosh_small(x: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
641
+ │ ├── qexp_large(z: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
642
+ │ ├── qexp_small(z: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
637
643
  │ ├── qfactorial(n: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
638
644
  │ ├── qgamma(n: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
639
- └── qpochhammer(a: typing.Union[int, float, complex], q: typing.Union[int, float, complex], n: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
645
+ ├── qpi(q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
646
+ │ ├── qpochhammer(a: typing.Union[int, float, complex], q: typing.Union[int, float, complex], n: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
647
+ │ ├── qsin_large(x: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
648
+ │ ├── qsin_small(x: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
649
+ │ ├── qsinh_large(x: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
650
+ │ └── qsinh_small(x: typing.Union[int, float, complex], q: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
640
651
  ├── stattest
641
652
  │ ├── CLASS
642
653
  │ └── FUNCTION
@@ -669,8 +680,10 @@ PyPyNum
669
680
  │ ├── cos_sim(seq1: typing.Union[list, tuple, str], seq2: typing.Union[list, tuple, str], is_vector: bool) -> float
670
681
  │ ├── dedup(iterable: typing.Union[list, tuple, str]) -> typing.Union[list, tuple, str]
671
682
  │ ├── fast_pow(a: typing.Any, n: int, init: typing.Any, mul: typing.Callable) -> typing.Any
683
+ │ ├── findall(seq: typing.Union[list, tuple, str], pat: typing.Union[list, tuple, str]) -> list
672
684
  │ ├── frange(start: typing.Union[int, float], stop: typing.Union[int, float], step: float) -> list
673
685
  │ ├── geomspace(start: typing.Union[int, float], stop: typing.Union[int, float], number: int) -> list
686
+ │ ├── kmp_table(pattern: typing.Union[list, tuple, str]) -> list
674
687
  │ ├── lcsubseq(x: typing.Union[list, tuple, str], y: typing.Union[list, tuple, str]) -> list
675
688
  │ ├── lcsubstr(x: typing.Union[list, tuple, str], y: typing.Union[list, tuple, str]) -> list
676
689
  │ ├── levenshtein(x: typing.Union[list, tuple, str], y: typing.Union[list, tuple, str]) -> int
pypynum/__init__.py CHANGED
@@ -68,7 +68,7 @@ from .ufuncs import *
68
68
  from .utils import *
69
69
  from .vectors import *
70
70
 
71
- __version__ = "1.16.1"
71
+ __version__ = "1.16.2"
72
72
  print("PyPyNum", "Version -> " + __version__, "PyPI -> https://pypi.org/project/PyPyNum/",
73
73
  "Gitee -> https://www.gitee.com/PythonSJL/PyPyNum", "GitHub -> https://github.com/PythonSJL/PyPyNum", sep=" | ")
74
74
  for _ in list(globals().keys()):
pypynum/arrays.py CHANGED
@@ -294,16 +294,22 @@ def get_shape(data):
294
294
 
295
295
 
296
296
  def is_valid_array(_array, _shape):
297
- if len(_shape) != 1 and not isinstance(_array, list):
298
- raise ArrayError
299
- if len(_shape) == 1:
300
- if not isinstance(_array, list) or len(_array) != _shape[0]:
297
+ def inner(a, s, al, sl):
298
+ if sl == 1:
299
+ if not isinstance(a, list) or al != s[0]:
300
+ raise ArrayError
301
+ elif al == s[0]:
302
+ for i in a:
303
+ if not isinstance(i, list):
304
+ raise ArrayError
305
+ inner(i, s[1:], len(i), sl - 1)
306
+ else:
301
307
  raise ArrayError
302
- elif len(_array) == _shape[0]:
303
- for _ in _array:
304
- is_valid_array(_, _shape[1:])
305
- else:
308
+
309
+ shape_len = len(_shape)
310
+ if shape_len != 1 and not isinstance(_array, list):
306
311
  raise ArrayError
312
+ inner(_array, _shape, len(_array), shape_len)
307
313
 
308
314
 
309
315
  def array(data=None):
@@ -327,12 +333,12 @@ def asarray(data):
327
333
 
328
334
 
329
335
  def full(shape: arr, fill_value: Any, rtype: Callable = Array) -> Any:
330
- def inner(data):
331
- return fill_value if len(data) == 0 else [(inner(data[1:])) for _ in range(data[0])]
336
+ def inner(data, length):
337
+ return fill_value if length == 0 else [inner(data[1:], length - 1) for _ in range(data[0])]
332
338
 
333
339
  if isinstance(fill_value, list):
334
340
  raise TypeError("The filled value cannot be a list")
335
- result = inner(shape)
341
+ result = inner(shape, len(shape))
336
342
  return result if rtype is list else rtype(result)
337
343
 
338
344
 
@@ -374,17 +380,17 @@ def fill(shape: arr, sequence: arr = None, repeat: bool = True, pad: Any = 0, rt
374
380
  total = len(sequence)
375
381
  last = total - 1
376
382
 
377
- def inner(_shape):
383
+ def inner(_shape, depth):
378
384
  nonlocal pointer
379
- if len(_shape) == 0:
385
+ if depth == 0:
380
386
  if pointer == last and not repeat:
381
387
  return pad
382
388
  pointer += 1
383
389
  return sequence[pointer % total]
384
390
  else:
385
- return [inner(_shape[1:]) for _ in range(_shape[0])]
391
+ return [inner(_shape[1:], depth - 1) for _ in range(_shape[0])]
386
392
 
387
- result = inner(shape)
393
+ result = inner(shape, len(shape))
388
394
  return result if rtype is list else rtype(result)
389
395
 
390
396
 
@@ -395,7 +401,9 @@ def tensorproduct(*tensors: Array) -> Array:
395
401
  return tensors[0].copy()
396
402
 
397
403
  def mul(a, b):
398
- return Array(fill(a.shape + b.shape, [i * j for i in a.flatten() for j in b.flatten()], rtype=list), False)
404
+ flattened_a = a.flatten()
405
+ flattened_b = b.flatten()
406
+ return Array(fill(a.shape + b.shape, [i * j for i in flattened_a for j in flattened_b], rtype=list), False)
399
407
 
400
408
  first = tensors[0]
401
409
  for second in tensors[1:]:
pypynum/chars.py CHANGED
@@ -25,7 +25,16 @@ tab = [
25
25
  ["│", "╰", "╯"]
26
26
  ]
27
27
  pi = "Ππ𝜫𝝅𝝥𝝿𝞟𝞹Пп∏ϖ∐ℼㄇ兀"
28
- others = "¬°‰‱′″∀∂∃∅∆∇∈∉∏∐∑∝∞∟∠∣∥∧∨∩∪∫∬∭∮∯∰∴∵∷∽≈≌≒≠≡≢≤≥≪≫≮≯≰≱≲≳⊕⊙⊥⊿⌒㏑㏒"
28
+ notsign = "¬"
29
+ degree = "°"
30
+ permille = "‰"
31
+ permyriad = "‱"
32
+ prime = "′"
33
+ dprime = "″"
34
+ arc = "⌒"
35
+ ln = "㏑"
36
+ log = "㏒"
37
+ others = "".join(map(chr, range(0x2200, 0x2300)))
29
38
 
30
39
 
31
40
  def int2superscript(standard_str: str) -> str:
pypynum/dists.py CHANGED
@@ -284,7 +284,7 @@ def hypergeom_pmf(k, mg, n, nt):
284
284
  return comb(nt, k) * comb(mg - nt, n - k) / comb(mg, n)
285
285
 
286
286
 
287
- def inv_gauss_pdf(x, mu, lambda_, alpha):
287
+ def invgauss_pdf(x, mu, lambda_, alpha):
288
288
  """
289
289
  Introduction
290
290
  ==========
@@ -292,7 +292,7 @@ def inv_gauss_pdf(x, mu, lambda_, alpha):
292
292
 
293
293
  Example
294
294
  =========
295
- >>> inv_gauss_pdf(1, 1, 1, 1)
295
+ >>> invgauss_pdf(1, 1, 1, 1)
296
296
  0.3989422804014327
297
297
  >>>
298
298
  :param x: The value at which to evaluate the PDF. It must be positive.
pypynum/maths.py CHANGED
@@ -639,7 +639,7 @@ def central_moment(data: arr, order: int) -> float:
639
639
  return math.fsum(map(lambda item: (item - avg) ** order, data)) / len(data)
640
640
 
641
641
 
642
- def var(numbers: arr, dof: int = 0) -> num:
642
+ def var(numbers: arr, ddof: int = 0) -> num:
643
643
  """
644
644
  Introduction
645
645
  ==========
@@ -651,10 +651,10 @@ def var(numbers: arr, dof: int = 0) -> num:
651
651
  8.25
652
652
  >>>
653
653
  :param numbers: list | tuple
654
- :param dof: integer
654
+ :param ddof: integer
655
655
  :return:
656
656
  """
657
- if dof >= len(numbers):
657
+ if ddof >= len(numbers):
658
658
  return float("inf")
659
659
  avg = mean(numbers)
660
660
 
@@ -662,7 +662,7 @@ def var(numbers: arr, dof: int = 0) -> num:
662
662
  d = item - avg
663
663
  return d * d
664
664
 
665
- return math.fsum(map(inner, numbers)) / (len(numbers) - dof)
665
+ return math.fsum(map(inner, numbers)) / (len(numbers) - ddof)
666
666
 
667
667
 
668
668
  def skew(data: arr) -> float:
@@ -703,7 +703,7 @@ def kurt(data: arr, fisher: bool = True) -> float:
703
703
  return result
704
704
 
705
705
 
706
- def std(numbers: arr, dof: int = 0) -> num:
706
+ def std(numbers: arr, ddof: int = 0) -> num:
707
707
  """
708
708
  Introduction
709
709
  ==========
@@ -715,13 +715,13 @@ def std(numbers: arr, dof: int = 0) -> num:
715
715
  2.8722813232690143
716
716
  >>>
717
717
  :param numbers: list | tuple
718
- :param dof: integer
718
+ :param ddof: integer
719
719
  :return:
720
720
  """
721
- return math.sqrt(var(numbers, dof=dof))
721
+ return math.sqrt(var(numbers, ddof=ddof))
722
722
 
723
723
 
724
- def cov(x: arr, y: arr, dof: int = 0) -> num:
724
+ def cov(x: arr, y: arr, ddof: int = 0) -> num:
725
725
  """
726
726
  Introduction
727
727
  ==========
@@ -734,14 +734,14 @@ def cov(x: arr, y: arr, dof: int = 0) -> num:
734
734
  >>>
735
735
  :param x: list | tuple
736
736
  :param y: list | tuple
737
- :param dof: integer
737
+ :param ddof: integer
738
738
  :return:
739
739
  """
740
- if dof >= min(len(x), len(y)):
740
+ if ddof >= min(len(x), len(y)):
741
741
  return float("inf")
742
742
  mean_x = mean(x)
743
743
  mean_y = mean(y)
744
- return math.fsum([(x_i - mean_x) * (y_i - mean_y) for x_i, y_i in zip(x, y)]) / (len(x) - dof)
744
+ return math.fsum([(x_i - mean_x) * (y_i - mean_y) for x_i, y_i in zip(x, y)]) / (len(x) - ddof)
745
745
 
746
746
 
747
747
  def corr_coeff(x: arr, y: arr) -> num:
pypynum/seqs.py CHANGED
@@ -54,8 +54,9 @@ def farey(n: int) -> list:
54
54
  return [(0, 1), (1, 1)]
55
55
  else:
56
56
  f = farey(n - 1)
57
+ m = len(f) - 1
57
58
  result = []
58
- for i in range(len(f) - 1):
59
+ for i in range(m):
59
60
  a1, b1 = f[i]
60
61
  a2, b2 = f[i + 1]
61
62
  result.append((a1, b1))
pypynum/special.py CHANGED
@@ -1,6 +1,8 @@
1
1
  import math
2
2
  from .types import arr, num, real
3
3
 
4
+ ConvError = ValueError("The absolute value of q must be less than 1 to ensure convergence.")
5
+
4
6
 
5
7
  def besselj0(x: num) -> num:
6
8
  """
@@ -336,7 +338,7 @@ def qfactorial(n: num, q: num) -> num:
336
338
  :return: The value of the q-factorial.
337
339
  """
338
340
  if abs(q) >= 1:
339
- raise ValueError("The absolute value of q must be less than 1 to ensure convergence.")
341
+ raise ConvError
340
342
  qpoch_q = qpochhammer(q, q)
341
343
  qpoch_q_pow_n = qpochhammer(q ** (1 + n), q)
342
344
  result = qpoch_q / ((1 - q) ** n * qpoch_q_pow_n)
@@ -361,7 +363,7 @@ def qgamma(n: num, q: num) -> num:
361
363
  :return: The value of the q-gamma function.
362
364
  """
363
365
  if abs(q) >= 1:
364
- raise ValueError("The absolute value of q must be less than 1 to ensure convergence.")
366
+ raise ConvError
365
367
  if n == 0:
366
368
  return 1 / (1 - q)
367
369
  qpoch_q = qpochhammer(q, q)
@@ -370,6 +372,34 @@ def qgamma(n: num, q: num) -> num:
370
372
  return result
371
373
 
372
374
 
375
+ def qbeta(a: num, b: num, q: num) -> num:
376
+ """
377
+ Introduction
378
+ ==========
379
+ Calculate the q-beta function for given parameters using the q-gamma function.
380
+
381
+ The q-beta function is defined as: Β_q(a, b) = Γ_q(a) * Γ_q(b) / Γ_q(a + b)
382
+
383
+ Example
384
+ ==========
385
+ >>> qbeta(2, 3, 0.5)
386
+ 0.3047619047619047
387
+ >>>
388
+ :param a: The first parameter of the q-beta function.
389
+ :param b: The second parameter of the q-beta function.
390
+ :param q: The q-parameter, must have an absolute value less than 1 for convergence.
391
+ :return: The value of the q-beta function.
392
+ """
393
+ if abs(q) >= 1:
394
+ raise ConvError
395
+ gamma_a_plus_b = qgamma(a + b, q)
396
+ if gamma_a_plus_b == 0:
397
+ return float("inf")
398
+ gamma_a = qgamma(a, q)
399
+ gamma_b = qgamma(b, q)
400
+ return (gamma_a * gamma_b) / gamma_a_plus_b
401
+
402
+
373
403
  def qbinomial(n: num, m: num, q: num) -> num:
374
404
  """
375
405
  Introduction
@@ -390,8 +420,252 @@ def qbinomial(n: num, m: num, q: num) -> num:
390
420
  :return: The value of the q-binomial coefficient.
391
421
  """
392
422
  if abs(q) >= 1:
393
- raise ValueError("The absolute value of q must be less than 1 to ensure convergence.")
423
+ raise ConvError
394
424
  divisor = qpochhammer(q, q) * qpochhammer(q ** (n + 1), q)
395
425
  if not divisor:
396
426
  return float("inf")
397
427
  return qpochhammer(q ** (m + 1), q) * qpochhammer(q ** (-m + n + 1), q) / divisor
428
+
429
+
430
+ def qexp_small(z: num, q: num) -> num:
431
+ """
432
+ Introduction
433
+ ==========
434
+ Calculate the q-exponential function for small values of z.
435
+
436
+ The q-exponential function is defined as: exp_q(z) = 1 / (z; q)_∞
437
+
438
+ Example
439
+ ==========
440
+ >>> qexp_small(2 + 1j, 0.5 + 0.1j)
441
+ (0.4218918210477187-1.4462561722357514j)
442
+ >>>
443
+ :param z: The argument of the q-exponential function.
444
+ :param q: The q-parameter, must have an absolute value less than 1 for convergence.
445
+ :return: The value of the q-exponential function for small z.
446
+ """
447
+ if abs(q) >= 1:
448
+ raise ConvError
449
+ qpoch_z = qpochhammer(z, q)
450
+ if qpoch_z == 0:
451
+ return float("inf")
452
+ return 1 / qpoch_z
453
+
454
+
455
+ def qexp_large(z: num, q: num) -> num:
456
+ """
457
+ Introduction
458
+ ==========
459
+ Calculate the q-exponential function for large values of z.
460
+
461
+ The q-exponential function is defined as: Exp_q(z) = (-z; q)_∞
462
+
463
+ Example
464
+ ==========
465
+ >>> qexp_large(2 + 1j, 0.5 + 0.1j)
466
+ (0.9080956334931816+11.389341006647559j)
467
+ >>>
468
+ :param z: The argument of the q-exponential function.
469
+ :param q: The q-parameter, must have an absolute value less than 1 for convergence.
470
+ :return: The value of the q-exponential function for large z.
471
+ """
472
+ if abs(q) >= 1:
473
+ raise ConvError
474
+ return qpochhammer(-z, q)
475
+
476
+
477
+ def qsin_small(x: num, q: num) -> num:
478
+ """
479
+ Introduction
480
+ ==========
481
+ Calculate the q-sine function for small values of x.
482
+
483
+ The q-sine function is defined as: sin_q(x) = (exp_q(i*x) - exp_q(-i*x)) / (2*i*q)
484
+
485
+ Example
486
+ ==========
487
+ >>> qsin_small(0.5, 0.5)
488
+ (1.404936279305213+0j)
489
+ >>>
490
+ :param x: The argument of the q-sine function.
491
+ :param q: The q-parameter, must have an absolute value less than 1 for convergence.
492
+ :return: The value of the q-sine function for small x.
493
+ """
494
+ if abs(q) >= 1:
495
+ raise ConvError
496
+ return (qexp_small(1j * x, q) - qexp_small(-1j * x, q)) / (2 * 1j * q)
497
+
498
+
499
+ def qsin_large(x: num, q: num) -> num:
500
+ """
501
+ Introduction
502
+ ==========
503
+ Calculate the q-sine function for large values of x.
504
+
505
+ The q-sine function is defined as: Sin_q(x) = (Exp_q(i*x) - Exp_q(-i*x)) / (2*i*q)
506
+
507
+ Example
508
+ ==========
509
+ >>> qsin_large(0.5, 0.5)
510
+ (1.904966692271702+0j)
511
+ >>>
512
+ :param x: The argument of the q-sine function.
513
+ :param q: The q-parameter, must have an absolute value less than 1 for convergence.
514
+ :return: The value of the q-sine function for large x.
515
+ """
516
+ if abs(q) >= 1:
517
+ raise ConvError
518
+ return (qexp_large(1j * x, q) - qexp_large(-1j * x, q)) / (2 * 1j * q)
519
+
520
+
521
+ def qsinh_small(x: num, q: num) -> num:
522
+ """
523
+ Introduction
524
+ ==========
525
+ Calculate the q-hyperbolic sine function for small values of x.
526
+
527
+ The q-hyperbolic sine function is defined as: sinh_q(x) = (exp_q(x) - exp_q(-x)) / 2
528
+
529
+ Example
530
+ ==========
531
+ >>> qsinh_small(0.5, 0.5)
532
+ 1.521662088829978
533
+ >>>
534
+ :param x: The argument of the q-hyperbolic sine function.
535
+ :param q: The q-parameter, must have an absolute value less than 1 for convergence.
536
+ :return: The value of the q-hyperbolic sine function for small x.
537
+ """
538
+ if abs(q) >= 1:
539
+ raise ConvError
540
+ return (qexp_small(x, q) - qexp_small(-x, q)) / 2
541
+
542
+
543
+ def qsinh_large(x: num, q: num) -> num:
544
+ """
545
+ Introduction
546
+ ==========
547
+ Calculate the q-hyperbolic sine function for large values of x.
548
+
549
+ The q-hyperbolic sine function is defined as: Sinh_q(x) = (Exp_q(x) - Exp_q(-x)) / 2
550
+
551
+ Example
552
+ ==========
553
+ >>> qsinh_large(0.5, 0.5)
554
+ 1.0477214669723844
555
+ >>>
556
+ :param x: The argument of the q-hyperbolic sine function.
557
+ :param q: The q-parameter, must have an absolute value less than 1 for convergence.
558
+ :return: The value of the q-hyperbolic sine function for large x.
559
+ """
560
+ if abs(q) >= 1:
561
+ raise ConvError
562
+ return (qexp_large(x, q) - qexp_large(-x, q)) / 2
563
+
564
+
565
+ def qcos_small(x: num, q: num) -> num:
566
+ """
567
+ Introduction
568
+ ==========
569
+ Calculate the q-cosine function for small values of x.
570
+
571
+ The q-cosine function is defined as: cos_q(x) = (exp_q(i*x) + exp_q(-i*x)) / 2
572
+
573
+ Example
574
+ ==========
575
+ >>> qcos_small(0.5, 0.5)
576
+ (0.49401494605609575+0j)
577
+ >>>
578
+ :param x: The argument of the q-cosine function.
579
+ :param q: The q-parameter, must have an absolute value less than 1 for convergence.
580
+ :return: The value of the q-cosine function for small x.
581
+ """
582
+ if abs(q) >= 1:
583
+ raise ConvError
584
+ return (qexp_small(1j * x, q) + qexp_small(-1j * x, q)) / 2
585
+
586
+
587
+ def qcos_large(x: num, q: num) -> num:
588
+ """
589
+ Introduction
590
+ ==========
591
+ Calculate the q-cosine function for large values of x.
592
+
593
+ The q-cosine function is defined as: Cos_q(x) = (Exp_q(i*x) + Exp_q(-i*x)) / 2
594
+
595
+ Example
596
+ ==========
597
+ >>> qcos_large(0.5, 0.5)
598
+ (0.6698396443906053+0j)
599
+ >>>
600
+ :param x: The argument of the q-cosine function.
601
+ :param q: The q-parameter, must have an absolute value less than 1 for convergence.
602
+ :return: The value of the q-cosine function for large x.
603
+ """
604
+ if abs(q) >= 1:
605
+ raise ConvError
606
+ return (qexp_large(1j * x, q) + qexp_large(-1j * x, q)) / 2
607
+
608
+
609
+ def qcosh_small(x: num, q: num) -> num:
610
+ """
611
+ Introduction
612
+ ==========
613
+ Calculate the q-hyperbolic cosine function for small values of x.
614
+
615
+ The q-hyperbolic cosine function is defined as: cosh_q(x) = (exp_q(x) + exp_q(-x)) / 2
616
+
617
+ Example
618
+ ==========
619
+ >>> qcosh_small(0.5, 0.5)
620
+ 1.9410845306250857
621
+ >>>
622
+ :param x: The argument of the q-hyperbolic cosine function.
623
+ :param q: The q-parameter, must have an absolute value less than 1 for convergence.
624
+ :return: The value of the q-hyperbolic cosine function for small x.
625
+ """
626
+ if abs(q) >= 1:
627
+ raise ConvError
628
+ return (qexp_small(x, q) + qexp_small(-x, q)) / 2
629
+
630
+
631
+ def qcosh_large(x: num, q: num) -> num:
632
+ """
633
+ Introduction
634
+ ==========
635
+ Calculate the q-hyperbolic cosine function for large values of x.
636
+
637
+ The q-hyperbolic cosine function is defined as: Cosh_q(x) = (Exp_q(x) + Exp_q(-x)) / 2
638
+
639
+ Example
640
+ ==========
641
+ >>> qcosh_large(0.5, 0.5)
642
+ 1.3365095620589869
643
+ >>>
644
+ :param x: The argument of the q-hyperbolic cosine function.
645
+ :param q: The q-parameter, must have an absolute value less than 1 for convergence.
646
+ :return: The value of the q-hyperbolic cosine function for large x.
647
+ """
648
+ if abs(q) >= 1:
649
+ raise ConvError
650
+ return (qexp_large(x, q) + qexp_large(-x, q)) / 2
651
+
652
+
653
+ def qpi(q: num) -> num:
654
+ """
655
+ Introduction
656
+ ==========
657
+ Calculate the q-pi function for a given q-parameter.
658
+
659
+ The q-pi function is defined as: π_q = q ^ (1 / 4)([-1 / 2]_(q ^ 2)!) ^ 2
660
+
661
+ Example
662
+ ==========
663
+ >>> qpi(0.5)
664
+ 1.6996350531822835
665
+ >>>
666
+ :param q: The q-parameter, must have an absolute value less than 1 for convergence.
667
+ :return: The value of the q-pi function.
668
+ """
669
+ if abs(q) >= 1:
670
+ raise ValueError("The absolute value of q must be less than 1 to ensure convergence.")
671
+ return q ** 0.25 * qfactorial(-0.5, q * q) ** 2
pypynum/tools.py CHANGED
@@ -581,6 +581,89 @@ def cos_sim(seq1: ite, seq2: ite, is_vector: bool = False) -> float:
581
581
  return dot_product / (magnitude_seq1 * magnitude_seq2)
582
582
 
583
583
 
584
+ def kmp_table(pattern: ite) -> list:
585
+ """
586
+ Introduction
587
+ ==========
588
+ Generate the KMP (Knuth-Morris-Pratt) table for a given pattern.
589
+
590
+ The KMP table is used to efficiently find occurrences of a pattern within a sequence by avoiding unnecessary
591
+ comparisons after a mismatch. This table determines how many characters can be skipped after a mismatch.
592
+
593
+ Example
594
+ ========
595
+ >>> kmp_table("AGCTGATCGTACGTAAGCTAGCTA")
596
+ [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 2, 3, 4, 1, 2, 3, 4, 1]
597
+ >>>
598
+ :param pattern: The pattern for which to generate the KMP table.
599
+ :return: A list representing the KMP table for the given pattern.
600
+ """
601
+ pattern_len = len(pattern)
602
+ table = [0] * pattern_len
603
+ pos, cnd = 1, 0
604
+ while pos < pattern_len:
605
+ if pattern[pos] == pattern[cnd]:
606
+ cnd += 1
607
+ table[pos] = cnd
608
+ pos += 1
609
+ elif cnd > 0:
610
+ cnd = table[cnd - 1]
611
+ else:
612
+ table[pos] = 0
613
+ pos += 1
614
+ return table
615
+
616
+
617
+ def findall(seq: ite, pat: ite) -> list:
618
+ """
619
+ Introduction
620
+ ==========
621
+ Find all indices of the subsequence 'pat' in 'seq'.
622
+
623
+ This function is designed to handle sequences such as lists, tuples, or strings and find all indices
624
+ of specified subsequences. It allows overlapping matches.
625
+
626
+ Example
627
+ ========
628
+ >>> findall([2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2])
629
+ [1, 3]
630
+ >>>
631
+ :param seq: The sequence in which to find the subsequence.
632
+ :param pat: The subsequence to be found.
633
+ :return: A list of starting indices where the subsequence is found.
634
+ """
635
+ if not isinstance(seq, (list, tuple, str)):
636
+ raise TypeError("Parameter 'seq' must be a list, tuple, or string, got {}".format(type(seq)))
637
+ if not isinstance(pat, (list, tuple, str)):
638
+ raise TypeError("Parameter 'pat' must be a list, tuple, or string, got {}".format(type(pat)))
639
+ if not pat:
640
+ raise ValueError("Parameter 'pat' must not be empty")
641
+ if isinstance(seq, str):
642
+ seq = tuple(seq)
643
+ if isinstance(pat, str):
644
+ pat = tuple(pat)
645
+ pat_len = len(pat)
646
+ table = kmp_table(pat)
647
+ indices = []
648
+ i, j = 0, 0
649
+ seq_len = len(seq)
650
+ while i < seq_len:
651
+ if j == pat_len:
652
+ indices.append(i - j)
653
+ j = table[j - 1]
654
+ elif seq[i] == pat[j]:
655
+ i += 1
656
+ j += 1
657
+ else:
658
+ if j != 0:
659
+ j = table[j - 1]
660
+ else:
661
+ i += 1
662
+ if j == pat_len:
663
+ indices.append(i - j)
664
+ return indices
665
+
666
+
584
667
  def replace(seq: arr, old: arr, new: arr, count: int = -1) -> arr:
585
668
  """
586
669
  Introduction
@@ -614,18 +697,7 @@ def replace(seq: arr, old: arr, new: arr, count: int = -1) -> arr:
614
697
  if count == 0:
615
698
  return seq[:]
616
699
  old_len = len(old)
617
- table = [0] * old_len
618
- pos, cnd = 1, 0
619
- while pos < old_len:
620
- if old[pos] == old[cnd]:
621
- cnd += 1
622
- table[pos] = cnd
623
- pos += 1
624
- elif cnd > 0:
625
- cnd = table[cnd - 1]
626
- else:
627
- table[pos] = 0
628
- pos += 1
700
+ table = kmp_table(old)
629
701
  result = []
630
702
  i, j = 0, 0
631
703
  replaced = 0
pypynum/vectors.py CHANGED
@@ -18,73 +18,82 @@ class Vector(Array):
18
18
  raise ShapeError("Vectors can only be one-dimensional in shape")
19
19
  self.len = len(data)
20
20
 
21
- def __add__(self, other):
22
- if self.len != other.len:
23
- raise MatchError
24
- return Vector([self.data[i] + other.data[i] for i in range(self.len)])
25
-
26
- def __sub__(self, other):
27
- if self.len != other.len:
28
- raise MatchError
29
- return Vector([self.data[i] - other.data[i] for i in range(self.len)])
30
-
31
- def __mul__(self, other):
32
- if isinstance(other, Vector):
33
- if self.len != other.len:
34
- raise MatchError
35
- return Vector([self.data[i] * other.data[i] for i in range(self.len)])
36
- else:
37
- return Vector([i * other for i in self.data])
38
-
39
21
  def __matmul__(self, other):
40
22
  if self.len != other.len:
41
23
  raise MatchError
42
- return sum([self.data[i] * other.data[i] for i in range(self.len)])
24
+ return sum([x * y for x, y in zip(self.data, other.data)])
43
25
 
44
26
  def __abs__(self):
45
27
  return self.norm()
46
28
 
47
29
  def __pos__(self):
48
- return Vector([item for item in self.data])
30
+ return Vector([x for x in self.data])
49
31
 
50
32
  def __neg__(self):
51
- return Vector([-item for item in self.data])
33
+ return Vector([-x for x in self.data])
52
34
 
53
35
  def norm(self, p=2):
54
36
  if p == 0:
55
- return len([item for item in self.data if item != 0])
37
+ return len([x for x in self.data if x != 0])
56
38
  elif p == 1:
57
- return sum([abs(item) for item in self.data])
39
+ return sum(map(abs, self.data))
58
40
  elif p == 2:
59
- return sum([i ** 2 for i in self.data]) ** 0.5
41
+ return sum([x ** 2 for x in self.data]) ** 0.5
60
42
  elif p == float("inf"):
61
- return max([abs(item) for item in self.data])
43
+ return max(map(abs, self.data))
62
44
  else:
63
- return sum([i ** p for i in self.data]) ** (1 / p)
45
+ return sum([x ** p for x in self.data]) ** (1 / p)
64
46
 
65
47
  def normalize(self):
66
48
  norm = self.norm()
67
- return Vector([i / norm for i in self.data])
49
+ return Vector([x / norm for x in self.data])
50
+
51
+ def cosine(self, other):
52
+ if self.len != other.len:
53
+ raise MatchError
54
+ dot_product = self @ other
55
+ norm_self = self.norm()
56
+ norm_other = other.norm()
57
+ return dot_product / (norm_self * norm_other)
68
58
 
69
59
  def angles(self, axes=None):
70
60
  from math import acos
61
+ identity = []
62
+ for i in range(self.len):
63
+ unit_vector = [0] * self.len
64
+ unit_vector[i] = 1
65
+ identity.append(Vector(unit_vector))
71
66
  if axes is None or axes == [] or axes == ():
72
- result = []
73
- for a in range(self.len):
74
- axis = Vector([1 if p == a else 0 for p in range(self.len)])
75
- result.append(acos(self @ axis / (self.norm() * axis.norm())))
76
- elif int(abs(axes)) == axes:
77
- axis = Vector([1 if p == axes else 0 for p in range(self.len)])
67
+ result = [acos(self @ axis / (self.norm() * axis.norm())) for axis in identity]
68
+ elif isinstance(axes, int) and axes >= 0:
69
+ axis = identity[axes]
78
70
  result = acos(self @ axis / (self.norm() * axis.norm()))
79
71
  elif isinstance(axes, (list, tuple)):
80
- result = []
81
- for a in axes:
82
- axis = Vector([1 if p == a else 0 for p in range(self.len)])
83
- result.append(acos(self @ axis / (self.norm() * axis.norm())))
72
+ result = [acos(self @ identity[a] / (self.norm() * identity[a].norm())) for a in axes]
84
73
  else:
85
- raise TypeError("The axes parameter can only be None, natural number, list, or tuple")
74
+ raise TypeError("The axes parameter can only be None, non-negative integer, list, or tuple")
86
75
  return result
87
76
 
77
+ def chebyshev(self, other):
78
+ if self.len != other.len:
79
+ raise MatchError
80
+ return max([abs(x - y) for x, y in zip(self.data, other.data)])
81
+
82
+ def manhattan(self, other):
83
+ if self.len != other.len:
84
+ raise MatchError
85
+ return sum([abs(x - y) for x, y in zip(self.data, other.data)])
86
+
87
+ def euclidean(self, other):
88
+ if self.len != other.len:
89
+ raise MatchError
90
+ return sum([(x - y) ** 2 for x, y in zip(self.data, other.data)]) ** 0.5
91
+
92
+ def minkowski(self, other, p):
93
+ if self.len != other.len:
94
+ raise MatchError
95
+ return sum([abs(x - y) ** p for x, y in zip(self.data, other.data)]) ** (1 / p)
96
+
88
97
 
89
98
  def vec(data):
90
99
  return Vector(data)
pypynum/zh_cn.py CHANGED
@@ -225,27 +225,27 @@ def 上伽玛(s: num, x: num) -> num:
225
225
 
226
226
 
227
227
  def 贝塞尔函数J0(x: num) -> num:
228
- return bessel_j0(x)
228
+ return besselj0(x)
229
229
 
230
230
 
231
231
  def 贝塞尔函数J1(x: num) -> num:
232
- return bessel_j1(x)
232
+ return besselj1(x)
233
233
 
234
234
 
235
235
  def 贝塞尔函数Jv(v: real, x: num) -> num:
236
- return bessel_jv(v, x)
236
+ return besseljv(v, x)
237
237
 
238
238
 
239
239
  def 贝塞尔函数I0(x: num) -> num:
240
- return bessel_i0(x)
240
+ return besseli0(x)
241
241
 
242
242
 
243
243
  def 贝塞尔函数I1(x: num) -> num:
244
- return bessel_i1(x)
244
+ return besseli1(x)
245
245
 
246
246
 
247
247
  def 贝塞尔函数Iv(v: real, x: num) -> num:
248
- return bessel_iv(v, x)
248
+ return besseliv(v, x)
249
249
 
250
250
 
251
251
  def 乘积和(*多个数组: List[Any]) -> float: