Skip to content

🌐 [translation-sync] [python_by_example.md] Update np.random → Generator API#114

Open
mmcky wants to merge 2 commits intomainfrom
translation-sync-2026-04-25T11-42-26-pr-538
Open

🌐 [translation-sync] [python_by_example.md] Update np.random → Generator API#114
mmcky wants to merge 2 commits intomainfrom
translation-sync-2026-04-25T11-42-26-pr-538

Conversation

@mmcky
Copy link
Copy Markdown
Contributor

@mmcky mmcky commented Apr 25, 2026

Automated Translation Sync

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

Source PR

#538 - [python_by_example.md] Update np.random → Generator API

Files Updated

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

Details

  • Source Language: en
  • Target Language: fa
  • Model: claude-sonnet-4-6

This PR was created automatically by the translation action.

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 25, 2026

Deploy Preview for majestic-griffin-10b166 ready!

Name Link
🔨 Latest commit aa4fb1b
🔍 Latest deploy log https://app.netlify.com/projects/majestic-griffin-10b166/deploys/69eca8a8f130de000876bcd4
😎 Deploy Preview https://deploy-preview-114--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
Copy link
Copy Markdown

github-actions Bot commented Apr 25, 2026

✅ Translation Quality Review

Verdict: PASS | Model: claude-sonnet-4-6 | Date: 2026-04-25


📝 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 modified sections is of high quality overall, with accurate technical content and good Persian fluency. The main issues are a typo ('blind' instead of 'bind') in The For Loop section, a subtle inaccuracy in the While Loop condition description, and a significant error in Exercise 2 where 'three time series' is mistranslated as 'one time series'. The Subpackages, Random Draws, and Version 1 sections are well translated with appropriate terminology and natural Persian phrasing. Technical terminology is consistently and accurately translated throughout all modified sections, following the reference glossary appropriately Mathematical notation and LaTeX expressions are preserved correctly in all modified sections including equations and variable names The translation of the Subpackages section accurately explains the concept of subdirectories and provides a clear Persian explanation The While Loops section correctly preserves the code structure and inline code references while providing clear Persian explanations The Exercises section maintains the mathematical formulas, exercise structure, and hint formatting correctly

Suggestions:

  • The For Loop section - 'blind' typo in translation: 'نام متغیر variable_name را به آن عنصر متصل (blind) می کند' → should be 'bind' not 'blind': 'نام متغیر variable_name را به آن عنصر متصل (bind) می کند'

  • While Loops section - Slightly inaccurate condition description: 'حلقه while به اجرای بلوک کد ادامه می دهد تا زمانی که شرط برقرار باشد' → The while loop continues WHILE the condition is true, but the phrasing implies it runs UNTIL the condition is satisfied. Should be: 'حلقه while تا زمانی که شرط برقرار است به اجرای بلوک کد ادامه می دهد'

  • Random Draws section - 'genererate' typo in original is silently dropped but the Persian translation omits the nuance of 'We can and will look at various ways': 'در ادامه، روش های مختلفی را بررسی خواهیم کرد تا بتوانیم این نمودار را بهتر تنظیم و بهینه سازی کنیم' → consider adding 'در زیر' to match 'below': 'در ادامه و در بخش های زیر، روش های مختلفی را بررسی خواهیم کرد'

  • Exercises section - Exercise 2 instruction 'Starting with your solution to exercise 1, plot three simulated time series' is translated as 'با استفاده از راه حل تمرین 1، یک سری زمانی شبیه سازی شده رسم کنید' which says 'one time series' instead of 'three': should be 'سه سری زمانی شبیه سازی شده رسم کنید'

  • A Version with a For Loop - The bullet point translation 'سه خط بعدی حلقه for هستند، که به طور مکرر یک عدد تصادفی جدید $\epsilon_t$ می‌کشد' uses 'می‌کشد' (draws/pulls) which is acceptable but 'تولید می‌کند' would be more natural for 'draws a random number' in a mathematical context


🔍 Diff Quality

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

Summary: The translation document correctly mirrors all source changes, replacing legacy numpy random calls with the new rng-based API throughout all corresponding code cells, while preserving document structure, section order, and translation metadata unchanged.


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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Persian translation of python_by_example.md to use NumPy’s Generator-based random API (default_rng) instead of legacy np.random.* calls, in sync with the upstream lecture changes.

Changes:

  • Replaced np.random.randn() with rng = np.random.default_rng() + rng.standard_normal(...) across examples.
  • Replaced np.random.uniform() with rng.uniform() in the Monte Carlo section.
  • Updated translation sync state metadata (source SHA, model, tool version, sync date/mode).

Reviewed changes

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

File Description
lectures/python_by_example.md Migrates random number generation examples to NumPy Generator API in the translated lecture.
.translate/state/python_by_example.md.yml Updates translation-sync bookkeeping (sha/date/model/tool-version).

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

Comment on lines 189 to 193
بیاید به کدی که نویز سفید رسم می کند برگردیم. سه خط بعد از دستور Import به این صورت هستند:

```{code-cell} ipython
ϵ_values = np.random.randn(100)
ϵ_values = rng.standard_normal(100)
plt.plot(ϵ_values)
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

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

The narrative says “three lines after the import” and the snippet starts with ϵ_values = rng.standard_normal(100), but the updated program now includes rng = np.random.default_rng() immediately after the imports. This section should be updated so the description and the displayed snippet reflect the new extra line (e.g., adjust the wording/count and/or include the rng = ... line in the snippet).

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

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