Hi,
I have a question regarding tests - do some of them actually test for a correctness? It seems to me, that most of them only test, if sfepy runs for the given input and mesh, but we should also test, that the result of the calculation is actually correct. For example when I polish the schrodinger solver, the simple test is to check that all the energies are correct.
For example this one:
tests/test_quadratures.py
Does it test for a correctness? It seems to me, that this code
def test_problemCreation( self ):
from sfe.solvers.generic import solveStationary
problem, vec, data = solveStationary( self.conf )
ok = True
return ok
Always returns "ok", no matter what was returned in vec and data.
Ondrej
Ondrej Certik wrote:
I have a question regarding tests - do some of them actually test for a correctness? It seems to me, that most of them only test, if sfepy runs for the given input and mesh, but we should also test, that the result of the calculation is actually correct. For example when I polish the schrodinger solver, the simple test is to check that all the energies are correct.
The test_input_* files test only, that an input file included in the distro works (= some result is obtained, and the process converged). They do not test actual physical/mathematical correctness of the results (yet).
For example this one:
tests/test_quadratures.py
Does it test for a correctness? It seems to me, that this code
def test_problemCreation( self ): from sfe.solvers.generic import solveStationary problem, vec, data = solveStationary( self.conf ) ok = True return ok
Always returns "ok", no matter what was returned in vec and data.
Yes, this test file is not finished. There are probably others that could test more than they test so far. I have usually written tests only when something went actually wrong :)
So for schroedinger: you can use Test( TestInput ) to have test_input() method for free and add, for example, test_energies() and other methods to your Test class to verify correctness - those can use the solution already computed in test_input(), but you have to enforce a correct order of evaluation by using the 'tests' list (attribute of your Test class, see test_meshio.py).
r.
r.
The test_input_* files test only, that an input file included in the distro works (= some result is obtained, and the process converged). They do not test actual physical/mathematical correctness of the results (yet).
Right.
Yes, this test file is not finished. There are probably others that could test more than they test so far. I have usually written tests only when something went actually wrong :)
Yes, from now on, if something goes wrong, let's write a test for it.
So for schroedinger: you can use Test( TestInput ) to have test_input() method for free and add, for example, test_energies() and other methods to your Test class to verify correctness - those can use the solution already computed in test_input(), but you have to enforce a correct order of evaluation by using the 'tests' list (attribute of your Test class, see test_meshio.py).
Perfect, I'll do that.
Generally, I think it's a very good idea, when you (or we) implement something and you are sure that it works perfectly (which - at least for me - takes some time playing with the problem to be sure that what I get is correct), to write a test testing the correct result immediatelly. Because once we test it, we can forget about it, as it will always work.
Ondrej
Ondrej Certik wrote:
Generally, I think it's a very good idea, when you (or we) implement something and you are sure that it works perfectly (which - at least for me - takes some time playing with the problem to be sure that what I get is correct), to write a test testing the correct result immediatelly. Because once we test it, we can forget about it, as it will always work.
Sure. In those rare cases when one knows that a result is correct...
btw. the figures with eigensolutions of your equation would be a nice addition to the Examples wiki!
r.
On Feb 6, 2008 11:59 AM, Robert Cimrman <cimr...@ntc.zcu.cz> wrote:
Ondrej Certik wrote:
Generally, I think it's a very good idea, when you (or we) implement something and you are sure that it works perfectly (which - at least for me - takes some time playing with the problem to be sure that what I get is correct), to write a test testing the correct result immediatelly. Because once we test it, we can forget about it, as it will always work.
Sure. In those rare cases when one knows that a result is correct...
Yep. For example the result from the schrodinger solver is incorrect (probably just due to mesh).
btw. the figures with eigensolutions of your equation would be a nice addition to the Examples wiki!
Yes, absolutely. I am learning for my exam tomorrow from Lie groups, but I hope to work on this tomorrow after the exam. I need to import my own mesh and then I'll hopefully get the correct eigenvalues. If I do, then I'll write a test for it and put it into examples.
Ondrej
btw. the figures with eigensolutions of your equation would be a nice addition to the Examples wiki!
Yes, absolutely. I am learning for my exam tomorrow from Lie groups,
I hated algebra and groups especially... :) Now it's getting better as I am mildly aware of some actual applications.
but I hope to work on this tomorrow after the exam. I need to import my own mesh and then I'll hopefully get the correct eigenvalues. If I do, then I'll write a test for it and put it into examples.
Great!
r.
participants (2)
-
Ondrej Certik
-
Robert Cimrman