Refactor scintools: remove Python 2 compat, improve docstrings, update docs#29
Closed
Refactor scintools: remove Python 2 compat, improve docstrings, update docs#29
Conversation
Co-authored-by: danielreardon <40694862+danielreardon@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor scintools Python code with improved documentation
Refactor scintools: remove Python 2 compat, improve docstrings, update docs
Mar 3, 2026
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.
Modernises the scintools codebase by dropping Python 2 compatibility shims, expanding docstrings to NumPy style, and replacing placeholder documentation with real content.
Python 2 compatibility removal
from __future__ import (absolute_import, division, print_function, unicode_literals)from all five source files (__init__.py,dynspec.py,scint_models.py,scint_sim.py,scint_utils.py)NumPy-style docstrings
scint_utils.py— 16 functions upgraded:is_valid,autocorr,read_dynlist,write_results,read_results,cov_to_corr,float_array_from_dict,difference,get_ssb_delay,get_earth_velocity,read_par,mjd_to_year,find_nearest,pars_to_params,get_true_anomaly,get_binphasescint_models.py—fitter,powerspectrum_model,arc_curvature,effective_velocity_annualscint_sim.py—Simulation.__init__(all 24 parameters documented, plus Notes and References)Example of the improved docstring style:
Documentation
dynspec.rst— replaced "blah blah this is how you do things" placeholder with a proper overview, usage examples for all major operations, and anautoclassAPI directiveexamples.rst(new) — runnable examples covering loading/visualising spectra, processing, secondary spectra, arc fitting (including parameter-selection guide and troubleshooting), ACF analysis, and simulationsindex.rst— addedexamplesto the toctreeOriginal prompt
Refactor scintools Python code with improved documentation
Overview
Refactor the Python code in the
scintools/directory (excludingththmod.py) to improve code organization, modernize patterns, and enhance documentation. The primary focus is ondynspec.py, which is the most important file to refactor.Specific Refactoring Goals
1. Code Organization & Structure (dynspec.py)
scint_utils.pyto reduce code duplicationDynspecclass2. Modernize Code Patterns
from __future__ importstatements are no longer needed.format()and%formatting3. Improve fit_arc Function
The
fit_arcmethod indynspec.py(starting at line 967) needs significant improvements:4. Enhanced Docstrings
Add comprehensive NumPy-style docstrings to all functions and methods:
Currently, many functions have minimal or incomplete docstrings. For example:
is_valid()in scint_utils.py has a brief docstring but no parameter/return documentationautocorr()in scint_utils.py needs expanded documentationDynspecclass need better documentation5. Move Repeated Functions to scint_utils.py
Identify and extract commonly used utility functions that appear in multiple files:
Examples to look for:
6. Improve Other Files
Also refactor
scint_utils.py,scint_models.py, andscint_sim.py:Documentation Enhancements
7. Create Comprehensive Example Usage Documentation
Create a new file
docs/source/examples.rstwith practical, runnable examples:Include examples for:
Loading and visualizing dynamic spectra
Processing dynamic spectra
Computing secondary spectra
Arc fitting workflow
fit_arc()ACF analysis
Simulations
Example format:
Each example should include:
8. Update docs/source/dynspec.rst
The current
dynspec.rstis incomplete (has placeholder text "blah blah this is how you do things"). Replace it with:9. Update docs/source/index.rst
Add the new examples page to the table of contents.
Files to Modify
Primary Files:
scintools/dynspec.py- MAIN FOCUS - extensive refactoring neededscintools/scint_utils.py- add extracted utility functions, ...This pull request was created from Copilot chat.
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.