install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/add-type" ~/.claude/skills/majiayu000-claude-skill-registry-add-type && rm -rf "$T"
manifest:
skills/data/add-type/SKILL.mdsource content
Implement GWExPy Type
This skill guides the implementation of new array/field types in
gwexpy, ensuring consistency with the existing class hierarchy, metadata management, and documentation standards.
Workflow
1. Survey & Plan
- Identify Base Class: Inherit from
,gwexpy.types.Array
, or similar.Array2D - Metadata: Determine new metadata slots needed (e.g.,
,_axis0_name
)._unit - Behavior: Define slicing behavior (does it drop dimensions or maintain them?), arithmetic rules, and domain logic (FFT, etc.).
2. Implementation: Core Class
- File: Create
.gwexpy/types/yourtype.py - Class Definition:
class YourType(BaseArray): _metadata_slots = BaseArray._metadata_slots + ("_new_slot",)
:__new__- Validate input structure (ndim, etc.).
- Initialize metadata slots (handling defaults).
- Call
.super().__new__
:__array_finalize__- Handle 3 creation scenarios:
is None (explicit new),obj
is subclass (view casting),obj
is different type (copy/slice).obj - Copy metadata from
toobj
.self
- Handle 3 creation scenarios:
- Metadata-Preserving Indexing:
等の多次元クラスでは、インデックス操作 (Field4D
) 時に次元を落とさないことが推奨されます。整数インデックス__getitem__
をi
に変換して処理することで、軸の数とメタデータ(軸名称や単位)を一貫して維持できます。詳細はslice(i, i+1)
スキルを参照してください。manage_field_metadata - Transpose/Swapaxes:
- Override to update axis-dependent metadata if applicable.
3. Implementation: Collections
- File:
(or inside the same file if small).gwexpy/types/yourtype_collections.py - List Class: Inherit
. Add batch methods (e.g.,list
).process_all - Dict Class: Inherit
. Add batch methods.dict
4. Integration
- Export: Add the new classes to
.gwexpy/types/__init__.py - Docs:
- Create
anddocs/reference/en/YourType.md
.docs/reference/ja/YourType.md - Add to
.docs/reference/{en,ja}/index.rst
- Create
5. Testing
- Location:
.tests/types/test_yourtype.py - Coverage:
- Construction (from array, from list, with units).
- Metadata persistence.
- Slicing behavior (key feature).
- Arithmetic operations.
- Collection behavior.
Key Considerations
- Quantity Compatibility: gwexpy types are often subclasses of
. Ensureastropy.units.Quantity
handling works.unit - Axis Management: If managing axes, use
or look atAxisApiMixin
/Array3D
for how to sync separate axis properties with the array shape.Array4D - Documentation: Always provide both English and Japanese API references.