expose PETScOptions.clear() in the Python interface

Issue #841 resolved
Nico Schlömer created an issue

In https://github.com/FEniCS/dolfin/blob/master/dolfin/la/PETScOptions.h, there are two functions by the name clear: One with a string argument to clear a specific option, one without to clear all options.

I suppose it's the fact that those two bear the same name that makes it impossible to expose both in Python.

The request for clearing all options has come up twice recently (once by myself, once by dajuno, so I suppose it's worthwhile fixing it.

Perhaps clear_all is an appropriate name.

Comments (3)

  1. Jan Blechta

    It seems that that both clearing a single option and all the options is supported

    from dolfin import *
    from petsc4py import PETSc
    
    PETScOptions.set("foo")
    PETScOptions.set("bar")
    assert 'foo' in PETSc.Options().getAll()
    assert 'bar' in PETSc.Options().getAll()
    
    PETScOptions.clear('foo')
    assert 'bar' in PETSc.Options().getAll()
    
    PETScOptions.clear()
    assert len(PETSc.Options().getAll()) == 0
    

    Can you provide a MWE?

  2. Nico Schlömer reporter

    The line

    PETScOptions.clear()
    

    gives

    TypeError: clear() takes exactly 1 argument (0 given)
    

    for me on 2016.2. Certainly that's something that's been fixed in the meantime.

  3. Log in to comment