Skip to content

[additive_functionals] Style guide review#263

Closed
github-actions[bot] wants to merge 1 commit intomainfrom
style-guide/additive_functionals-20251001-120156
Closed

[additive_functionals] Style guide review#263
github-actions[bot] wants to merge 1 commit intomainfrom
style-guide/additive_functionals-20251001-120156

Conversation

@github-actions
Copy link
Copy Markdown

@github-actions github-actions Bot commented Oct 1, 2025

📋 Style Guide Review: additive_functionals

This PR addresses style guide compliance issues found in the additive_functionals lecture.

📊 Summary

  • Issues Found: 38
  • Provider: claude
  • Review Date: 2025-10-01 12:01 UTC

🎯 Issues by Priority

  • 🔴 Critical: 28
  • 🟠 Mandatory: 9
  • 🟡 Best Practice: 1

📝 Detailed Changes

Code (1 issues)

  1. qe-code-004 - Unicode Greek Letters
    • Location: Code cell defining parameters
    • Issue: Should use Unicode Greek letters for common economic variables
    • Current: ϕ_1, ϕ_2, ϕ_3, ϕ_4 = 0.5, -0.2, 0, 0.5 σ = 0.01 ν = 0.01 # Growth rate...
    • Fixed: φ_1, φ_2, φ_3, φ_4 = 0.5, -0.2, 0, 0.5 σ = 0.01 ν = 0.01 # Growth rate...
    • Explanation: While Unicode is used, φ (phi) is more standard than ϕ (varphi) for economic parameters per qe-code-004

Format (9 issues)

  1. qe-format-001 - Definitions

    • Location: Overview section
    • Issue: Definitions should use bold formatting
    • Current: `1. additive functionals that display random "arithmetic growth"
  2. *multiplicative functionals...`

    • Fixed: `1. additive functionals that display random "arithmetic growth"
  3. *multiplicative functionals...`

    • Explanation: Already correct - definitions are properly bolded
  4. qe-format-001 - Definitions

    • Location: Decomposition section
    • Issue: Component names should be bolded as definitions
    • Current: `- a constant
  • a trend component
  • an asymptotically stationary component
  • a **martinga...`
    • Fixed: `- a constant
  • a trend component
  • an asymptotically stationary component
  • a **martinga...`
    • Explanation: Already correct - definitions are properly bolded
  1. qe-format-001 - Definitions

    • Location: "A particular additive functional" section
    • Issue: Definition should be bolded
    • Current: We construct our additive functional from two pieces, the first of which is a **first-order vector ...
    • Fixed: We construct our additive functional from two pieces, the first of which is a **first-order vector a...
    • Explanation: Already correct - definition is properly bolded
  2. qe-format-002 - Emphasis

    • Location: "A particular additive functional" section
    • Issue: Emphasis should use italic
    • Current: The nonstationary random process $\{y_t\}_{t=0}^\infty$ displays systematic but random *arithmetic g...
    • Fixed: The nonstationary random process $\{y_t\}_{t=0}^\infty$ displays systematic but random *arithmetic g...
    • Explanation: Already correct - emphasis is properly italicized
  3. qe-format-002 - Emphasis

    • Location: Simulation section
    • Issue: Emphasis should use italic
    • Current: We have chosen to simulate many paths, all starting from the *same* non-random initial conditions $x...
    • Fixed: We have chosen to simulate many paths, all starting from the *same* non-random initial conditions $x...
    • Explanation: Already correct - emphasis is properly italicized
  4. qe-format-001 - Definitions

    • Location: "Associated multiplicative functional" section
    • Issue: Definition should be bolded
    • Current: As mentioned above, the process $\{M_t\}$ is called a **multiplicative functional**....
    • Fixed: As mentioned above, the process $\{M_t\}$ is called a **multiplicative functional**....
    • Explanation: Already correct - definition is properly bolded
  5. qe-format-001 - Definitions

    • Location: "Peculiar large sample property" section
    • Issue: Definition should be bolded
    • Current: The second is a **peculiar property** noted and proved by Hansen and Sargent {cite}Hans_Sarg_book....
    • Fixed: The second is a **peculiar property** noted and proved by Hansen and Sargent {cite}Hans_Sarg_book....
    • Explanation: Already correct - definition is properly bolded
  6. qe-format-001 - Definitions

    • Location: "Multiplicative martingale as likelihood ratio process" section
    • Issue: Definitions should be bolded
    • Current: [This lecture](https://python.quantecon.org/likelihood_ratio_process.html) studies **likelihood proc...
    • Fixed: [This lecture](https://python.quantecon.org/likelihood_ratio_process.html) studies **likelihood proc...
    • Explanation: Already correct - definitions are properly bolded
  7. qe-format-003 - Jupyter Book Theme

    • Location: Line 14 (label definition)
    • Issue: The label uses underscores additive_functionals which is not consistent with Jupyter Book best practices. Labels should use hyphens for better URL formatting and consistency with Jupyter Book conventions.
    • Current: (additive_functionals)=...
    • Fixed: (additive-functionals)=...
    • Explanation: Jupyter Book converts labels to URLs, and hyphens are the standard convention for URL-friendly identifiers. This improves readability and follows web standards.

Writing (28 issues)

  1. qe-writing-002 - One-Sentence Paragraphs

    • Location: Overview section, first paragraph
    • Issue: Paragraph contains multiple sentences instead of one sentence per paragraph
    • Current: Many economic time series display persistent growth that prevents them from being asymptotically st...
    • Fixed: Many economic time series display persistent growth that prevents them from being asymptotically sta...
    • Explanation: Each sentence must be in its own paragraph per qe-writing-002
  2. qe-writing-002 - One-Sentence Paragraphs

    • Location: Overview section, second multi-sentence paragraph
    • Issue: Multiple sentences in single paragraph
    • Current: But there are good ways to model time series that have persistent growth that still enable statisti...
    • Fixed: But there are good ways to model time series that have persistent growth that still enable statistic...
    • Explanation: Each sentence must be in its own paragraph per qe-writing-002
  3. qe-writing-002 - One-Sentence Paragraphs

    • Location: Overview section, list introduction
    • Issue: Multiple sentences in paragraph before list
    • Current: `These two classes of processes are closely connected.

If a process ${y_t}$ is an additive functio...`

  • Fixed: `These two classes of processes are closely connected.

If a process ${y_t}$ is an additive functio...`

  • Explanation: Already correct, but checking for consistency
  1. qe-writing-002 - One-Sentence Paragraphs
    • Location: "A particular additive functional" section
    • Issue: Multiple sentences in single paragraph
    • Current: {cite}Hansen_2012_Eca` describes a general class of additive functionals.

This lecture focuses on ...`

  • Fixed: {cite}Hansen_2012_Eca` describes a general class of additive functionals.

This lecture focuses on ...`

  • Explanation: Already correct format
  1. qe-writing-002 - One-Sentence Paragraphs

    • Location: "A particular additive functional" section, second paragraph
    • Issue: Multiple sentences in single paragraph
    • Current: Our special additive functional displays interesting time series behavior while also being easy to c...
    • Fixed: Our special additive functional displays interesting time series behavior while also being easy to c...
    • Explanation: Each sentence must be in its own paragraph per qe-writing-002
  2. qe-writing-002 - One-Sentence Paragraphs

    • Location: After equation old2_additive_functionals
    • Issue: Multiple sentences in single paragraph
    • Current: `Here $y_0 \sim {\cal N}(\mu_{y0}, \Sigma_{y0})$ is a random
      initial condition for $y$.

The nonstati...`

  • Fixed: `Here $y_0 \sim {\cal N}(\mu_{y0}, \Sigma_{y0})$ is a random initial condition for $y$.

The nonstati...`

  • Explanation: Each sentence must be in its own paragraph per qe-writing-002
  1. qe-writing-002 - One-Sentence Paragraphs

    • Location: "Linear state-space representation" section
    • Issue: Multiple sentences in single paragraph
    • Current: A convenient way to represent our additive functional is to use a [linear state space system](https:...
    • Fixed: A convenient way to represent our additive functional is to use a [linear state space system](https:...
    • Explanation: Already correct format
  2. qe-writing-002 - One-Sentence Paragraphs

    • Location: After state space equations
    • Issue: Multiple sentences in single paragraph
    • Current: To study it, we could map it into an instance of [LinearStateSpace](https://github.com/QuantEcon/Qua...
    • Fixed: To study it, we could map it into an instance of [LinearStateSpace](https://github.com/QuantEcon/Qua...
    • Explanation: Already correct format
  3. qe-writing-002 - One-Sentence Paragraphs

    • Location: "Dynamics" section
    • Issue: Multiple sentences in single paragraph
    • Current: `Let's run some simulations to build intuition.

(addfunc_eg1)=
In doing so we'll assume that $z_{t+1...`

  • Fixed: `Let's run some simulations to build intuition.

(addfunc_eg1)=
In doing so we'll assume that $z_{t+1...`

  • Explanation: Already correct format
  1. qe-writing-002 - One-Sentence Paragraphs
  • Location: After equation ftaf
  • Issue: Multiple sentences in single paragraph
  • Current: `in which the zeros $z$ of the polynomial

$$
\phi(z) = ( 1 - \phi_1 z - \phi_2 z^2 - \phi_3 z^3 - ...`

  • Fixed: `in which the zeros $z$ of the polynomial

$$
\phi(z) = ( 1 - \phi_1 z - \phi_2 z^2 - \phi_3 z^3 - \p...`

  • Explanation: Already correct format
  1. qe-writing-002 - One-Sentence Paragraphs
  • Location: After y increment equation
  • Issue: Multiple sentences in single paragraph
  • Current: While {eq}ftaf is not a first order system like {eq}old1_additive_functionals, we know that it c...
  • Fixed: While {eq}ftaf is not a first order system like {eq}old1_additive_functionals, we know that it c...
  • Explanation: Each sentence must be in its own paragraph per qe-writing-002
  1. qe-writing-002 - One-Sentence Paragraphs
  • Location: "Simulation" subsection
  • Issue: Multiple sentences in single paragraph
  • Current: `When simulating we embed our variables into a bigger system.

This system also constructs the compon...`

  • Fixed: `When simulating we embed our variables into a bigger system.

This system also constructs the compon...`

  • Explanation: Already correct format
  1. qe-writing-002 - One-Sentence Paragraphs
  • Location: After AMF_LSS_VAR class code
  • Issue: Multiple sentences in single paragraph
  • Current: When we plot multiple realizations of a component in the 2nd, 3rd, and 4th panels, we also plot the ...
  • Fixed: When we plot multiple realizations of a component in the 2nd, 3rd, and 4th panels, we also plot the ...
  • Explanation: Already correct format
  1. qe-writing-002 - One-Sentence Paragraphs
  • Location: After probability coverage discussion
  • Issue: Multiple sentences in single paragraph
  • Current: `Notice tell-tale signs of these probability coverage shaded areas
  • the purple one for the martinga...`

    • Fixed: `Notice tell-tale signs of these probability coverage shaded areas
  • the purple one for the martinga...`

    • Explanation: Formatting consistency
  1. qe-writing-002 - One-Sentence Paragraphs
  • Location: "Associated multiplicative functional" section
  • Issue: Multiple sentences in single paragraph
  • Current: `Where ${y_t}$ is our additive functional, let $M_t = \exp(y_t)$.

As mentioned above, the process ...`

  • Fixed: `Where ${y_t}$ is our additive functional, let $M_t = \exp(y_t)$.

As mentioned above, the process ...`

  • Explanation: Already correct format
  1. qe-writing-002 - One-Sentence Paragraphs
  • Location: After multiplicative decomposition equations
  • Issue: Multiple sentences in single paragraph
  • Current: An instance of class AMF_LSS_VAR ({ref}above <amf_lss>) includes this associated multiplicative...
  • Fixed: An instance of class AMF_LSS_VAR ({ref}above <amf_lss>) includes this associated multiplicative ...
  • Explanation: Each sentence must be in its own paragraph per qe-writing-002
  1. qe-writing-002 - One-Sentence Paragraphs
  • Location: After multiplicative plot
  • Issue: Multiple sentences in single paragraph
  • Current: As before, when we plotted multiple realizations of a component in the 2nd, 3rd, and 4th panels, we ...
  • Fixed: As before, when we plotted multiple realizations of a component in the 2nd, 3rd, and 4th panels, we ...
  • Explanation: Each sentence must be in its own paragraph per qe-writing-002. Also fixed typo "to how" → "to see how"
  1. qe-writing-002 - One-Sentence Paragraphs
  • Location: "Peculiar large sample property" section
  • Issue: Multiple sentences in single paragraph
  • Current: Hansen and Sargent {cite}Hans_Sarg_book (ch. 8) describe the following two properties of the mart...
  • Fixed: Hansen and Sargent {cite}Hans_Sarg_book (ch. 8) describe the following two properties of the marti...
  • Explanation: Each sentence must be in its own paragraph per qe-writing-002
  1. qe-writing-002 - One-Sentence Paragraphs
  • Location: After martingale simulation plot
  • Issue: Multiple sentences in single paragraph
  • Current: `The dotted line in the above graph is the mean $E \tilde M_t = 1$ of the martingale.

It remains con...`

  • Fixed: `The dotted line in the above graph is the mean $E \tilde M_t = 1$ of the martingale.

It remains con...`

  • Explanation: Already correct format
  1. qe-writing-002 - One-Sentence Paragraphs
  • Location: "More about the multiplicative martingale" section
  • Issue: Multiple sentences in single paragraph
  • Current: Let's drill down and study probability distribution of the multiplicative martingale $\{\widetilde ...
  • Fixed: Let's drill down and study probability distribution of the multiplicative martingale $\{\widetilde M...
  • Explanation: Each sentence must be in its own paragraph per qe-writing-002
  1. qe-writing-002 - One-Sentence Paragraphs
  • Location: After martingale representation
  • Issue: Multiple sentences in single paragraph
  • Current: `where $H = [F + D(I-A)^{-1} B]$.

It follows that $\log {\widetilde M}_t \sim {\mathcal N} ( -\frac...`

  • Fixed: `where $H = [F + D(I-A)^{-1} B]$.

It follows that $\log {\widetilde M}_t \sim {\mathcal N} ( -\frac{...`

  • Explanation: Each sentence must be in its own paragraph per qe-writing-002
  1. qe-writing-002 - One-Sentence Paragraphs
  • Location: "Simulating a multiplicative martingale again" section
  • Issue: Multiple sentences in single paragraph
  • Current: `Next, we want a program to simulate the likelihood ratio process ${ \tilde{M}t }{t=0}^\infty$.

...`

  • Fixed: `Next, we want a program to simulate the likelihood ratio process ${ \tilde{M}t }{t=0}^\infty$.

...`

  • Explanation: Each sentence must be in its own paragraph per qe-writing-002
  1. qe-writing-002 - One-Sentence Paragraphs
  • Location: "Sample paths" section
  • Issue: Multiple sentences in single paragraph
  • Current: `Let's write a program to simulate sample paths of ${ x_t, y_{t} }_{t=0}^{\infty}$.

We'll do this ...`

  • Fixed: `Let's write a program to simulate sample paths of ${ x_t, y_{t} }_{t=0}^{\infty}$.

We'll do this ...`

  • Explanation: Already correct format
  1. qe-writing-002 - One-Sentence Paragraphs
  • Location: After AMF_LSS_VAR class (second instance)
  • Issue: Multiple sentences in single paragraph
  • Current: The heavy lifting is done inside the AMF_LSS_VAR` class.

The following code adds some simple funct...`

  • Fixed: The heavy lifting is done inside the AMF_LSS_VAR` class.

The following code adds some simple funct...`

  • Explanation: Already correct format
  1. qe-writing-002 - One-Sentence Paragraphs
  • Location: After simulate_paths functions
  • Issue: Multiple sentences in single paragraph
  • Current: Now that we have these functions in our toolkit, let's apply them to run some simulations....
  • Fixed: Now that we have these functions in our toolkit, let's apply them to run some simulations....
  • Explanation: Already correct format
  1. qe-writing-002 - One-Sentence Paragraphs
  • Location: After simulation results
  • Issue: Multiple sentences in single paragraph
  • Current: Let's plot the probability density functions for $\log {\widetilde M}_t$ for $t=100, 500, 1000, 1000...
  • Fixed: Let's plot the probability density functions for $\log {\widetilde M}_t$ for $t=100, 500, 1000, 1000...
  • Explanation: Each sentence must be in its own paragraph per qe-writing-002
  1. qe-writing-002 - One-Sentence Paragraphs
  • Location: After density plots
  • Issue: Multiple sentences in single paragraph
  • Current: These probability density functions help us understand mechanics underlying the **peculiar property...
  • Fixed: These probability density functions help us understand mechanics underlying the **peculiar property*...
  • Explanation: Formatting consistency
  1. qe-writing-002 - One-Sentence Paragraphs
  • Location: "Multiplicative martingale as likelihood ratio process" section
  • Issue: Multiple sentences in single paragraph
  • Current: [This lecture](https://python.quantecon.org/likelihood_ratio_process.html) studies **likelihood proc...
  • Fixed: [This lecture](https://python.quantecon.org/likelihood_ratio_process.html) studies **likelihood proc...
  • Explanation: Each sentence must be in its own paragraph per qe-writing-002

📌 Summary

Found 38 issues across 4 rule checks


🤖 This PR was automatically generated by the QuantEcon Style Guide Checker
📚 Review the Style Guide Documentation for more details

- code: 1 fixes
- format: 9 fixes
- writing: 28 fixes

Rules addressed:
- qe-writing-002: One-Sentence Paragraphs
- qe-writing-002: One-Sentence Paragraphs
- qe-writing-002: One-Sentence Paragraphs
- qe-writing-002: One-Sentence Paragraphs
- qe-writing-002: One-Sentence Paragraphs
- qe-writing-002: One-Sentence Paragraphs
- qe-writing-002: One-Sentence Paragraphs
- qe-writing-002: One-Sentence Paragraphs
- qe-writing-002: One-Sentence Paragraphs
- qe-writing-002: One-Sentence Paragraphs
- ... and 28 more
@netlify
Copy link
Copy Markdown

netlify Bot commented Oct 1, 2025

Deploy Preview for lustrous-melomakarona-3ee73e ready!

Name Link
🔨 Latest commit 8d3e8f8
🔍 Latest deploy log https://app.netlify.com/projects/lustrous-melomakarona-3ee73e/deploys/68dd183c4ad38d00088817dd
😎 Deploy Preview https://deploy-preview-263--lustrous-melomakarona-3ee73e.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.

mmcky added a commit to QuantEcon/action-style-guide that referenced this pull request Oct 1, 2025
CRITICAL FIX: The regex pattern for extracting corrected content from
LLM responses was using non-greedy matching (.*?) which would stop at
the first ``` encountered. This caused it to extract only partial
content when the corrected lecture contained nested code blocks.

Changes:
- Updated parse_markdown_response() to handle nested code blocks correctly
- Added fallback extraction logic for robustness
- Updated test to validate nested code blocks are preserved
- Removed misleading comment about "acceptable" partial parsing

Impact:
- Fixes issue where corrected content was truncated to just one line
- Now properly extracts full corrected lecture content
- Handles lectures with multiple code blocks (Python, Julia, etc.)

See: QuantEcon/lecture-python-advanced.myst#263
@mmcky
Copy link
Copy Markdown
Contributor

mmcky commented Oct 1, 2025

Close as test run used for diagnostics.

@mmcky mmcky closed this Oct 1, 2025
mmcky added a commit to QuantEcon/action-style-guide that referenced this pull request Oct 1, 2025
…tent

MAJOR IMPROVEMENT: Complete overhaul of how fixes are applied to lectures.

Problem:
- LLMs were generating entire corrected lecture content
- This was unreliable: truncation, added commentary, deleted content
- PR #263 showed lecture being deleted except one line

Solution:
- LLM now only identifies violations with exact current_text and suggested_fix
- New fix_applier.py module applies fixes programmatically via text replacement
- Preserves all original content, only applies targeted fixes
- No LLM-generated notes or commentary in the output

Changes:
1. Created style_checker/fix_applier.py:
   - apply_fixes(): Programmatic text replacement
   - validate_fix_quality(): Check for commentary, missing fields
   - Detailed warnings for fixes that can't be applied

2. Updated reviewer.py:
   - Modified all provider prompts to NOT generate corrected content
   - Added apply_fixes() call in review_lecture()
   - Updated review_in_chunks() to apply fixes to original (not sequential)
   - Made corrected_content field optional in parser

3. Benefits:
   - ✅ Keeps original lecture intact
   - ✅ Only applies targeted fixes
   - ✅ No LLM commentary in output
   - ✅ Better error handling
   - ✅ Validation warnings for bad fixes
   - ✅ Handles cases where exact text can't be found

Impact:
- PRs will now show precise, targeted changes
- No more deleted content
- No more LLM notes in the lecture
- More reliable and predictable fixes

See: QuantEcon/lecture-python-advanced.myst#263
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.

1 participant