diff --git a/temp.pre-commit-config.yaml b/.pre-commit-config.yaml similarity index 100% rename from temp.pre-commit-config.yaml rename to .pre-commit-config.yaml diff --git a/src/amisc/__init__.py b/src/amisc/__init__.py index 2284078..786d549 100644 --- a/src/amisc/__init__.py +++ b/src/amisc/__init__.py @@ -98,16 +98,17 @@ class Compression { We recommend using the built-in `YamlLoader` for this purpose, as it includes custom YAML tags for reading/writing `amisc` objects from file. """ -from abc import ABC as _ABC, abstractmethod as _abstractmethod +from abc import ABC as _ABC +from abc import abstractmethod as _abstractmethod from pathlib import Path as _Path from typing import Any as _Any import yaml as _yaml -from amisc.variable import Variable, VariableList from amisc.component import Component from amisc.system import System from amisc.utils import to_model_dataset, to_surrogate_dataset +from amisc.variable import Variable, VariableList __version__ = "0.4.0" __all__ = ['System', 'Component', 'Variable', 'VariableList', 'FileLoader', 'YamlLoader', diff --git a/src/amisc/component.py b/src/amisc/component.py index a1d2298..da9d558 100644 --- a/src/amisc/component.py +++ b/src/amisc/component.py @@ -39,13 +39,21 @@ from pydantic import BaseModel, ConfigDict, ValidationInfo, field_validator from typing_extensions import TypedDict -from amisc.interpolator import InterpolatorState, Interpolator, Lagrange -from amisc.serialize import YamlSerializable, PickleSerializable, Serializable, StringSerializable -from amisc.training import TrainingData, SparseGrid -from amisc.typing import MultiIndex, Dataset, LATENT_STR_ID -from amisc.utils import get_logger, format_inputs, format_outputs, search_for_file, to_model_dataset, \ - to_surrogate_dataset -from amisc.utils import _get_yaml_path, _inspect_assignment, _inspect_function +from amisc.interpolator import Interpolator, InterpolatorState, Lagrange +from amisc.serialize import PickleSerializable, Serializable, StringSerializable, YamlSerializable +from amisc.training import SparseGrid, TrainingData +from amisc.typing import LATENT_STR_ID, Dataset, MultiIndex +from amisc.utils import ( + _get_yaml_path, + _inspect_assignment, + _inspect_function, + format_inputs, + format_outputs, + get_logger, + search_for_file, + to_model_dataset, + to_surrogate_dataset, +) from amisc.variable import Variable, VariableList __all__ = ["ModelKwargs", "StringKwargs", "IndexSet", "MiscTree", "Component"] @@ -706,7 +714,8 @@ def _match_index_set(self, index_set, misc_coeff): case 'test': misc_coeff = self.misc_coeff_test case other: - raise ValueError(f"Index set must be 'train' or 'test' if you do not provide `misc_coeff`.") + raise ValueError(f"Index set must be 'train' or 'test' if you do not provide `misc_coeff`. " + f"{other} not recognized.") if isinstance(index_set, str): match index_set: case 'train': @@ -714,7 +723,7 @@ def _match_index_set(self, index_set, misc_coeff): case 'test': index_set = self.active_set.union(self.candidate_set) case other: - raise ValueError(f"Index set must be 'train' or 'test'.") + raise ValueError(f"Index set must be 'train' or 'test'. {other} not recognized.") return index_set, misc_coeff @@ -868,7 +877,7 @@ def call_model(self, inputs: dict | Dataset, ret = (ret,) if not isinstance(ret, tuple) else ret ret = {out_var.name: ret[i] for i, out_var in enumerate(self.outputs)} results.append(ret) - except Exception as e: + except Exception: results.append({'inputs': {k: v[i] for k, v in inputs.items()}, 'index': i, 'model_kwargs': kwargs.copy(), 'error': traceback.format_exc()}) else: # Parallel @@ -893,7 +902,7 @@ def call_model(self, inputs: dict | Dataset, ret = (ret,) if not isinstance(ret, tuple) else ret ret = {out_var.name: ret[i] for i, out_var in enumerate(self.outputs)} results.append(ret) - except Exception as e: + except Exception: results.append({'inputs': {k: v[i] for k, v in inputs.items()}, 'index': i, 'model_kwargs': kwargs.copy(), 'error': traceback.format_exc()}) diff --git a/src/amisc/distribution.py b/src/amisc/distribution.py index 5b1ddd9..036950e 100644 --- a/src/amisc/distribution.py +++ b/src/amisc/distribution.py @@ -14,7 +14,7 @@ """ from __future__ import annotations -from abc import abstractmethod, ABC +from abc import ABC, abstractmethod import numpy as np diff --git a/src/amisc/examples/tutorial.py b/src/amisc/examples/tutorial.py index 49cb815..6fb8081 100644 --- a/src/amisc/examples/tutorial.py +++ b/src/amisc/examples/tutorial.py @@ -28,7 +28,7 @@ def fun2(y): def single_component(): # --8<-- [start:single] - from amisc import Variable, Component, System + from amisc import Component, System, Variable def fun(inputs): return {'y': inputs['x'] ** 2} @@ -69,7 +69,7 @@ def field_quantity(): # --8<-- [start:field_qty] import numpy as np - from amisc import Variable, Component, System, to_model_dataset + from amisc import Component, System, Variable, to_model_dataset from amisc.compression import SVD def my_model(inputs): diff --git a/src/amisc/interpolator.py b/src/amisc/interpolator.py index b6f4f4f..a093e49 100644 --- a/src/amisc/interpolator.py +++ b/src/amisc/interpolator.py @@ -18,8 +18,8 @@ import numpy as np -from amisc.serialize import Serializable, Base64Serializable, StringSerializable -from amisc.typing import MultiIndex, Dataset +from amisc.serialize import Base64Serializable, Serializable, StringSerializable +from amisc.typing import Dataset, MultiIndex __all__ = ["InterpolatorState", "LagrangeState", "Interpolator", "Lagrange"] @@ -120,7 +120,7 @@ def from_dict(cls, config: dict) -> Interpolator: case 'lagrange': return Lagrange(**config) case other: - raise NotImplementedError(f"Unknown interpolator method: {method}") + raise NotImplementedError(f"Unknown interpolator method: {other}") @dataclass @@ -401,7 +401,8 @@ def hessian(self, x: Dataset, state: LagrangeState, training_data: tuple[Dataset curr_j_idx = div_zero_idx[..., k, j[k]] other_j_idx = np.any(other_pts[..., k, :], axis=-1) dLJ_dx[curr_j_idx] = -np.nansum((w_j[k, p_idx] / w_j[k, j[k]]) / - (x_arr[curr_j_idx, k, np.newaxis] - x_j[k, p_idx]), axis=-1) + (x_arr[curr_j_idx, k, np.newaxis] - x_j[k, p_idx]), + axis=-1) dLJ_dx[other_j_idx] = ((w_j[k, j[k]] / w_j_large[other_pts[..., k, :]]) / (x_arr[other_j_idx, k] - x_j[k, j[k]])) @@ -430,11 +431,11 @@ def hessian(self, x: Dataset, state: LagrangeState, training_data: tuple[Dataset # if these points are at the current j interpolation point d2LJ_dx2[curr_j_idx] = (2 * np.nansum((w_j[m, p_idx] / w_j[m, j[m]]) / - (x_arr[curr_j_idx, m, np.newaxis] - x_j[m, p_idx]), - axis=-1) ** 2 + # noqa: E501 + (x_arr[curr_j_idx, m, np.newaxis] - x_j[m, p_idx]), # noqa: E501 + axis=-1) ** 2 + 2 * np.nansum((w_j[m, p_idx] / w_j[m, j[m]]) / - (x_arr[curr_j_idx, m, np.newaxis] - x_j[m, p_idx]) ** 2, - axis=-1)) # noqa: E501 + (x_arr[curr_j_idx, m, np.newaxis] - x_j[m, p_idx]) ** 2, # noqa: E501 + axis=-1)) # if these points are at any other interpolation point other_pts_inv = other_pts.copy() diff --git a/src/amisc/system.py b/src/amisc/system.py index 7728a9e..c9687d2 100644 --- a/src/amisc/system.py +++ b/src/amisc/system.py @@ -31,11 +31,11 @@ import random import string import time -from collections import ChainMap, deque, UserList -from concurrent.futures import Executor, wait, ALL_COMPLETED +from collections import ChainMap, UserList, deque +from concurrent.futures import ALL_COMPLETED, Executor, wait from datetime import timezone from pathlib import Path -from typing import ClassVar, Annotated, Optional, Callable, Literal +from typing import Annotated, Callable, ClassVar, Literal, Optional import matplotlib.pyplot as plt import networkx as nx @@ -46,10 +46,18 @@ from amisc.component import Component, IndexSet, MiscTree from amisc.serialize import Serializable, _builtin -from amisc.utils import get_logger, format_inputs, format_outputs, constrained_lls, relative_error, to_model_dataset, \ - to_surrogate_dataset, _combine_latent_arrays +from amisc.typing import LATENT_STR_ID, Dataset, MultiIndex, TrainIteration +from amisc.utils import ( + _combine_latent_arrays, + constrained_lls, + format_inputs, + format_outputs, + get_logger, + relative_error, + to_model_dataset, + to_surrogate_dataset, +) from amisc.variable import VariableList -from amisc.typing import Dataset, TrainIteration, MultiIndex, LATENT_STR_ID __all__ = ['TrainHistory', 'System'] @@ -650,8 +658,8 @@ def fit(self, targets: list = None, var.update_domain(var.denormalize(new_domain), override=True) del y_samples else: - self.logger.warning(f'Could not estimate bounds for coupling variables: no test set provided. ' - f'Make sure you manually provide (good) coupling variable domains.') + self.logger.warning('Could not estimate bounds for coupling variables: no test set provided. ' + 'Make sure you manually provide (good) coupling variable domains.') # Track convergence progress on the error indicator and test set (plot to file) if self.root_dir is not None: @@ -1153,8 +1161,8 @@ def _end_conditions_met(): start_idx = 0 for j, var in enumerate(coupling_prev): end_idx = start_idx + xdims[j] - coupling_snap[:, start_idx:end_idx, i] = coupling_iter[var][samples.curr_idx, ...].reshape((N_curr, -1)) - res_snap[:, start_idx:end_idx, i] = residual_iter[var][samples.curr_idx, ...].reshape((N_curr, -1)) + coupling_snap[:, start_idx:end_idx, i] = coupling_iter[var][samples.curr_idx, ...].reshape((N_curr, -1)) # noqa: E501 + res_snap[:, start_idx:end_idx, i] = residual_iter[var][samples.curr_idx, ...].reshape((N_curr, -1)) # noqa: E501 start_idx = end_idx C = np.ones((N_curr, 1, mk)) b = np.zeros((N_curr, N_couple, 1)) @@ -1164,7 +1172,7 @@ def _end_conditions_met(): start_idx = 0 for j, var in enumerate(coupling_prev): end_idx = start_idx + xdims[j] - coupling_prev[var][samples.curr_idx, ...] = coupling_new[:, start_idx:end_idx].reshape((N_curr, *var_shapes[j])) + coupling_prev[var][samples.curr_idx, ...] = coupling_new[:, start_idx:end_idx].reshape((N_curr, *var_shapes[j])) # noqa: E501 start_idx = end_idx k += 1 diff --git a/src/amisc/training.py b/src/amisc/training.py index 2fc1172..4d1ec20 100644 --- a/src/amisc/training.py +++ b/src/amisc/training.py @@ -11,18 +11,18 @@ import copy import itertools from abc import ABC, abstractmethod -from dataclasses import field, dataclass +from dataclasses import dataclass, field from typing import Any, ClassVar import numpy as np +from numpy.typing import ArrayLike from scipy.optimize import direct from sklearn.linear_model import Ridge from sklearn.pipeline import Pipeline from sklearn.preprocessing import MaxAbsScaler -from numpy.typing import ArrayLike from amisc.serialize import PickleSerializable, Serializable -from amisc.typing import MultiIndex, Dataset, LATENT_STR_ID +from amisc.typing import LATENT_STR_ID, Dataset, MultiIndex __all__ = ['TrainingData', 'SparseGrid'] @@ -124,7 +124,7 @@ def from_dict(cls, config: dict) -> TrainingData: case 'sparse-grid': return SparseGrid(**config) case other: - raise NotImplementedError(f"Unknown training data method: {method}") + raise NotImplementedError(f"Unknown training data method: {other}") @dataclass @@ -245,7 +245,7 @@ def set(self, alpha: MultiIndex, beta: MultiIndex, coords: list, yi_dict: dict[s new_yi = {} for var, yi in yi_dict.items(): yi = np.atleast_1d(yi[i]) - new_yi[var] = (float(yi[0]) if self._is_numeric(yi) else yi[0]) if self._is_singleton(yi) else yi.tolist() + new_yi[var] = (float(yi[0]) if self._is_numeric(yi) else yi[0]) if self._is_singleton(yi) else yi.tolist() # noqa: E501 self.yi_map[alpha][coord] = copy.deepcopy(new_yi) def impute_missing_data(self, alpha: MultiIndex, beta: MultiIndex): @@ -419,7 +419,7 @@ def _numeric_outputs(cls, yi_dict: dict[str, ArrayLike]) -> list[str]: try: if cls._is_numeric(np.atleast_1d(yi_dict[var])): output_vars.append(var) - except: + except Exception: continue return output_vars @@ -507,6 +507,6 @@ def collocation_1d(N: int, z_bds: tuple, z_pts: np.ndarray = None, z_star = res.x z_pts = np.concatenate((z_pts, z_star)) case other: - raise NotImplementedError(f"Unknown collocation method: {method}") + raise NotImplementedError(f"Unknown collocation method: {other}") return z_pts diff --git a/src/amisc/transform.py b/src/amisc/transform.py index fbffb88..9947870 100644 --- a/src/amisc/transform.py +++ b/src/amisc/transform.py @@ -49,7 +49,8 @@ def from_string(cls, transform_spec: str | list[str]) -> list[Transform] | None: default, `(a, b)` is the Variable's domain and `(l, u)` is `(0, 1)`. Use simply as `minmax` to use all defaults. - **zscore** — $x_{norm} = \\frac{x - m}{s}$ specified as `zscore(m, s)` or `zscore(mu=m, std=s)`. If the - Variable is specified as `distribution=normal`, then `zscore` defaults to the Variable's own `mu, std`. + Variable is specified as `distribution=normal`, then `zscore` defaults to the Variable's + own `mu, std`. !!! Example ```python diff --git a/src/amisc/typing.py b/src/amisc/typing.py index b5884e6..3e586ce 100644 --- a/src/amisc/typing.py +++ b/src/amisc/typing.py @@ -12,11 +12,9 @@ from pathlib import Path as _Path from typing import Optional as _Optional -from typing_extensions import TypedDict as _TypedDict - import numpy as _np from numpy.typing import ArrayLike as _ArrayLike - +from typing_extensions import TypedDict as _TypedDict __all__ = ["MultiIndex", "Dataset", "TrainIteration", "CompressionData", "LATENT_STR_ID"] diff --git a/src/amisc/utils.py b/src/amisc/utils.py index a597a4c..cec5a3b 100644 --- a/src/amisc/utils.py +++ b/src/amisc/utils.py @@ -21,6 +21,7 @@ import re import sys from pathlib import Path +from typing import TYPE_CHECKING import numpy as np import yaml @@ -28,8 +29,10 @@ __all__ = ['parse_function_string', 'relative_error', 'get_logger', 'format_inputs', 'format_outputs', 'search_for_file', 'constrained_lls', 'to_surrogate_dataset', 'to_model_dataset'] -import amisc.variable -from amisc.typing import Dataset, LATENT_STR_ID +from amisc.typing import LATENT_STR_ID, Dataset + +if TYPE_CHECKING: + import amisc.variable LOG_FORMATTER = logging.Formatter(u"%(asctime)s — [%(levelname)s] — %(name)-15s — %(message)s") @@ -44,7 +47,7 @@ def _combine_latent_arrays(arr): del arr[var] -def to_surrogate_dataset(dataset: Dataset, variables: amisc.variable.VariableList, del_fields: bool = True, +def to_surrogate_dataset(dataset: Dataset, variables: 'amisc.variable.VariableList', del_fields: bool = True, **field_coords) -> tuple[Dataset, list[str]]: """Convert true model input/output dataset to a form usable by the surrogate. Primarily, compress field quantities and normalize. @@ -80,7 +83,7 @@ def to_surrogate_dataset(dataset: Dataset, variables: amisc.variable.VariableLis return dataset, surr_vars -def to_model_dataset(dataset: Dataset, variables: amisc.variable.VariableList, del_latent: bool = True, +def to_model_dataset(dataset: Dataset, variables: 'amisc.variable.VariableList', del_latent: bool = True, **field_coords) -> tuple[Dataset, Dataset]: """Convert surrogate input/output dataset to a form usable by the true model. Primarily, reconstruct field quantities and denormalize. @@ -181,7 +184,7 @@ def visit_Return(self, node): return_visitor.visit(tree) return pos_args, return_visitor.return_values - except: + except Exception: return [], [] @@ -221,7 +224,7 @@ def __init__(self): if isinstance(assignment.value, ast.Call) and isinstance(assignment.value.func, ast.Name): if assignment.value.func.id == class_name: variable_name = target_name - except: + except Exception: variable_name = None finally: # del current_frame, caller_frame diff --git a/src/amisc/variable.py b/src/amisc/variable.py index a7bb3c3..50b8912 100644 --- a/src/amisc/variable.py +++ b/src/amisc/variable.py @@ -26,11 +26,11 @@ from pydantic import BaseModel, ConfigDict, ValidationInfo, field_validator from amisc.compression import Compression -from amisc.distribution import Distribution, Normal, Uniform, LogUniform +from amisc.distribution import Distribution, LogUniform, Normal, Uniform from amisc.serialize import Serializable -from amisc.transform import Transform, Minmax, Zscore -from amisc.utils import search_for_file, _get_yaml_path, _inspect_assignment -from amisc.typing import CompressionData, LATENT_STR_ID +from amisc.transform import Minmax, Transform, Zscore +from amisc.typing import LATENT_STR_ID, CompressionData +from amisc.utils import _get_yaml_path, _inspect_assignment, search_for_file __all__ = ['Variable', 'VariableList'] _TransformLike = Union[str, Transform, list[str | Transform]] # something that can be converted to a Transform diff --git a/tests/profile_fit.py b/tests/profile_fit.py index 4b89c54..fc1897a 100644 --- a/tests/profile_fit.py +++ b/tests/profile_fit.py @@ -5,7 +5,7 @@ import numpy as np from matplotlib import pyplot as plt -from amisc import Variable, Component, System +from amisc import Component, System, Variable def io_bound_model(inputs, model_cost=1): diff --git a/tests/profile_predict.py b/tests/profile_predict.py index 8cfa085..994dbff 100644 --- a/tests/profile_predict.py +++ b/tests/profile_predict.py @@ -12,11 +12,10 @@ """ from concurrent.futures import ProcessPoolExecutor -from pathlib import Path import numpy as np -from amisc import Variable, Component, System +from amisc import Component, System, Variable def compute_output(inputs): @@ -68,7 +67,7 @@ def predict_surrogate(save_file): for num_samples in sample_nums: inputs = surr.sample_inputs(num_samples) - outputs = surr.predict(inputs) + outputs = surr.predict(inputs) # noqa: F841 if __name__ == '__main__': diff --git a/tests/test_component.py b/tests/test_component.py index 38e40ce..c9f442d 100644 --- a/tests/test_component.py +++ b/tests/test_component.py @@ -10,12 +10,12 @@ import numpy as np from matplotlib import pyplot as plt from numpy.typing import ArrayLike -from uqtils import ax_default, approx_hess, approx_jac +from uqtils import approx_hess, approx_jac, ax_default from amisc import YamlLoader from amisc.component import Component, IndexSet, MiscTree, ModelKwargs, StringKwargs from amisc.compression import SVD -from amisc.interpolator import LagrangeState, Interpolator, InterpolatorState +from amisc.interpolator import Interpolator, InterpolatorState, LagrangeState from amisc.serialize import Base64Serializable, Serializable, StringSerializable from amisc.training import TrainingData from amisc.typing import LATENT_STR_ID @@ -453,7 +453,8 @@ def test_comp_jacobian_and_hessian(): f2 = lambda theta: np.exp(theta['x2']) * theta['x1'] + np.sin(theta['x3']) * theta['x2'] fun = lambda theta: {'y1': f1(theta), 'y2': f2(theta)} - x1, x2, x3 = Variable('x1', distribution='U(0, 2)'), Variable('x2', distribution='U(-1, 1)'), Variable('x3', distribution='U(-3.14, 3.14)') + x1, x2, x3 = (Variable('x1', distribution='U(0, 2)'), Variable('x2', distribution='U(-1, 1)'), + Variable('x3', distribution='U(-3.14, 3.14)')) y1, y2 = Variable('y1'), Variable('y2') max_beta = (4, 4, 5) diff --git a/tests/test_interpolator.py b/tests/test_interpolator.py index 9317ef0..9136737 100644 --- a/tests/test_interpolator.py +++ b/tests/test_interpolator.py @@ -7,9 +7,9 @@ from amisc.examples.models import nonlinear_wave, tanh_func from amisc.interpolator import Lagrange +from amisc.training import SparseGrid from amisc.utils import relative_error from amisc.variable import Variable -from amisc.training import SparseGrid def test_tensor_product_1d(plots=False): @@ -164,7 +164,8 @@ def test_interp_jacobian_and_hessian(): np.sin(theta['x3']) * theta['x1']) fun = lambda theta: {'y1': f1(theta), 'y2': f2(theta)} - x1, x2, x3 = Variable('x1', distribution='U(-2, 1)'), Variable('x2', distribution='U(-1, 2)'), Variable('x3', distribution='U(-3.14, 3.14)') + x1, x2, x3 = (Variable('x1', distribution='U(-2, 1)'), Variable('x2', distribution='U(-1, 2)'), + Variable('x3', distribution='U(-3.14, 3.14)')) interp = Lagrange() domains = {'x1': x1.get_domain(), 'x2': x2.get_domain(), 'x3': x3.get_domain()} alpha = () diff --git a/tests/test_serialize.py b/tests/test_serialize.py index 273e899..dc0265c 100644 --- a/tests/test_serialize.py +++ b/tests/test_serialize.py @@ -1,5 +1,5 @@ """Test serialization mixin classes.""" -from amisc.serialize import Base64Serializable, YamlSerializable, PickleSerializable, Serializable, StringSerializable +from amisc.serialize import Base64Serializable, PickleSerializable, Serializable, StringSerializable, YamlSerializable class ClassTestBase64(Base64Serializable): diff --git a/tests/test_system.py b/tests/test_system.py index eee74f9..4217bb2 100644 --- a/tests/test_system.py +++ b/tests/test_system.py @@ -10,7 +10,7 @@ from scipy.stats import gaussian_kde from uqtils import ax_default -from amisc import Variable, Component, System +from amisc import Component, System, Variable from amisc.compression import SVD from amisc.utils import relative_error, to_model_dataset diff --git a/tests/test_system_spec.py b/tests/test_system_spec.py index d3ea707..a15578a 100644 --- a/tests/test_system_spec.py +++ b/tests/test_system_spec.py @@ -1,4 +1,5 @@ """Test that the [`SystemSurrogate`][amisc.system.SystemSurrogate] class validation works.""" +# ruff: noqa: E741 import os import shutil import warnings @@ -7,7 +8,7 @@ import numpy as np import pytest -from amisc import Variable, Component, System, YamlLoader +from amisc import Component, System, Variable, YamlLoader from amisc.system import TrainHistory @@ -110,7 +111,7 @@ def my_model(inputs): with pytest.raises(ValueError): s = System(Component(my_model, inputs=None, outputs=None)) with pytest.raises(ValueError): - s2 = System(lambda: None) + s2 = System(lambda: None) # noqa: F841 def test_save_and_load(tmp_path): diff --git a/tests/test_training_data.py b/tests/test_training_data.py index 8b69507..a8c4a3b 100644 --- a/tests/test_training_data.py +++ b/tests/test_training_data.py @@ -5,8 +5,8 @@ from amisc.compression import SVD from amisc.training import SparseGrid -from amisc.variable import Variable, VariableList from amisc.utils import to_model_dataset +from amisc.variable import Variable, VariableList def test_sparse_grid(): diff --git a/tests/test_utils.py b/tests/test_utils.py index ede2ba8..b33c7b9 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,4 +1,5 @@ """Test the package utilities.""" +# ruff: noqa: E741 import time import numpy as np @@ -6,8 +7,15 @@ from amisc.compression import SVD from amisc.typing import LATENT_STR_ID -from amisc.utils import get_logger, parse_function_string, format_inputs, _inspect_function, constrained_lls -from amisc.utils import to_model_dataset, to_surrogate_dataset +from amisc.utils import ( + _inspect_function, + constrained_lls, + format_inputs, + get_logger, + parse_function_string, + to_model_dataset, + to_surrogate_dataset, +) from amisc.variable import Variable, VariableList diff --git a/tests/test_variable.py b/tests/test_variable.py index e300fdc..de6221b 100644 --- a/tests/test_variable.py +++ b/tests/test_variable.py @@ -3,9 +3,9 @@ import pytest from amisc import YamlLoader +from amisc.compression import SVD from amisc.utils import relative_error from amisc.variable import Variable, VariableList -from amisc.compression import SVD def test_load_and_dump_variables(tmp_path): @@ -62,7 +62,8 @@ def test_two_norms(): xnorm2 = var2.normalize(x) xtilde1 = var1.normalize(xnorm1, denorm=True) xtilde2 = var2.normalize(xnorm2, denorm=True) - assert np.allclose(x, xtilde1), f'Failed the two-normalization test for distribution: {dist_method}, norm: {case}' + assert np.allclose(x, xtilde1), (f'Failed the two-normalization test for distribution: {dist_method}, ' + f'norm: {case}') assert np.allclose(x, xtilde2), (f'Failed the two-normalization test for distribution: ' f'{dist_method}, norm: {var2.norm}')