Skip to content

Commit

Permalink
🚧🗑️ Properly deprecated 'glotaran.examples'
Browse files Browse the repository at this point in the history
  • Loading branch information
s-weigand committed Jan 21, 2022
1 parent 72d6b21 commit 8f9a656
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
8 changes: 8 additions & 0 deletions glotaran/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Glotaran package __init__.py"""
from glotaran.deprecation.deprecation_utils import deprecate_submodule
from glotaran.deprecation.modules.glotaran_root import read_model_from_yaml
from glotaran.deprecation.modules.glotaran_root import read_model_from_yaml_file
from glotaran.deprecation.modules.glotaran_root import read_parameters_from_csv_file
Expand All @@ -10,6 +11,13 @@

__version__ = "0.6.0.dev0"

examples = deprecate_submodule(
deprecated_module_name="glotaran.examples",
new_module_name="glotaran.testing.simulated_data",
to_be_removed_in_version="0.8.0",
module_load_overwrite="glotaran.deprecation.modules.examples",
)


def __getattr__(attribute_name: str):
from glotaran.deprecation.deprecation_utils import deprecate_module_attribute
Expand Down
1 change: 1 addition & 0 deletions glotaran/deprecation/modules/examples/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Deprecation package for 'glotaran.examples'."""
36 changes: 36 additions & 0 deletions glotaran/deprecation/modules/examples/sequential.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Deprecated functionality export for 'glotaran.examples.sequential'."""

sequential_deprecation_mapping = {
"sim_model": "SIMULATION_MODEL",
"dataset": "DATASET",
"model": "MODEL",
"scheme": "SCHEME",
}
shared_deprecation_mapping = {
"wanted_parameter": "SIMULATION_PARAMETER",
"parameter": "PARAMETER",
"_time": "TIME_AXIS",
"_spectral": "SPECTRAL_AXIS",
}


def __getattr__(attribute_name: str):
from glotaran.deprecation.deprecation_utils import deprecate_module_attribute

for deprecated, new in shared_deprecation_mapping.items():
if attribute_name == deprecated:
return deprecate_module_attribute(
deprecated_qual_name=f"glotaran.examples.sequential.{deprecated}",
new_qual_name=f"glotaran.testing.simulated_data.shared_decay.{new}",
to_be_removed_in_version="0.8.0",
)

for deprecated, new in sequential_deprecation_mapping.items():
if attribute_name == deprecated:
return deprecate_module_attribute(
deprecated_qual_name=f"glotaran.examples.sequential.{deprecated}",
new_qual_name=f"glotaran.testing.simulated_data.sequential_spectral_decay.{new}",
to_be_removed_in_version="0.8.0",
)

raise AttributeError(f"module {__name__} has no attribute {attribute_name}")

0 comments on commit 8f9a656

Please sign in to comment.