Skip to content

Commit 4b9df8b

Browse files
authored
Merge pull request #96 from konbraphat51/dev
Version Update: 1.0.9
2 parents b18b0a7 + 92d079b commit 4b9df8b

File tree

4 files changed

+34
-22
lines changed

4 files changed

+34
-22
lines changed

AnimatedWordCloud/Animator/AllocationCalculator/AnimatetdAllocationCalculator.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ def animated_allocate(
4343
time_name_to = allocation_timelapse.timelapse[index + 1][0]
4444

4545
# interpolate between two frames
46-
interpolated_frames: list[
47-
AllocationInFrame
48-
] = _get_interpolated_frames(
46+
interpolated_frames = _get_interpolated_frames(
4947
from_allocation_frame,
5048
to_allocation_frame,
5149
config,

AnimatedWordCloud/Animator/AllocationCalculator/StaticAllocationCalculator/StaticAllocationStrategies/MagneticAllocation/MagneticAllocation.py

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import math
1818
from typing import Iterable
1919
from tqdm import tqdm
20-
import joblib
2120
from AnimatedWordCloud.Utils import (
2221
is_rect_hitting_rects,
2322
AllocationInFrame,
@@ -230,15 +229,9 @@ def _find_best_position(
230229
]
231230

232231
# get center position candidates
233-
results_by_sides = joblib.Parallel(n_jobs=-1, verbose=0)(
234-
joblib.delayed(self._get_candidates_from_one_side)(
235-
pivots_to_center_list[cnt], frontier_sides[cnt]
236-
)
237-
for cnt in range(4)
232+
center_position_candidates = self._compute_candidates(
233+
pivots_to_center_list, frontier_sides
238234
)
239-
center_position_candidates = []
240-
for results_by_side in results_by_sides:
241-
center_position_candidates.extend(results_by_side)
242235

243236
# error handling: too small image area that cannot put the word anywhere anymore
244237
if len(center_position_candidates) == 0:
@@ -259,6 +252,31 @@ def _find_best_position(
259252

260253
return best_position_left_top
261254

255+
def _compute_candidates(
256+
self,
257+
pivots_to_center_list: Iterable[Iterable[Vector]],
258+
frontier_sides: Iterable[Iterable[Vector]],
259+
) -> list[tuple[int, int]]:
260+
"""
261+
Compute all candidates of the center position
262+
263+
:param Iterable[Iterable[Vector]] pivots_to_center_list:
264+
List of vectors from the pivot to the center of the word
265+
:param Iterable[Iterable[Vector]]
266+
List of vectors from the frontier to the center of the word
267+
:return: Candidates of the center position
268+
"""
269+
270+
center_position_candidates = []
271+
for cnt in range(4):
272+
center_position_candidates.extend(
273+
self._get_candidates_from_one_side(
274+
pivots_to_center_list[cnt], frontier_sides[cnt]
275+
)
276+
)
277+
278+
return center_position_candidates
279+
262280
def _get_candidates_from_one_side(
263281
self,
264282
pivots_to_center: Iterable[Vector],
@@ -303,12 +321,10 @@ def _try_put_all_candidates(
303321
:rtype: tuple[int, int]
304322
"""
305323

306-
results_evaluation = joblib.Parallel(n_jobs=-1, verbose=0)(
307-
joblib.delayed(self._try_put_position)(
308-
center_position, size, position_from
309-
)
324+
results_evaluation = [
325+
self._try_put_position(center_position, size, position_from)
310326
for center_position in center_positions
311-
)
327+
]
312328

313329
# find best score
314330
best_position = None

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# AnimatedWordCloud ver 1.0.8
2-
3-
**UNDER CONSTRUCTION**
1+
# AnimatedWordCloud ver 1.0.9
42

53
<a href="https://codeclimate.com/github/konbraphat51/AnimatedWordCloud/maintainability"><img src="https://api.codeclimate.com/v1/badges/7a03252f77e7af46dc0f/maintainability" /></a>
64
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/20a71da0d9d841a2af236f6362a08ae7)](https://app.codacy.com/gh/konbraphat51/AnimatedWordCloud/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def requirements_from_file(file_name):
1919

2020
setup(
2121
name="AnimatedWordCloudTimelapse",
22-
version="1.0.8",
22+
version="1.0.9",
2323
description="Animate a timelapse of word cloud",
2424
long_description=readme,
2525
long_description_content_type="text/markdown",
@@ -32,7 +32,7 @@ def requirements_from_file(file_name):
3232
package_data={"AnimatedWordCloud": ["Assets/**"]},
3333
include_package_data=True,
3434
install_requires=[
35-
"Pillow==10.1.0",
35+
"Pillow==10.3.0",
3636
"numpy",
3737
"matplotlib",
3838
"joblib",

0 commit comments

Comments
 (0)