-
Notifications
You must be signed in to change notification settings - Fork 0
Decouple fitting from results and add show_fit_results API
#118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f016f69
551d8f7
48dda4d
18a1a90
c6c9efc
9787ce2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -554,8 +554,8 @@ def paragraph(cls, title: str) -> None: | |
| def section(cls, title: str) -> None: | ||
| """Formats a section header with bold green text.""" | ||
| full_title = f'{title.upper()}' | ||
| line = '━' * len(full_title) | ||
| formatted = f'[bold green]\n{line}\n{full_title}\n{line}[/bold green]' | ||
| line = '—' * len(full_title) | ||
| formatted = f'[bold green]{line}\n{full_title}\n{line}[/bold green]' | ||
| if not in_jupyter(): | ||
| formatted = f'\n{formatted}' | ||
| cls._console.print(formatted) | ||
|
|
@@ -566,7 +566,7 @@ def chapter(cls, title: str) -> None: | |
| and padding. | ||
| """ | ||
| width = ConsoleManager._detect_width() | ||
| symbol = '─' | ||
| symbol = '—' | ||
|
||
| full_title = f' {title.upper()} ' | ||
| pad_len = (width - len(full_title)) // 2 | ||
| padding = symbol * pad_len | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -82,3 +82,56 @@ def test_fit_modes_show_and_switch_to_joint(monkeypatch, capsys): | |||
| out2 = capsys.readouterr().out | ||||
| assert 'Current fit mode changed to' in out2 | ||||
| assert a.fit_mode == 'joint' | ||||
|
|
||||
|
|
||||
| def test_show_fit_results_warns_when_no_results(capsys): | ||||
| """Test that show_fit_results logs a warning when fit() has not been run.""" | ||||
| from easydiffraction.analysis.analysis import Analysis | ||||
|
|
||||
| a = Analysis(project=_make_project_with_names([])) | ||||
|
|
||||
| # Ensure fit_results is not set | ||||
| assert not hasattr(a, 'fit_results') or a.fit_results is None | ||||
|
|
||||
| a.show_fit_results() | ||||
| out = capsys.readouterr().out | ||||
| assert 'No fit results available' in out | ||||
|
|
||||
|
|
||||
| def test_show_fit_results_calls_process_fit_results(monkeypatch): | ||||
| """Test that show_fit_results delegates to fitter._process_fit_results.""" | ||||
| from easydiffraction.analysis.analysis import Analysis | ||||
|
|
||||
| # Track if _process_fit_results was called | ||||
| process_called = {'called': False, 'args': None} | ||||
|
|
||||
| def mock_process_fit_results(sample_models, experiments): | ||||
| process_called['called'] = True | ||||
| process_called['args'] = (sample_models, experiments) | ||||
|
|
||||
| # Create a mock project with sample_models and experiments | ||||
| class MockProject: | ||||
| sample_models = object() | ||||
| experiments = object() | ||||
|
||||
| experiments = object() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The character changed from box drawing character '━' (U+2501, BOX DRAWINGS HEAVY HORIZONTAL) to em dash '—' (U+2014, EM DASH). Box drawing characters are specifically designed for creating visual lines and borders in terminal output and typically render more consistently across terminals. The em dash is a punctuation mark and may not create visually continuous lines. Consider whether this change was intentional, as it may affect the visual appearance of section headers in console output.