Skip to content
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

joseki version 2.4.0 #355

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
## [2.4.0] - 2023-08-04

### Added

* parameter `regularize` to `make`.
* parameters `rescale_to` and `check_x_sum` to `make`.
* Tests for `make` with parameters `regularize` and `rescale_to`
* Instructions to run tests and verify test coverage for maintainers

### Changed

Expand Down
13 changes: 13 additions & 0 deletions maintainers.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@
* run the notebook and check that it executes successfully
* strip the output: `nbstripout docs/tutorials`
* convert to markdown: `jupyter nbconvert --to markdown docs/tutorials.ipynb`

## Run the tests and verify test coverage

* run the test with `pytest tests`
* to verify the test coverage, run:
```shell
coverage run -m pytest -v tests
python -m coverage combine
python -m coverage html --skip-covered --skip-empty
python -m coverage report --fail-under=100
```
and inspect the coverage report.

## Make a PyPI/conda release

### Before the release
Expand Down
2 changes: 1 addition & 1 deletion src/joseki/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.3.0"
__version__ = "2.4.0"
69 changes: 66 additions & 3 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,71 @@ def test_make_conserve_column():
significant=6
)

def test_select_molecules():
"""Returns xr.Dataset."""
def test_make_molecules():
"""Returns dataset with molecules corresponding to selection."""
ds = make(identifier="afgl_1986-tropical", molecules=["H2O", "CO2"])
assert ds.joseki.molecules == ["H2O", "CO2"]


def test_make_regularize_bool():
"""Returns valid dataset with constant altitude step."""
ds = make(identifier="afgl_1986-tropical", regularize=True)

assert np.allclose(
np.diff(ds.z.values),
np.diff(ds.z.values)[0],
rtol=1e-9,
atol=1e-6,
)
assert ds.joseki.is_valid


def test_make_regularize_dict():
"""Returns valid dataset with constant altitude step."""
num = 1201
ds = make(
identifier="afgl_1986-tropical",
regularize={"options": {"num": num}},
)

assert ds.z.size == num


@pytest.mark.parametrize(
"target",
[
{
"H2O": 25 * ureg.kg / ureg.m**2
},
{
"H2O": 25 * ureg.kg / ureg.m**2,
"CO2": 420 * ureg.ppm
},
{
"H2O": 25 * ureg.kg / ureg.m**2,
"CO2": 420 * ureg.ppm,
"O3": 350 * ureg.dobson_unit
}
],
)
def test_make_rescale_to(target):
ds = make(
identifier="afgl_1986-tropical",
rescale_to=target,
)
value = {
"H2O": ds.joseki.column_mass_density["H2O"],
"CO2": ds.joseki.mole_fraction_at_sea_level["CO2"],
"O3": ds.joseki.column_number_density["O3"],
}

for molecule in target:
assert_approx_equal(
value[molecule].m_as(target[molecule].units),
target[molecule].m,
significant=6,
)

def test_open_dataset(tmpdir):
"""Returns xr.Dataset."""
ds = make(identifier="afgl_1986-tropical")
Expand All @@ -96,6 +156,7 @@ def test_open_dataset(tmpdir):
ds2 = open_dataset(path)
assert ds2.joseki.is_valid


def test_load_dataset(tmpdir):
"""Returns xr.Dataset."""
ds = make(identifier="afgl_1986-tropical")
Expand All @@ -104,12 +165,14 @@ def test_load_dataset(tmpdir):
ds2 = load_dataset(path)
assert ds2.joseki.is_valid

def test_merge_1():

def test_merge():
ds1 = make(identifier="afgl_1986-tropical", molecules=["H2O", "CO2"])
ds2 = make(identifier="afgl_1986-tropical", molecules=["O3"])
ds = merge([ds1, ds2])
assert ds.joseki.molecules == ["H2O", "CO2", "O3"]


def test_identifiers():
"""Returns list of identifiers."""
assert isinstance(identifiers(), list)
Loading