Skip to content

Commit 9b51d3e

Browse files
committed
Removed docstrings on tests.
1 parent 6d216fe commit 9b51d3e

File tree

3 files changed

+4
-53
lines changed

3 files changed

+4
-53
lines changed

doc/source/whatsnew/v3.0.0.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,6 @@ Reshaping
11561156
- Bug in :meth:`DataFrame.unstack` producing incorrect results when manipulating empty :class:`DataFrame` with an :class:`ExtentionDtype` (:issue:`59123`)
11571157
- Bug in :meth:`concat` where concatenating DataFrame and Series with ``ignore_index = True`` drops the series name (:issue:`60723`, :issue:`56257`)
11581158
- Bug in :func:`melt` where calling with duplicate column names in ``id_vars`` raised a misleading ``AttributeError`` (:issue:`61475`)
1159-
- Bug in :meth:`DataFrame.merge` where the result of a merge does not contain any metadata or flag information from the inputs to the merge. (:issue:`28283`)
11601159
- Bug in :meth:`DataFrame.merge` where user-provided suffixes could result in duplicate column names if the resulting names matched existing columns. Now raises a :class:`MergeError` in such cases. (:issue:`61402`)
11611160
- Bug in :meth:`DataFrame.merge` with :class:`CategoricalDtype` columns incorrectly raising ``RecursionError`` (:issue:`56376`)
11621161
- Bug in :meth:`DataFrame.merge` with a ``float32`` index incorrectly casting the index to ``float64`` (:issue:`41626`)

pandas/core/reshape/merge.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,21 +1139,13 @@ def get_result(self) -> DataFrame:
11391139

11401140
result = self._reindex_and_concat(join_index, left_indexer, right_indexer)
11411141

1142-
# Is this call to __finalize__ really necessary?
1143-
result = result.__finalize__(
1144-
types.SimpleNamespace(input_objs=[self.left, self.right]),
1145-
method=self._merge_type,
1146-
)
1147-
11481142
if self.indicator:
11491143
result = self._indicator_post_merge(result)
11501144

11511145
self._maybe_add_join_keys(result, left_indexer, right_indexer)
11521146

11531147
self._maybe_restore_index_levels(result)
11541148

1155-
# __finalize is responsible for copying the metadata from the inputs to merge
1156-
# to the result.
11571149
return result.__finalize__(
11581150
types.SimpleNamespace(input_objs=[self.left, self.right]), method="merge"
11591151
)
@@ -1175,8 +1167,7 @@ def _indicator_pre_merge(
11751167
self, left: DataFrame, right: DataFrame
11761168
) -> tuple[DataFrame, DataFrame]:
11771169
"""
1178-
Add one indicator column to each of the left and right inputs to a
1179-
merge operation.
1170+
Add one indicator column to each of the left and right inputs.
11801171
11811172
These columns are used to produce another column in the output of the
11821173
merge, indicating for each row of the output whether it was produced

pandas/tests/generic/test_finalize.py

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -691,30 +691,24 @@ def test_finalize_frame_series_name():
691691
"cross",
692692
],
693693
)
694-
def test_merge_sets_duplication_allowance_flag(
694+
def test_merge_correctly_sets_duplication_allowance_flag(
695695
how: MergeHow,
696696
allow_on_left: bool,
697697
allow_on_right: bool,
698698
):
699699
"""Check that DataFrame.merge correctly sets the allow_duplicate_labels flag
700700
on its result.
701-
702-
The flag on the result should be set to true if and only if both arguments
703-
to merge have their flags set to True.
704701
"""
705-
# Arrange
706702
left = pd.DataFrame({"test": [1]}).set_flags(allows_duplicate_labels=allow_on_left)
707703
right = pd.DataFrame({"test": [1]}).set_flags(
708704
allows_duplicate_labels=allow_on_right,
709705
)
710706

711-
# Act
712707
if not how == "cross":
713708
result = left.merge(right, how=how, on="test")
714709
else:
715710
result = left.merge(right, how=how)
716711

717-
# Assert
718712
expected_duplication_allowance = allow_on_left and allow_on_right
719713
assert result.flags.allows_duplicate_labels == expected_duplication_allowance
720714

@@ -723,64 +717,44 @@ def test_merge_sets_duplication_allowance_flag(
723717
["allow_on_left", "allow_on_right"],
724718
[(False, False), (False, True), (True, False), (True, True)],
725719
)
726-
def test_merge_asof_sets_duplication_allowance_flag(
720+
def test_merge_asof_correctly_sets_duplication_allowance_flag(
727721
allow_on_left: bool,
728722
allow_on_right: bool,
729723
):
730-
"""Check that pandas.merge_asof correctly sets the allow_duplicate_labels flag
731-
on its result.
732-
733-
The flag on the result should be set to true if and only if both arguments
734-
to merge_asof have their flags set to True.
735-
"""
736-
# Arrange
737724
left = pd.DataFrame({"test": [1]}).set_flags(allows_duplicate_labels=allow_on_left)
738725
right = pd.DataFrame({"test": [1]}).set_flags(
739726
allows_duplicate_labels=allow_on_right,
740727
)
741728

742-
# Act
743729
result = pd.merge_asof(left, right)
744730

745-
# Assert
746731
expected_duplication_allowance = allow_on_left and allow_on_right
747732
assert result.flags.allows_duplicate_labels == expected_duplication_allowance
748733

749734

750735
def test_merge_propagates_metadata_from_equal_input_metadata():
751-
"""Check that pandas.merge sets the metadata of its result to a deep copy of
752-
the metadata from its left input, if the metadata from both inputs are equal.
753-
"""
754-
# Arrange
755736
metadata = {"a": 2}
756737
left = pd.DataFrame({"test": [1]})
757738
left.attrs = metadata
758739
right = pd.DataFrame({"test": [1]})
759740
right.attrs = metadata.copy()
760741

761-
# Act
762742
result = left.merge(right, how="inner", on="test")
763743

764-
# Assert
765744
assert result.attrs == metadata
745+
# Verify that merge deep-copies the attr dictionary.
766746
left.attrs = {"b": 3}
767747
assert result.attrs == metadata
768748

769749

770750
def test_merge_does_not_propagate_metadata_from_unequal_input_metadata():
771-
"""Check that the metadata for the result of pandas.merge is empty if the
772-
metadata for both inputs to pandas.merge are not equal.
773-
"""
774-
# Arrange
775751
left = pd.DataFrame({"test": [1]})
776752
left.attrs = {"a": 2}
777753
right = pd.DataFrame({"test": [1]})
778754
right.attrs = {"b": 3}
779755

780-
# Act
781756
result = left.merge(right, how="inner", on="test")
782757

783-
# Assert
784758
assert result.attrs == {}
785759

786760

@@ -804,19 +778,6 @@ def test_merge_does_not_propagate_metadata_if_one_input_has_no_metadata(
804778
right: pd.DataFrame,
805779
expected: dict,
806780
):
807-
"""Check that if the metadata for one input to pandas.merge is empty, the result
808-
of merge has the same metadata as the other input.
809-
810-
(empty) (A) (A) (empty) (empty) (empty)
811-
| | | | | |
812-
--> merge <-- --> merge <-- --> merge <--
813-
| | |
814-
(empty) (empty) (empty)
815-
"""
816-
# Arrange
817-
818-
# Act
819781
result = left.merge(right, how="inner", on="test")
820782

821-
# Assert
822783
assert result.attrs == expected

0 commit comments

Comments
 (0)