Skip to content

Commit a19a389

Browse files
#709 some more test fixes
1 parent 824283f commit a19a389

File tree

6 files changed

+152
-275
lines changed

6 files changed

+152
-275
lines changed

examples/notebooks/compare-comsol-discharge-curve.ipynb

+9-23
Large diffs are not rendered by default.

examples/notebooks/models/compare-lithium-ion.ipynb

+52-100
Large diffs are not rendered by default.

examples/notebooks/parameter-values.ipynb

+45-62
Large diffs are not rendered by default.

examples/notebooks/spatial_methods/finite-volumes.ipynb

+43-88
Original file line numberDiff line numberDiff line change
@@ -615,19 +615,7 @@
615615
" ├── @\n",
616616
" │ ├── Sparse Matrix (42, 40)\n",
617617
" │ └── y[0:40]\n",
618-
" └── numpy concatenation\n",
619-
" ├── Column vector of length 0\n",
620-
" ├── *\n",
621-
" │ ├── *\n",
622-
" │ │ ├── 2.0\n",
623-
" │ │ └── 1.0\n",
624-
" │ └── Column vector of length 1\n",
625-
" ├── Column vector of length 40\n",
626-
" └── *\n",
627-
" ├── *\n",
628-
" │ ├── 2.0\n",
629-
" │ └── 2.0\n",
630-
" └── Column vector of length 1\n",
618+
" └── Column vector of length 42\n",
631619
"The value of u on the left-hand boundary is [1.]\n",
632620
"The value of u on the right-hand boundary is [2.]\n"
633621
]
@@ -663,25 +651,13 @@
663651
"output_type": "stream",
664652
"text": [
665653
"The gradient object is:\n",
666-
"@\n",
667-
"├── Sparse Matrix (41, 42)\n",
668-
"└── +\n",
669-
" ├── @\n",
670-
" │ ├── Sparse Matrix (42, 40)\n",
671-
" │ └── y[0:40]\n",
672-
" └── numpy concatenation\n",
673-
" ├── Column vector of length 0\n",
674-
" ├── *\n",
675-
" │ ├── *\n",
676-
" │ │ ├── -0.024999999999999998\n",
677-
" │ │ └── 3.0\n",
678-
" │ └── Column vector of length 1\n",
679-
" ├── Column vector of length 40\n",
680-
" └── *\n",
681-
" ├── *\n",
682-
" │ ├── 0.02499999999999991\n",
683-
" │ └── 4.0\n",
684-
" └── Column vector of length 1\n",
654+
"+\n",
655+
"├── @\n",
656+
"│ ├── Sparse Matrix (41, 39)\n",
657+
"│ └── @\n",
658+
"│ ├── Sparse Matrix (39, 40)\n",
659+
"│ └── y[0:40]\n",
660+
"└── Column vector of length 41\n",
685661
"The gradient on the left-hand boundary is [3.]\n",
686662
"The gradient of u on the right-hand boundary is [4.]\n"
687663
]
@@ -714,26 +690,18 @@
714690
"output_type": "stream",
715691
"text": [
716692
"The gradient object is:\n",
717-
"@\n",
718-
"├── Sparse Matrix (41, 42)\n",
719-
"└── +\n",
720-
" ├── @\n",
721-
" │ ├── Sparse Matrix (42, 40)\n",
722-
" │ └── y[0:40]\n",
723-
" └── numpy concatenation\n",
724-
" ├── Column vector of length 0\n",
725-
" ├── *\n",
726-
" │ ├── *\n",
727-
" │ │ ├── 2.0\n",
728-
" │ │ └── 5.0\n",
729-
" │ └── Column vector of length 1\n",
730-
" ├── Column vector of length 40\n",
731-
" └── *\n",
732-
" ├── *\n",
733-
" │ ├── 0.02499999999999991\n",
734-
" │ └── 6.0\n",
735-
" └── Column vector of length 1\n",
736-
"The value of u on the left-hand boundary is [5.]\n",
693+
"+\n",
694+
"├── @\n",
695+
"│ ├── Sparse Matrix (41, 40)\n",
696+
"│ └── @\n",
697+
"│ ├── Sparse Matrix (40, 41)\n",
698+
"│ └── +\n",
699+
"│ ├── @\n",
700+
"│ │ ├── Sparse Matrix (41, 40)\n",
701+
"│ │ └── y[0:40]\n",
702+
"│ └── Column vector of length 41\n",
703+
"└── Column vector of length 41\n",
704+
"The value of u on the left-hand boundary is [0.]\n",
737705
"The gradient on the right-hand boundary is [6.]\n"
738706
]
739707
}
@@ -797,25 +765,13 @@
797765
"text": [
798766
"@\n",
799767
"├── Sparse Matrix (40, 41)\n",
800-
"└── @\n",
801-
" ├── Sparse Matrix (41, 42)\n",
802-
" └── +\n",
803-
" ├── @\n",
804-
" │ ├── Sparse Matrix (42, 40)\n",
805-
" │ └── y[0:40]\n",
806-
" └── numpy concatenation\n",
807-
" ├── Column vector of length 0\n",
808-
" ├── *\n",
809-
" │ ├── *\n",
810-
" │ │ ├── -0.024999999999999998\n",
811-
" │ │ └── -1.0\n",
812-
" │ └── Column vector of length 1\n",
813-
" ├── Column vector of length 40\n",
814-
" └── *\n",
815-
" ├── *\n",
816-
" │ ├── 0.02499999999999991\n",
817-
" │ └── 1.0\n",
818-
" └── Column vector of length 1\n"
768+
"└── +\n",
769+
" ├── @\n",
770+
" │ ├── Sparse Matrix (41, 39)\n",
771+
" │ └── @\n",
772+
" │ ├── Sparse Matrix (39, 40)\n",
773+
" │ └── y[0:40]\n",
774+
" └── Column vector of length 41\n"
819775
]
820776
}
821777
],
@@ -878,11 +834,11 @@
878834
"output_type": "stream",
879835
"text": [
880836
"@\n",
881-
"├── Sparse Matrix (40, 42)\n",
837+
"├── Sparse Matrix (40, 41)\n",
882838
"└── +\n",
883-
" ├── Column vector of length 42\n",
839+
" ├── Column vector of length 41\n",
884840
" └── @\n",
885-
" ├── Sparse Matrix (42, 40)\n",
841+
" ├── Sparse Matrix (41, 40)\n",
886842
" └── y[0:40]\n"
887843
]
888844
}
@@ -904,13 +860,13 @@
904860
"laplacian matrix is:\n",
905861
"\n",
906862
"1/dx^2 *\n",
907-
"[[ 1. -2. 1. ... 0. 0. 0.]\n",
908-
" [ 0. 1. -2. ... 0. 0. 0.]\n",
909-
" [ 0. 0. 1. ... 0. 0. 0.]\n",
863+
"[[-0.025 0.025 0. ... 0. 0. 0. ]\n",
864+
" [ 0. -0.025 0.025 ... 0. 0. 0. ]\n",
865+
" [ 0. 0. -0.025 ... 0. 0. 0. ]\n",
910866
" ...\n",
911-
" [ 0. 0. 0. ... 1. 0. 0.]\n",
912-
" [ 0. 0. 0. ... -2. 1. 0.]\n",
913-
" [ 0. 0. 0. ... 1. -2. 1.]]\n"
867+
" [ 0. 0. 0. ... 0.025 0. 0. ]\n",
868+
" [ 0. 0. 0. ... -0.025 0.025 0. ]\n",
869+
" [ 0. 0. 0. ... 0. -0.025 0.025]]\n"
914870
]
915871
}
916872
],
@@ -936,7 +892,7 @@
936892
{
937893
"data": {
938894
"text/plain": [
939-
"0.5950588420091663"
895+
"0.4124502999475226"
940896
]
941897
},
942898
"execution_count": 25,
@@ -957,7 +913,7 @@
957913
{
958914
"data": {
959915
"text/plain": [
960-
"0.3470027389994357"
916+
"0.2925413999473676"
961917
]
962918
},
963919
"execution_count": 26,
@@ -1035,9 +991,7 @@
1035991
"int(v):\n",
1036992
"\n",
1037993
"@\n",
1038-
"├── *\n",
1039-
"│ ├── 39.47841760435743\n",
1040-
"│ └── Sparse Matrix (1, 10)\n",
994+
"├── Sparse Matrix (1, 10)\n",
1041995
"└── *\n",
1042996
" ├── /\n",
1043997
" │ ├── y[40:50]\n",
@@ -1083,7 +1037,8 @@
10831037
{
10841038
"data": {
10851039
"text/plain": [
1086-
"matrix([[1., 1., 1., 1., 1., 1., 1., 1., 1., 1.]])"
1040+
"matrix([[39.4784176, 39.4784176, 39.4784176, 39.4784176, 39.4784176,\n",
1041+
" 39.4784176, 39.4784176, 39.4784176, 39.4784176, 39.4784176]])"
10871042
]
10881043
},
10891044
"execution_count": 30,
@@ -1092,7 +1047,7 @@
10921047
}
10931048
],
10941049
"source": [
1095-
"int_v_over_r_disc.children[0].children[1].evaluate() / micro_mesh.d_edges"
1050+
"int_v_over_r_disc.children[0].evaluate() / micro_mesh.d_edges"
10961051
]
10971052
},
10981053
{
@@ -1282,7 +1237,7 @@
12821237
"name": "python",
12831238
"nbconvert_exporter": "python",
12841239
"pygments_lexer": "ipython3",
1285-
"version": "3.7.3"
1240+
"version": "3.6.9"
12861241
}
12871242
},
12881243
"nbformat": 4,

tests/unit/test_expression_tree/test_matrix.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ def test_matrix_evaluate(self):
2424

2525
def test_matrix_operations(self):
2626
np.testing.assert_array_equal((self.mat + self.mat).evaluate(), 2 * self.A)
27-
np.testing.assert_array_equal((self.mat - self.mat).evaluate(), 0 * self.A)
27+
np.testing.assert_array_equal(
28+
(self.mat - self.mat).evaluate().toarray(), 0 * self.A
29+
)
2830
np.testing.assert_array_equal(
2931
(self.mat @ self.vect).evaluate(), np.array([[5], [2], [3]])
3032
)

tests/unit/test_expression_tree/test_unary_operators.py

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def test_unary_operator(self):
1616

1717
# with number
1818
log = pybamm.log(10)
19-
self.assertIsInstance(log.children[0], pybamm.Scalar)
2019
self.assertEqual(log.evaluate(), np.log(10))
2120

2221
def test_negation(self):

0 commit comments

Comments
 (0)