Skip to content

Commit bb0f46a

Browse files
MNT: refactors cached_property imports
1 parent afb3b32 commit bb0f46a

File tree

11 files changed

+12
-46
lines changed

11 files changed

+12
-46
lines changed

rocketpy/environment/environment_analysis.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@
33
import datetime
44
import json
55
from collections import defaultdict
6+
from functools import cached_property
67

78
import netCDF4
89
import numpy as np
910
import pytz
1011

11-
try:
12-
from functools import cached_property
13-
except ImportError:
14-
from ..tools import cached_property
15-
1612
from ..mathutils.function import Function
1713
from ..plots.environment_analysis_plots import _EnvironmentAnalysisPlots
1814
from ..prints.environment_analysis_prints import _EnvironmentAnalysisPrints

rocketpy/mathutils/function.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,14 @@
77
import warnings
88
from collections.abc import Iterable
99
from copy import deepcopy
10+
from functools import cached_property
1011
from inspect import signature
1112
from pathlib import Path
1213

1314
import matplotlib.pyplot as plt
1415
import numpy as np
1516
from scipy import integrate, linalg, optimize
1617

17-
try:
18-
from functools import cached_property
19-
except ImportError:
20-
from ..tools import cached_property
21-
2218
NUMERICAL_TYPES = (float, int, complex, np.ndarray, np.integer, np.floating)
2319

2420

rocketpy/mathutils/vector_matrix.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from cmath import isclose
2+
from functools import cached_property
23
from itertools import product
34

4-
from rocketpy.tools import cached_property
5-
65

76
class Vector:
87
"""Pure python basic R3 vector class designed for simple operations.

rocketpy/motors/hybrid_motor.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from functools import cached_property
2+
13
from rocketpy.tools import parallel_axis_theorem_from_com
24

35
from ..mathutils.function import Function, funcify_method, reset_funcified_methods
@@ -7,11 +9,6 @@
79
from .motor import Motor
810
from .solid_motor import SolidMotor
911

10-
try:
11-
from functools import cached_property
12-
except ImportError:
13-
from ..tools import cached_property
14-
1512

1613
class HybridMotor(Motor):
1714
"""Class to specify characteristics and useful operations for Hybrid

rocketpy/motors/liquid_motor.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import warnings
1+
from functools import cached_property
22

33
import numpy as np
44

@@ -13,11 +13,6 @@
1313
from ..prints.liquid_motor_prints import _LiquidMotorPrints
1414
from .motor import Motor
1515

16-
try:
17-
from functools import cached_property
18-
except ImportError:
19-
from ..tools import cached_property
20-
2116

2217
class LiquidMotor(Motor):
2318
"""Class to specify characteristics and useful operations for Liquid

rocketpy/motors/motor.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import re
22
import warnings
33
from abc import ABC, abstractmethod
4+
from functools import cached_property
45

56
import numpy as np
67

@@ -9,11 +10,6 @@
910
from ..prints.motor_prints import _MotorPrints
1011
from ..tools import parallel_axis_theorem_from_com, tuple_handler
1112

12-
try:
13-
from functools import cached_property
14-
except ImportError:
15-
from ..tools import cached_property
16-
1713

1814
class Motor(ABC):
1915
"""Abstract class to specify characteristics and useful operations for

rocketpy/motors/solid_motor.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from functools import cached_property
2+
13
import numpy as np
24
from scipy import integrate
35

@@ -6,11 +8,6 @@
68
from ..prints.solid_motor_prints import _SolidMotorPrints
79
from .motor import Motor
810

9-
try:
10-
from functools import cached_property
11-
except ImportError:
12-
from ..tools import cached_property
13-
1411

1512
class SolidMotor(Motor):
1613
"""Class to specify characteristics and useful operations for solid motors.

rocketpy/motors/tank_geometry.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111

1212
cache = lru_cache(maxsize=None)
1313

14-
try:
15-
from functools import cached_property
16-
except ImportError:
17-
from ..tools import cached_property
14+
from functools import cached_property
1815

1916

2017
class TankGeometry:

rocketpy/plots/flight_plots.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1+
from functools import cached_property
2+
13
import matplotlib.pyplot as plt
24
import numpy as np
35

4-
try:
5-
from functools import cached_property
6-
except ImportError:
7-
from ..tools import cached_property
8-
96

107
class _FlightPlots:
118
"""Class that holds plot methods for Flight class.

rocketpy/rocket/aero_surface.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import warnings
22
from abc import ABC, abstractmethod
3-
from functools import cached_property
43

54
import numpy as np
65
from scipy.optimize import fsolve

rocketpy/tools.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
import pytz
88
from cftime import num2pydate
99
from packaging import version as packaging_version
10-
from functools import cached_property
11-
12-
_NOT_FOUND = object()
1310

1411
# Mapping of module name and the name of the package that should be installed
1512
INSTALL_MAPPING = {"IPython": "ipython"}

0 commit comments

Comments
 (0)