Skip to content

Commit

Permalink
Use utils.iter_subclasses to discover complex types
Browse files Browse the repository at this point in the history
  • Loading branch information
eslavich committed Apr 16, 2023
1 parent ede2d03 commit e02d517
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion asdf/core/_converters/complex.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import re

import numpy as np

from asdf.extension import Converter
from asdf import util


_REPLACEMENTS = {
re.compile("i(?!nf)"): "j",
Expand All @@ -10,7 +14,8 @@

class ComplexConverter(Converter):
tags = ["tag:stsci.edu:asdf/core/complex-1.0.0"]
types = ["builtins.complex", "numpy.complex64", "numpy.complex128", "numpy.complex256"]

types = [*list(util.iter_subclasses(np.complexfloating)), complex]

def to_yaml_tree(self, obj, tag, ctx):
return str(obj)
Expand Down

0 comments on commit e02d517

Please sign in to comment.