Skip to content

Add metadata decorations to check_x functions in tests#9

Merged
ktras merged 5 commits intoBerkeleyLab:rag-metadatafrom
ktras:attempt-test-metadata-change
Feb 25, 2026
Merged

Add metadata decorations to check_x functions in tests#9
ktras merged 5 commits intoBerkeleyLab:rag-metadatafrom
ktras:attempt-test-metadata-change

Conversation

@ktras
Copy link
Collaborator

@ktras ktras commented Feb 24, 2026

I added empty metadata comments to all of the check_x tests in the test dir in the first commit in this PR. The second commit includes filled in meta data comments that were generated from prompts to Claude using the following type of prompt:

Prompt:

Hello, I want to decorate some code with metadata comments that will be used in a python workflow that does prompt engineering through RAG techniques. Currently the code has the metadata comments but without the fields, "PURPOSE", "KEYWORDS", and "CONTEXT" filled in. Can you use the source code context from this branch of a public github repo, https://github.com/ktras/formal/tree/rag-metadata, to then fill in the "PURPOSE", "KEYWORDS", and "CONTEXT" fields for the following code chunk?

  ! PURPOSE: 
  ! KEYWORDS: 
  ! CONTEXT: 
  function check_2nd_order_laplacian_parabola() result(test_diagnosis)
    type(test_diagnosis_t) test_diagnosis
    procedure(scalar_1D_initializer_i), pointer :: scalar_1D_initializer => parabola
    double precision, parameter :: expected_laplacian = 1D0
#ifdef __GFORTRAN__
    type(laplacian_1D_t) laplacian_scalar
    laplacian_scalar = .laplacian. scalar_1D_t(scalar_1D_initializer, order=2, cells=16, x_min=0D0, x_max=5D0)
#else
    associate(laplacian_scalar => .laplacian. scalar_1D_t(scalar_1D_initializer, order=2, cells=16, x_min=0D0, x_max=5D0))
#endif

      test_diagnosis = passing_test()
      test_diagnosis = test_diagnosis .also. (.all. (laplacian_scalar%values() .approximates. expected_laplacian .within. tight_tolerance)) &
        // " (2nd-order .laplacian. [(x**2)/2]"

#ifndef __GFORTRAN__
    end associate
#endif
  end function
  ! END CODE CHUNK

@ktras ktras requested a review from rouson February 24, 2026 01:56
@ktras ktras changed the title Add empty metadata decorations to check_x functions in tests Add metadata decorations to check_x functions in tests Feb 24, 2026
! 1.0 everywhere, and reports a passing or failing test diagnosis based on whether the
! computed values approximate the expected result within a tight tolerance.
! KEYWORDS: divergence, gradient, div-grad, laplacian-equivalence, finite-difference,
! operator-overloading, unit-test, scalar_1D, parabola, 4th-order, structured-grid,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
! operator-overloading, unit-test, scalar_1D, parabola, 4th-order, structured-grid,
! defined-operation unit-test, scalar_1D, parabola, 4th-order, structured-grid,

! It verifies that both grids approximate the expected divergence within a rough tolerance
! and that the observed convergence rate matches 2nd-order accuracy.
! KEYWORDS: divergence, finite-difference, convergence-rate, 2nd-order, operator-overloading,
! unit-test, vector_1D, sinusoid, structured-grid, test-diagnosis, differential-operator,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
! unit-test, vector_1D, sinusoid, structured-grid, test-diagnosis, differential-operator,
! unit-test, vector_1D, sinusoid, structured-grid, staggered-grid, test-diagnosis, differential-operator,

! verification, grid-refinement, order-of-accuracy
! CONTEXT: This function is part of the divergence operator test suite in the formal library, which
! provides overloaded mathematical operators (.div., .grad., .laplacian., etc.) for
! structured-grid scalar and vector fields. It constructs two vector_1D_t objects
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
! structured-grid scalar and vector fields. It constructs two vector_1D_t objects
! staggered-grid scalar and vector fields. It constructs two vector_1D_t objects

@ktras
Copy link
Collaborator Author

ktras commented Feb 25, 2026

Merging based on verbal approval from @rouson.

@ktras ktras merged commit 4747eab into BerkeleyLab:rag-metadata Feb 25, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants