@@ -939,19 +939,19 @@ class Axes(VGroup, CoordinateSystem):
939939
940940 Parameters
941941 ----------
942- x_range :
942+ x_range
943943 The :code:`[x_min, x_max, x_step]` values of the x-axis.
944- y_range :
944+ y_range
945945 The :code:`[y_min, y_max, y_step]` values of the y-axis.
946- x_length : Optional[:class:`float`]
946+ x_length
947947 The length of the x-axis.
948- y_length : Optional[:class:`float`]
948+ y_length
949949 The length of the y-axis.
950- axis_config : Optional[:class:`dict`]
950+ axis_config
951951 Arguments to be passed to :class:`~.NumberLine` that influences both axes.
952- x_axis_config : Optional[:class:`dict`]
952+ x_axis_config
953953 Arguments to be passed to :class:`~.NumberLine` that influence the x-axis.
954- y_axis_config : Optional[:class:`dict`]
954+ y_axis_config
955955 Arguments to be passed to :class:`~.NumberLine` that influence the y-axis.
956956 include_tips
957957 Whether or not to include the tips on both axes.
@@ -963,11 +963,11 @@ def __init__(
963963 self ,
964964 x_range : Optional [Sequence [float ]] = None ,
965965 y_range : Optional [Sequence [float ]] = None ,
966- x_length = round (config .frame_width ) - 2 ,
967- y_length = round (config .frame_height ) - 2 ,
968- axis_config = None ,
969- x_axis_config = None ,
970- y_axis_config = None ,
966+ x_length : Optional [ float ] = round (config .frame_width ) - 2 ,
967+ y_length : Optional [ float ] = round (config .frame_height ) - 2 ,
968+ axis_config : Optional [ dict ] = None ,
969+ x_axis_config : Optional [ dict ] = None ,
970+ y_axis_config : Optional [ dict ] = None ,
971971 tips : bool = True ,
972972 ** kwargs ,
973973 ):
@@ -998,17 +998,27 @@ def update_default_configs(default_configs, passed_configs):
998998 if passed_config is not None :
999999 update_dict_recursively (default_config , passed_config )
10001000
1001- def create_axis (self , range_terms , axis_config , length ):
1001+ def create_axis (
1002+ self ,
1003+ range_terms : Sequence [float ],
1004+ axis_config : dict ,
1005+ length : float ,
1006+ ) -> NumberLine :
10021007 """Creates an axis and dynamically adjusts its position depending on where 0 is located on the line.
10031008
10041009 Parameters
10051010 ----------
1006- range_terms : Union[:class:`list`, :class:`numpy.ndarray`]
1011+ range_terms
10071012 The range of the the axis : `(x_min, x_max, x_step)`.
1008- axis_config : :class:`dict`
1013+ axis_config
10091014 Additional parameters that are passed to :class:`NumberLine`.
1010- length : :class:`float`
1015+ length
10111016 The length of the axis.
1017+
1018+ Returns
1019+ -------
1020+ :class:`NumberLine`
1021+ Returns a number line with the provided x and y axis range.
10121022 """
10131023 new_config = merge_dicts_recursively (self .axis_config , axis_config )
10141024 new_config ["length" ] = length
@@ -1019,28 +1029,89 @@ def create_axis(self, range_terms, axis_config, length):
10191029 axis .shift (- axis .number_to_point (self .origin_shift (range_terms )))
10201030 return axis
10211031
1022- def coords_to_point (self , * coords ):
1032+ def coords_to_point (self , * coords : Sequence [float ]) -> np .ndarray :
1033+ """Transforms the vector formed from ``coords`` formed by the :class:`Axes`
1034+ into the corresponding vector with respect to the default basis.
1035+
1036+ Returns
1037+ -------
1038+ np.ndarray
1039+ A point that results from a change of basis from the coordinate system
1040+ defined by the :class:`Axes` to that of ``manim``'s default coordinate system
1041+ """
10231042 origin = self .x_axis .number_to_point (self .origin_shift (self .x_range ))
10241043 result = np .array (origin )
10251044 for axis , coord in zip (self .get_axes (), coords ):
10261045 result += axis .number_to_point (coord ) - origin
10271046 return result
10281047
1029- def point_to_coords (self , point ):
1048+ def point_to_coords (self , point : float ) -> Tuple :
1049+ """Transforms the coordinates of the point which are with respect to ``manim``'s default
1050+ basis into the coordinates of that point with respect to the basis defined by :class:`Axes`.
1051+
1052+ Parameters
1053+ ----------
1054+ point
1055+ The point whose coordinates will be found.
1056+
1057+ Returns
1058+ -------
1059+ Tuple
1060+ Coordinates of the point with respect to :class:`Axes`'s basis
1061+ """
10301062 return tuple ([axis .point_to_number (point ) for axis in self .get_axes ()])
10311063
1032- def get_axes (self ):
1064+ def get_axes (self ) -> VGroup :
1065+ """Gets the axes.
1066+
1067+ Returns
1068+ -------
1069+ :class:`~.VGroup`
1070+ A pair of axes.
1071+ """
10331072 return self .axes
10341073
1035- def get_coordinate_labels (self , x_values = None , y_values = None , ** kwargs ):
1074+ def get_coordinate_labels (
1075+ self ,
1076+ x_values : Optional [Iterable [float ]] = None ,
1077+ y_values : Optional [Iterable [float ]] = None ,
1078+ ** kwargs ,
1079+ ) -> VDict :
1080+ """Gets labels for the coordinates
1081+
1082+ Parameters
1083+ ----------
1084+ x_values
1085+ Iterable of values along the x-axis, by default None.
1086+ y_values
1087+ Iterable of values along the y-axis, by default None.
1088+
1089+ Returns
1090+ -------
1091+ VDict
1092+ Labels for the x and y values.
1093+ """
10361094 axes = self .get_axes ()
10371095 self .coordinate_labels = VGroup ()
10381096 for axis , values in zip (axes , [x_values , y_values ]):
10391097 labels = axis .add_numbers (values , ** kwargs )
10401098 self .coordinate_labels .add (labels )
10411099 return self .coordinate_labels
10421100
1043- def add_coordinates (self , x_values = None , y_values = None ):
1101+ def add_coordinates (
1102+ self ,
1103+ x_values : Optional [Iterable [float ]] = None ,
1104+ y_values : Optional [Iterable [float ]] = None ,
1105+ ):
1106+ """Adds the coordinates.
1107+
1108+ Parameters
1109+ ----------
1110+ x_values
1111+ Iterable of values along the x-axis, by default None.
1112+ y_values
1113+ Iterable of values along the y-axis, by default None.
1114+ """
10441115 self .add (self .get_coordinate_labels (x_values , y_values ))
10451116 return self
10461117
@@ -1152,25 +1223,25 @@ class ThreeDAxes(Axes):
11521223
11531224 Parameters
11541225 ----------
1155- x_range :
1226+ x_range
11561227 The :code:`[x_min, x_max, x_step]` values of the x-axis.
1157- y_range :
1228+ y_range
11581229 The :code:`[y_min, y_max, y_step]` values of the y-axis.
1159- z_range :
1230+ z_range
11601231 The :code:`[z_min, z_max, z_step]` values of the z-axis.
1161- x_length : Optional[:class:`float`]
1232+ x_length
11621233 The length of the x-axis.
1163- y_length : Optional[:class:`float`]
1234+ y_length
11641235 The length of the y-axis.
1165- z_length : Optional[:class:`float`]
1236+ z_length
11661237 The length of the z-axis.
1167- z_axis_config : Optional[:class:`dict`]
1238+ z_axis_config
11681239 Arguments to be passed to :class:`~.NumberLine` that influence the z-axis.
1169- z_normal : Union[:class:`list`, :class:`numpy.ndarray`]
1240+ z_normal
11701241 The direction of the normal.
1171- num_axis_pieces : :class:`int`
1242+ num_axis_pieces
11721243 The number of pieces used to construct the axes.
1173- light_source : Union[:class:`list`, :class:`numpy.ndarray`]
1244+ light_source
11741245 The direction of the light source.
11751246 depth
11761247 Currently non-functional.
@@ -1185,13 +1256,13 @@ def __init__(
11851256 x_range : Optional [Sequence [float ]] = (- 6 , 6 , 1 ),
11861257 y_range : Optional [Sequence [float ]] = (- 5 , 5 , 1 ),
11871258 z_range : Optional [Sequence [float ]] = (- 4 , 4 , 1 ),
1188- x_length = config .frame_height + 2.5 ,
1189- y_length = config .frame_height + 2.5 ,
1190- z_length = config .frame_height - 1.5 ,
1191- z_axis_config = None ,
1192- z_normal = DOWN ,
1193- num_axis_pieces = 20 ,
1194- light_source = 9 * DOWN + 7 * LEFT + 10 * OUT ,
1259+ x_length : Optional [ float ] = config .frame_height + 2.5 ,
1260+ y_length : Optional [ float ] = config .frame_height + 2.5 ,
1261+ z_length : Optional [ float ] = config .frame_height - 1.5 ,
1262+ z_axis_config : Optional [ dict ] = None ,
1263+ z_normal : Sequence [ float ] = DOWN ,
1264+ num_axis_pieces : int = 20 ,
1265+ light_source : Sequence [ float ] = 9 * DOWN + 7 * LEFT + 10 * OUT ,
11951266 # opengl stuff (?)
11961267 depth = None ,
11971268 gloss = 0.5 ,
@@ -1259,23 +1330,23 @@ class NumberPlane(Axes):
12591330
12601331 Parameters
12611332 ----------
1262- x_range :
1333+ x_range
12631334 The :code:`[x_min, x_max, x_step]` values of the plane in the horizontal direction.
1264- y_range :
1335+ y_range
12651336 The :code:`[y_min, y_max, y_step]` values of the plane in the vertical direction.
1266- x_length : Optional[:class:`float`]
1337+ x_length
12671338 The width of the plane.
1268- y_length : Optional[:class:`float`]
1339+ y_length
12691340 The height of the plane.
1270- axis_config : Optional[:class:`dict`]
1341+ axis_config
12711342 Arguments to be passed to :class:`~.NumberLine` that influences both axes.
1272- y_axis_config : Optional[:class:`dict`]
1343+ y_axis_config
12731344 Arguments to be passed to :class:`~.NumberLine` that influence the y-axis.
1274- background_line_style : Optional[:class:`dict`]
1345+ background_line_style
12751346 Arguments that influence the construction of the background lines of the plane.
1276- faded_line_style : Optional[:class:`dict`]
1347+ faded_line_style
12771348 Similar to :attr:`background_line_style`, affects the construction of the scene's background lines.
1278- faded_line_ratio : Optional[:class:`int`]
1349+ faded_line_ratio
12791350 Determines the number of boxes within the background lines: :code:`2` = 4 boxes, :code:`3` = 9 boxes.
12801351 make_smooth_after_applying_functions
12811352 Currently non-functional.
@@ -1298,13 +1369,13 @@ def __init__(
12981369 config ["frame_y_radius" ],
12991370 1 ,
13001371 ),
1301- x_length = None ,
1302- y_length = None ,
1303- axis_config = None ,
1304- y_axis_config = None ,
1305- background_line_style = None ,
1306- faded_line_style = None ,
1307- faded_line_ratio = 1 ,
1372+ x_length : Optional [ float ] = None ,
1373+ y_length : Optional [ float ] = None ,
1374+ axis_config : Optional [ dict ] = None ,
1375+ y_axis_config : Optional [ dict ] = None ,
1376+ background_line_style : Optional [ dict ] = None ,
1377+ faded_line_style : Optional [ dict ] = None ,
1378+ faded_line_ratio : Optional [ float ] = 1 ,
13081379 make_smooth_after_applying_functions = True ,
13091380 ** kwargs ,
13101381 ):
@@ -1379,7 +1450,7 @@ def init_background_lines(self):
13791450 self .background_lines ,
13801451 )
13811452
1382- def get_lines (self ):
1453+ def get_lines (self ) -> Tuple [ VGroup , VGroup ] :
13831454 """Generate all the lines, faded and not faded. Two sets of lines are generated: one parallel to the X-axis, and parallel to the Y-axis.
13841455
13851456 Returns
@@ -1407,22 +1478,26 @@ def get_lines(self):
14071478 return lines1 , lines2
14081479
14091480 def get_lines_parallel_to_axis (
1410- self , axis_parallel_to , axis_perpendicular_to , freq , ratio_faded_lines
1411- ):
1481+ self ,
1482+ axis_parallel_to : Line ,
1483+ axis_perpendicular_to : Line ,
1484+ freq : float ,
1485+ ratio_faded_lines : float ,
1486+ ) -> Tuple [VGroup , VGroup ]:
14121487 """Generate a set of lines parallel to an axis.
14131488
14141489 Parameters
14151490 ----------
1416- axis_parallel_to : :class:`~.Line`
1491+ axis_parallel_to
14171492 The axis with which the lines will be parallel.
14181493
1419- axis_perpendicular_to : :class:`~.Line`
1494+ axis_perpendicular_to
14201495 The axis with which the lines will be perpendicular.
14211496
1422- ratio_faded_lines : :class:`float`
1497+ ratio_faded_lines
14231498 The ratio between the space between faded lines and the space between non-faded lines.
14241499
1425- freq : :class:`float`
1500+ freq
14261501 Frequency of non-faded lines (number of non-faded lines per graph unit).
14271502
14281503 Returns
@@ -1452,7 +1527,14 @@ def get_lines_parallel_to_axis(
14521527 lines2 .add (new_line )
14531528 return lines1 , lines2
14541529
1455- def get_center_point (self ):
1530+ def get_center_point (self ) -> np .ndarray :
1531+ """Gets the origin of :class:`NumberPlane`.
1532+
1533+ Returns
1534+ -------
1535+ np.ndarray
1536+ The center point.
1537+ """
14561538 return self .coords_to_point (0 , 0 )
14571539
14581540 def get_x_unit_size (self ):
@@ -1461,7 +1543,15 @@ def get_x_unit_size(self):
14611543 def get_y_unit_size (self ):
14621544 return self .get_x_axis ().get_unit_size ()
14631545
1464- def get_axes (self ):
1546+ def get_axes (self ) -> VGroup :
1547+ # Method Already defined at Axes.get_axes so we could remove this a later PR.
1548+ """Gets the pair of axes.
1549+
1550+ Returns
1551+ -------
1552+ :class:`~.VGroup`
1553+ Axes
1554+ """
14651555 return self .axes
14661556
14671557 def get_vector (self , coords , ** kwargs ):
0 commit comments