extend_gwpy

Preserve metadata and units when subclassing GWpy and Astropy classes.

1|Updated Dec 17, 2025
One-click install
npx skills add https://github.com/tatsuki-washimi/gwexpy --skill extend-gwpy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: extend_gwpy
Source: https://github.com/tatsuki-washimi/gwexpy/tree/main/.agent/skills/extend_gwpy
Command: npx skills add https://github.com/tatsuki-washimi/gwexpy --skill extend-gwpy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Subclassing GWpy/Astropy classes can inadvertently drop metadata and units during arithmetic operations. This Skill provides guidelines and patterns to ensure metadata and unit information is preserved when extending TimeSeries, FrequencySeries, and Spectrogram subclasses.

Core Features & Use Cases

  • Safe inheritance patterns for GWpy/Astropy classes (TimeSeries, FrequencySeries, Spectrogram)
  • Metadata and unit preservation across operations and NumPy ufuncs
  • Practical guidance with common pitfalls and robust implementation strategies

Quick Start

Subclass GWpy TimeSeries and implement metadata-preserving new and array_finalize patterns.

Frequently Asked Questions about extend_gwpy

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does my GWpy TimeSeries subclass lose metadata after arithmetic operations?

GWpy TimeSeries subclasses lose metadata because standard NumPy ufuncs often bypass custom initialization. Implementing metadata-preserving __new__ and __array_finalize__ patterns ensures domain metadata and units survive arithmetic operations.

How do I subclass GWpy FrequencySeries without dropping units?

To subclass GWpy FrequencySeries without dropping units, apply safe inheritance guidelines that override __new__ for metadata propagation and use __array_finalize__ to preserve unit information across operations.

What is the best way to preserve Astropy metadata in custom Spectrogram subclasses?

The best way to preserve Astropy metadata in custom Spectrogram subclasses is implementing safe inheritance patterns that explicitly propagate domain metadata through __new__ and ensure __array_finalize__ restores it after ufuncs.

Does GWpy support custom TimeSeries subclasses in batched processing collections?

GWpy supports custom TimeSeries subclasses in batched processing when __array_finalize__ is correctly implemented, ensuring consistent metadata propagation and unit preservation behavior across all items in collections.

When do I need to implement __array_finalize__ for GWpy extensions?

You need to implement __array_finalize__ for GWpy extensions whenever custom TimeSeries, FrequencySeries, or Spectrogram subclasses must maintain domain metadata and units across NumPy ufunc operations and arithmetic.

What are common pitfalls when subclassing GWpy Astropy classes?

Common pitfalls when subclassing GWpy Astropy classes include neglecting __new__ metadata propagation, omitting __array_finalize__ preservation, and inconsistent behavior during collections or batched processing that strips units and metadata.