Skip to content

Commit

Permalink
Fix: Deduplicate entries according to the (name, mtype, layer) triplet (
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-berchet authored Sep 10, 2024
1 parent 0e184fe commit 62e7cba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
rev: v2.3.0
hooks:
- id: codespell
- repo: https://github.com/PyCQA/pydocstyle
Expand All @@ -22,7 +22,7 @@ repos:
- id: pydocstyle
exclude: ^(functional_tests|tests|doc|examples|setup.py)
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 5.0.4
hooks:
- id: flake8
exclude: ^(functional_tests|tests|doc)
7 changes: 5 additions & 2 deletions morph_tool/morphdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def from_folder(cls,
Args:
morphology_folder: a folder containing morphologies
mtypes: a sequence of 2-tuples (morphology name, mtype)
label: (optional) a group label to be used to identify the morphlogies from this folder
label: (optional) a group label to be used to identify the morphologies from this folder
extension: Specify the morphology format to consider, if the folder contains multiple
formats
Expand Down Expand Up @@ -373,7 +373,10 @@ def __add__(self, other):
def __iadd__(self, other):
"""Overloaded method."""
if isinstance(other, MorphDB):
self.df = pd.concat([self.df, other.df]).drop_duplicates()
self.df = pd.concat(
[self.df, other.df],
ignore_index=True,
).drop_duplicates(["name", "mtype", "layer"])
MorphDB._sanitize_df_types(self.df)
else:
raise TypeError(f'Must be MorphDB or a sequence of MorphInfo, not {type(other)}')
Expand Down

0 comments on commit 62e7cba

Please sign in to comment.