Skip to content

Commit

Permalink
use typing_extensions.deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
anilbey committed Nov 30, 2023
1 parent 8bc636f commit 1db8d9f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 30 deletions.
5 changes: 3 additions & 2 deletions bluecellulab/cell/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
from pathlib import Path
import queue
from typing import Optional
from typing_extensions import deprecated

import numpy as np
import pandas as pd

import bluecellulab
from bluecellulab import neuron, psection, tools
from bluecellulab import neuron, psection
from bluecellulab.cell.injector import InjectableMixin
from bluecellulab.cell.plotting import PlottableMixin
from bluecellulab.cell.section_distance import EuclideanSectionDistance
Expand Down Expand Up @@ -692,7 +693,7 @@ def somatic_branches(self):
dend found in section %s" % secname)

@staticmethod
@tools.deprecated("bluecellulab.cell.section_distance.EuclideanSectionDistance")
@deprecated("Use bluecellulab.cell.section_distance.EuclideanSectionDistance instead.")
def euclid_section_distance(
hsection1=None,
hsection2=None,
Expand Down
6 changes: 3 additions & 3 deletions bluecellulab/cell/injector.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import logging

import numpy as np
from typing_extensions import deprecated

import bluecellulab
from bluecellulab import tools
from bluecellulab.cell.stimuli_generator import (
gen_ornstein_uhlenbeck,
gen_shotnoise_signal,
Expand Down Expand Up @@ -416,13 +416,13 @@ def inject_current_waveform(self, t_content, i_content, section=None,
currents.play(pulse._ref_amp, time)
return currents

@tools.deprecated("inject_current_waveform")
@deprecated("Use inject_current_waveform instead.")
def injectCurrentWaveform(self, t_content, i_content, section=None,
segx=0.5):
"""Inject a current in the cell."""
return self.inject_current_waveform(t_content, i_content, section, segx)

@tools.deprecated("add_sin_current")
@deprecated("Use add_sin_current instead.")
def addSineCurrentInject(self, start_time, stop_time, freq,
amplitude, mid_level, dt=1.0):
"""Add a sinusoidal current injection.
Expand Down
25 changes: 0 additions & 25 deletions bluecellulab/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from pathlib import Path
import sys
from typing import Any, Optional, Tuple
import warnings
import logging

import numpy as np
Expand Down Expand Up @@ -74,30 +73,6 @@ def set_verbose_from_env() -> None:
set_verbose_from_env()


class deprecated:
"""Decorator to mark a function as deprecated."""

def __init__(self, new_function=""):
self.new_function = new_function

def __call__(self, func):
def rep_func(*args, **kwargs):
"""Replacement function."""
warnings.warn(
"Call to deprecated function {%s}. Use {%s} instead." % (
func.__name__, self.new_function),
category=DeprecationWarning)
return func(*args, **kwargs)
rep_func.__name__ = func.__name__
if func.__doc__ is None or func.__doc__ == "":
func.__doc__ = "Deprecated"
rep_func.__doc__ = func.__doc__ + "\n\n \
.. note:: Replaced by %s\n\n \
.. deprecated:: .1\n" % self.new_function
rep_func.__dict__.update(func.__dict__)
return rep_func


def calculate_input_resistance(
template_path: str | Path,
morphology_path: str | Path,
Expand Down

0 comments on commit 1db8d9f

Please sign in to comment.