[WIP] Complete extensive code refactoring of scintools#30
Closed
Copilot wants to merge 1 commit intocopilot/refactor-scintools-codefrom
Closed
[WIP] Complete extensive code refactoring of scintools#30Copilot wants to merge 1 commit intocopilot/refactor-scintools-codefrom
Copilot wants to merge 1 commit intocopilot/refactor-scintools-codefrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.
Original prompt
Complete Extensive Code Refactoring of scintools
Overview
This PR builds on PR #29 to complete the extensive code refactoring that was deferred. The focus is on modernizing code patterns, improving architecture, and enhancing maintainability while maintaining backward compatibility.
Branch to Work From
Base this PR on the branch
copilot/refactor-scintools-codefrom PR #29, NOT on master. This ensures we build on the documentation improvements already made.Primary Focus: dynspec.py Refactoring
1. Extract Repeated Utility Functions to scint_utils.py
Identify and extract commonly used patterns that appear multiple times in dynspec.py:
Array Validation & Cleaning:
Example patterns to extract:
Look specifically for:
2. Modernize Code Patterns Throughout
A. Replace .format() with f-strings:
Current pattern:
Modern pattern:
Scan ALL print statements, error messages, and string formatting throughout dynspec.py and replace with f-strings.
B. Add Type Hints:
Add type hints to all method signatures in the Dynspec class:
Add type hints to:
__init__and class methodsC. Use pathlib for File Operations:
Current pattern:
Modern pattern:
Replace all:
os.path.join()→Path() / filenameos.path.split()→Path().parentandPath().namePath().exists()D. Improve Error Handling:
Replace generic print statements with proper exceptions:
Current pattern:
Modern pattern:
Add specific exceptions:
ValueErrorfor invalid parameter valuesFileNotFoundErrorfor missing filesTypeErrorfor wrong typesDynspecError)3. Refactor fit_arc() Method
This is the HIGHEST PRIORITY item. The
fit_arcmethod has 24 parameters and is very complex.A. Create Configuration Classes:
Use dataclasses to group related parameters: