Skip to content

Refactor to standard Python package structure#19

Merged
SBFRF merged 4 commits intomasterfrom
copilot/refactor-repository-organization
Feb 10, 2026
Merged

Refactor to standard Python package structure#19
SBFRF merged 4 commits intomasterfrom
copilot/refactor-repository-organization

Conversation

Copy link
Contributor

Copilot AI commented Feb 3, 2026

Repository Organization Refactoring - Complete ✅

This PR successfully refactors the pyDIWASP repository to follow traditional Python package structure, making it deployable, maintainable, and ready for PyPI distribution.

✅ Completed Tasks

  • Analyze current repository structure
  • Create proper package directory pydiwasp/
  • Move main modules into package directory
  • Update private/ as a subpackage
  • Create package __init__.py files
  • Update all import statements in tests
  • Update all import statements in main modules
  • Update setup.py configuration
  • Add modern packaging files (pyproject.toml, MANIFEST.in)
  • Update documentation and examples
  • Verify tests still pass (28/28 ✓)
  • Verify package builds successfully
  • Run security scan (0 vulnerabilities)
  • Address review feedback (remove duplicate imports, cleanup dependencies)

📦 Package Structure Changes

Before:

pyDIWASP/
├── dirspec.py
├── infospec.py
├── plotspec.py
├── writespec.py
├── interpspec.py
├── private/
│   ├── hsig.py
│   └── ...
└── tests/

After (Traditional Python Package):

pyDIWASP/
├── pydiwasp/              # Main package
│   ├── __init__.py       # Package exports
│   ├── dirspec.py
│   ├── infospec.py
│   ├── plotspec.py
│   ├── writespec.py
│   ├── interpspec.py
│   └── private/          # Subpackage
│       ├── __init__.py
│       └── ...
├── tests/
├── setup.py
├── pyproject.toml        # Modern packaging (PEP 518)
└── MANIFEST.in           # Distribution manifest

🔄 Import Changes

Before:

from dirspec import dirspec
from private.hsig import hsig

After:

from pydiwasp import dirspec
from pydiwasp.private.hsig import hsig

📝 Key Benefits

  1. Standard Package Structure: Follows Python packaging best practices
  2. Pip Installable: pip install -e . or pip install pyDIWASP (when published)
  3. Clean Imports: from pydiwasp import dirspec instead of direct file imports
  4. PyPI Ready: Can be published to PyPI with python -m build and twine upload
  5. Modern Standards: Uses pyproject.toml (PEP 518) for build configuration
  6. Better Isolation: Package code isolated from repository root
  7. CI/CD Compatible: Existing GitHub Actions workflows work without changes

✅ Verification

  • All 28 tests pass
  • Package builds successfully as source distribution
  • Package installs correctly in editable mode
  • No security vulnerabilities detected (CodeQL)
  • Documentation updated with new import patterns
  • Example notebook updated to use new structure
  • Review feedback addressed
Original prompt

This section details on the original issue you should resolve

<issue_title>organize repository</issue_title>
<issue_description>refactor organization to make more deployable and traditional </issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 3, 2026 02:57
Co-authored-by: SBFRF <8375832+SBFRF@users.noreply.github.com>
Co-authored-by: SBFRF <8375832+SBFRF@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor repository organization for better deployability Refactor to standard Python package structure Feb 3, 2026
Copilot AI requested a review from SBFRF February 3, 2026 03:02
Copy link
Owner

@SBFRF SBFRF left a comment

Choose a reason for hiding this comment

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

Lgtm

Copy link
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

Refactors the repo into an installable Python package (pydiwasp) with updated imports, packaging metadata, and documentation/examples so users can pip install and import via pydiwasp.

Changes:

  • Introduces pydiwasp/ package + pydiwasp.private/ subpackage and updates internal imports to be package-relative.
  • Updates tests/examples/docs to import via pydiwasp instead of root-level modules.
  • Adds/updates packaging files (pyproject.toml, MANIFEST.in, setup.py) to support building/installing the package.

Reviewed changes

Copilot reviewed 15 out of 35 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/test_integration.py Updates integration test imports to use pydiwasp.
tests/test_core.py Updates core test imports to use pydiwasp.private paths.
tests/test_api.py Updates API tests to import public functions from pydiwasp.
setup.py Restricts package discovery to pydiwasp packages.
pyproject.toml Adds PEP 518/621 project/build metadata for packaging.
MANIFEST.in Adds sdist include/exclude rules for key repo files.
README.md Updates installation and import examples for installed package usage.
examples/pyDIWASP_example.ipynb Removes sys.path manipulation; imports from pydiwasp.
pydiwasp/init.py Defines package public API re-exports.
pydiwasp/dirspec.py Switches to relative imports for package modules.
pydiwasp/infospec.py Updates internal import to use package-relative private.
pydiwasp/interpspec.py Updates internal imports to use package-relative private.
pydiwasp/plotspec.py Updates internal import to use package-relative private.
pydiwasp/writespec.py Adds writespec module under package.
pydiwasp/private/init.py Defines private as a subpackage (docstring only).
pydiwasp/private/accs.py Adds transfer functions for acceleration measurements.
pydiwasp/private/BDM.py Adds Bayesian Directional Method implementation.
pydiwasp/private/check_data.py Adds DIWASP data structure validation/utilities.
pydiwasp/private/DFTM.py Adds Direct Fourier Transform Method implementation.
pydiwasp/private/diwasp_csd.py Adds cross-spectral density helper.
pydiwasp/private/elev.py Adds elevation transfer function.
pydiwasp/private/EMEP.py Adds EMEP estimation method implementation.
pydiwasp/private/EMLM.py Adds EMLM estimation method implementation.
pydiwasp/private/hsig.py Adds significant wave height helper.
pydiwasp/private/IMLM.py Adds IMLM estimation method implementation.
pydiwasp/private/pres.py Adds pressure transfer function.
pydiwasp/private/slpx.py Adds x-direction surface slope transfer function.
pydiwasp/private/slpy.py Adds y-direction surface slope transfer function.
pydiwasp/private/smoothspec.py Adds spectrum smoothing helper.
pydiwasp/private/spectobasis.py Adds spectral unit conversion helper.
pydiwasp/private/vels.py Updates import to be relative within private subpackage.
pydiwasp/private/velx.py Adds x-velocity transfer function.
pydiwasp/private/vely.py Adds y-velocity transfer function.
pydiwasp/private/velz.py Adds vertical velocity transfer function.
pydiwasp/private/wavenumber.py Adds wave number calculation helper.
Comments suppressed due to low confidence (9)

pydiwasp/dirspec.py:19

  • dirspec selects the estimation algorithm via eval(EP['method']), but only IMLM and EMEP are imported in this module. If a caller sets EP['method'] to one of the other allowed values (DFTM, EMLM, BDM per check_data), this will raise NameError. Import the missing methods into this module (or replace eval with an explicit dispatch map).
    pydiwasp/dirspec.py:9
  • Import of 'velx' is not used.
    pydiwasp/dirspec.py:10
  • Import of 'vely' is not used.
    pydiwasp/dirspec.py:11
  • Import of 'pres' is not used.
    pydiwasp/dirspec.py:12
  • Import of 'elev' is not used.
    pydiwasp/dirspec.py:13
  • Import of 'vels' is not used.
    pydiwasp/dirspec.py:14
  • Import of 'accs' is not used.
    Import of 'accz' is not used.
    pydiwasp/dirspec.py:16
  • Import of 'IMLM' is not used.
    pydiwasp/dirspec.py:17
  • Import of 'EMEP' is not used.

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

@SBFRF
Copy link
Owner

SBFRF commented Feb 10, 2026

@copilot fix based on review comments

@SBFRF SBFRF marked this pull request as ready for review February 10, 2026 15:09
…ols-scm

Co-authored-by: SBFRF <8375832+SBFRF@users.noreply.github.com>
Copilot AI requested a review from SBFRF February 10, 2026 15:10
Copy link
Owner

@SBFRF SBFRF left a comment

Choose a reason for hiding this comment

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

Lgtm. @Thesser

@SBFRF SBFRF merged commit c91c36b into master Feb 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

organize repository

2 participants