<commit_before>//
//  msym.c
//  libmsym
//
//  Created by <NAME> on 30/01/15.
//  Copyright (c) 2015 <NAME>. 
//
//  Distributed under the MIT License ( See LICENSE file or copy at http://opensource.org/licenses/MIT )
//

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "msym.h"
#include "context.h"
#include "symmetry.h"
#include "equivalence_set.h"
#include "point_group.h"
#include "symmetrize.h"
#include "orbital.h"
#include "vibration.h"
#include "linalg.h"

msym_error_t msymFindSymmetry(msym_context ctx){
    msym_error_t ret = MSYM_SUCCESS;
    int elementsl = 0, esl = 0;
    msym_element_t *elements = NULL;
    msym_thresholds_t *t = NULL;
    msym_equivalence_set_t *es = NULL;
    msym_point_group_t *pg = NULL;
    int sopsl = 0;
    msym_symmetry_operation_t *sops = NULL;
    msym_equivalence_set_t *ses = NULL;
    int sesl = 0;
    
    clock_t start, end;

    double time;
    
    
    if(MSYM_SUCCESS != (ret = ctxGetElements(ctx, &elementsl, &elements))) goto err;
    
    if(MSYM_SUCCESS != (ret = msymGetThresholds(ctx, &t))) goto err;
    
    if(MSYM_SUCCESS != (ret = ctxGetEquivalenceSets(ctx, &esl, &es))){
        if(MSYM_SUCCESS != (ret = msymFindEquivalenceSets(ctx))) goto err;
    }
    
    if(MSYM_SUCCESS != (ret = ctxGetEquivalenceSets(ctx, &esl, &es))) goto err;
    if(MSYM_SUCCESS != (ret = ctxGetPointGroup(ctx, &pg))){
        start = clock();
        if(MSYM_SUCCESS != (ret = findSymmetryOperations(esl,es,t,&sopsl,&sops))) goto err;
        end = clock();
        time = (double)(end - start) / CLOCKS_PER_SEC;
        printf("time: %lf seconds to find %d symmetry operations in %d equivalence sets\n",time,sopsl,esl);
        start = clock();
        if(MSYM_SUCCESS != (ret = findPointGroup(sopsl, sops, t, &pg))) goto err;
        end = clock();
        time = (double)(end - start) / CLOCKS_PER_SEC;
        printf("time: %lf seconds to find point group %s\n",time,pg->name);
        if(MSYM_SUCCESS != (ret = ctxSetPointGroup(ctx, pg))) {
            free(pg);
            goto err;
        }
        
        // Reuild equivalence sets after determining poing group in case they are very similar
        start = clock();
        //if(MSYM_SUCCESS != (ret = msymFindEquivalenceSets(ctx))) goto err;
        if(MSYM_SUCCESS != (ret = splitPointGroupEquivalenceSets(pg, esl, es, &sesl, &ses, t))) goto err;
        if(MSYM_SUCCESS != (ret = ctxSetEquivalenceSets(ctx, sesl, ses))) goto err;
        ses = NULL; sesl = 0;
        if(MSYM_SUCCESS != (ret = ctxGetEquivalenceSets(ctx, &esl, &es))) goto err;
        end = clock();
        time = (double)(end - start) / CLOCKS_PER_SEC;
        printf("time: %lf seconds to regenerate %d equivalence sets\n",time,esl);
        
    }
    
    start = clock();
    if(MSYM_SUCCESS != (ret = msymFindEquivalenceSetPermutations(ctx))) goto err;
    
    end = clock();
    time = (double)(end - start) / CLOCKS_PER_SEC;
    if(MSYM_SUCCESS != (ret = ctxGetEquivalenceSets(ctx, &esl, &es))) goto err; //This is only for printing, since permutation may regenerate sets
    printf("time: %lf seconds to find permutations of %d symmetry operations in %d equivalence sets\n",time,pg->sopsl,esl);
    
    //for(int i = 0;i < pg->sopsl;i++){printSymmetryOperation(&pg->sops[i]);}
    
    free(sops);
    return ret;
    
err:
    free(ses);
    free(sops);
    return ret;
}
<commit_msg>fix find symmetry bug with changing thresholds<commit_after>//
//  msym.c
//  libmsym
//
//  Created by <NAME> on 30/01/15.
//  Copyright (c) 2015 <NAME>. 
//
//  Distributed under the MIT License ( See LICENSE file or copy at http://opensource.org/licenses/MIT )
//

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "msym.h"
#include "context.h"
#include "symmetry.h"
#include "equivalence_set.h"
#include "point_group.h"
#include "symmetrize.h"
#include "orbital.h"
#include "vibration.h"
#include "linalg.h"

msym_error_t msymFindSymmetry(msym_context ctx){
    msym_error_t ret = MSYM_SUCCESS;
    int elementsl = 0, esl = 0;
    msym_element_t *elements = NULL;
    msym_thresholds_t *t = NULL;
    msym_equivalence_set_t *es = NULL, *des = NULL;;
    msym_point_group_t *pg = NULL;
    int sopsl = 0;
    msym_symmetry_operation_t *sops = NULL;
    msym_equivalence_set_t *ses = NULL;
    int sesl = 0;
    
    clock_t start, end;

    double time;
    
    
    if(MSYM_SUCCESS != (ret = ctxGetElements(ctx, &elementsl, &elements))) goto err;
    
    if(MSYM_SUCCESS != (ret = msymGetThresholds(ctx, &t))) goto err;
    
    if(MSYM_SUCCESS != (ret = ctxGetEquivalenceSets(ctx, &esl, &des))){
        if(MSYM_SUCCESS != (ret = msymFindEquivalenceSets(ctx))) goto err;
    }
    
    if(MSYM_SUCCESS != (ret = ctxGetEquivalenceSets(ctx, &esl, &es))) goto err;
    if(MSYM_SUCCESS != (ret = ctxGetPointGroup(ctx, &pg))){
        start = clock();
        if(MSYM_SUCCESS != (ret = findSymmetryOperations(esl,es,t,&sopsl,&sops))) goto err;
        end = clock();
        time = (double)(end - start) / CLOCKS_PER_SEC;
        printf("time: %lf seconds to find %d symmetry operations in %d equivalence sets\n",time,sopsl,esl);
        start = clock();
        if(MSYM_SUCCESS != (ret = findPointGroup(sopsl, sops, t, &pg))) goto err;
        end = clock();
        time = (double)(end - start) / CLOCKS_PER_SEC;
        printf("time: %lf seconds to find point group %s\n",time,pg->name);
        if(MSYM_SUCCESS != (ret = ctxSetPointGroup(ctx, pg))) {
            free(pg);
            goto err;
        }
        
        // Reuild equivalence sets after determining poing group in case they are very similar
        start = clock();
        //if(MSYM_SUCCESS != (ret = msymFindEquivalenceSets(ctx))) goto err;
        if(MSYM_SUCCESS != (ret = splitPointGroupEquivalenceSets(pg, esl, es, &sesl, &ses, t))) goto err;
        if(MSYM_SUCCESS != (ret = ctxSetEquivalenceSets(ctx, sesl, ses))) goto err;
        ses = NULL; sesl = 0;
        if(MSYM_SUCCESS != (ret = ctxGetEquivalenceSets(ctx, &esl, &es))) goto err;
        end = clock();
        time = (double)(end - start) / CLOCKS_PER_SEC;
        printf("time: %lf seconds to regenerate %d equivalence sets\n",time,esl);
        
    }
    
    start = clock();
    if(MSYM_SUCCESS != (ret = msymFindEquivalenceSetPermutations(ctx))) goto err;
    
    end = clock();
    time = (double)(end - start) / CLOCKS_PER_SEC;
    if(MSYM_SUCCESS != (ret = ctxGetEquivalenceSets(ctx, &esl, &es))) goto err; //This is only for printing, since permutation may regenerate sets
    printf("time: %lf seconds to find permutations of %d symmetry operations in %d equivalence sets\n",time,pg->sopsl,esl);
    
    //for(int i = 0;i < pg->sopsl;i++){printSymmetryOperation(&pg->sops[i]);}
    
    free(sops);
    return ret;
    
err:
    free(ses);
    free(sops);
    if(des == NULL) {
        ctxDestroyEquivalcenceSets(ctx);
    }
    return ret;
}

{'fraction_non_alphanumeric': 0.14256941447273774, 'fraction_numerical': 0.004603654150481945, 'mean_word_length': 2.977116704805492, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2671228', 'n_tokens_mistral': 2546, 'n_tokens_neox': 2426, 'n_words': 607}