Skip to content

Commit

Permalink
fix: threshold renamings
Browse files Browse the repository at this point in the history
  • Loading branch information
doinaoki committed Oct 5, 2024
1 parent b93fb52 commit c1f4cf1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion evaluation-lightweight.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
args=""
projects="projects/baasbox"

python3 -m renas.repository_analyzer $projects
python3 -m renas.repository_analyzer $projects -threshold 1
python3 -m renas.recommendation $projects
python3 -m renas.evaluator -sim -pre $projects
2 changes: 1 addition & 1 deletion renas/preliminaryResearch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ projects=("baasbox" "cordova-plugin-local-notifications" "morphia" "spring-integ

for line in "${projects[@]}"
do
python3 -m renas.repository_analyzer "projects/${line}"
python3 -m renas.repository_analyzer "projects/${line}" -threshold 1
python3 -m renas.recommendation "projects/${line}"
args="${args} projects/${line}"
done
Expand Down
11 changes: 5 additions & 6 deletions renas/relationship/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ def set_logger(level):
return root_logger


def filter_data(data, threshold):
def filter_data(data, threshold: int):
LOGGER.info("filter data")
commits = data.groupby("commit").size()
if threshold:
commits = commits[commits > 3]
else:
commits = commits[commits > 1]

commits = commits[commits > threshold]
LOGGER.info(f"threshold = more than {threshold} renames")
LOGGER.info(f"total {commits.sum()} renames")
LOGGER.info(f"pick {len(commits)} commits")
return data[data["commit"].isin(commits.index)]
Expand Down Expand Up @@ -86,7 +85,7 @@ def git_archive_wrapper(arg):
return git_archive(*arg)


def main(root: pathlib.Path, rename_data: pd.DataFrame, threshold: bool):
def main(root: pathlib.Path, rename_data: pd.DataFrame, threshold: int):
set_logger(INFO)
try:
rename_data = filter_data(rename_data, threshold)
Expand Down
8 changes: 4 additions & 4 deletions renas/repository_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def set_argument():
)
parser.add_argument(
"-threshold",
help="use commit which has more than 3 renames",
action="store_true",
default=False,
help="use commit which has more than specifying renames",
action="store",
default=0,
)
parser.add_argument(
"-f",
Expand All @@ -38,7 +38,7 @@ def main(root, args):
dump(root, rename_data)
else:
rename_data = pd.read_json(rename_path, orient="records")
analyzer.main(root, rename_data, args.threshold)
analyzer.main(root, rename_data, int(args.threshold))


def dump(root, data: pd.DataFrame):
Expand Down
2 changes: 1 addition & 1 deletion renas/researchQuestion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ projects=("testng" "jackson-databind" "rest.li" "Activiti" "k-9" "genie" "eucaly

for line in "${projects[@]}"
do
python3 -m renas.repository_analyzer "projects/${line}"
python3 -m renas.repository_analyzer "projects/${line}" -threshold 3
python3 -m renas.recommendation "projects/${line}"
args="${args} projects/${line}"
done
Expand Down
2 changes: 1 addition & 1 deletion renas/researchQuestionManually.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ projects=("ratpack" "argouml")

for line in "${projects[@]}"
do
python3 -m renas.repository_analyzer "projects/${line}"
python3 -m renas.repository_analyzer "projects/${line}" -threshold 1
python3 -m renas.recommendation "projects/${line}"
args="${args} projects/${line}"
done
Expand Down

0 comments on commit c1f4cf1

Please sign in to comment.