File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -405,7 +405,8 @@ def __get_inner_product_projection_matrices(
405405 ):
406406 if getattr (self , "_proj_stash" , None ) is None :
407407 self ._proj_stash = {}
408- if i_type not in self ._proj_stash :
408+ key = (i_type , with_volume )
409+ if key not in self ._proj_stash :
409410 dim = self .dim
410411 n_cells = self .n_cells
411412 if i_type == "F" :
@@ -456,8 +457,8 @@ def __get_inner_product_projection_matrices(
456457 )
457458 Ps .append (T @ P )
458459
459- self ._proj_stash [i_type ] = (Ps , T_col_inds , T_ind_ptr )
460- Ps , T_col_inds , T_ind_ptr = self ._proj_stash [i_type ]
460+ self ._proj_stash [key ] = (Ps , T_col_inds , T_ind_ptr )
461+ Ps , T_col_inds , T_ind_ptr = self ._proj_stash [key ]
461462 if return_pointers :
462463 return Ps , (T_col_inds , T_ind_ptr )
463464 else :
Original file line number Diff line number Diff line change @@ -14,14 +14,14 @@ found on the official websites of the packages
1414Python for scientific computing
1515-------------------------------
1616
17- * `Python for Scientists <https://sites.google.com/site/pythonforscientists/ >`_ Links to commonly used packages, Matlab to Python comparison
17+ * `Learn Python <https://pyzo.org/learn.html >`_ Links to commonly used packages, Matlab to Python comparison
1818* `Python Wiki <http://wiki.python.org/moin/NumericAndScientific >`_ Lists packages and resources for scientific computing in Python
1919
2020Numpy and Matlab
2121----------------
2222
2323* `NumPy for Matlab Users <https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html >`_
24- * `Python vs Matlab <https://sites.google.com/site/pythonforscientists/python-vs-matlab >`_
24+ * `Python vs Matlab <https://pyzo.org/python_vs_matlab.html >`_
2525
2626Lessons in Python
2727-----------------
Original file line number Diff line number Diff line change 11import numpy as np
2+ import pytest
3+
24import discretize
5+ from discretize import SimplexMesh
36from discretize .utils import example_simplex_mesh
47
58
@@ -179,3 +182,16 @@ def test_grad_order(self):
179182 self .name = "SimplexMesh grad order test"
180183 self ._test_type = "Grad"
181184 self .orderTest ()
185+
186+
187+ @pytest .mark .parametrize ("i_type" , ["E" , "F" ])
188+ def test_simplex_projection_caching (i_type ):
189+ n = 5
190+ mesh = SimplexMesh (* example_simplex_mesh ((n , n )))
191+ P1 = mesh ._SimplexMesh__get_inner_product_projection_matrices (
192+ i_type , with_volume = False , return_pointers = False
193+ )
194+ P2 = mesh ._SimplexMesh__get_inner_product_projection_matrices (
195+ i_type , with_volume = True , return_pointers = False
196+ )
197+ assert P1 is not P2
You can’t perform that action at this time.
0 commit comments