NWChemEx / NWChemEx/PluginPlay

Allow PropertyType instances to set default callback keys and descriptions

Open
#147 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

good first issue
Dominant language
C++
Stars
13
Forks
1
Avg merge
43m
Merged PRs (30d)
4

Description

Consider the declaration of the Fock class's ctor:

template<typename T>
Fock<T>::Fock() : sde::ModuleBase(this) {
    satisfies_property_type<f_type<T>>();
    satisfies_property_type<iter_type<T>>();
    description("Computes the Fock matrix and electronic energy");

    add_submodule<h_type<T>>("H Builder")
      .set_description("Computes core Hamiltonian");
    add_submodule<j_type<T>>("J Builder")
      .set_description("Computes the J matrix");
    add_submodule<k_type<T>>("K Builder")
      .set_description("Computes the K matrix");
}

if we have another module that needs, say a J builder, we're likely going to duplicate code:

AnotherModule::AnotherModule() : sde::ModuleBase(this) {
    satisfies_property_type<a_property_type>();

    add_submodule<j_type<T>>("J Builder")
      .set_description("Computes the J matrix");
}

or worse, we're going to use different callback keys and/or descriptions (it's worse because it makes the user's life harder as they have to remember different callback keys for different modules).

This issue proposes that PropertyType instances define the default callback key and description. When you're fine with the defaults, say declaring the Fock ctor, becomes:

template<typename T>
Fock<T>::Fock() : sde::ModuleBase(this) {
    satisfies_property_type<f_type<T>>();
    satisfies_property_type<iter_type<T>>();
    description("Computes the Fock matrix and electronic energy");

    add_submodule<h_type<T>>();
    add_submodule<j_type<T>>();
    add_submodule<k_type<T>>();
}

We'll still allow the old syntax because you may need to override the defaults (e.g. you need two different J calls, or you use a module in a non-standard way).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the PropertyType instances used by Fock and the add_submodule API in ModuleBase. Define how each property supplies a default callback key and description while preserving the existing explicit-key and explicit-description syntax. Done means Fock can use the no-argument add_submodule calls shown while callers can still override defaults for non-standard uses.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.