Skip to content

Fix PictGenerate to clear previous results before generating new ones #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented May 19, 2025

Problem

When PictGenerate is called multiple times on the same task, the function does not clean previous results before generating new ones. This causes duplication where calling the function n times while expecting i rows of results will generate n * i rows of results.

Root Cause

The issue is in the Model::Generate() method, where results are accumulated in the m_results collection without clearing previous results first. This means that even after fetching the results and cleaning the result buffers, if the model is modified and generation is triggered again, the initial results will still be present.

Solution

Added a simple one-line fix to clear the results collection at the beginning of the Model::Generate() method:

void Model::Generate()
{
    DOUT( L"Num of params " << (int) m_parameters.size() <<
          L", order: "      << m_order <<
          L", seed: "       << m_randomSeed << endl );
    for( ParamCollection::iterator ip = m_parameters.begin(); ip != m_parameters.end(); ++ip )
        DOUT( ( *ip )->GetName() << L", order: " << ( *ip )->GetOrder() << endl );

    // Clear previous results before generating new ones
    m_results.clear();

    switch( m_generationType )
    // ...
}

Testing

I verified the fix by creating a test program that calls PictGenerate twice and confirms that both calls produce the same number of rows rather than the second call producing twice as many.

All existing tests continue to pass with this change.

Fixes #123.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI assigned Copilot and jaccz May 19, 2025
@Copilot Copilot AI changed the title [WIP] PictGenerate does not clean previous results before generating the new ones Fix PictGenerate to clear previous results before generating new ones May 19, 2025
@Copilot Copilot AI requested a review from jaccz May 19, 2025 18:08
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.

PictGenerate does not clean previous results before generating the new ones
2 participants