PyFinitDiff 2.0.0.post0__py3-none-any.whl → 2.0.1.post0__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.
PyFinitDiff/_version.py CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '2.0.0.post0'
16
- __version_tuple__ = version_tuple = (2, 0, 0)
15
+ __version__ = version = '2.0.1.post0'
16
+ __version_tuple__ = version_tuple = (2, 0, 1)
@@ -12,7 +12,7 @@ config_dict = ConfigDict(
12
12
  strict=True,
13
13
  arbitrary_types_allowed=True,
14
14
  kw_only=True,
15
- frozen=True
15
+ frozen=False
16
16
  )
17
17
 
18
18
 
@@ -7,7 +7,6 @@ from dataclasses import dataclass, field
7
7
  # Local imports
8
8
  import numpy
9
9
  from PyFinitDiff.triplet import Triplet
10
- from PyFinitDiff.finite_difference_1D.utils import MeshInfo
11
10
  from PyFinitDiff.finite_difference_1D.boundaries import Boundary
12
11
 
13
12
 
@@ -16,7 +16,7 @@ config_dict = ConfigDict(
16
16
  strict=True,
17
17
  arbitrary_types_allowed=True,
18
18
  kw_only=True,
19
- frozen=True
19
+ frozen=False
20
20
  )
21
21
 
22
22
 
@@ -11,7 +11,7 @@ config_dict = ConfigDict(
11
11
  strict=True,
12
12
  arbitrary_types_allowed=True,
13
13
  kw_only=True,
14
- frozen=True
14
+ frozen=False
15
15
  )
16
16
 
17
17
 
@@ -9,7 +9,6 @@ def get_array_derivative(
9
9
  array: np.ndarray,
10
10
  derivative: int,
11
11
  accuracy: int = 4,
12
- coefficient_type: str = 'central',
13
12
  dx: float = 1,
14
13
  dy: float = 1,
15
14
  x_derivative: bool = True,
@@ -22,7 +21,6 @@ def get_array_derivative(
22
21
  array (np.ndarray): The array for which to compute the nth derivative.
23
22
  derivative (int): The order of the derivative.
24
23
  accuracy (int, optional): The accuracy for the derivative. Defaults to 4.
25
- coefficient_type (str, optional): The coefficient type. Defaults to 'central'.
26
24
  dx (float, optional): The delta value in the x direction. Defaults to 1.
27
25
  dy (float, optional): The delta value in the y direction. Defaults to 1.
28
26
  x_derivative (bool, optional): Whether to compute the x derivative. Defaults to True.
@@ -18,7 +18,7 @@ config_dict = ConfigDict(
18
18
  extra='forbid',
19
19
  strict=True,
20
20
  kw_only=True,
21
- frozen=True,
21
+ frozen=False,
22
22
  arbitrary_types_allowed=True
23
23
  )
24
24
 
@@ -17,7 +17,7 @@ config_dict = ConfigDict(
17
17
  strict=True,
18
18
  arbitrary_types_allowed=True,
19
19
  kw_only=True,
20
- frozen=True
20
+ frozen=False
21
21
  )
22
22
 
23
23
 
PyFinitDiff/triplet.py CHANGED
@@ -1,216 +1,108 @@
1
- import numpy
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
2
3
 
3
- from MPSPlots.render2D import SceneList
4
+ from typing import NoReturn, Tuple, Union
5
+ import numpy
4
6
  from scipy.sparse import coo_matrix
5
7
  from dataclasses import dataclass
8
+ import matplotlib.pyplot as plt
6
9
 
7
10
 
8
11
  @dataclass
9
- class Triplet():
10
- shape: list
12
+ class Triplet:
13
+ shape: Tuple[int, int]
11
14
  array: numpy.ndarray
12
15
  add_extra_column: bool = False
13
16
 
14
17
  def __post_init__(self):
18
+ """
19
+ Post-initialization to ensure the correct shape of the input array and to handle optional
20
+ addition of an extra column to the array.
21
+ """
15
22
  self.array = numpy.atleast_2d(self.array)
16
23
  self.shape = numpy.asarray(self.shape)
17
24
 
18
25
  if self.add_extra_column:
19
26
  self.array = numpy.c_[self.array, numpy.ones(self.array.shape[0])]
20
27
 
21
- assert self.array.shape[1] == 3, 'Array shape error'
28
+ if self.array.shape[1] != 3:
29
+ raise ValueError("Array must have exactly 3 columns.")
22
30
 
23
31
  @property
24
32
  def index(self) -> numpy.ndarray:
25
- return self.array[:, 0:2].astype(int)
26
-
27
- @property
28
- def index_with_label(self) -> numpy.ndarray:
29
- return numpy.c_[self.label, self.index].astype(int)
33
+ """Return the first two columns of the array, representing the indices."""
34
+ return self.array[:, :2].astype(int)
30
35
 
31
36
  @property
32
37
  def rows(self) -> numpy.ndarray:
33
- """
34
- Returns the first index i of the Triplet
35
-
36
- :returns: The values associated to the Triplet
37
- :rtype: numpy.ndarray
38
- """
38
+ """Return the row indices (first column)."""
39
39
  return self.array[:, 0].astype(int)
40
40
 
41
41
  @property
42
42
  def columns(self) -> numpy.ndarray:
43
- """
44
- Returns the second index j of the Triplet
45
-
46
- :returns: The values associated to the Triplet
47
- :rtype: numpy.ndarray
48
- """
49
- return self.array[:, 1].astype(int)
50
-
51
- @property
52
- def i(self) -> numpy.ndarray:
53
- """
54
- Returns the first index i of the Triplet
55
-
56
- :returns: The values associated to the Triplet
57
- :rtype: numpy.ndarray
58
- """
59
- return self.array[:, 0].astype(int)
60
-
61
- @property
62
- def j(self) -> numpy.ndarray:
63
- """
64
- Returns the second index j of the Triplet
65
-
66
- :returns: The values associated to the Triplet
67
- :rtype: numpy.ndarray
68
- """
43
+ """Return the column indices (second column)."""
69
44
  return self.array[:, 1].astype(int)
70
45
 
71
46
  @property
72
47
  def values(self) -> numpy.ndarray:
73
- """
74
- Returns the values of the Triplet
75
-
76
- :returns: The values associated to the Triplet
77
- :rtype: numpy.ndarray
78
- """
48
+ """Return the values (third column)."""
79
49
  return self.array[:, 2]
80
50
 
51
+ @values.setter
52
+ def values(self, value: Union[float, numpy.ndarray]) -> None:
53
+ """Set the values in the array."""
54
+ self.array[:, 2] = value
55
+
81
56
  @property
82
57
  def size(self) -> int:
83
- """
84
- Return the size of the Triplet, which means the number of values.
85
-
86
- :returns: Size of the triplet
87
- :rtype: int
88
- """
89
- return self.i.size
58
+ """Return the number of entries in the triplet."""
59
+ return self.array.shape[0]
90
60
 
91
61
  def remove_below_i(self, i_value: int) -> 'Triplet':
92
- idx = self.i > i_value
93
- self.array = self.array[idx, :]
62
+ """Remove all entries with row indices below i_value."""
63
+ self.array = self.array[self.rows > i_value]
94
64
  return self
95
65
 
96
66
  def remove_above_i(self, i_value: int) -> 'Triplet':
97
- idx = self.i < i_value
98
- self.array = self.array[idx, :]
67
+ """Remove all entries with row indices above i_value."""
68
+ self.array = self.array[self.rows < i_value]
99
69
  return self
100
70
 
101
71
  def remove_below_j(self, j_value: int) -> 'Triplet':
102
- idx = self.j > j_value
103
- self.array = self.array[idx, :]
72
+ """Remove all entries with column indices below j_value."""
73
+ self.array = self.array[self.columns > j_value]
104
74
  return self
105
75
 
106
76
  def remove_above_j(self, j_value: int) -> 'Triplet':
107
- idx = self.j < j_value
108
- self.array = self.array[idx, :]
77
+ """Remove all entries with column indices above j_value."""
78
+ self.array = self.array[self.columns < j_value]
109
79
  return self
110
80
 
111
- @values.setter
112
- def values(self, value: float) -> None:
113
- self.array[:, 2] = value
114
-
115
- def delete(self, index) -> None:
81
+ def delete(self, index: numpy.ndarray) -> None:
82
+ """Delete entries at the given indices."""
116
83
  self.array = numpy.delete(self.array, index.astype(int), axis=0)
117
84
 
118
- def append(self, other: object) -> None:
85
+ def append(self, other: 'Triplet') -> None:
86
+ """Append another triplet to this one."""
119
87
  self.array = numpy.r_[self.array, other.array]
120
88
 
121
- def append_array(self, array: object) -> None:
89
+ def append_array(self, array: numpy.ndarray) -> None:
90
+ """Append a NumPy array to this triplet."""
122
91
  self.array = numpy.r_[self.array, array]
123
92
 
124
- def __add__(self, other: object) -> 'Triplet':
125
- """
126
- The methode concatenate the two triplet array and
127
- reduce if any coinciding index values.
128
-
129
- """
130
- new_array = numpy.r_[self.array, other.array]
131
-
132
- new_triplet = Triplet(array=new_array, shape=self.shape)
133
-
134
- return new_triplet.remove_duplicate()
93
+ def __add__(self, other: 'Triplet') -> 'Triplet':
94
+ """Concatenate two triplets and merge any duplicate indices."""
95
+ combined_array = numpy.r_[self.array, other.array]
96
+ return Triplet(array=combined_array, shape=self.shape).remove_duplicate()
135
97
 
136
98
  def __mul__(self, factor: float) -> 'Triplet':
137
- """
138
- The method output a new triplet where the values
139
- are left-multiplied by the factor
140
-
141
- :param factor: The factor
142
- :type factor: float
143
-
144
- :returns: The triplet after multiplication
145
- :rtype: Triplet
146
- """
147
- new_triplet = Triplet(array=self.array, shape=self.shape)
148
-
149
- new_triplet.values *= factor
150
-
151
- return new_triplet
152
-
153
- def __rmul__(self, factor: float) -> 'Triplet':
154
- """
155
- The method output a new triplet where the values
156
- are right-multiplied by the factor
157
-
158
- :param factor: The factor
159
- :type factor: float
160
-
161
- :returns: The triplet after multiplication
162
- :rtype: Triplet
163
- """
164
- return self.__mul__(factor)
165
-
166
- def __div__(self, factor) -> 'Triplet':
167
- """
168
- The method output a new triplet where the values
169
- are left-divided by the factor
99
+ """Multiply all values in the triplet by a factor."""
100
+ return Triplet(array=self.array * [1, 1, factor], shape=self.shape)
170
101
 
171
- :param factor: The factor
172
- :type factor: float
173
-
174
- :returns: The triplet after division
175
- :rtype: Triplet
176
- """
177
- new_triplet = Triplet(array=self.array, shape=self.shape)
178
-
179
- new_triplet /= factor
180
-
181
- return new_triplet
182
-
183
- def __rdiv__(self, factor: float) -> 'Triplet':
184
- """
185
- The method output a new triplet where the values
186
- are right-divided by the factor
187
-
188
- :param factor: The factor
189
- :type factor: float
190
-
191
- :returns: The triplet after division
192
- :rtype: Triplet
193
- """
194
- new_triplet = Triplet(array=self.array, shape=self.shape)
195
-
196
- new_triplet /= factor
197
-
198
- return new_triplet
199
-
200
- def add_triplet(self, *others) -> 'Triplet':
201
- others_array = (other.array for other in others)
202
-
203
- self.array = numpy.r_[(self.array, *others_array)]
204
-
205
- self.merge_duplicate()
102
+ __rmul__ = __mul__
206
103
 
207
104
  def remove_duplicate(self) -> 'Triplet':
208
- """
209
- Removes the duplicate values of the Triplet.
210
-
211
- :returns: The triplet with removed duplicate values
212
- :rtype: Triplet
213
- """
105
+ """Remove duplicate entries by summing their values."""
214
106
  new_array = self.array
215
107
  index_to_delete = []
216
108
  duplicate = self.get_duplicate_index()
@@ -228,222 +120,102 @@ class Triplet():
228
120
 
229
121
  return Triplet(array=triplet_array, shape=self.shape)
230
122
 
231
- def coincide_i(self, mask) -> 'Triplet':
232
- """
233
- The methode removing all index i which do not coincide with the
234
- other triplet
235
- """
236
- mask_i = numpy.unique(mask.i[mask.values != 0])
237
-
238
- temp = (self.array[self.i == i] for i in mask_i)
239
-
240
- self.array = numpy.r_[tuple(temp)]
241
-
242
- def __sub__(self, other: object) -> 'Triplet':
243
- """
244
- The methode removing index[i] (rows) value corresponding between the two triplets.
245
- It doesn't change the other triplet, only the instance that called the method.
246
-
247
- :param other: The other
248
- :type other: object
249
-
250
- :returns: The substracted triplet
251
- :rtype: Triplet
252
- """
253
- index_duplicate = numpy.isin(self.i, other.i)
254
- index_duplicate = numpy.arange(self.size)[index_duplicate]
255
-
256
- triplet_array = numpy.delete(self.array, index_duplicate, axis=0)
257
-
258
- return Triplet(array=triplet_array, shape=self.shape)
259
-
260
- def __iter__(self) -> tuple:
261
- """
262
- Creates an iterator for this container yielding the
263
- indexes i, j and value.
264
-
265
- :returns: The iterator.
266
- :rtype: tuple
267
- """
268
- for i, j, value in self.array:
269
- yield (int(i), int(j)), value
270
-
271
- def enumerate(self, start: int = None, stop: int = None) -> tuple:
272
- """
273
- Does the same as __iter__ but adds an overall single index n.
274
-
275
- :param start: The start
276
- :type start: int
277
- :param stop: The stop
278
- :type stop: int
123
+ def coincide_i(self, mask: 'Triplet') -> None:
124
+ """Remove entries whose row indices do not coincide with those in the mask."""
125
+ mask_i_unique = numpy.unique(mask.rows[mask.values != 0])
126
+ self.array = numpy.vstack([self.array[self.rows == i] for i in mask_i_unique])
279
127
 
280
- :returns: The enumerator
281
- :rtype: tuple
282
- """
283
- for n, (i, j, value) in enumerate(self.array[start:stop, :]):
284
- yield n, (int(i), int(j), value)
128
+ def __sub__(self, other: 'Triplet') -> 'Triplet':
129
+ """Subtract another triplet by removing matching row indices."""
130
+ non_matching_indices = ~numpy.isin(self.rows, other.rows)
131
+ return Triplet(array=self.array[non_matching_indices], shape=self.shape)
285
132
 
286
- def get_duplicate_index(self) -> numpy.ndarray:
287
- """
288
- Gets the duplicate index.
289
-
290
- :returns: The duplicate index.
291
- :rtype: numpy.ndarray
292
- """
293
- _, inverse, count = numpy.unique(self.index, axis=0, return_inverse=True, return_counts=True)
133
+ def __iter__(self):
134
+ """Iterator to yield the indices and values as tuples."""
135
+ return iter((int(i), int(j), value) for i, j, value in self.array)
294
136
 
295
- index_duplicate = numpy.where(count > 1)[0]
137
+ def enumerate(self, start: int = 0, stop: int = None):
138
+ """Enumerate over the entries, yielding an index and the entry values."""
139
+ for idx, (i, j, value) in enumerate(self.array[start:stop], start=start):
140
+ yield idx, (int(i), int(j), value)
296
141
 
297
- rows, cols = numpy.where(inverse == index_duplicate[:, numpy.newaxis])
298
-
299
- _, inverse_rows = numpy.unique(rows, return_index=True)
300
-
301
- return numpy.asarray(numpy.split(cols, inverse_rows[1:]), dtype=object)
302
-
303
- def merge_duplicate(self):
142
+ def merge_duplicate(self) -> None:
143
+ """Merge duplicate entries by summing their values."""
304
144
  duplicates = self.get_duplicate_index()
145
+ if duplicates.size == 0:
146
+ return
147
+ for duplicate in duplicates:
148
+ first_idx = duplicate[0]
149
+ self.array[first_idx, 2] = self.array[duplicate, 2].sum()
150
+ self.delete(duplicate[1:])
305
151
 
306
- if numpy.size(duplicates) == 0:
307
- return self.array
308
-
309
- for duplicate in duplicates: # merge values
310
- self.array[int(duplicate[0]), 2] = self.array[duplicate.astype(int)][:, 2].sum()
311
-
312
- duplicates = [d[1:] for d in duplicates]
313
-
314
- self.array = numpy.delete(self.array, numpy.concatenate(duplicates).astype(int), axis=0)
152
+ def get_duplicate_index(self) -> numpy.ndarray:
153
+ """Get indices of duplicate entries."""
154
+ unique_indices, inverse_indices, counts = numpy.unique(self.index, axis=0, return_inverse=True, return_counts=True)
155
+ duplicate_indices = numpy.where(counts > 1)[0]
156
+ return numpy.array([numpy.where(inverse_indices == idx)[0] for idx in duplicate_indices], dtype=object)
315
157
 
316
158
  @property
317
159
  def max_i(self) -> int:
318
- """
319
- Return max i value, which is the first element of the index format.
320
-
321
- :returns: The maximum index value i
322
- :rtype: int
323
- """
324
- return self.i.max()
160
+ """Return the maximum row index."""
161
+ return self.rows.max()
325
162
 
326
163
  @property
327
164
  def max_j(self) -> int:
328
- """
329
- Return max j value, which is the second element of the index format.
330
-
331
- :returns: The maximum index value j
332
- :rtype: int
333
- """
334
- return self.j.max()
165
+ """Return the maximum column index."""
166
+ return self.columns.max()
335
167
 
336
168
  @property
337
- def min_i(self) -> float:
338
- """
339
- Return min i value, which is the first element of the index format.
340
-
341
- :returns: The minimum index value i
342
- :rtype: float
343
- """
344
- return self.i.min()
169
+ def min_i(self) -> int:
170
+ """Return the minimum row index."""
171
+ return self.rows.min()
345
172
 
346
173
  @property
347
- def min_j(self) -> float:
348
- """
349
- Return max j value, which is the second element of the index format.
350
-
351
- :returns: The minimum index value j
352
- :rtype: float
353
- """
354
- return self.j.min()
174
+ def min_j(self) -> int:
175
+ """Return the minimum column index."""
176
+ return self.columns.min()
355
177
 
356
178
  @property
357
179
  def diagonal(self) -> numpy.ndarray:
358
- """
359
- Return the diagonal element of the Triplet values.
360
-
361
- :returns: The diagonal elements
362
- :rtype: numpy.ndarray
363
- """
364
- return self.array[self.i == self.j]
180
+ """Return the diagonal elements of the triplet."""
181
+ return self.array[self.rows == self.columns]
365
182
 
366
- def shift_diagonal(self, value: float) -> None:
367
- """
368
- Shift the diagonal element of a certain value.
369
-
370
- :param value: The value to shift
371
- :type value: float
372
- """
373
- size = min(self.max_j, self.max_i)
374
- vector = numpy.ones(size) * value
375
- shift_triplet = DiagonalTriplet(vector)
376
-
377
- return self + shift_triplet
183
+ def shift_diagonal(self, value: float) -> 'Triplet':
184
+ """Shift the diagonal elements by a specified value."""
185
+ diagonal_triplet = DiagonalTriplet(numpy.ones(min(self.max_i, self.max_j)) * value, shape=self.shape)
186
+ return self + diagonal_triplet
378
187
 
379
188
  def update_elements(self, other_triplet: 'Triplet', i_range: slice) -> 'Triplet':
189
+ """Update elements within a specified range."""
380
190
  self.array[i_range, :] = other_triplet.array[i_range, :]
381
-
382
191
  return self
383
192
 
384
193
  def to_dense(self) -> numpy.ndarray:
385
- """
386
- Returns a dense representation of the object.
387
-
388
- :returns: Dense representation of the object.
389
- :rtype: numpy.ndarray:
390
- """
391
- dense_matrix = self.to_scipy_sparse().todense()
392
-
393
- dense_matrix = numpy.asarray(dense_matrix)
394
-
395
- return dense_matrix
396
-
397
- def plot(self) -> SceneList:
398
- """
399
- Plot the dense matrix representation of the triplet.
400
-
401
- :returns: The figure
402
- :rtype: SceneList
403
- """
404
- figure = SceneList(unit_size=(6, 6), tight_layout=True)
405
-
406
- ax = figure.append_ax(
407
- title='Finite-difference coefficients structure',
408
- show_legend=False,
409
- show_grid=True,
410
- )
411
-
412
- dense_matrix = numpy.flip(self.to_dense(), axis=[0])
413
-
414
- artist = ax.add_mesh(
415
- scalar=dense_matrix,
416
- )
417
-
418
- ax.add_colorbar(artist=artist, colormap='Blues')
419
-
420
- return figure
194
+ """Convert the triplet to a dense matrix representation."""
195
+ return self.to_scipy_sparse().toarray()
196
+
197
+ def plot(self) -> NoReturn:
198
+ """Plot the dense matrix representation of the triplet."""
199
+ plt.figure()
200
+ plt.title('Finite-difference coefficients structure')
201
+ plt.xlabel('Columns')
202
+ plt.ylabel('Rows')
203
+
204
+ dense_matrix = numpy.flip(self.to_dense(), axis=0)
205
+ plt.pcolormesh(dense_matrix, cmap='Blues')
206
+ plt.gca().set_aspect('equal')
207
+ plt.grid(True)
208
+ plt.colorbar()
209
+ plt.show()
421
210
 
422
211
  def to_scipy_sparse(self) -> coo_matrix:
423
- """
424
- Returns a scipy sparse representation of the object.
425
-
426
- :returns: Scipy sparse representation of the object.
427
- :rtype: coo_matrix
428
- """
429
- size = numpy.prod(self.shape)
430
-
431
- output_shape = [size, size]
432
-
433
- sparse_matrix = coo_matrix((self.values, (self.i, self.j)), shape=output_shape)
434
-
435
- return sparse_matrix
212
+ """Convert the triplet to a SciPy sparse matrix."""
213
+ return coo_matrix((self.values, (self.rows, self.columns)), shape=(numpy.prod(self.shape),) * 2)
436
214
 
437
215
 
438
216
  class DiagonalTriplet(Triplet):
439
- def __init__(self, mesh: numpy.ndarray, shape: list):
217
+ def __init__(self, mesh: numpy.ndarray, shape: Tuple[int, int]):
440
218
  size = mesh.size
441
- triplet_array = numpy.zeros([size, 3])
442
- triplet_array[:, 0] = numpy.arange(size)
443
- triplet_array[:, 1] = numpy.arange(size)
444
- triplet_array[:, 2] = mesh.ravel()
445
-
219
+ triplet_array = numpy.column_stack((numpy.arange(size), numpy.arange(size), mesh.ravel()))
446
220
  super().__init__(array=triplet_array, shape=shape)
447
221
 
448
-
449
- # -
@@ -0,0 +1,175 @@
1
+ Metadata-Version: 2.1
2
+ Name: PyFinitDiff
3
+ Version: 2.0.1.post0
4
+ Summary: A package finit-difference matrix generation.
5
+ Author-email: Martin Poinsinet de Sivry-Houle <martin.poinsinet.de.sivry@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2020 Martin de Sivry
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/MartinPdeS/PyFinitDiff
29
+ Project-URL: Documentation, https://pyfinitdiff.readthedocs.io/en/latest/
30
+ Project-URL: Repository, https://github.com/MartinPdeS/PyFinitDiff.git
31
+ Keywords: finit-difference,matrix
32
+ Classifier: Programming Language :: Python
33
+ Classifier: Programming Language :: Python :: 3
34
+ Classifier: Programming Language :: Python :: 3.11
35
+ Classifier: Programming Language :: Python :: 3.12
36
+ Classifier: Programming Language :: Python :: Implementation :: CPython
37
+ Classifier: Development Status :: 4 - Beta
38
+ Classifier: Topic :: Scientific/Engineering :: Physics
39
+ Classifier: License :: OSI Approved :: MIT License
40
+ Classifier: Intended Audience :: Science/Research
41
+ Requires-Python: >=3.10
42
+ Description-Content-Type: text/x-rst
43
+ License-File: LICENSE
44
+ Requires-Dist: pydantic>=2.6.3
45
+ Requires-Dist: numpy
46
+ Requires-Dist: scipy
47
+ Requires-Dist: MPSPlots
48
+ Requires-Dist: tabulate
49
+ Provides-Extra: documentation
50
+ Requires-Dist: numpydoc==1.8.0; extra == "documentation"
51
+ Requires-Dist: sphinx>=5.1.1; extra == "documentation"
52
+ Requires-Dist: sphinx-gallery==0.17.1; extra == "documentation"
53
+ Requires-Dist: sphinx-rtd-theme==2.0.0; extra == "documentation"
54
+ Requires-Dist: pydata-sphinx-theme==0.15.4; extra == "documentation"
55
+ Provides-Extra: testing
56
+ Requires-Dist: pytest>=0.6; extra == "testing"
57
+ Requires-Dist: pytest-cov>=2.0; extra == "testing"
58
+ Requires-Dist: pytest-json-report==1.5.0; extra == "testing"
59
+ Requires-Dist: mypy>=0.910; extra == "testing"
60
+ Requires-Dist: flake8>=3.9; extra == "testing"
61
+ Requires-Dist: tox>=3.24; extra == "testing"
62
+ Requires-Dist: coverage==7.6.1; extra == "testing"
63
+
64
+ PyFinitDiff
65
+ ===========
66
+
67
+ |python| |docs| |coverage| |PyPi| |PyPi_download|
68
+
69
+ PyFinitDiff
70
+ ===========
71
+
72
+ PyFinitDiff is a robust Python package designed to compute finite-difference matrices with an intuitive API. This package provides an efficient and user-friendly interface for generating finite-difference approximations, making it ideal for numerical analysis and scientific computing.
73
+
74
+
75
+ Features
76
+ ********
77
+ - **Intuitive API**: PyFinitDiff offers an easy-to-use interface that allows users to generate finite-difference matrices with minimal effort.
78
+ - **Versatile Applications**: Suitable for a wide range of numerical methods including solving partial differential equations (PDEs), performing numerical differentiation, and more.
79
+ - **Comprehensive Documentation**: Detailed documentation and examples to help users get started quickly.
80
+
81
+ Installation
82
+ ------------
83
+
84
+ PyFinitDiff requires Python 3.10+ and is available on PyPi for various operating systems including Linux and macOS.
85
+
86
+ Install PyFinitDiff via pip:
87
+
88
+ .. code-block:: bash
89
+
90
+ pip install PyFinitDiff
91
+
92
+ Documentation
93
+ *************
94
+ Comprehensive and up-to-date documentation is available online. You can access it `here <https://pyfinitdiff.readthedocs.io/en/latest/>`_ or by clicking the badge below:
95
+
96
+ |docs|
97
+
98
+ Usage Example
99
+ *************
100
+
101
+ Below is a simple example to illustrate how to use PyFinitDiff:
102
+
103
+ .. code-block:: python
104
+
105
+ from PyFinitDiff.finite_difference_1D import FiniteDifference
106
+ from PyFinitDiff.finite_difference_1D import Boundaries
107
+
108
+ boundaries = Boundaries(left='none', right='none')
109
+
110
+ n_x = 100
111
+ fd = FiniteDifference(
112
+ n_x=n_x,
113
+ dx=1,
114
+ derivative=2,
115
+ accuracy=2,
116
+ boundaries=boundaries
117
+ )
118
+
119
+ fd.triplet.plot()
120
+
121
+ dense_matrix = fd.triplet.to_scipy_sparse()
122
+
123
+ sparse_matrix = fd.triplet.to_scipy_sparse()
124
+
125
+ This would produce the following figure:
126
+
127
+ |example_triplet_0|
128
+
129
+ This example demonstrates the creation of a second-order finite-difference matrix with a specified grid spacing and size.
130
+
131
+ Testing
132
+ *******
133
+
134
+ To test PyFinitDiff locally, clone the GitHub repository and run the tests with coverage:
135
+
136
+ .. code-block:: bash
137
+
138
+ git clone https://github.com/MartinPdeS/PyFinitDiff.git
139
+ cd PyFinitDiff
140
+ pip install PyFinitDiff[testing]
141
+ pytest
142
+
143
+ Contributing
144
+ ************
145
+
146
+ As PyFinitDiff is under continuous development, contributions are welcome! If you would like to collaborate or suggest improvements, feel free to fork the repository and submit a pull request. For major changes, please open an issue first to discuss your ideas.
147
+
148
+ Contact Information
149
+ ********************
150
+ As of 2024, the project is still under development. If you want to collaborate, it would be a pleasure! I encourage you to contact me.
151
+
152
+ PyMieSim was written by `Martin Poinsinet de Sivry-Houle <https://github.com/MartinPdS>`_ .
153
+
154
+ Email:`martin.poinsinet.de.sivry@gmail.ca <mailto:martin.poinsinet.de.sivry@gmail.ca?subject=PyFinitDiff>`_ .
155
+
156
+
157
+ .. |python| image:: https://img.shields.io/pypi/pyversions/pyfinitdiff.svg
158
+ :target: https://www.python.org/
159
+
160
+ .. |example_triplet_0| image:: https://github.com/MartinPdeS/PyFinitDiff/blob/master/docs/images/triplet_example_0.png
161
+ :target: https://www.python.org/
162
+
163
+ .. |docs| image:: https://readthedocs.org/projects/pyfinitdiff/badge/?version=latest
164
+ :target: https://pyfinitdiff.readthedocs.io/en/latest/
165
+ :alt: Documentation Status
166
+
167
+ .. |coverage| image:: https://raw.githubusercontent.com/MartinPdeS/PyFinitDiff/python-coverage-comment-action-data/badge.svg
168
+ :alt: Unittest coverage
169
+ :target: https://htmlpreview.github.io/?https://github.com/MartinPdeS/PyFinitDiff/blob/python-coverage-comment-action-data/htmlcov/index.html
170
+
171
+ .. |PyPi| image:: https://badge.fury.io/py/PyFinitDiff.svg
172
+ :target: https://pypi.org/project/PyFinitDiff/
173
+
174
+ .. |PyPi_download| image:: https://img.shields.io/pypi/dm/pyfinitdiff.svg
175
+ :target: https://pypistats.org/packages/pyfinitdiff
@@ -0,0 +1,27 @@
1
+ PyFinitDiff/__init__.py,sha256=aM48cMAdbYIlGfbEhIvsYBykH2h-u4UpT8DL2utijYQ,121
2
+ PyFinitDiff/_version.py,sha256=Azt7tAUWXPC0gsb9IlTvyJz0fApCN04P0AE4nmRvkxA,417
3
+ PyFinitDiff/triplet.py,sha256=KLV3PENX4ApkNxU-iXoGBrZH2UlJjXbt6ycCvRI9Vuw,8275
4
+ PyFinitDiff/utils.py,sha256=oKaaG1qbAjJe3Kd9rS86LuylEuoYu2oPeKgTjKtdxME,3175
5
+ PyFinitDiff/coefficients/__init__.py,sha256=D6leOHW6065G9S6rdcQLmTc99bhWJ9OldfR8lWYQJIU,4179
6
+ PyFinitDiff/coefficients/backward.py,sha256=cTti5MkcrhvuJVNURLJqnTcMmSQhdPvRPImu6ZSEsfY,1977
7
+ PyFinitDiff/coefficients/central.py,sha256=Xq1W-yXnTFLNugYwHajl8XynHPWdV7jH6ll2fy_NVSI,2377
8
+ PyFinitDiff/coefficients/forward.py,sha256=znCszjYptZpQiINx_VQXFeLTNKhntm3MV1g7CNOW67E,1973
9
+ PyFinitDiff/finite_difference_1D/__init__.py,sha256=VIxWZB2VhtmtnU-Qz-VDGLIz1V1ufqXHyUxlIAYKgW4,237
10
+ PyFinitDiff/finite_difference_1D/boundaries.py,sha256=dImhobxLM5p71NR8pLvxmwOPp3ABIxcWOS3zx--EJ78,6160
11
+ PyFinitDiff/finite_difference_1D/derivative.py,sha256=OK6jN426iXHriiesQSy4hsZEN6z1I6osTw7IUK5aqMY,1476
12
+ PyFinitDiff/finite_difference_1D/diagonals.py,sha256=DB9TlSLZ21Tsxm1c5mMOnGTkcO6ejGgwOcgdU4Xm8dQ,7022
13
+ PyFinitDiff/finite_difference_1D/finite_difference.py,sha256=ZNtPr7A-oCGaXJOVL_m9VZHzMd8jjJFeh-yztBVghf4,5872
14
+ PyFinitDiff/finite_difference_1D/utils.py,sha256=wFToOvAEK3A9VqBf_9e4O3cXRdP_igA_iS-67_5JV3Y,1708
15
+ PyFinitDiff/finite_difference_2D/__init__.py,sha256=TIijlPbN-SiZ9UsaO5zVSZrb5ZsKVm0P63TZ_rjEySU,234
16
+ PyFinitDiff/finite_difference_2D/boundaries.py,sha256=Q88apnODpxBV0TJM21vg2-W4WWt_1fr_OHlR__qIf9s,7313
17
+ PyFinitDiff/finite_difference_2D/derivative.py,sha256=E6E4zkZYUy_lzGxHgBI0i7X9N4r7F41eVfgA1QaUJ70,1690
18
+ PyFinitDiff/finite_difference_2D/diagonals.py,sha256=pQ-SC49feCl1yjAOgoaynaVwHI_ZoGlZTIOZrO_iMoc,9582
19
+ PyFinitDiff/finite_difference_2D/finite_difference.py,sha256=qtlQNm3nTUyztZCkA0-K2n07QrI2J5-hIcVyI6OT1mg,6890
20
+ PyFinitDiff/finite_difference_2D/utils.py,sha256=OZgp9Wk1NuOEwXSf8PvQyHXOe927K37shu-WDjN21CM,2182
21
+ PyFinitDiff/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
+ PyFinitDiff/tools/directories.py,sha256=CjG37eY-Z68Czo5L7MzHJpu8KEJNhZPnh5VB5MTQ2Tg,837
23
+ PyFinitDiff-2.0.1.post0.dist-info/LICENSE,sha256=U6YG4UEW9XJzHa53oijR0qw6JNN_SZ38WOBmYn3NPd0,1072
24
+ PyFinitDiff-2.0.1.post0.dist-info/METADATA,sha256=tU0x3ME4Vaaz78XrCcHKJVGp5YPuFiT4sKa2ojROQ80,6995
25
+ PyFinitDiff-2.0.1.post0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
26
+ PyFinitDiff-2.0.1.post0.dist-info/top_level.txt,sha256=yl_A1Z9VT4HxBK5PTOM4ZyRcXZb-VtbQo1TzRUc1mW4,12
27
+ PyFinitDiff-2.0.1.post0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (73.0.1)
2
+ Generator: setuptools (75.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,238 +0,0 @@
1
- import numpy as np
2
- import numpy
3
- import matplotlib.pyplot as plt
4
- from scipy import sparse
5
- from dataclasses import field
6
- from typing import Dict, Optional
7
-
8
- from pydantic.dataclasses import dataclass
9
- from pydantic import ConfigDict
10
-
11
- from PyFinitDiff.utils import NameSpace
12
- from PyFinitDiff.coefficients import FinitCoefficients
13
-
14
-
15
- config_dict = ConfigDict(extra='forbid', strict=True, kw_only=True, frozen=True)
16
-
17
-
18
- @dataclass(config=config_dict)
19
- class FiniteDifference():
20
- """
21
- Reference : ['math.toronto.edu/mpugh/Teaching/Mat1062/notes2.pdf']
22
- """
23
- n_x: int
24
- n_y: int
25
- dx: Optional[float] = 1
26
- dy: Optional[float] = 1
27
- derivative: Optional[int] = 1
28
- accuracy: Optional[int] = 2
29
- naive: Optional[bool] = False
30
- symmetries: Dict[str, int] = field(default_factory=lambda: ({'left': 0, 'right': 0, 'top': 0, 'bottom': 0}))
31
-
32
- def __post_init__(self):
33
- self.finit_coefficient = FinitCoefficients(
34
- derivative=self.derivative,
35
- accuracy=self.accuracy
36
- )
37
-
38
- @property
39
- def size(self):
40
- return self.n_y * self.n_x
41
-
42
- @property
43
- def shape(self):
44
- return [self.size, self.size]
45
-
46
- def _set_right_boundary_(self, symmetry, mesh: numpy.ndarray) -> numpy.ndarray:
47
- if symmetry in ['symmetric', 1]:
48
- for idx, value in self.finit_coefficient.Central().items():
49
- mesh[self.Index.i == self.Index.j + idx] = (value if idx == 0 else 2 * value if idx > 0 else 0)
50
-
51
- elif symmetry in ['anti_symmetric', -1]:
52
- for idx, value in self.finit_coefficient.Central().items():
53
- mesh[self.Index.i == self.Index.j + idx] = (value if idx == 0 else 0 if idx > 0 else 0)
54
-
55
- elif symmetry in ['zero', 0]:
56
- for idx, value in {0: -2, 1: 1}.items():
57
- mesh[self.Index.i == self.Index.j + idx * self.n_y] = value
58
-
59
- elif symmetry == 'none':
60
- for idx, value in self.finit_coefficient.Forward().items():
61
- mesh[self.Index.i == self.Index.j + idx] = value
62
-
63
- return mesh
64
-
65
- def _set_left_boundary_(self, symmetry, mesh: numpy.ndarray) -> numpy.ndarray:
66
- if symmetry in ['symmetric', 1]:
67
- for idx, value in self.finit_coefficient.Central().items():
68
- mesh[self.Index.i == self.Index.j + idx] = (value if idx == 0 else 2 * value if idx < 0 else 0)
69
-
70
- elif symmetry in ['anti_symmetric', -1]:
71
- for idx, value in self.finit_coefficient.Central().items():
72
- mesh[self.Index.i == self.Index.j + idx] = (value if idx == 0 else 0 if idx < 0 else 0)
73
-
74
- elif symmetry in ['zero', 0]:
75
- for idx, value in {0: -2, -1: 1}.items():
76
- mesh[self.Index.i == self.Index.j + idx * self.n_y] = value
77
-
78
- elif symmetry == 'none':
79
- for idx, value in self.finit_coefficient.Backward().items():
80
- mesh[self.Index.i == self.Index.j + idx] = value
81
-
82
- return mesh
83
-
84
- def _set_top_boundary_(self, symmetry, mesh: numpy.ndarray) -> numpy.ndarray:
85
- if symmetry in ['symmetric', 1]:
86
- for idx, value in self.finit_coefficient.Central().items():
87
- mesh[self.Index.i == self.Index.j + idx * self.n_y] = (value if idx == 0 else 2 * value if idx > 0 else 0)
88
-
89
- elif symmetry in ['anti_symmetric', -1]:
90
- for idx, value in self.finit_coefficient.Central().items():
91
- mesh[self.Index.i == self.Index.j + idx * self.n_y] = (value if idx == 0 else 0 if idx > 0 else 0)
92
-
93
- elif symmetry in ['zero', 0]:
94
- for idx, value in {0: -2, 1: 1}.items():
95
- mesh[self.Index.i == self.Index.j + idx * self.n_y] = value
96
-
97
- elif symmetry == 'none':
98
- for idx, value in self.finit_coefficient.Forward().items():
99
- mesh[self.Index.i == self.Index.j + idx * self.n_y] = value
100
-
101
- return mesh
102
-
103
- def _set_bottom_boundary_(self, symmetry, mesh: numpy.ndarray) -> numpy.ndarray:
104
- if symmetry in ['symmetric', 1]:
105
- for idx, value in self.finit_coefficient.Central().items():
106
- mesh[self.Index.i == self.Index.j + idx * self.n_y] = (value if idx == 0 else 2 * value if idx < 0 else 0)
107
-
108
- elif symmetry in ['anti_symmetric', -1]:
109
- for idx, value in self.finit_coefficient.Central().items():
110
- mesh[self.Index.i == self.Index.j + idx * self.n_y] = (value if idx == 0 else 0 if idx > 0 else 0)
111
-
112
- elif symmetry in ['zero', 0]:
113
- for idx, value in {0: -2, -1: 1}.items():
114
- mesh[self.Index.i == self.Index.j + idx * self.n_y] = value
115
-
116
- elif symmetry == 'none':
117
- for idx, value in self.finit_coefficient.Backward().items():
118
- mesh[self.Index.i == self.Index.j + idx * self.n_y] = value
119
-
120
- return mesh
121
-
122
- def _compute_slices_(self) -> None:
123
- self.slice_right, self.slice_left, self.slice_bottom, self.slice_top = self._get_zeros_(n=4, Type=bool)
124
-
125
- for offset in range(1, self.finit_coefficient.offset_index + 1):
126
- self.slice_right[self.n_y - offset::self.n_y, :] = True
127
-
128
- for offset in range(0, self.finit_coefficient.offset_index):
129
- self.slice_left[offset::self.n_y, :] = True
130
-
131
- for offset in range(1, self.finit_coefficient.offset_index + 1):
132
- self.slice_top[self.size - offset * self.n_y:, :] = True
133
-
134
- for offset in range(1, self.finit_coefficient.offset_index + 1):
135
- self.slice_bottom[:offset * self.n_y, :] = True
136
-
137
- def _get_x_diagonal_(self) -> None:
138
- for idx, value in self.finit_coefficient.Central().items():
139
- self.x_meshes.center[self.Index.i == self.Index.j + idx] = value
140
-
141
- self.x_meshes.right = self._set_right_boundary_(self.symmetries['right'], self.x_meshes.right)
142
- self.x_meshes.left = self._set_left_boundary_(self.symmetries['left'], self.x_meshes.left)
143
-
144
- def _get_zeros_(self, n, Type=float) -> list:
145
- return [np.zeros(self.shape).astype(Type) for i in range(n)]
146
-
147
- def _get_ones_(self, n, Type=float) -> list:
148
- return [np.ones(self.shape).astype(Type) for i in range(n)]
149
-
150
- def _compute_meshes_(self) -> None:
151
- self.x_meshes = NameSpace(right=self._get_zeros_(1)[0],
152
- left=self._get_zeros_(1)[0],
153
- center=self._get_zeros_(1)[0])
154
-
155
- self.y_meshes = NameSpace(top=self._get_zeros_(1)[0],
156
- bottom=self._get_zeros_(1)[0],
157
- center=self._get_zeros_(1)[0])
158
-
159
- def _slices_meshes_(self) -> None:
160
- if self.naive:
161
- self.y_meshes.bottom = 0
162
- self.y_meshes.top = 0
163
-
164
- self.x_meshes.right = 0
165
- self.x_meshes.left = 0
166
-
167
- else:
168
- self.y_meshes.bottom[~self.slice_bottom] = 0
169
- self.y_meshes.top[~self.slice_top] = 0
170
- self.y_meshes.center[self.slice_bottom + self.slice_top] = 0
171
-
172
- self.x_meshes.right[~self.slice_right] = 0
173
- self.x_meshes.left[~self.slice_left] = 0
174
- self.x_meshes.center[self.slice_right + self.slice_left] = 0
175
-
176
- def _add_meshes_(self) -> None:
177
- self.M = (self.y_meshes.top + self.y_meshes.bottom + self.y_meshes.center) / (self.dx**self.finit_coefficient.derivative) # Y derivative
178
-
179
- self.M += (self.x_meshes.left + self.x_meshes.right + self.x_meshes.center) / (self.dy**self.finit_coefficient.derivative) # X derivative
180
-
181
- self.M = sparse.csr_matrix(self.M)
182
-
183
- def _get_y_diagonal_(self):
184
- for idx, value in self.finit_coefficient.Central().items():
185
- self.y_meshes.center[self.Index.i == self.Index.j - idx * self.n_y] = value
186
-
187
- self.y_meshes.top = self._set_top_boundary_(self.symmetries['top'], self.y_meshes.top)
188
- self.y_meshes.bottom = self._set_bottom_boundary_(self.symmetries['bottom'], self.y_meshes.bottom)
189
-
190
- def plot(self, add_text=False):
191
- from pylab import cm
192
- cmap = cm.get_cmap('viridis', 101)
193
-
194
- Figure, Axes = plt.subplots(1, 1, figsize=(10, 9))
195
- Axes.set_title('Finite-difference coefficients.')
196
- Data = self.M.todense()
197
-
198
- Axes.grid(True)
199
- im0 = Axes.imshow(Data, cmap=cmap)
200
- plt.colorbar(im0, ax=Axes)
201
- if add_text:
202
- for (i, j), z in np.ndenumerate(Data.astype(float)):
203
- Axes.text(j, i, '{:.0e}'.format(z), ha='center', va='center', size=8)
204
-
205
- plt.show()
206
-
207
- def construct_matrix(self, Addmesh: numpy.ndarray = None):
208
- i, j = np.indices(self.shape)
209
-
210
- self.Index = NameSpace(i=i, j=j)
211
-
212
- self._compute_slices_()
213
-
214
- self._compute_meshes_()
215
-
216
- self._get_y_diagonal_()
217
-
218
- self._get_x_diagonal_()
219
-
220
- self._slices_meshes_()
221
-
222
- self._add_meshes_()
223
-
224
- # if Addmesh is not None:
225
- # np.fill_diagonal(self.M, self.M.diagonal() + Addmesh.flatten())
226
-
227
- @property
228
- def Dense(self):
229
- return self.M
230
-
231
- @property
232
- def Sparse(self):
233
- return sparse.csr_matrix(self.M)
234
-
235
- def _to_triplet_(self):
236
- Coordinate = self.Sparse.tocoo()
237
- return numpy.array([Coordinate.col, Coordinate.row, Coordinate.data])
238
-
@@ -1,147 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: PyFinitDiff
3
- Version: 2.0.0.post0
4
- Summary: A package finit-difference matrix generation.
5
- Author-email: Martin Poinsinet de Sivry-Houle <martin.poinsinet.de.sivry@gmail.com>
6
- License: MIT License
7
-
8
- Copyright (c) 2020 Martin de Sivry
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
-
28
- Project-URL: Homepage, https://github.com/MartinPdeS/PyFinitDiff
29
- Project-URL: Documentation, https://pyfinitdiff.readthedocs.io/en/latest/
30
- Project-URL: Repository, https://github.com/MartinPdeS/PyFinitDiff.git
31
- Keywords: finit-difference,matrix
32
- Classifier: Programming Language :: Python
33
- Classifier: Programming Language :: Python :: 3
34
- Classifier: Programming Language :: Python :: 3.11
35
- Classifier: Programming Language :: Python :: 3.12
36
- Classifier: Programming Language :: Python :: Implementation :: CPython
37
- Classifier: Development Status :: 4 - Beta
38
- Classifier: Topic :: Scientific/Engineering :: Physics
39
- Classifier: License :: OSI Approved :: MIT License
40
- Classifier: Intended Audience :: Science/Research
41
- Requires-Python: >=3.10
42
- Description-Content-Type: text/x-rst
43
- License-File: LICENSE
44
- Requires-Dist: pydantic>=2.6.3
45
- Requires-Dist: numpy
46
- Requires-Dist: scipy
47
- Requires-Dist: MPSPlots
48
- Requires-Dist: tabulate
49
- Provides-Extra: documentation
50
- Requires-Dist: numpydoc==1.6.0; extra == "documentation"
51
- Requires-Dist: sphinx>=5.1.1; extra == "documentation"
52
- Requires-Dist: sphinx-gallery==0.15.0; extra == "documentation"
53
- Requires-Dist: sphinx-rtd-theme==2.0.0; extra == "documentation"
54
- Requires-Dist: pydata-sphinx-theme==0.14.1; extra == "documentation"
55
- Provides-Extra: testing
56
- Requires-Dist: pytest>=0.6; extra == "testing"
57
- Requires-Dist: pytest-cov>=2.0; extra == "testing"
58
- Requires-Dist: pytest-json-report==1.5.0; extra == "testing"
59
- Requires-Dist: mypy>=0.910; extra == "testing"
60
- Requires-Dist: flake8>=3.9; extra == "testing"
61
- Requires-Dist: tox>=3.24; extra == "testing"
62
- Requires-Dist: coverage==6.5.0; extra == "testing"
63
-
64
- PyFinitDiff
65
- ===========
66
-
67
- |python|
68
- |docs|
69
- |unittest|
70
- |PyPi|
71
- |PyPi_download|
72
-
73
- A Python package to compute finit-difference matrices with an intuitive API.
74
-
75
-
76
- ----
77
-
78
- Documentation
79
- **************
80
- All the latest available documentation is available `here <https://pyfinitdiff.readthedocs.io/en/latest/>`_ or you can click the following badge:
81
-
82
- |docs|
83
-
84
-
85
- ----
86
-
87
- Installation
88
- ------------
89
-
90
-
91
- Pip installation
92
- ****************
93
-
94
- The package have been uploaded as wheel for a few OS (Linux, MacOS) and need Python 3.10+ version.
95
- As such, with the adequate configuration one can simply do
96
-
97
- .. code-block:: python
98
-
99
- >>> pip3 install PyFinitDiff
100
-
101
-
102
- ----
103
-
104
- Testing
105
- *******
106
-
107
- To test localy (with cloning the GitHub repository) you'll need to install the dependencies and run the coverage command as
108
-
109
- .. code:: python
110
-
111
- >>> git clone https://github.com/MartinPdeS/PyFinitDiff.git
112
- >>> cd PyFinitDiff
113
- >>> pip install -r requirements/requirements.txt
114
- >>> coverage run --source=PyFinitDiff --module pytest --verbose tests
115
- >>> coverage report --show-missing
116
-
117
- ----
118
-
119
-
120
- Contact Information
121
- *******************
122
-
123
- As of 2021 the project is still under development if you want to collaborate it would be a pleasure. I encourage you to contact me.
124
-
125
- PyFinitDiff was written by `Martin Poinsinet de Sivry-Houle <https://github.com/MartinPdS>`_ .
126
-
127
- Email:`martin.poinsinet-de-sivry@polymtl.ca <mailto:martin.poinsinet-de-sivry@polymtl.ca?subject=PyFinitDiff>`_ .
128
-
129
-
130
- .. |python| image:: https://img.shields.io/badge/Made%20with-Python-1f425f.svg
131
- :target: https://www.python.org/
132
-
133
- .. |docs| image:: https://readthedocs.org/projects/pyfinitdiff/badge/?version=latest
134
- :target: https://pyfinitdiff.readthedocs.io/en/latest/
135
- :alt: Documentation Status
136
-
137
- .. |unittest| image:: https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/MartinPdeS/19aef38017fa4be1dc71b6f5d853a932/raw
138
-
139
- .. |PyPi| image:: https://badge.fury.io/py/PyFinitDiff.svg
140
- :target: https://pypi.org/project/PyFinitDiff/
141
-
142
- .. |PyPi_download| image:: https://img.shields.io/pypi/dm/pyfinitdiff.svg
143
- :target: https://pypistats.org/packages/pyfinitdiff
144
-
145
-
146
-
147
-
@@ -1,28 +0,0 @@
1
- PyFinitDiff/__init__.py,sha256=aM48cMAdbYIlGfbEhIvsYBykH2h-u4UpT8DL2utijYQ,121
2
- PyFinitDiff/_version.py,sha256=SNS4RofNHfIk5adzMeBrr3fs3NDC5R9cQ1UbL_LRKYE,417
3
- PyFinitDiff/triplet.py,sha256=o_pnW-Y_igF29IosZGQX6WJdX0QZtIGDL2Mu-1X1Ihg,12701
4
- PyFinitDiff/utils.py,sha256=oKaaG1qbAjJe3Kd9rS86LuylEuoYu2oPeKgTjKtdxME,3175
5
- PyFinitDiff/coefficients/__init__.py,sha256=D6leOHW6065G9S6rdcQLmTc99bhWJ9OldfR8lWYQJIU,4179
6
- PyFinitDiff/coefficients/backward.py,sha256=cTti5MkcrhvuJVNURLJqnTcMmSQhdPvRPImu6ZSEsfY,1977
7
- PyFinitDiff/coefficients/central.py,sha256=Xq1W-yXnTFLNugYwHajl8XynHPWdV7jH6ll2fy_NVSI,2377
8
- PyFinitDiff/coefficients/forward.py,sha256=znCszjYptZpQiINx_VQXFeLTNKhntm3MV1g7CNOW67E,1973
9
- PyFinitDiff/finite_difference_1D/__init__.py,sha256=VIxWZB2VhtmtnU-Qz-VDGLIz1V1ufqXHyUxlIAYKgW4,237
10
- PyFinitDiff/finite_difference_1D/boundaries.py,sha256=2HWURIrSMWLUTn4KoSBXYHZdWQEISzw-m6yZxt7CF3w,6159
11
- PyFinitDiff/finite_difference_1D/derivative.py,sha256=OK6jN426iXHriiesQSy4hsZEN6z1I6osTw7IUK5aqMY,1476
12
- PyFinitDiff/finite_difference_1D/diagonals.py,sha256=v6C0bPAApLl4qSwFMeoDPKzg8THlObVm9qc7co8QgnM,7082
13
- PyFinitDiff/finite_difference_1D/finite_difference.py,sha256=q9UpPDxAxN78iBarW1x8W5UEdHTsE6o2BcXddKBIDXM,5871
14
- PyFinitDiff/finite_difference_1D/utils.py,sha256=wFToOvAEK3A9VqBf_9e4O3cXRdP_igA_iS-67_5JV3Y,1708
15
- PyFinitDiff/finite_difference_2D/__init__.py,sha256=TIijlPbN-SiZ9UsaO5zVSZrb5ZsKVm0P63TZ_rjEySU,234
16
- PyFinitDiff/finite_difference_2D/boundaries.py,sha256=jokzZ1VXq680XLCMsgAxS9Aza_DTmlYN-w2O_IRe33c,7312
17
- PyFinitDiff/finite_difference_2D/dense.py,sha256=hWcncevb1gSk_-LSHr2SIk5LWy1bcCKN8UKCFI2robM,9199
18
- PyFinitDiff/finite_difference_2D/derivative.py,sha256=MlO2aGFuxuK5yAf8q8dEOlc3dgRdf68lf1HTFh7IRzo,1820
19
- PyFinitDiff/finite_difference_2D/diagonals.py,sha256=KPcmx8LoNyUuBQIJC330GUNEdP5UP4mrg__Vtpy1ZQU,9581
20
- PyFinitDiff/finite_difference_2D/finite_difference.py,sha256=QRMwCjp4iF7jqkp3LqwzOQum2qT_VwRpjl7ZZp73aEI,6889
21
- PyFinitDiff/finite_difference_2D/utils.py,sha256=OZgp9Wk1NuOEwXSf8PvQyHXOe927K37shu-WDjN21CM,2182
22
- PyFinitDiff/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
- PyFinitDiff/tools/directories.py,sha256=CjG37eY-Z68Czo5L7MzHJpu8KEJNhZPnh5VB5MTQ2Tg,837
24
- PyFinitDiff-2.0.0.post0.dist-info/LICENSE,sha256=U6YG4UEW9XJzHa53oijR0qw6JNN_SZ38WOBmYn3NPd0,1072
25
- PyFinitDiff-2.0.0.post0.dist-info/METADATA,sha256=7ZiNmmaEeZuumv-MsEcacviQ_yXbO73Pzvi5skYAuOw,5192
26
- PyFinitDiff-2.0.0.post0.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
27
- PyFinitDiff-2.0.0.post0.dist-info/top_level.txt,sha256=yl_A1Z9VT4HxBK5PTOM4ZyRcXZb-VtbQo1TzRUc1mW4,12
28
- PyFinitDiff-2.0.0.post0.dist-info/RECORD,,