Skip to content

🌐 [translation-sync] [numba.md] Update np.random → Generator API#133

Merged
mmcky merged 2 commits into
mainfrom
translation-sync-2026-07-15T23-50-59-pr-550
Jul 16, 2026
Merged

🌐 [translation-sync] [numba.md] Update np.random → Generator API#133
mmcky merged 2 commits into
mainfrom
translation-sync-2026-07-15T23-50-59-pr-550

Conversation

@mmcky

@mmcky mmcky commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Automated Translation Sync

This PR contains automated translations from QuantEcon/lecture-python-programming.

Source PR

#550 - [numba.md] Update np.random → Generator API

Files Updated

  • ✏️ lectures/numba.md
  • ✏️ .translate/state/numba.md.yml

Details

  • Source Language: en
  • Target Language: fa
  • Model: claude-sonnet-5

This PR was created automatically by the translation action.

@netlify

netlify Bot commented Jul 15, 2026

Copy link
Copy Markdown

Deploy Preview for majestic-griffin-10b166 ready!

Name Link
🔨 Latest commit bbc46f6
🔍 Latest deploy log https://app.netlify.com/projects/majestic-griffin-10b166/deploys/6a581ce83445850007395a20
😎 Deploy Preview https://deploy-preview-133--majestic-griffin-10b166.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

✅ Translation Quality Review

Verdict: PASS | Model: claude-sonnet-5 | Date: 2026-07-15


📝 Translation Quality

Criterion Score
Accuracy 9/10
Fluency 9/10
Terminology 9/10
Formatting 10/10
Overall 9.2/10

Summary: ترجمه بخش تغییر یافته 'Exercises' با کیفیت بالا، دقت مفهومی خوب، رعایت اصطلاحات فنی مطابق گلاسری، و حفظ کامل ساختار Markdown/MyST انجام شده است. هیچ خطای نحوی یافت نشد و مشکلات جدی در محتوا مشاهده نمی‌شود؛ نکات ارائه‌شده صرفاً پیشنهادهای جزئی سبک نگارشی هستند. ترجمه بخش Exercises دقیق، روان و با حفظ کامل ساختار MyST/Markdown از جمله دایرکتیوهای exercise/solution انجام شده است اصطلاحات فنی مانند 'data race'، 'thread-safe'، 'Generator' و 'prange' با توضیحات مناسب و ارجاع به گلاسری حفظ شده‌اند معادلات ریاضی، بلوک‌های کد و ارجاعات متقابل (cross-references) به‌درستی بدون تغییر باقی مانده‌اند لحن آکادمیک و طبیعی فارسی در توضیحات تمرین‌ها و راه‌حل‌ها به‌خوبی رعایت شده است

Suggestions:

  • Exercises section, code comment: 'در همه نخ‌ها' برای 'across all threads' در ترجمه توضیحات solution numba_ex_draw_speed دقیق است اما می‌توان برای وضوح بیشتر 'در تمام نخ‌ها به‌طور همزمان' نوشت — این یک پیشنهاد جزئی است، نه اشکال.
  • In numba_ex_race solution, 'می‌بینیم که' مورد استفاده نشده و ترجمه 'This is a data race' به 'این یک رقابت داده است' به‌درستی انجام شده؛ می‌توان برای رعایت یکدست‌سازی اصطلاح فنی، 'data race' را در پرانتز نگه داشت (که قبلاً انجام شده) — بدون مشکل.
  • Exercises heading translation 'مروری کلی' برای Overview در بخش‌های تغییر نکرده تکرار شده اما در بخش Exercises عنوان 'تمرین‌ها' به‌درستی و به‌طور یکنواخت در سراسر سند به کار رفته است — نکته مثبت است نه اشکال.

🔍 Diff Quality

Check Status
Scope Correct
Position Correct
Structure Preserved
Heading-map Correct
Overall 10/10

Summary: The translation sync correctly added all new content (intro paragraph, code cells, two new exercises/solutions, note block) in matching positions within the single modified file, with no heading changes required or missed.


This review was generated automatically by action-translation review mode.

@github-actions

Copy link
Copy Markdown

✅ Translation Quality Review

Verdict: PASS | Model: claude-sonnet-5 | Date: 2026-07-15


📝 Translation Quality

Criterion Score
Accuracy 9/10
Fluency 8/10
Terminology 9/10
Formatting 9/10
Overall 8.8/10

Summary: The translation of the Exercises section is highly accurate, fluent, and terminologically consistent with the established glossary. Technical concepts around Numba, parallelization, Monte Carlo simulation, and data races are rendered clearly in Persian while preserving all code, math, and MyST formatting. Minor stylistic inconsistencies exist in code comment translation choices and occasional informal phrasing, but these do not impact comprehension or technical accuracy. Technical terminology (Monte Carlo, JIT, parallelization, data race, generator) is translated accurately and consistently with appropriate transliteration where needed (e.g., 'رقابت داده' for data race) Mathematical notation and LaTeX equations are preserved correctly throughout the Exercises section Code blocks, MyST directives (exercise, solution-start/end, hint), and cross-references (e.g., {ref}speed_ex1) are all correctly preserved Complex conceptual explanations about thread safety, data races, and parallel RNG behavior are translated clearly and maintain the technical nuance of the original

Suggestions:

  • Exercises section, comment translation inconsistency: In the code cell for calculate_pi, the comment '# dividing by radius2' was translated to Persian ('# تقسیم بر radius2') while other code comments in the same section (e.g., 'For each sample path' in numba_ex4) were also translated, but this creates inconsistency with untranslated code elsewhere in the document (e.g., '# Warm up', '# Second run' remain in English) - consider keeping code comments consistently in one language throughout the Exercises section for better readability.
  • numba_ex_race solution, methods list: 'per-thread state (correct)' and 'shared generator in prange (data race)' were translated as plot labels ('حالت مخصوص هر نخ (درست)', 'تولیدکننده مشترک در prange (رقابت داده)') - this is good practice, but ensure the translated string length doesn't cause legend overflow issues in the actual rendered plot, as Persian text tends to be longer.
  • Exercises intro paragraph: 'so that we can use them in both exercises and compare results' translated as 'تا بتوانیم در هر دو تمرین از آن‌ها استفاده کرده و نتایج را مقایسه کنیم' - accurate and fluent, no change needed, but verify 'exercises' consistently maps to 'تمرین‌ها' (plural) vs 'تمرین' (singular) is used correctly across the section, which it is.
  • speed_ex2 exercise text: 'Represent the low state as 0 and the high state as 1' was translated well, but the hint code comment '# Start in state 1' in the solution was translated to '# در حالت 1 شروع کن' using informal imperative form ('شروع کن') which is less formal than the surrounding academic register; consider using more neutral phrasing like 'شروع می‌شود' for consistency with academic tone used elsewhere.

🔍 Diff Quality

Check Status
Scope Correct
Position Correct
Structure Preserved
Heading-map Correct
Overall 10/10

Summary: The translation sync correctly added all new content (intro paragraph, modified exercises, two new exercises, and the note block) in the same positions as the source, with proper translation and no structural or scope issues.


This review was generated automatically by action-translation review mode.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR syncs the Persian (fa) translation of the Numba lecture with upstream changes that migrate examples away from legacy np.random.* usage toward the NumPy Generator API, including new material explaining correctness/performance tradeoffs under parallel execution.

Changes:

  • Pre-generates Monte Carlo draws using np.random.default_rng() and passes them into JIT-compiled functions instead of drawing via np.random.uniform() inside loops.
  • Adds new exercises/solutions discussing RNG data races in prange and safe approaches under parallel Numba execution.
  • Updates translation sync state metadata (source SHA, sync date, model, tool version).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lectures/numba.md Updates translated lecture content and exercises to use Generator-based RNG patterns and adds explanations about parallel RNG safety.
.translate/state/numba.md.yml Updates translation sync metadata to match the upstream source commit and tooling/model versions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lectures/numba.md
Comment on lines 681 to +683
@jit(parallel=True)
def calculate_pi(n=1_000_000):
def calculate_pi_parallel(u_draws, v_draws):
n = len(u_draws)
@github-actions

Copy link
Copy Markdown

@github-actions github-actions Bot temporarily deployed to pull request July 15, 2026 23:56 Inactive
mmcky added a commit that referenced this pull request Jul 16, 2026
Ports the fix from QuantEcon/lecture-python-programming.fr#7. This repo
has the identical trigger list and no concurrency guard, and the bug is
already reproducing here: PR #133 carries two "Translation Quality
Review" comments, scoring 9.2/10 and 8.8/10, both posted at 23:51:37.

A single translation sync fires `opened` plus one `labeled` event per
label applied, all within a couple of seconds. Each starts its own run of
this workflow, and the review action's "update existing comment, else
create" logic is a check-then-act with no lock: concurrent runs all see
"no comment yet" and each create one. On PR #133 three runs fired; two
logged `Posted review comment` and one logged `Updated existing review
comment`, leaving two independent reports of the same diff and three full
model calls where one was intended.

Add a per-PR concurrency group so runs queue instead of racing — the
first creates the comment, any later run updates it. cancel-in-progress
is left false on purpose: the labels are applied in one API call so event
order is not guaranteed, and cancelling would let a `labeled` event for
'automated' kill the in-flight review and then skip its own job, leaving
no review at all.

Also ignore `labeled` events for labels other than 'action-translation',
which removes the redundant review triggered by the 'automated' label.

The underlying unsynchronised upsert is tracked in
QuantEcon/action-translation#96.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mmcky added a commit that referenced this pull request Jul 16, 2026
Ports the fix from QuantEcon/lecture-python-programming.fr#7. This repo
has the identical trigger list and no concurrency guard, and the bug is
already reproducing here: PR #133 carries two "Translation Quality
Review" comments, scoring 9.2/10 and 8.8/10, both posted at 23:51:37.

A single translation sync fires `opened` plus one `labeled` event per
label applied, all within a couple of seconds. Each starts its own run of
this workflow, and the review action's "update existing comment, else
create" logic is a check-then-act with no lock: concurrent runs all see
"no comment yet" and each create one. On PR #133 three runs fired; two
logged `Posted review comment` and one logged `Updated existing review
comment`, leaving two independent reports of the same diff and three full
model calls where one was intended.

Add a per-PR concurrency group so runs queue instead of racing — the
first creates the comment, any later run updates it. cancel-in-progress
is left false on purpose: the labels are applied in one API call so event
order is not guaranteed, and cancelling would let a `labeled` event for
'automated' kill the in-flight review and then skip its own job, leaving
no review at all.

Also ignore `labeled` events for labels other than 'action-translation',
which removes the redundant review triggered by the 'automated' label.

The underlying unsynchronised upsert is tracked in
QuantEcon/action-translation#96.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mmcky mmcky merged commit 7cd985b into main Jul 16, 2026
10 checks passed
@mmcky mmcky deleted the translation-sync-2026-07-15T23-50-59-pr-550 branch July 16, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants