Skip to content

Commit 556afaf

Browse files
committed
MNT: Remove unused imports and deprecated functions from mathutils/function.py
1 parent 03f20c1 commit 556afaf

1 file changed

Lines changed: 1 addition & 53 deletions

File tree

rocketpy/mathutils/function.py

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,15 @@
55
carefully as it may impact all the rest of the project.
66
"""
77

8-
import base64
9-
import functools
108
import operator
119
import warnings
1210
from bisect import bisect_left
1311
from collections.abc import Iterable
1412
from copy import deepcopy
15-
from enum import Enum
1613
from functools import cached_property
1714
from inspect import signature
1815
from pathlib import Path
1916

20-
import dill
2117
import matplotlib.pyplot as plt
2218
import numpy as np
2319
from scipy import integrate, linalg, optimize
@@ -29,6 +25,7 @@
2925
)
3026

3127
from rocketpy.plots.plot_helpers import show_or_save_plot
28+
from rocketpy.tools import deprecated
3229

3330
# Numpy 1.x compatibility,
3431
# TODO: remove these lines when all dependencies support numpy>=2.0.0
@@ -51,55 +48,6 @@
5148
EXTRAPOLATION_TYPES = {"zero": 0, "natural": 1, "constant": 2}
5249

5350

54-
def deprecated(reason=None, version=None, alternative=None):
55-
"""Decorator to mark functions or methods as deprecated.
56-
57-
This decorator issues a DeprecationWarning when the decorated function
58-
is called, indicating that it will be removed in future versions.
59-
"""
60-
61-
def decorator(func):
62-
@functools.wraps(func)
63-
def wrapper(*args, **kwargs):
64-
if reason:
65-
message = reason
66-
else:
67-
message = f"The function `{func.__name__}` is deprecated"
68-
69-
if version:
70-
message += f" and will be removed in {version}"
71-
72-
if alternative:
73-
message += f". Use `{alternative}` instead"
74-
75-
message += "."
76-
warnings.warn(message, DeprecationWarning, stacklevel=2)
77-
return func(*args, **kwargs)
78-
79-
return wrapper
80-
81-
return decorator
82-
83-
84-
def to_hex_encode(obj, encoder=base64.b85encode):
85-
"""Converts an object to hex representation using dill."""
86-
return encoder(dill.dumps(obj)).hex()
87-
88-
89-
def from_hex_decode(obj_bytes, decoder=base64.b85decode):
90-
"""Converts an object from hex representation using dill."""
91-
return dill.loads(decoder(bytes.fromhex(obj_bytes)))
92-
93-
94-
class SourceType(Enum):
95-
"""Enumeration of the source types for the Function class.
96-
The source can be either a callable or an array.
97-
"""
98-
99-
CALLABLE = 0
100-
ARRAY = 1
101-
102-
10351
class Function: # pylint: disable=too-many-public-methods
10452
"""Class converts a python function or a data sequence into an object
10553
which can be handled more naturally, enabling easy interpolation,

0 commit comments

Comments
 (0)