Skip to content

Commit

Permalink
rename implementation BitInformation.jl -> julia
Browse files Browse the repository at this point in the history
  • Loading branch information
observingClouds committed Oct 20, 2022
1 parent f683884 commit b70268e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
26 changes: 13 additions & 13 deletions tests/test_get_bitinformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def bitinfo_assert_different(bitinfo1, bitinfo2):
assert (bitinfo1 != bitinfo2).any()


@pytest.mark.parametrize("implementation", ["BitInformation.jl", "python"])
@pytest.mark.parametrize("implementation", ["julia", "python"])
def test_get_bitinformation_returns_dataset(implementation):
"""Test xb.get_bitinformation returns xr.Dataset."""
ds = xr.tutorial.load_dataset("rasm")
Expand All @@ -72,7 +72,7 @@ def test_get_bitinformation_returns_dataset(implementation):
)


@pytest.mark.parametrize("implementation", ["BitInformation.jl", "python"])
@pytest.mark.parametrize("implementation", ["julia", "python"])
def test_get_bitinformation_dim(implementation):
"""Test xb.get_bitinformation is sensitive to dim."""
ds = xr.tutorial.load_dataset("rasm")
Expand All @@ -81,7 +81,7 @@ def test_get_bitinformation_dim(implementation):
assert_different(bitinfo0, bitinfo2)


@pytest.mark.parametrize("implementation", ["BitInformation.jl", "python"])
@pytest.mark.parametrize("implementation", ["julia", "python"])
def test_get_bitinformation_dim_string_equals_axis_int(implementation):
"""Test xb.get_bitinformation undestands xarray dimension names the same way as axis as integers."""
ds = xr.tutorial.load_dataset("rasm")
Expand All @@ -90,7 +90,7 @@ def test_get_bitinformation_dim_string_equals_axis_int(implementation):
assert_identical(bitinfox, bitinfo2)


def test_get_bitinformation_masked_value(implementation="BitInformation.jl"):
def test_get_bitinformation_masked_value(implementation="julia"):
"""Test xb.get_bitinformation is sensitive to masked_value."""
ds = xr.tutorial.load_dataset("rasm")
bitinfo = xb.get_bitinformation(ds, dim="x", implementation=implementation)
Expand All @@ -104,7 +104,7 @@ def test_get_bitinformation_masked_value(implementation="BitInformation.jl"):
assert_different(bitinfo, bitinfo_no_mask)


@pytest.mark.parametrize("implementation", ["BitInformation.jl", "python"])
@pytest.mark.parametrize("implementation", ["julia", "python"])
def test_get_bitinformation_set_zero_insignificant(implementation):
"""Test xb.get_bitinformation is sensitive to set_zero_insignificant."""
ds = xr.tutorial.load_dataset("air_temperature")
Expand All @@ -122,11 +122,11 @@ def test_get_bitinformation_set_zero_insignificant(implementation):
assert implementation == "python"
if implementation == "python":
assert_identical(bitinfo, bitinfo_szi_False)
elif implementation == "BitInformation.jl":
elif implementation == "julia":
assert_different(bitinfo, bitinfo_szi_False)


@pytest.mark.parametrize("implementation", ["BitInformation.jl", "python"])
@pytest.mark.parametrize("implementation", ["julia", "python"])
def test_get_bitinformation_confidence(implementation):
"""Test xb.get_bitinformation is sensitive to confidence."""
ds = xr.tutorial.load_dataset("air_temperature")
Expand All @@ -145,7 +145,7 @@ def test_get_bitinformation_confidence(implementation):
assert implementation == "python"


@pytest.mark.parametrize("implementation", ["BitInformation.jl", "python"])
@pytest.mark.parametrize("implementation", ["julia", "python"])
def test_get_bitinformation_label(rasm, implementation):
"""Test xb.get_bitinformation serializes when label given."""
ds = rasm
Expand All @@ -160,7 +160,7 @@ def test_get_bitinformation_label(rasm, implementation):
os.remove("./tmp_testdir/rasm.json")


@pytest.mark.parametrize("implementation", ["BitInformation.jl", "python"])
@pytest.mark.parametrize("implementation", ["julia", "python"])
@pytest.mark.parametrize("dtype", ["float64", "float32", "float16"])
def test_get_bitinformation_dtype(rasm, dtype, implementation):
"""Test xb.get_bitinformation returns correct number of bits depending on dtype."""
Expand All @@ -172,7 +172,7 @@ def test_get_bitinformation_dtype(rasm, dtype, implementation):
)


@pytest.mark.parametrize("implementation", ["BitInformation.jl", "python"])
@pytest.mark.parametrize("implementation", ["julia", "python"])
def test_get_bitinformation_multidim(rasm, implementation):
"""Test xb.get_bitinformation runs on all dimensions by default"""
ds = rasm
Expand All @@ -187,7 +187,7 @@ def test_get_bitinformation_multidim(rasm, implementation):
assert any(bi_y != bi_x)


@pytest.mark.parametrize("implementation", ["BitInformation.jl", "python"])
@pytest.mark.parametrize("implementation", ["julia", "python"])
def test_get_bitinformation_different_variables_dims(rasm, implementation):
"""Test xb.get_bitinformation runs with variables of different dimensionality"""
ds = rasm
Expand All @@ -200,7 +200,7 @@ def test_get_bitinformation_different_variables_dims(rasm, implementation):
assert_different(bi_Tair_mean_x, bi_Tair_x)


@pytest.mark.parametrize("implementation", ["BitInformation.jl", "python"])
@pytest.mark.parametrize("implementation", ["julia", "python"])
def test_get_bitinformation_different_dtypes(rasm, implementation):
ds = rasm
ds["Tair32"] = ds.Tair.astype("float32")
Expand All @@ -211,7 +211,7 @@ def test_get_bitinformation_different_dtypes(rasm, implementation):
assert bitdim in bi.coords


@pytest.mark.parametrize("implementation", ["BitInformation.jl", "python"])
@pytest.mark.parametrize("implementation", ["julia", "python"])
def test_get_bitinformation_dim_list(rasm, implementation):
bi = xb.get_bitinformation(rasm, dim=["x", "y"], implementation=implementation)
assert (bi.dim == ["x", "y"]).all()
14 changes: 7 additions & 7 deletions xbitinfo/xbitinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def get_bitinformation(
axis=None,
label=None,
overwrite=False,
implementation="BitInformation.jl",
implementation="julia",
**kwargs,
):
"""Wrap `BitInformation.jl.bitinformation() <https://github.com/milankl/BitInformation.jl/blob/main/src/mutual_information.jl>`__.
Expand All @@ -117,14 +117,14 @@ def get_bitinformation(
If ``False``, try using serialized bitinfo based on label; if true or label does not exist, run bitinformation
implementation : str
Bitinformation algorithm implementation. Valid options are
- BitInformation.jl, the original implementation in julia by Milan Kloewer
- python, a copy of the core functionality of BitInformation.jl in python
- julia, the original implementation of julia in julia by Milan Kloewer
- python, a copy of the core functionality of julia in python
kwargs
to be passed to bitinformation:
- masked_value: defaults to ``NaN`` (different to ``bitinformation.jl`` defaulting to ``"nothing"``), set ``None`` disable masking
- masked_value: defaults to ``NaN`` (different to ``julia`` defaulting to ``"nothing"``), set ``None`` disable masking
- mask: use ``masked_value`` instead
- set_zero_insignificant (``bool``): defaults to ``True`` (BitInformation.jl implementation) or ``False`` (python implementation)
- set_zero_insignificant (``bool``): defaults to ``True`` (julia implementation) or ``False`` (python implementation)
- confidence (``float``): defaults to ``0.99``
Expand Down Expand Up @@ -216,7 +216,7 @@ def get_bitinformation(
pbar = tqdm(ds.data_vars)
for var in pbar:
pbar.set_description("Processing %s" % var)
if implementation == "BitInformation.jl":
if implementation == "julia":
info_per_bit_var = _jl_get_bitinformation(ds, var, axis, dim, kwargs)
if info_per_bit_var is None:
continue
Expand Down Expand Up @@ -298,7 +298,7 @@ def _get_bitinformation_along_dims(
dim=None,
label=None,
overwrite=False,
implementation="BitInformation.jl",
implementation="julia",
**kwargs,
):
"""Helper function for :py:func:`xbitinfo.xbitinfo.get_bitinformation` to handle multi-dimensional analysis for each dim specified.
Expand Down

0 comments on commit b70268e

Please sign in to comment.