Skip to content

Pull in refactor from old branch.#70

Merged
kbonney merged 4 commits intosandialabs:mainfrom
kbonney:cleanup
Feb 24, 2026
Merged

Pull in refactor from old branch.#70
kbonney merged 4 commits intosandialabs:mainfrom
kbonney:cleanup

Conversation

@kbonney
Copy link
Copy Markdown
Collaborator

@kbonney kbonney commented Feb 24, 2026

Summary

Cleans up core abstractions in src/pynumad/objects/, improves separation of concerns, eliminates dead code, and replaces parallel array structures with pandas.DataFrame.

Structural / design changes

  • Blade.ispan is now a @property delegating to definition.ispan, eliminating the need to keep two copies in sync
  • BillOfMaterials and MaterialDatabase no longer inherit from dict; both are plain classes with typed attributes
  • BladeSettings collapsed into Blade (mesh_size: float = 0.45); settings.py deleted
  • Stack / Ply moved to a new objects/stack.py module; Layer moved from materialdb.py to material.py
  • KEY_LABELS extracted as a module-level constant in keypoints.py and imported by component.py
  • ispan consolidated to Definition: Removed self.ispan from Geometry entirely. Geometry.generate() now uses a local variable, update_oml_geometry() receives span location as an explicit transZ parameter, and all external callers (KeyPoints, BillOfMaterials, analysis modules) read directly from blade.definition.ispan.

Data model changes

  • Definition parallel ndarray attributes (chord, degreestwist, leband, sparcapwidth_hp, etc.) replaced by two pd.DataFrame objects — span_data (indexed by span location) and ispan_data (indexed by ispan location); original attribute names remain as properties for backward compatibility
  • BillOfMaterials hp/lp/sw changed from lists of BillOfMaterialsEntry objects to pd.DataFrame; the separate indices dict is removed and its contents are now columns within the same DataFrames; sw consolidates from a list-of-lists to a single DataFrame with a web_id column
  • MaterialDatabaseEntry converted to a @dataclass

Code quality

  • Material, BillOfMaterialsEntry (now removed), Ply, Layer, and Station converted to @dataclass
  • rotate2d moved to utils/affinetrans.py; airfoil utility functions made private (_ prefix); dead _adjust_te deleted
  • Component._compare() and redundant _compare() on Layer removed in favor of __eq__
  • Dead code removed: ShearWeb class, MATLAB-remnant comment blocks, unreachable swRegion branch, commented-out Station property stubs
  • KeyPoints.generate() no longer mutates definition.leband/definition.teband
  • Geometry config flags (_natural_offset, _rotorspin, _swtwisted) initialized to None in __init__ rather than hardcoded defaults
  • BillOfMaterials.generate() explicit inputs: Signature changed from generate(definition, keypoints) to generate(ispan, components, materials, keypoints), naming its actual dependencies rather than accepting the entire Definition object.

Bug fixes

  • Blade.__init__ file-reading block was misplaced inside ispan.setter; moved back to __init__
  • keypoints.py web_areas scalar assignment failed when np.dot returned a 1-element array instead of a scalar; fixed with np.squeeze + float()
  • Definition.span / ispan setters now always recreate the DataFrame on assignment, fixing a pandas length-mismatch error triggered by the Excel reader's double-assignment pattern

Tests and documentation

Tests still pass after the refactor!

Acknowledgement

By contributing to this software project, I acknowledge that I have reviewed the software quality assurance guidelines and that my contributions are submitted under the Revised BSD License.

@kbonney kbonney merged commit 1676ddc into sandialabs:main Feb 24, 2026
6 of 9 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.

1 participant