@@ -29,7 +29,7 @@ function DefaultSpec(c::AbstractChar, syms...; kwargs...)
2929 end
3030end
3131
32- const DEFAULT_FORMATTERS = Dict {DataType , DefaultSpec} ()
32+ const DEFAULT_FORMATTERS = Dict {Type{T} where T , DefaultSpec} ()
3333
3434# adds a new default formatter for this type
3535default_spec! (:: Type{T} , c:: AbstractChar ) where {T} =
@@ -79,6 +79,9 @@ default_spec(::Type{<:AbstractString}) = DEFAULT_FORMATTERS[AbstractString]
7979default_spec (:: Type{<:AbstractChar} ) = DEFAULT_FORMATTERS[AbstractChar]
8080default_spec (:: Type{<:AbstractIrrational} ) = DEFAULT_FORMATTERS[AbstractIrrational]
8181default_spec (:: Type{<:Number} ) = DEFAULT_FORMATTERS[Number]
82+ default_spec (:: Complex{T} where T<: Integer ) = DEFAULT_FORMATTERS[Complex{T} where T<: Integer ]
83+ default_spec (:: Complex{T} where T<: AbstractFloat ) = DEFAULT_FORMATTERS[Complex{T} where T<: AbstractFloat ]
84+ default_spec (:: Complex{T} where T<: Rational ) = DEFAULT_FORMATTERS[Complex{T} where T<: Rational ]
8285
8386default_spec (:: Type{T} ) where {T} =
8487 get (DEFAULT_FORMATTERS, T) do
@@ -189,7 +192,7 @@ function fmt end
189192# TODO : do more caching to optimize repeated calls
190193
191194# creates a new FormatSpec by overriding the defaults and passes it to pyfmt
192- # note: adding kwargs is only appropriate for one-off formatting.
195+ # note: adding kwargs is only appropriate for one-off formatting.
193196# normally it will be much faster to change the fmt_default formatting as needed
194197function fmt (x; kwargs... )
195198 fspec = fmt_default (x)
220223for (t, c) in [(Integer,' d' ),
221224 (AbstractFloat,' f' ),
222225 (AbstractChar,' c' ),
223- (AbstractString,' s' )]
226+ (AbstractString,' s' ),
227+ (Complex{T} where T<: Integer , ' d' ),
228+ (Complex{T} where T<: AbstractFloat , ' f' )]
224229 default_spec! (t, c)
225230end
226231
227232default_spec! (Number, ' s' , :right )
228233default_spec! (AbstractIrrational, ' s' , :right )
234+ default_spec! (Complex{T} where T<: Rational , ' s' , :right )
0 commit comments