From c8ae32b4e1920e70f420534ada179e989705735e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 14:10:08 -0500 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#172) --- .pre-commit-config.yaml | 2 +- src/stream_mapper/pytorch/_connect/data.py | 6 +++--- src/stream_mapper/pytorch/builtin/_skewnorm.py | 4 +--- src/stream_mapper/pytorch/builtin/_truncskewnorm.py | 4 +--- src/stream_mapper/pytorch/builtin/compat/nflow.py | 8 +++++--- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2a6bcda..0b25236 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,7 +39,7 @@ repos: - --fix - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black additional_dependencies: [toml] diff --git a/src/stream_mapper/pytorch/_connect/data.py b/src/stream_mapper/pytorch/_connect/data.py index f680b2c..5f2344a 100644 --- a/src/stream_mapper/pytorch/_connect/data.py +++ b/src/stream_mapper/pytorch/_connect/data.py @@ -58,6 +58,6 @@ def _from_ndarraytype_to_tensor( array.flags.writeable = True return replace(data, array=xp.asarray(array, **kwargs)) - ASTYPE_REGISTRY[ - (asdf.tags.core.ndarray.NDArrayType, xp.Tensor) - ] = _from_ndarraytype_to_tensor + ASTYPE_REGISTRY[(asdf.tags.core.ndarray.NDArrayType, xp.Tensor)] = ( + _from_ndarraytype_to_tensor + ) diff --git a/src/stream_mapper/pytorch/builtin/_skewnorm.py b/src/stream_mapper/pytorch/builtin/_skewnorm.py index b9a39f3..48d2d0d 100644 --- a/src/stream_mapper/pytorch/builtin/_skewnorm.py +++ b/src/stream_mapper/pytorch/builtin/_skewnorm.py @@ -87,9 +87,7 @@ def ln_likelihood( # TODO: I suspect there are better ways to write this sigma_o = data[cens].array[idx] sigma = self.xp.exp(ln_s) - skew = ( - skew * sigma / self.xp.sqrt(sigma**2 + (1 + skew**2) * sigma_o**2) - ) + skew = skew * sigma / self.xp.sqrt(sigma**2 + (1 + skew**2) * sigma_o**2) ln_s = self.xp.log(sigma**2 + sigma_o**2) / 2 # Find where -inf diff --git a/src/stream_mapper/pytorch/builtin/_truncskewnorm.py b/src/stream_mapper/pytorch/builtin/_truncskewnorm.py index 46243a6..467583f 100644 --- a/src/stream_mapper/pytorch/builtin/_truncskewnorm.py +++ b/src/stream_mapper/pytorch/builtin/_truncskewnorm.py @@ -80,9 +80,7 @@ def ln_likelihood( # TODO: I suspect there are better ways to write this sigma_o = data[cens].array[idx] sigma = self.xp.exp(ln_s) - skew = ( - skew * sigma / self.xp.sqrt(sigma**2 + (1 + skew**2) * sigma_o**2) - ) + skew = skew * sigma / self.xp.sqrt(sigma**2 + (1 + skew**2) * sigma_o**2) ln_s = self.xp.log(sigma**2 + sigma_o**2) / 2 # Find where -inf diff --git a/src/stream_mapper/pytorch/builtin/compat/nflow.py b/src/stream_mapper/pytorch/builtin/compat/nflow.py index 17b2eb8..c3b9e40 100644 --- a/src/stream_mapper/pytorch/builtin/compat/nflow.py +++ b/src/stream_mapper/pytorch/builtin/compat/nflow.py @@ -23,7 +23,9 @@ def _log_prob(self, data: Data[Array], idx: Array) -> Array: """Log-probability of the array.""" return self.net.log_prob( inputs=data[self.coord_names].array[idx], - context=data[self.indep_coord_names].array[idx] - if self.indep_coord_names is not None - else None, + context=( + data[self.indep_coord_names].array[idx] + if self.indep_coord_names is not None + else None + ), )