Skip to content

Commit

Permalink
test(utils): stub head/budget file write fn tests, rebase onto develop
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Dec 19, 2022
1 parent b401abe commit fe42a91
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 37 deletions.
1 change: 0 additions & 1 deletion .github/workflows/commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
branches:
- master
- develop
- release*
- ci-diagnose*
pull_request:
branches:
Expand Down
29 changes: 0 additions & 29 deletions autotest/generate_classes.py

This file was deleted.

48 changes: 41 additions & 7 deletions autotest/test_binaryfile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from pprint import pprint

import numpy as np
import pytest
from autotest.conftest import get_example_data_path
Expand All @@ -13,7 +15,12 @@
HeadUFile,
Util2d,
)
from flopy.utils.binaryfile import get_headfile_precision
from flopy.utils.binaryfile import (
get_headfile_precision,
write_budget,
write_head,
)
from flopy.utils.gridutil import uniform_flow_field


@pytest.fixture
Expand Down Expand Up @@ -241,11 +248,38 @@ def test_budgetfile_detect_precision_double(path):
assert file.realtype == np.float64


@pytest.mark.skip(reason="todo")
def test_write_head():
pass
def test_write_head(function_tmpdir):
file_path = function_tmpdir / "headfile"
head_data = np.random.random((10, 10))

write_head(file_path, head_data)

assert file_path.is_file()
content = np.fromfile(file_path)
assert np.array_equal(head_data.ravel(), content)

# TODO: what else needs to be checked here?


def test_write_budget(function_tmpdir):
file_path = function_tmpdir / "budgetfile"

nlay = 3
nrow = 3
ncol = 3
qx = 1.0
qy = 0.0
qz = 0.0
shape = (nlay, nrow, ncol)
spdis, flowja = uniform_flow_field(qx, qy, qz, shape)

write_budget(file_path, flowja, kstp=0)
assert file_path.is_file()
content1 = np.fromfile(file_path)

write_budget(file_path, flowja, kstp=1, kper=1, text="text")
assert file_path.is_file()
content2 = np.fromfile(file_path)

@pytest.mark.skip(reason="todo")
def test_write_budget():
pass
# TODO: why are these the same?
assert np.array_equal(content1, content2)

0 comments on commit fe42a91

Please sign in to comment.