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

Follow up PR#866 ♻️ - 👌Minor cosmetic changes #965

Merged
merged 1 commit into from
Jan 22, 2022
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: 2 additions & 2 deletions benchmark/pytest/analysis/test_optimization_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
np.ones((TEST_AXIS_GLOBAL_SIZE, TEST_AXIS_MODEL_SIZE)),
coords=(("global", TEST_AXIS_GLOBAL.data), ("test", TEST_AXIS_MODEL.data)),
)
TEST_PARAMETER = ParameterGroup.from_list([])
TEST_PARAMETERS = ParameterGroup.from_list([])


@megacomplex(dimension="test", properties={"is_index_dependent": bool})
Expand Down Expand Up @@ -74,7 +74,7 @@ def setup_model(index_dependent, link_clp):
def setup_scheme(model):
return Scheme(
model=model,
parameters=TEST_PARAMETER,
parameters=TEST_PARAMETERS,
data={
"dataset1": TEST_DATA,
"dataset2": TEST_DATA,
Expand Down
6 changes: 3 additions & 3 deletions glotaran/builtin/io/yml/test/test_save_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from glotaran.project import Scheme
from glotaran.testing.simulated_data.sequential_spectral_decay import DATASET
from glotaran.testing.simulated_data.sequential_spectral_decay import MODEL
from glotaran.testing.simulated_data.sequential_spectral_decay import PARAMETER
from glotaran.testing.simulated_data.sequential_spectral_decay import PARAMETERS

if TYPE_CHECKING:
from pathlib import Path
Expand All @@ -36,11 +36,11 @@

def test_save_scheme(tmp_path: Path):
save_model(MODEL, tmp_path / "m.yml")
save_parameters(PARAMETER, tmp_path / "p.csv")
save_parameters(PARAMETERS, tmp_path / "p.csv")
save_dataset(DATASET, tmp_path / "d.nc")
scheme = Scheme(
MODEL,
PARAMETER,
PARAMETERS,
{"dataset_1": DATASET},
)
scheme_path = tmp_path / "testscheme.yml"
Expand Down
10 changes: 4 additions & 6 deletions glotaran/deprecation/deprecation_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,9 +611,8 @@ def deprecate_module_attribute(
Version the support for this usage will be removed.
module_load_overwrite : str
Overwrite the location the functionality will be set from.
This allows preserving functionality without polluting new
module with code just for the sake of it.
, by default ''
This allows preserving functionality without polluting a new
module with code just for the sake of it. By default ''

Returns
-------
Expand Down Expand Up @@ -703,9 +702,8 @@ def deprecate_submodule(
Version the support for this usage will be removed.
module_load_overwrite : str
Overwrite the location for the new module the deprecated functionality is loaded from.
This allows preserving functionality without polluting new
module with code just for the sake of it.
, by default ''
This allows preserving functionality without polluting a new
module with code just for the sake of it. By default ''

Returns
-------
Expand Down
4 changes: 2 additions & 2 deletions glotaran/deprecation/modules/examples/sequential.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"scheme": "SCHEME",
}
shared_deprecation_mapping = {
"wanted_parameter": "SIMULATION_PARAMETER",
"parameter": "PARAMETER",
"wanted_parameter": "SIMULATION_PARAMETERS",
"parameter": "PARAMETERS",
"_time": "TIME_AXIS",
"_spectral": "SPECTRAL_AXIS",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_io_read_data_file(recwarn: WarningsRecorder):
"attribute_name", ("sim_model", "dataset", "model", "scheme", "wanted_parameter", "parameter")
)
def test_examples_sequential(recwarn: WarningsRecorder, attribute_name: str):
"""glotaran.examples.sequential exported addributes"""
"""glotaran.examples.sequential exported attributes"""
from glotaran.examples import sequential # noqa: F401

recwarn.clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from textwrap import dedent

from glotaran.deprecation.modules.test import deprecation_warning_on_call_test_helper
from glotaran.testing.simulated_data.sequential_spectral_decay import PARAMETER
from glotaran.testing.simulated_data.sequential_spectral_decay import PARAMETERS


def test_parameter_group_to_csv_no_stderr(tmp_path: Path):
"""``ParameterGroup.to_csv`` raises deprecation warning and saves file."""
parameter_path = tmp_path / "test_parameter.csv"
deprecation_warning_on_call_test_helper(
PARAMETER.to_csv, args=[parameter_path.as_posix()], raise_exception=True
PARAMETERS.to_csv, args=[parameter_path.as_posix()], raise_exception=True
)
expected = dedent(
"""\
Expand Down
8 changes: 4 additions & 4 deletions glotaran/deprecation/modules/test/test_project_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from glotaran.project.scheme import Scheme
from glotaran.testing.simulated_data.parallel_spectral_decay import DATASET
from glotaran.testing.simulated_data.parallel_spectral_decay import MODEL
from glotaran.testing.simulated_data.parallel_spectral_decay import PARAMETER
from glotaran.testing.simulated_data.parallel_spectral_decay import PARAMETERS

if TYPE_CHECKING:
from pathlib import Path
Expand Down Expand Up @@ -58,7 +58,7 @@ def test_scheme_from_yaml_file_method(tmp_path: Path):

def test_scheme_group_tolerance():
"""Argument ``group_tolerance`` raises deprecation and maps to ``clp_link_tolerance``."""
model, parameters, dataset = MODEL, PARAMETER, DATASET
model, parameters, dataset = MODEL, PARAMETERS, DATASET

warnings, result = deprecation_warning_on_call_test_helper(
Scheme,
Expand All @@ -78,7 +78,7 @@ def test_scheme_group_tolerance():
)
def test_scheme_group(group: bool):
"""Argument ``group`` raises deprecation and maps to ``dataset_groups.default.link_clp``."""
model, parameters, dataset = MODEL, PARAMETER, DATASET
model, parameters, dataset = MODEL, PARAMETERS, DATASET

warnings, result = deprecation_warning_on_call_test_helper(
Scheme,
Expand All @@ -100,7 +100,7 @@ def test_scheme_non_negative_least_squares(non_negative_least_squares: bool, exp
"""Argument ``non_negative_least_squares`` raises deprecation and maps to
``dataset_groups.default.residual_function``.
"""
model, parameters, dataset = MODEL, PARAMETER, DATASET
model, parameters, dataset = MODEL, PARAMETERS, DATASET

warnings, result = deprecation_warning_on_call_test_helper(
Scheme,
Expand Down
10 changes: 5 additions & 5 deletions glotaran/parameter/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ class Keys:
VARY = "vary"


PARAMETER_EXPRESION_REGEX = re.compile(r"\$(?P<parameter_expression>[\w\d\.]+)((?![\w\d\.]+)|$)")
"""A regexpression to find and replace parameter names in expressions."""
PARAMETER_EXPRESSION_REGEX = re.compile(r"\$(?P<parameter_expression>[\w\d\.]+)((?![\w\d\.]+)|$)")
"""A regular expression to find and replace parameter names in expressions."""
VALID_LABEL_REGEX = re.compile(r"\W", flags=re.ASCII)
"""A regexpression to validate labels."""
"""A regular expression to validate labels."""


class Parameter(_SupportsArray):
Expand Down Expand Up @@ -394,7 +394,7 @@ def transformed_expression(self) -> str | None:
The transformed expression.
"""
if self.expression is not None and self._transformed_expression is None:
self._transformed_expression = PARAMETER_EXPRESION_REGEX.sub(
self._transformed_expression = PARAMETER_EXPRESSION_REGEX.sub(
r"group.get('\g<parameter_expression>').value", self.expression
)
return self._transformed_expression
Expand Down Expand Up @@ -500,7 +500,7 @@ def markdown(
elif parameter.expression is not None:
expression = parameter.expression
if all_parameters is not None:
for match in PARAMETER_EXPRESION_REGEX.findall(expression):
for match in PARAMETER_EXPRESSION_REGEX.findall(expression):
label = match[0]
parameter = all_parameters.get(label)
expression = expression.replace(
Expand Down
9 changes: 4 additions & 5 deletions glotaran/testing/simulated_data/parallel_spectral_decay.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
from glotaran.io import load_model
from glotaran.project import Scheme
from glotaran.project.generators import generate_model_yml
from glotaran.testing.simulated_data.shared_decay import PARAMETER
from glotaran.testing.simulated_data.shared_decay import PARAMETERS
from glotaran.testing.simulated_data.shared_decay import SIMULATION_COORDINATES
from glotaran.testing.simulated_data.shared_decay import SIMULATION_PARAMETER
from glotaran.testing.simulated_data.shared_decay import * # noqa F403
from glotaran.testing.simulated_data.shared_decay import SIMULATION_PARAMETERS

SIMULATION_MODEL_YML = generate_model_yml(
generator_name="spectral_decay_parallel",
Expand All @@ -24,10 +23,10 @@
DATASET = simulate(
SIMULATION_MODEL,
"dataset_1",
SIMULATION_PARAMETER,
SIMULATION_PARAMETERS,
SIMULATION_COORDINATES,
noise=True,
noise_std_dev=1e-2,
)

SCHEME = Scheme(model=MODEL, parameters=PARAMETER, data={"dataset_1": DATASET})
SCHEME = Scheme(model=MODEL, parameters=PARAMETERS, data={"dataset_1": DATASET})
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
from glotaran.io import load_model
from glotaran.project import Scheme
from glotaran.project.generators import generate_model_yml
from glotaran.testing.simulated_data.shared_decay import PARAMETER
from glotaran.testing.simulated_data.shared_decay import PARAMETERS
from glotaran.testing.simulated_data.shared_decay import SIMULATION_COORDINATES
from glotaran.testing.simulated_data.shared_decay import SIMULATION_PARAMETER
from glotaran.testing.simulated_data.shared_decay import * # noqa F403
from glotaran.testing.simulated_data.shared_decay import SIMULATION_PARAMETERS

SIMULATION_MODEL_YML = generate_model_yml(
generator_name="spectral_decay_sequential",
Expand All @@ -25,10 +24,10 @@
DATASET = simulate(
SIMULATION_MODEL,
"dataset_1",
SIMULATION_PARAMETER,
SIMULATION_PARAMETERS,
SIMULATION_COORDINATES,
noise=True,
noise_std_dev=1e-2,
)

SCHEME = Scheme(model=MODEL, parameters=PARAMETER, data={"dataset_1": DATASET})
SCHEME = Scheme(model=MODEL, parameters=PARAMETERS, data={"dataset_1": DATASET})
8 changes: 4 additions & 4 deletions glotaran/testing/simulated_data/shared_decay.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from glotaran.io import load_parameters

SIMULATION_PARAMETER_YML = """
SIMULATION_PARAMETERS_YML = """
rates:
- [species_1, 0.5]
- [species_2, 0.3]
Expand All @@ -27,9 +27,9 @@
- [location, 650]
- [width, 60]
"""
SIMULATION_PARAMETER = load_parameters(SIMULATION_PARAMETER_YML, format_name="yml_str")
SIMULATION_PARAMETERS = load_parameters(SIMULATION_PARAMETERS_YML, format_name="yml_str")

PARAMETER_YML = """
PARAMETERS_YML = """
rates:
- [species_1, 0.5]
- [species_2, 0.3]
Expand All @@ -39,7 +39,7 @@
- [center, 0.3]
- [width, 0.1]
"""
PARAMETER = load_parameters(PARAMETER_YML, format_name="yml_str")
PARAMETERS = load_parameters(PARAMETERS_YML, format_name="yml_str")

TIME_AXIS = np.arange(-1, 20, 0.01)
SPECTRAL_AXIS = np.arange(600, 700, 1.4)
Expand Down