@classmethod
def factory(cls, circuit, *args, **kwargs):
    """Return a :obj:`PySpice.Spice.Simulation.SubprocessCircuitSimulator` or
        :obj:`PySpice.Spice.Simulation.NgSpiceSharedCircuitSimulator` instance depending of the
        value of the *simulator* parameter: ``subprocess`` or ``shared``, respectively. If this
        parameter is not specified then a subprocess simulator is returned.

        """
    if 'simulator' in kwargs:
        simulator = kwargs['simulator']
        del kwargs['simulator']
    else:
        simulator = cls.DEFAULT_SIMULATOR
    sub_cls = None
    if simulator in ('ngspice-subprocess', 'ngspice-shared'):
        if simulator == 'ngspice-subprocess':
            from .NgSpice.Simulation import NgSpiceSubprocessCircuitSimulator
            sub_cls = NgSpiceSubprocessCircuitSimulator
        elif simulator == 'ngspice-shared':
            from .NgSpice.Simulation import NgSpiceSharedCircuitSimulator
            sub_cls = NgSpiceSharedCircuitSimulator
    elif simulator in ('xyce-serial', 'xyce-parallel'):
        from .Xyce.Simulation import XyceCircuitSimulator
        sub_cls = XyceCircuitSimulator
        if simulator == 'xyce-parallel':
            kwargs['parallel'] = True
    if sub_cls is not None:
        return sub_cls(circuit, *args, **kwargs)
    else:
        raise ValueError('Unknown simulator type')
