<commit_before>"""
Some basic tests for SFR checker (not super rigorous)
need to add a test case that has elevation input by reach
"""

import sys
import os
import flopy
from flopy.modflow.mfsfr2 import check


def load_check_sfr(mfnam, model_ws, checker_output_path):

    #print('Testing {}\n'.format(mfnam) + '='*100)
    m = flopy.modflow.Modflow.load(mfnam, model_ws=model_ws)
    m.change_model_ws(checker_output_path)
    checker_outfile = '{}_SFRcheck.txt'.format(m.get_name())
    
    return m.sfr2.check(checker_outfile, level=1)


def test_sfrcheck():
    path = os.path.join('..', 'examples', 'data', 'mf2005_test')
    cpth = os.path.join('data')
    m = flopy.modflow.Modflow.load('test1tr.nam', model_ws=path, verbose=False)
    
    sfr = flopy.modflow.ModflowSfr2.load(os.path.join(path, 'test1tr.sfr'), m)
    
    # run level=0 check
    m.change_model_ws(cpth)
    fpth = 'SFRchecker_results.txt'
    m.sfr2.check(fpth, level=0)
    
    # test checks without modifications
    chk = check(m.sfr2)
    chk.numbering()
    assert 'continuity in segment and reach numbering' in chk.passed
    chk.routing()
    assert 'circular routing' in chk.passed
    chk.overlapping_conductance()
    assert 'overlapping conductance' in chk.failed # this example model has overlapping conductance
    chk.elevations()
    for test in ['segment elevations', 'reach elevations', 'reach elevations vs. grid elevations']:
        assert test in chk.passed
    chk.slope()<commit_msg>Renamed checker output so that it doesn't run the txt files as py.test.<commit_after>"""
Some basic tests for SFR checker (not super rigorous)
need to add a test case that has elevation input by reach
"""

import sys
import os
import flopy
from flopy.modflow.mfsfr2 import check


def load_check_sfr(mfnam, model_ws, checker_output_path):

    #print('Testing {}\n'.format(mfnam) + '='*100)
    m = flopy.modflow.Modflow.load(mfnam, model_ws=model_ws)
    m.change_model_ws(checker_output_path)
    checker_outfile = 'SFRcheck_{}.txt'.format(m.get_name())
    
    return m.sfr2.check(checker_outfile, level=1)


def test_sfrcheck():
    path = os.path.join('..', 'examples', 'data', 'mf2005_test')
    cpth = os.path.join('data')
    m = flopy.modflow.Modflow.load('test1tr.nam', model_ws=path, verbose=False)
    
    sfr = flopy.modflow.ModflowSfr2.load(os.path.join(path, 'test1tr.sfr'), m)
    
    # run level=0 check
    m.change_model_ws(cpth)
    fpth = 'SFRchecker_results.txt'
    m.sfr2.check(fpth, level=0)
    
    # test checks without modifications
    chk = check(m.sfr2)
    chk.numbering()
    assert 'continuity in segment and reach numbering' in chk.passed
    chk.routing()
    assert 'circular routing' in chk.passed
    chk.overlapping_conductance()
    assert 'overlapping conductance' in chk.failed # this example model has overlapping conductance
    chk.elevations()
    for test in ['segment elevations', 'reach elevations', 'reach elevations vs. grid elevations']:
        assert test in chk.passed
    chk.slope()
{'fraction_non_alphanumeric': 0.11782178217821782, 'fraction_numerical': 0.011221122112211221, 'mean_word_length': 3.758241758241758, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3278106', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1067, 'n_words': 261}