PyFinitDiff 1.2.1__py3-none-any.whl → 1.2.3__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.
Files changed (41) hide show
  1. PyFinitDiff/VERSION +1 -1
  2. PyFinitDiff/__pycache__/__init__.cpython-311.pyc +0 -0
  3. PyFinitDiff/__pycache__/triplet.cpython-311.pyc +0 -0
  4. PyFinitDiff/__pycache__/utils.cpython-311.pyc +0 -0
  5. PyFinitDiff/coefficients/__pycache__/__init__.cpython-311.pyc +0 -0
  6. PyFinitDiff/coefficients/__pycache__/backward.cpython-311.pyc +0 -0
  7. PyFinitDiff/coefficients/__pycache__/central.cpython-311.pyc +0 -0
  8. PyFinitDiff/coefficients/__pycache__/forward.cpython-311.pyc +0 -0
  9. PyFinitDiff/finite_difference_1D/__pycache__/__init__.cpython-311.pyc +0 -0
  10. PyFinitDiff/finite_difference_1D/__pycache__/boundaries.cpython-311.pyc +0 -0
  11. PyFinitDiff/finite_difference_1D/__pycache__/derivatives.cpython-311.pyc +0 -0
  12. PyFinitDiff/finite_difference_1D/__pycache__/diagonals.cpython-311.pyc +0 -0
  13. PyFinitDiff/finite_difference_1D/__pycache__/finite_difference.cpython-311.pyc +0 -0
  14. PyFinitDiff/finite_difference_1D/__pycache__/meshes.cpython-311.pyc +0 -0
  15. PyFinitDiff/finite_difference_1D/__pycache__/utils.cpython-311.pyc +0 -0
  16. PyFinitDiff/finite_difference_1D/boundaries.py +10 -6
  17. PyFinitDiff/finite_difference_1D/diagonals.py +12 -11
  18. PyFinitDiff/finite_difference_2D/__pycache__/__init__.cpython-311.pyc +0 -0
  19. PyFinitDiff/finite_difference_2D/__pycache__/boundaries.cpython-311.pyc +0 -0
  20. PyFinitDiff/finite_difference_2D/__pycache__/derivative.cpython-311.pyc +0 -0
  21. PyFinitDiff/finite_difference_2D/__pycache__/diagonals.cpython-311.pyc +0 -0
  22. PyFinitDiff/finite_difference_2D/__pycache__/finite_difference.cpython-311.pyc +0 -0
  23. PyFinitDiff/finite_difference_2D/__pycache__/meshes.cpython-311.pyc +0 -0
  24. PyFinitDiff/finite_difference_2D/__pycache__/utils.cpython-311.pyc +0 -0
  25. {PyFinitDiff-1.2.1.dist-info → PyFinitDiff-1.2.3.dist-info}/METADATA +1 -1
  26. {PyFinitDiff-1.2.1.dist-info → PyFinitDiff-1.2.3.dist-info}/RECORD +41 -41
  27. tests/1D/__pycache__/__init__.cpython-311.pyc +0 -0
  28. tests/1D/__pycache__/test_api.cpython-311-pytest-8.2.2.pyc +0 -0
  29. tests/1D/__pycache__/test_derivative.cpython-311-pytest-8.2.2.pyc +0 -0
  30. tests/1D/test_api.py +19 -12
  31. tests/1D/test_derivative.py +30 -9
  32. tests/2D/__pycache__/__init__.cpython-311.pyc +0 -0
  33. tests/2D/__pycache__/test_api.cpython-311-pytest-8.2.2.pyc +0 -0
  34. tests/2D/__pycache__/test_derivative.cpython-311-pytest-8.2.2.pyc +0 -0
  35. tests/2D/__pycache__/test_eigen.cpython-311-pytest-8.2.2.pyc +0 -0
  36. tests/2D/test_api.py +19 -13
  37. tests/2D/test_derivative.py +32 -25
  38. tests/2D/test_eigen.py +21 -6
  39. {PyFinitDiff-1.2.1.dist-info → PyFinitDiff-1.2.3.dist-info}/LICENSE +0 -0
  40. {PyFinitDiff-1.2.1.dist-info → PyFinitDiff-1.2.3.dist-info}/WHEEL +0 -0
  41. {PyFinitDiff-1.2.1.dist-info → PyFinitDiff-1.2.3.dist-info}/top_level.txt +0 -0
PyFinitDiff/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.1
1
+ 1.2.3
@@ -2,13 +2,18 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  import numpy
5
- from dataclasses import dataclass
6
5
 
6
+ from typing import Optional, Union
7
+ from pydantic.dataclasses import dataclass
8
+ from pydantic import ConfigDict
7
9
 
8
- @dataclass(frozen=True)
10
+ config_dict = ConfigDict(extra='forbid', strict=True)
11
+
12
+
13
+ @dataclass(config=config_dict, kw_only=True, frozen=True)
9
14
  class Boundary():
10
15
  name: str
11
- value: str
16
+ value: Union[str, None]
12
17
  mesh_info: object
13
18
 
14
19
  def get_factor(self) -> float:
@@ -40,9 +45,9 @@ class Boundary():
40
45
 
41
46
  @dataclass()
42
47
  class Boundaries():
43
- left: str = 'zero'
48
+ left: Optional[str] = 'zero'
44
49
  """ Value of the left boundary, either ['zero', 'symmetric', 'anti-symmetric'] """
45
- right: str = 'zero'
50
+ right: Optional[str] = 'zero'
46
51
  """ Value of the right boundary, either ['zero', 'symmetric', 'anti-symmetric'] """
47
52
 
48
53
  acceptable_boundary = ['zero', 'symmetric', 'anti-symmetric', 'none']
@@ -99,5 +104,4 @@ class Boundaries():
99
104
  if offset > -self.mesh_info.n_x:
100
105
  return self.get_boundary('left')
101
106
 
102
-
103
107
  # -
@@ -1,5 +1,6 @@
1
- # Built-in imports
2
- from typing import Self
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
3
4
  from dataclasses import dataclass, field
4
5
 
5
6
 
@@ -118,11 +119,11 @@ class DiagonalSet():
118
119
  mesh_info: object
119
120
  diagonals: list = field(default_factory=list)
120
121
 
121
- def append(self, diagonal: Diagonal) -> Self:
122
+ def append(self, diagonal: Diagonal) -> 'DiagonalSet':
122
123
  self.diagonals.append(diagonal)
123
124
  return self
124
125
 
125
- def concatenate(self, other_diagonal_set: Self) -> Self:
126
+ def concatenate(self, other_diagonal_set: 'DiagonalSet') -> 'DiagonalSet':
126
127
  self.diagonals += other_diagonal_set.diagonals
127
128
 
128
129
  return self
@@ -186,12 +187,12 @@ class DiagonalSet():
186
187
 
187
188
  return self.triplet.array[rows_index]
188
189
 
189
- def remove_nan_rows(self) -> Self:
190
+ def remove_nan_rows(self) -> 'DiagonalSet':
190
191
  nan_rows = self.get_row_nan_bool()
191
192
 
192
193
  return self.remove_rows(rows=nan_rows)
193
194
 
194
- def remove_rows(self, rows: numpy.ndarray) -> Self:
195
+ def remove_rows(self, rows: numpy.ndarray) -> 'DiagonalSet':
195
196
  index_to_remove = numpy.isin(self.triplet.rows, rows)
196
197
 
197
198
  self.triplet.array = numpy.delete(
@@ -202,15 +203,15 @@ class DiagonalSet():
202
203
 
203
204
  return self
204
205
 
205
- def replace_nan_rows_with(self, other: Self) -> Self:
206
+ def replace_nan_rows_with(self, other: 'DiagonalSet') -> 'DiagonalSet':
206
207
  """
207
208
  Replace the nan rows in self for the equivalent rows in the other_diagonal_set if any.
208
209
 
209
210
  :param other_diagonal_set: The other diagonal set
210
- :type other_diagonal_set: Self
211
+ :type other_diagonal_set: 'DiagonalSet'
211
212
 
212
213
  :returns: The self instance
213
- :rtype: Self
214
+ :rtype: 'DiagonalSet'
214
215
  """
215
216
  self_nan_rows = self.get_list_of_nan_rows()
216
217
 
@@ -224,7 +225,7 @@ class DiagonalSet():
224
225
 
225
226
  self.triplet.append_array(add_array)
226
227
 
227
- def initialize_triplet(self) -> Self:
228
+ def initialize_triplet(self) -> 'DiagonalSet':
228
229
  triplet = Triplet(
229
230
  array=[0, 0, 0],
230
231
  shape=self.mesh_info.shape
@@ -238,7 +239,7 @@ class DiagonalSet():
238
239
 
239
240
  return self
240
241
 
241
- def __add__(self, other: Self) -> Self:
242
+ def __add__(self, other: 'DiagonalSet') -> 'DiagonalSet':
242
243
  self.diagonals += other.diagonals
243
244
 
244
245
  return self
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyFinitDiff
3
- Version: 1.2.1
3
+ Version: 1.2.3
4
4
  Summary: A package finit-difference matrix generation.
5
5
  Home-page: https://github.com/MartinPdeS/PyFinitDiff
6
6
  Author: Martin Poinsinet de Sivry
@@ -1,32 +1,32 @@
1
- PyFinitDiff/VERSION,sha256=bPTghLR_M8mwLveSedFXgzho-PcFFBaadovjU-4yj-o,6
1
+ PyFinitDiff/VERSION,sha256=2C80rpqkG8Sgy1KaGsCJj-0J1rR5-xzETLZsNPFe6E0,6
2
2
  PyFinitDiff/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  PyFinitDiff/triplet.py,sha256=o_pnW-Y_igF29IosZGQX6WJdX0QZtIGDL2Mu-1X1Ihg,12701
4
4
  PyFinitDiff/utils.py,sha256=oKaaG1qbAjJe3Kd9rS86LuylEuoYu2oPeKgTjKtdxME,3175
5
- PyFinitDiff/__pycache__/__init__.cpython-311.pyc,sha256=b3qsOy5deCGRde_1ng_SHgaoAc2PY9rsBTDqjd6YqFc,174
6
- PyFinitDiff/__pycache__/triplet.cpython-311.pyc,sha256=RlB4ClnZOFp4bWDjXeHEFuPdSNJYRR_FBn-n3izDbv4,21838
7
- PyFinitDiff/__pycache__/utils.cpython-311.pyc,sha256=RbzZL_nsp5kbQ9Pa5FdlCfH44SVqljdHN1ee_QQ9XNI,5020
5
+ PyFinitDiff/__pycache__/__init__.cpython-311.pyc,sha256=Bfp7tVgdD9j4ekwww1nRHfQ_UOJXr3r941ck9knY46U,174
6
+ PyFinitDiff/__pycache__/triplet.cpython-311.pyc,sha256=5MxcAidaZMvaAupxoxN77GRWLMaBfM7uuBFSPcqlhjA,21838
7
+ PyFinitDiff/__pycache__/utils.cpython-311.pyc,sha256=VFS5WUVX9LH53UNal9EOs2vAbMib3VFF_BkTghZ5g1w,5020
8
8
  PyFinitDiff/coefficients/__init__.py,sha256=D6leOHW6065G9S6rdcQLmTc99bhWJ9OldfR8lWYQJIU,4179
9
9
  PyFinitDiff/coefficients/backward.py,sha256=cTti5MkcrhvuJVNURLJqnTcMmSQhdPvRPImu6ZSEsfY,1977
10
10
  PyFinitDiff/coefficients/central.py,sha256=Xq1W-yXnTFLNugYwHajl8XynHPWdV7jH6ll2fy_NVSI,2377
11
11
  PyFinitDiff/coefficients/forward.py,sha256=znCszjYptZpQiINx_VQXFeLTNKhntm3MV1g7CNOW67E,1973
12
- PyFinitDiff/coefficients/__pycache__/__init__.cpython-311.pyc,sha256=Ea0ogUOdSoBIWzWnPZ23uU1JeaIj5Gy-bEJQ_Xew940,7581
13
- PyFinitDiff/coefficients/__pycache__/backward.cpython-311.pyc,sha256=BtJiD-Z9P2V9UBUHQbmmPyHRK47L_RSIVjTKUH6_-Ew,1326
14
- PyFinitDiff/coefficients/__pycache__/central.cpython-311.pyc,sha256=YTMNKR-Zueffg3nsp_MGJoVlNkamMifP92D9-JzNEE0,1404
15
- PyFinitDiff/coefficients/__pycache__/forward.cpython-311.pyc,sha256=hAZzHNtWloVSAZJs1opCLiJE5pOQHNjyH58cDJ1O-Z8,1321
12
+ PyFinitDiff/coefficients/__pycache__/__init__.cpython-311.pyc,sha256=rME1Nk-IhHBM1bowWtJkCqkGwaUIET6GPr9arOqfXAw,7581
13
+ PyFinitDiff/coefficients/__pycache__/backward.cpython-311.pyc,sha256=kZM1b4DReKTR3cdTit4-ZZHveT4dqPp_RLvKuOlHg7o,1326
14
+ PyFinitDiff/coefficients/__pycache__/central.cpython-311.pyc,sha256=zevTxbT8R5BzxxyIzGnziNb7QqtyCRG7roLPRR7lD6Y,1404
15
+ PyFinitDiff/coefficients/__pycache__/forward.cpython-311.pyc,sha256=5SIeGMRiKVAY-bYYuRXsSfqVy_LWaqf3jDy76OKCAbU,1321
16
16
  PyFinitDiff/finite_difference_1D/__init__.py,sha256=ObFxFFDp__KhrEhTluPJmi3jX9nGZEswPsYIk2Ixm-8,153
17
- PyFinitDiff/finite_difference_1D/boundaries.py,sha256=9vmgMENHVI0c-wkORSrDIAYeKcnORhd18Ope45fF99c,3083
17
+ PyFinitDiff/finite_difference_1D/boundaries.py,sha256=J6Mzal-8KVlo4ouA4Lalmnc1pWNBdsmurIDIpMUEc9A,3281
18
18
  PyFinitDiff/finite_difference_1D/derivatives.py,sha256=xCn2qrQ1jUq_0XJCarB4kBNZLd_x4BI_N0idvBYM_a0,1403
19
- PyFinitDiff/finite_difference_1D/diagonals.py,sha256=H7f-PIdCD6CsLmmAcK1PgaepGdHEEbpXqU_hUAF35m8,6909
19
+ PyFinitDiff/finite_difference_1D/diagonals.py,sha256=U_WKLLA-tM8f0dBss9rp1p7VPgM7o_pRHN1iYhHEnnk,7021
20
20
  PyFinitDiff/finite_difference_1D/finite_difference.py,sha256=hGyP8RSvwK2MQrJYrn5p1ux_XgtFvIUD15vYIk5t4LE,5526
21
21
  PyFinitDiff/finite_difference_1D/meshes.py,sha256=YEZf-RsGAwXb-xSK3TCI-fnPjLBbxg0p5RBVOAOLL6o,1153
22
22
  PyFinitDiff/finite_difference_1D/utils.py,sha256=-Vh8jdV30Cl3CkC_W7WzP2EftX6VQeZ8BkrVPj-fOfM,341
23
- PyFinitDiff/finite_difference_1D/__pycache__/__init__.cpython-311.pyc,sha256=duH7iVYvF-uhBVWhgTIdtAj_Ev-IBGfMSM62OIHGz80,388
24
- PyFinitDiff/finite_difference_1D/__pycache__/boundaries.cpython-311.pyc,sha256=U7Ax0OAsMYFAa0RA6nLbDwovux48ijurErrLLrqO3Xw,5230
25
- PyFinitDiff/finite_difference_1D/__pycache__/derivatives.cpython-311.pyc,sha256=tPrZQe3mMG_lbyoRrYf0XLGFIz7yltdHzUCnvI9dESM,1757
26
- PyFinitDiff/finite_difference_1D/__pycache__/diagonals.cpython-311.pyc,sha256=FK3BEBAv6AJDVg_0yi8lGDNpXX2TS2SZrxAE0btEDko,11376
27
- PyFinitDiff/finite_difference_1D/__pycache__/finite_difference.cpython-311.pyc,sha256=2eCPkm5LGSsR9vMsDTNJu9nQF4pRg4oDQgg5UCfXai0,6992
28
- PyFinitDiff/finite_difference_1D/__pycache__/meshes.cpython-311.pyc,sha256=EBE8Ek41rsFdNi0qC6X7cVLWYyMCdkDL-T0borx7O1o,1675
29
- PyFinitDiff/finite_difference_1D/__pycache__/utils.cpython-311.pyc,sha256=yPiFKtYhJeEPJ6H51s8DC95BNyvtLBGrqd_Mq8vi3no,848
23
+ PyFinitDiff/finite_difference_1D/__pycache__/__init__.cpython-311.pyc,sha256=xxfFS0fo88_LyBMcLM5yI63wv2weOWnsso-Sc4jg9fw,388
24
+ PyFinitDiff/finite_difference_1D/__pycache__/boundaries.cpython-311.pyc,sha256=O-04GpTRAfH68tI3f_KHhjC0mfCM54fk0TELuKbXgQU,5554
25
+ PyFinitDiff/finite_difference_1D/__pycache__/derivatives.cpython-311.pyc,sha256=pM4ZoU_EHH3IUtgYywfg7GqRHiwCtnSt6g2KBE32ai4,1757
26
+ PyFinitDiff/finite_difference_1D/__pycache__/diagonals.cpython-311.pyc,sha256=RE4TQUXIYmpNr5b5J2poiHLYZH3KEbkzG4DQ9Nuv4vU,11308
27
+ PyFinitDiff/finite_difference_1D/__pycache__/finite_difference.cpython-311.pyc,sha256=z4AsU3KUC5z8sJnhFyaDXIDxoNY0j4QuvO5tpmfY3Dk,6992
28
+ PyFinitDiff/finite_difference_1D/__pycache__/meshes.cpython-311.pyc,sha256=u_xcJLLr1g34Y9UEF72gidjLJLiFRwohCEuBItGhFjw,1675
29
+ PyFinitDiff/finite_difference_1D/__pycache__/utils.cpython-311.pyc,sha256=CZaxwyGboSlHv63KGu_bDm0TVAE7Kmmei8FeIHp2uiQ,848
30
30
  PyFinitDiff/finite_difference_2D/__init__.py,sha256=ca37gMSuzi5zoy-g4GkSUwTfnN8513dHobOKONg6Ntc,176
31
31
  PyFinitDiff/finite_difference_2D/boundaries.py,sha256=9OgXjUcMiEVfbnArPGocLlixA_nH1qyeDcVxxBXtWaY,4458
32
32
  PyFinitDiff/finite_difference_2D/dense.py,sha256=EJBuX-F_iXSD3sYAvXinhV8ZjnbMsRoGWNWQI4YgK5Q,8971
@@ -35,31 +35,31 @@ PyFinitDiff/finite_difference_2D/diagonals.py,sha256=dECNVSqfO_xnedjZoPgbhH5gTcS
35
35
  PyFinitDiff/finite_difference_2D/finite_difference.py,sha256=vNFFbaG9gm5_hwYT7RWVbyKJzvmCFrCCOFLMC-f1VOk,6174
36
36
  PyFinitDiff/finite_difference_2D/meshes.py,sha256=WABzzBU1ShfaJVhNZz8J3R5YgoJgmT7iCnjK_J1dRcU,1457
37
37
  PyFinitDiff/finite_difference_2D/utils.py,sha256=zP_mxy_HHXrii3YRvBbKYTy5lKLtEuIB2RvJPyBp63I,493
38
- PyFinitDiff/finite_difference_2D/__pycache__/__init__.cpython-311.pyc,sha256=VTdwLWw8QZ3zSKPUHqupaZRbtiENoD-2ak05-YTGVdc,387
39
- PyFinitDiff/finite_difference_2D/__pycache__/boundaries.cpython-311.pyc,sha256=0wvkIQ42wNzqNsPey9Um22nL91G2YeC90weTu33Zong,6683
40
- PyFinitDiff/finite_difference_2D/__pycache__/derivative.cpython-311.pyc,sha256=VOzL3CfA7uQTcKQj1COjMw23r5KkxHZJ87QzOkYtipE,2488
41
- PyFinitDiff/finite_difference_2D/__pycache__/diagonals.cpython-311.pyc,sha256=HO0W6ztj_GZaH5yvpW5K6a8jQP9etu-eDbqzupgtFvA,12184
42
- PyFinitDiff/finite_difference_2D/__pycache__/finite_difference.cpython-311.pyc,sha256=VtIQmd9HoOgOmoYmxOyA8-sd1BH5cg5LQa4WTJqKmPw,7697
43
- PyFinitDiff/finite_difference_2D/__pycache__/meshes.cpython-311.pyc,sha256=RSz6-wNN8zbaa2HWRzqMxcH8wM4rn8Ur-aMzitXhgkY,2069
44
- PyFinitDiff/finite_difference_2D/__pycache__/utils.cpython-311.pyc,sha256=ywT1s0wHmPuJiMUT-gPLC9aieo_fhbT15wBavDkXjj0,963
38
+ PyFinitDiff/finite_difference_2D/__pycache__/__init__.cpython-311.pyc,sha256=dvsiHTD6JWrktssxQx8jd1VX5wcrGbkWZjrscHo7Vfg,387
39
+ PyFinitDiff/finite_difference_2D/__pycache__/boundaries.cpython-311.pyc,sha256=YGLBPC8x3rftWemXY0DQO6qkdVyOBul8T9qhRvKAo8g,6683
40
+ PyFinitDiff/finite_difference_2D/__pycache__/derivative.cpython-311.pyc,sha256=Gsw6-DBGfKSCVGXODhzQr6GxWYq6PT-nyixYCgUTfcQ,2488
41
+ PyFinitDiff/finite_difference_2D/__pycache__/diagonals.cpython-311.pyc,sha256=GZVLUqHz_HeD7hp0GQOtQrZBvTYbiVmYPMH8LjMxdbQ,12184
42
+ PyFinitDiff/finite_difference_2D/__pycache__/finite_difference.cpython-311.pyc,sha256=y6Er2g-UCBq2DgjWuUUEuEU457z5j7jLU8lvJe1Do9A,7697
43
+ PyFinitDiff/finite_difference_2D/__pycache__/meshes.cpython-311.pyc,sha256=X7k8bf70N6YtNczOVTagcBfekEKTJlJxCerNfvUhzLI,2069
44
+ PyFinitDiff/finite_difference_2D/__pycache__/utils.cpython-311.pyc,sha256=xc2kxMcqqUr53oC2VK5u80Ay3Ty3Okq6l2d6RnQ5Uow,963
45
45
  PyFinitDiff/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
46
  PyFinitDiff/tools/directories.py,sha256=CjG37eY-Z68Czo5L7MzHJpu8KEJNhZPnh5VB5MTQ2Tg,837
47
47
  tests/1D/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
- tests/1D/test_api.py,sha256=9knTd2na6saUbB7fI2Psogy6NQZyxcyEmYvGecKJ6Fc,719
49
- tests/1D/test_derivative.py,sha256=QNnx26JxXp26Jj1Uk_LkpPREA5Z_c8Sxo5bR5WworBA,1057
50
- tests/1D/__pycache__/__init__.cpython-311.pyc,sha256=Q_iuoVGlE4a82d6Dcc1kiSuDSba5kFIhWgwSM1c2dZk,171
51
- tests/1D/__pycache__/test_api.cpython-311-pytest-8.2.2.pyc,sha256=6HI1O792FoL4XrK9x12NUAZPtiDNCcIkyqgWY-e2ci8,1374
52
- tests/1D/__pycache__/test_derivative.cpython-311-pytest-8.2.2.pyc,sha256=NZvgtVtNJwHcVrtbQ2Oi345dNT3Rx2hnbqL-51KR3r0,2677
48
+ tests/1D/test_api.py,sha256=A69vKTYoka7Xc2CCbsodzJOURzkVAipWlRQZQDdIoWY,1384
49
+ tests/1D/test_derivative.py,sha256=K0r0zg_Ds3WzIM3g37Jgrgk_ZmlYW64MZUhmgxBjIjs,2088
50
+ tests/1D/__pycache__/__init__.cpython-311.pyc,sha256=WQ2gfd2pRRI_e0pakPEZ4eVf03DaIdGE2np5i1_jiwI,171
51
+ tests/1D/__pycache__/test_api.cpython-311-pytest-8.2.2.pyc,sha256=xvtJ1kHbYi3MarIRip3XMyRuz18BrnTsuw_Oco1qe4I,2076
52
+ tests/1D/__pycache__/test_derivative.cpython-311-pytest-8.2.2.pyc,sha256=W6D0dcdw7yow06b2qJFwvz-GUjyvdF8nvNNSO9RcgDY,3335
53
53
  tests/2D/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
- tests/2D/test_api.py,sha256=gL5tWo08i-parto-bY7D0FIL6FrHWYlisJ_aJdXlWq4,1015
55
- tests/2D/test_derivative.py,sha256=bxv-uFlU47WL0UUmvOnMvYWs_PeVjkyHdGjYxxiWJMA,1593
56
- tests/2D/test_eigen.py,sha256=iT424P3qWsitadPUj7Z9RC6JjI6jFpraJIUOJ2YN8NY,905
57
- tests/2D/__pycache__/__init__.cpython-311.pyc,sha256=-RTTcPdaNB_N4Cpb-Yn_4aUGF5lfw6c7zvGn6cmIz6U,171
58
- tests/2D/__pycache__/test_api.cpython-311-pytest-8.2.2.pyc,sha256=yqRz_o3rGe-BRFbueS3adLHG-eWRFacMzgIWYiMn7Ag,1563
59
- tests/2D/__pycache__/test_derivative.cpython-311-pytest-8.2.2.pyc,sha256=Tinb4XkLj94DjihgdgXMuLWEC3J1uUAO-gsGMQOi3pY,3450
60
- tests/2D/__pycache__/test_eigen.cpython-311-pytest-8.2.2.pyc,sha256=rZfIe8EVp2gFL1V0Hz-ZxkjmIzqiz0T-K_mXkJYvhXc,1458
61
- PyFinitDiff-1.2.1.dist-info/LICENSE,sha256=U6YG4UEW9XJzHa53oijR0qw6JNN_SZ38WOBmYn3NPd0,1072
62
- PyFinitDiff-1.2.1.dist-info/METADATA,sha256=SGcwvYgIUZzexe_TtcbsCiXXoXGV10Wd8KwJuP7o0rY,3779
63
- PyFinitDiff-1.2.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
64
- PyFinitDiff-1.2.1.dist-info/top_level.txt,sha256=2ZG92aJV6elyv6Xl7U2Mhqv6Jcu9s3U2507uMBKTXiI,18
65
- PyFinitDiff-1.2.1.dist-info/RECORD,,
54
+ tests/2D/test_api.py,sha256=uZ_4cgfYhZvdreCpggFfHs_EUfE8YmkGcWDjEMlx-mc,1738
55
+ tests/2D/test_derivative.py,sha256=QkgXlrbZNkasyp_c8pcYYAr-kaA9RVUuhm_Ib66KXOI,2266
56
+ tests/2D/test_eigen.py,sha256=Pn_j_Fqkk6h0k94uOzEYIMyFeUKHDh5STg6BEgd4YAI,1702
57
+ tests/2D/__pycache__/__init__.cpython-311.pyc,sha256=eR_bKVTDaCWwAHPEx49qtaj9MBGlUxGXt4Kuy3ovhKE,171
58
+ tests/2D/__pycache__/test_api.cpython-311-pytest-8.2.2.pyc,sha256=c9Zwv9AZlCgLQjip8lWTaNkIQhq4likZ4iTmSYWfVA0,2292
59
+ tests/2D/__pycache__/test_derivative.cpython-311-pytest-8.2.2.pyc,sha256=AXFXMdgjD1BpoGLQjsAqR6P5VgIbXK_FUUjEVoBDuIo,4128
60
+ tests/2D/__pycache__/test_eigen.cpython-311-pytest-8.2.2.pyc,sha256=1Pin3KbG5GZnWFVT535f1xt7Sv-ehKfyAtTO9BUpGkE,2197
61
+ PyFinitDiff-1.2.3.dist-info/LICENSE,sha256=U6YG4UEW9XJzHa53oijR0qw6JNN_SZ38WOBmYn3NPd0,1072
62
+ PyFinitDiff-1.2.3.dist-info/METADATA,sha256=_lmfDCIY3bAodYjSKWC3AtqjL8BSjA-mEhHRymE59dY,3779
63
+ PyFinitDiff-1.2.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
64
+ PyFinitDiff-1.2.3.dist-info/top_level.txt,sha256=2ZG92aJV6elyv6Xl7U2Mhqv6Jcu9s3U2507uMBKTXiI,18
65
+ PyFinitDiff-1.2.3.dist-info/RECORD,,
tests/1D/test_api.py CHANGED
@@ -2,21 +2,29 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  import pytest
5
+ from PyFinitDiff.finite_difference_1D import FiniteDifference, Boundaries
5
6
 
6
- from PyFinitDiff.finite_difference_1D import FiniteDifference
7
- from PyFinitDiff.finite_difference_1D import Boundaries
8
-
9
- boundaries = [
7
+ # Define boundary conditions for testing
8
+ boundary_conditions = [
10
9
  Boundaries(left='zero', right='zero'),
11
10
  Boundaries(left='symmetric', right='zero')
12
11
  ]
13
12
 
14
13
 
15
- @pytest.mark.parametrize("boundaries", boundaries)
16
- @pytest.mark.parametrize('accuracy', [2, 4, 6], ids=[2, 4, 6])
17
- @pytest.mark.parametrize('derivative', [1, 2], ids=[1, 2])
18
- def test_0(boundaries, accuracy, derivative):
19
- sparse_instance = FiniteDifference(
14
+ @pytest.mark.parametrize("boundaries", boundary_conditions, ids=[b.__repr__() for b in boundary_conditions])
15
+ @pytest.mark.parametrize('accuracy', [2, 4, 6], ids=['accuracy_2', 'accuracy_4', 'accuracy_6'])
16
+ @pytest.mark.parametrize('derivative', [1, 2], ids=['derivative_1', 'derivative_2'])
17
+ def test_finite_difference(boundaries, accuracy, derivative):
18
+ """
19
+ Tests the FiniteDifference class with various boundary conditions, accuracy levels, and derivatives.
20
+
21
+ Args:
22
+ boundaries (Boundaries): Boundary conditions for the finite difference calculation.
23
+ accuracy (int): Accuracy level of the finite difference calculation.
24
+ derivative (int): Order of the derivative for the finite difference calculation.
25
+ """
26
+ # Initialize a FiniteDifference instance with specified parameters
27
+ finite_diff_instance = FiniteDifference(
20
28
  n_x=20,
21
29
  dx=1,
22
30
  derivative=derivative,
@@ -24,6 +32,5 @@ def test_0(boundaries, accuracy, derivative):
24
32
  boundaries=boundaries
25
33
  )
26
34
 
27
- sparse_instance.construct_triplet()
28
-
29
- # -
35
+ # Construct the finite difference triplet representation
36
+ finite_diff_instance.construct_triplet()
@@ -2,23 +2,42 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  import pytest
5
- import numpy
5
+ import numpy as np
6
6
  import math
7
-
8
7
  from PyFinitDiff.finite_difference_1D import get_function_derivative
9
8
 
10
9
 
11
10
  def foo(x, power: int):
11
+ """
12
+ A simple function to return x raised to the power specified.
13
+
14
+ Args:
15
+ x (float): The input value.
16
+ power (int): The power to which x is raised.
17
+
18
+ Returns:
19
+ float: x raised to the specified power.
20
+ """
12
21
  return x**power
13
22
 
14
23
 
24
+ # List of coefficient types to be tested
15
25
  coefficient_type_list = ['central', 'backward', 'forward']
16
26
 
17
27
 
18
28
  @pytest.mark.parametrize("coefficient_type", coefficient_type_list)
19
- @pytest.mark.parametrize("accuracy", [2, 4, 6], ids=[2, 4, 6])
20
- @pytest.mark.parametrize("derivative", [1, 2, 3], ids=[1, 2, 3])
29
+ @pytest.mark.parametrize("accuracy", [2, 4, 6], ids=['accuracy_2', 'accuracy_4', 'accuracy_6'])
30
+ @pytest.mark.parametrize("derivative", [1, 2, 3], ids=['derivative_1', 'derivative_2', 'derivative_3'])
21
31
  def test_central_derivative(accuracy: int, coefficient_type: str, derivative: int):
32
+ """
33
+ Tests the get_function_derivative function with various accuracy levels, coefficient types, and derivatives.
34
+
35
+ Args:
36
+ accuracy (int): Accuracy level of the finite difference calculation.
37
+ coefficient_type (str): Type of finite difference coefficients ('central', 'backward', 'forward').
38
+ derivative (int): Order of the derivative for the finite difference calculation.
39
+ """
40
+ # Evaluate the derivative of the function using finite differences
22
41
  evaluation = get_function_derivative(
23
42
  function=foo,
24
43
  x_eval=3,
@@ -29,11 +48,13 @@ def test_central_derivative(accuracy: int, coefficient_type: str, derivative: in
29
48
  coefficient_type=coefficient_type
30
49
  )
31
50
 
51
+ # Compute the theoretical value of the derivative
32
52
  theoretical = math.factorial(derivative)
33
53
 
34
- discrepency = numpy.isclose(evaluation, theoretical, atol=1e-5)
54
+ # Check if the evaluated derivative is close to the theoretical value
55
+ discrepancy = np.isclose(evaluation, theoretical, atol=1e-5)
35
56
 
36
- assert discrepency, f"[{derivative = } | {accuracy = }] Evaluation output is unexpected. {evaluation = :.7f} | {theoretical = :.7f}"
37
-
38
-
39
- # -
57
+ assert discrepancy, (
58
+ f"[derivative = {derivative} | accuracy = {accuracy}] "
59
+ f"Evaluation output is unexpected. evaluation = {evaluation:.7f} | theoretical = {theoretical:.7f}"
60
+ )
tests/2D/test_api.py CHANGED
@@ -2,15 +2,14 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  import pytest
5
+ from PyFinitDiff.finite_difference_2D import FiniteDifference, Boundaries
5
6
 
6
- from PyFinitDiff.finite_difference_2D import FiniteDifference
7
- from PyFinitDiff.finite_difference_2D import Boundaries
8
-
7
+ # Define accuracies and derivatives to be tested
9
8
  accuracies = [2, 4, 6]
10
-
11
9
  derivatives = [1, 2]
12
10
 
13
- boundaries = [
11
+ # Define boundary conditions for testing
12
+ boundary_conditions = [
14
13
  Boundaries(left='zero', right='zero', top='zero', bottom='zero'),
15
14
  Boundaries(left='symmetric', right='zero', top='zero', bottom='zero'),
16
15
  Boundaries(left='anti-symmetric', right='zero', top='zero', bottom='zero'),
@@ -18,11 +17,20 @@ boundaries = [
18
17
  ]
19
18
 
20
19
 
21
- @pytest.mark.parametrize("boundaries", boundaries)
22
- @pytest.mark.parametrize('accuracy', accuracies)
23
- @pytest.mark.parametrize('derivative', derivatives)
20
+ @pytest.mark.parametrize("boundaries", boundary_conditions, ids=[b.__repr__() for b in boundary_conditions])
21
+ @pytest.mark.parametrize('accuracy', accuracies, ids=['accuracy_2', 'accuracy_4', 'accuracy_6'])
22
+ @pytest.mark.parametrize('derivative', derivatives, ids=['derivative_1', 'derivative_2'])
24
23
  def test_compare_sparse_dense_0(boundaries, accuracy, derivative):
25
- sparse_instance = FiniteDifference(
24
+ """
25
+ Tests the FiniteDifference class with various boundary conditions, accuracy levels, and derivatives.
26
+
27
+ Args:
28
+ boundaries (Boundaries): Boundary conditions for the finite difference calculation.
29
+ accuracy (int): Accuracy level of the finite difference calculation.
30
+ derivative (int): Order of the derivative for the finite difference calculation.
31
+ """
32
+ # Initialize a FiniteDifference instance with specified parameters
33
+ finite_diff_instance = FiniteDifference(
26
34
  n_x=20,
27
35
  n_y=20,
28
36
  dx=1,
@@ -32,7 +40,5 @@ def test_compare_sparse_dense_0(boundaries, accuracy, derivative):
32
40
  boundaries=boundaries
33
41
  )
34
42
 
35
- sparse_instance.construct_triplet()
36
-
37
-
38
- # -
43
+ # Construct the finite difference triplet representation
44
+ finite_diff_instance.construct_triplet()
@@ -1,38 +1,46 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
- import numpy
4
+ import numpy as np
5
5
  import math
6
6
  import pytest
7
-
8
- from PyFinitDiff.finite_difference_2D import FiniteDifference
9
- from PyFinitDiff.finite_difference_2D import Boundaries
7
+ from PyFinitDiff.finite_difference_2D import FiniteDifference, Boundaries
10
8
 
11
9
 
12
10
  def foo(power: int, size: int = 20):
13
- x_array = numpy.arange(0, size) ** power
14
-
15
- y_array = numpy.ones(size)
16
-
17
- x_array, y_array = numpy.meshgrid(x_array, y_array)
18
-
11
+ """
12
+ Generates 2D arrays for testing finite difference calculations.
13
+
14
+ Args:
15
+ power (int): The power to which elements in the x_array are raised.
16
+ size (int, optional): The size of the generated arrays. Default is 20.
17
+
18
+ Returns:
19
+ tuple: A tuple containing the x_array and y_array.
20
+ """
21
+ x_array = np.arange(0, size) ** power
22
+ y_array = np.ones(size)
23
+ x_array, y_array = np.meshgrid(x_array, y_array)
19
24
  return x_array, y_array
20
25
 
21
26
 
27
+ # Define derivatives and accuracies to be tested
22
28
  derivatives = [1, 2, 3]
23
- derivatives_ids = [
24
- f'derivative: {d}' for d in derivatives
25
- ]
26
-
29
+ derivatives_ids = [f'derivative: {d}' for d in derivatives]
27
30
  accuracies = [2, 4, 6]
28
- accuracies_ids = [
29
- f'accuracy: {a}' for a in accuracies
30
- ]
31
+ accuracies_ids = [f'accuracy: {a}' for a in accuracies]
31
32
 
32
33
 
33
34
  @pytest.mark.parametrize('derivative', derivatives, ids=derivatives_ids)
34
35
  @pytest.mark.parametrize('accuracy', accuracies, ids=accuracies_ids)
35
36
  def test_derivative(accuracy, derivative):
37
+ """
38
+ Tests the finite difference derivative calculations with various accuracies and derivatives.
39
+
40
+ Args:
41
+ accuracy (int): Accuracy level of the finite difference calculation.
42
+ derivative (int): Order of the derivative for the finite difference calculation.
43
+ """
36
44
  size = 20
37
45
  x_array, y_array = foo(power=derivative, size=size)
38
46
 
@@ -43,7 +51,7 @@ def test_derivative(accuracy, derivative):
43
51
  left='symmetric'
44
52
  )
45
53
 
46
- finit_difference = FiniteDifference(
54
+ finite_difference = FiniteDifference(
47
55
  n_x=size,
48
56
  n_y=size,
49
57
  dx=1,
@@ -53,17 +61,16 @@ def test_derivative(accuracy, derivative):
53
61
  boundaries=boundaries
54
62
  )
55
63
 
56
- sparse_matrix = finit_difference.triplet.to_scipy_sparse()
57
-
64
+ sparse_matrix = finite_difference.triplet.to_scipy_sparse()
58
65
  y_gradient = sparse_matrix * x_array.ravel()
59
-
60
66
  y_gradient = y_gradient.reshape([size, size])
61
67
 
62
68
  theoretical = math.factorial(derivative)
63
69
  evaluation = y_gradient[size // 2, size // 2]
64
70
 
65
- discrepency = numpy.isclose(evaluation, theoretical, atol=1e-5)
71
+ discrepancy = np.isclose(evaluation, theoretical, atol=1e-5)
66
72
 
67
- assert discrepency, 'Deviation from theoretical value for derivative'
68
-
69
- # -
73
+ assert discrepancy, (
74
+ f'Deviation from theoretical value for derivative. '
75
+ f'Evaluation: {evaluation}, Theoretical: {theoretical}'
76
+ )
tests/2D/test_eigen.py CHANGED
@@ -1,16 +1,28 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding: utf-8 -*-
3
- from scipy.sparse import linalg
4
-
5
3
 
6
- from PyFinitDiff.finite_difference_2D import FiniteDifference
4
+ import pytest
5
+ from scipy.sparse import linalg
6
+ from PyFinitDiff.finite_difference_2D import FiniteDifference, Boundaries
7
7
  from PyFinitDiff.utils import get_2D_circular_mesh_triplet
8
- from PyFinitDiff.finite_difference_2D import Boundaries
8
+
9
+ # Define boundary conditions for testing
10
+ boundary_conditions = [
11
+ Boundaries(left='zero', right='zero', top='zero', bottom='zero'),
12
+ Boundaries(left='symmetric', right='zero', top='zero', bottom='zero'),
13
+ Boundaries(left='anti-symmetric', right='zero', top='zero', bottom='zero'),
14
+ Boundaries(left='anti-symmetric', right='zero', top='symmetric', bottom='zero')
15
+ ]
9
16
 
10
17
 
11
- def test_compute_eigenmode_sparse_0():
18
+ @pytest.mark.parametrize("boundaries", boundary_conditions, ids=[b.__repr__() for b in boundary_conditions])
19
+ def test_compute_eigenmode_sparse_0(boundaries):
20
+ """
21
+ Tests the computation of eigenmodes using sparse matrices with a 2D finite difference method.
22
+ """
12
23
  n_x = n_y = 40
13
24
 
25
+ # Create a FiniteDifference instance with specified parameters
14
26
  sparse_instance = FiniteDifference(
15
27
  n_x=n_x,
16
28
  n_y=n_y,
@@ -18,9 +30,10 @@ def test_compute_eigenmode_sparse_0():
18
30
  dy=1,
19
31
  derivative=2,
20
32
  accuracy=2,
21
- boundaries=Boundaries()
33
+ boundaries=boundaries
22
34
  )
23
35
 
36
+ # Create a 2D circular mesh triplet
24
37
  mesh_triplet = get_2D_circular_mesh_triplet(
25
38
  n_x=n_x,
26
39
  n_y=n_y,
@@ -31,8 +44,10 @@ def test_compute_eigenmode_sparse_0():
31
44
  radius=70
32
45
  )
33
46
 
47
+ # Combine the finite difference triplet with the mesh triplet
34
48
  dynamic_triplet = sparse_instance.triplet + mesh_triplet
35
49
 
50
+ # Compute the eigenvalues and eigenvectors
36
51
  eigen_values, eigen_vectors = linalg.eigs(
37
52
  dynamic_triplet.to_dense(),
38
53
  k=5,