Git Product home page Git Product logo

about.jl's People

Contributors

tecosaur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

about.jl's Issues

`about(Memory{Int})` fails

julia> about(Memory{Int})
Concrete (padded) DataTypeERROR: Type GenericMemory does not have a definite size.
[...]

julia> about(Memory{Int}(undef, 0))
0-element Memory{Int64} (mutable), 0B referencing 16B (<: DenseVector{Int64} <: AbstractVector{Int64} <: Any)
ERROR: Type GenericMemory does not have a definite size.
[...]

`about` errors on structs with fields that have no size

Currently, calling about(somestruct) is broken for fields that are functions:

julia> struct Foo
           a::Int
           b::Matrix{Float32}
           c::typeof(identity)
       end

julia> f = Foo(1, rand(3, 4), identity)
Foo(1, Float32[0.8633268 0.40085334 0.27201754 0.60436267; 0.34008977 0.2632495 0.82902575 0.6264377; 0.32734197 0.008732563 0.8294697 0.10690562], identity)

julia> about(f)
Foo, 16B referencing 128B (<: Any)
 a::Int64            8B 000000000000000000000000  00000000000000000000001 1
 b::Matrix{Float32}  8B Ptr{Float32} @0x000000010cbac5c0                   Float32[0.8  7 0.106906]
 c::typeof(identity) 0B Ptr?                                               identity

ERROR: InexactError: Int64(NaN)
Stacktrace:
 [1] Int64
   @ ./float.jl:981 [inlined]
 [2] convert
   @ ./number.jl:7 [inlined]
 [3] round
   @ ./rounding.jl:469 [inlined]
 [4] round
   @ ./rounding.jl:467 [inlined]
 [5] memorylayout(io::Base.TTY, type::DataType)
   @ About ~/.julia/packages/About/9q1TE/src/types.jl:102
 [6] memorylayout(io::Base.TTY, value::Foo)
   @ About ~/.julia/packages/About/9q1TE/src/values.jl:72
 [7] about(io::Base.TTY, value::Foo)
   @ About ~/.julia/packages/About/9q1TE/src/values.jl:18
 [8] about(x::Foo)
   @ About ~/.julia/packages/About/9q1TE/src/About.jl:24
 [9] top-level scope
   @ REPL[12]:1

It seems that the issue is that functions have a "size" of zero.

julia> About.structinfo(typeof(f))
3-element Vector{About.FieldInfo}:
 About.FieldInfo(1, :bright_green, 0, 8, 8, false, :a, Int64)
 About.FieldInfo(2, :bright_yellow, 8, 8, 0, true, :b, Matrix{Float32})
 About.FieldInfo(3, :bright_magenta, 16, 0, 0, true, :c, typeof(identity))

bug when used on `Return` ?

The following gives an error with About v0.1.0 on Julia 1.11.0-beta1

julia> Returns(3) |> about
ERROR: "Returns{Int64}(3)" is not defined in module Base
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] which
   @ ./reflection.jl:2237 [inlined]
 [3] about(io::Base.TTY, fn::Function)
   @ About ~/.julia/packages/About/wwaGm/src/functions.jl:2
 [4] about(x::Function)
   @ About ~/.julia/packages/About/wwaGm/src/About.jl:28
 [5] |>(x::Function, f::typeof(about))
   @ Base ./operators.jl:926
 [6] top-level scope
   @ REPL[8]:1

Fails on UnionAlls


julia> about(Vector)
UnionAllERROR: type UnionAll has no field name
Stacktrace:
 [1] getproperty
   @ ./Base.jl:43 [inlined]
 [2] about(io::Base.TTY, type::Type)
   @ About ~/.julia/packages/About/XPN7V/src/types.jl:48
 [3] about(x::Type)
   @ About ~/.julia/packages/About/XPN7V/src/About.jl:24
 [4] top-level scope
   @ REPL[12]:1

I had been hoping it would tell me what type parameters it had and what restrictions are on them.
We have code that does something like that in
https://github.com/invenia/ExprTools.jl/blob/bcc7765a177f39363dfcc9d9310c97ca26530a78/src/method.jl#L163-L174

Extraneous `end` in values.jl

Lines 454 and 455 of values.jl in src holds what seems to be two extraneous end keywords.
This causes About.jl to fail during precompilation on julia 1.12
Removing these fixes the problem.

Doesn't fully work on 1.10

Julia 1.10

julia> about(1)
Int64 (<: Signed <: Integer <: Real <: Number <: Any), occupies 8B.

 0000000000000000000000000000000000000000000000000000000000000001
 = +1

julia> about(2)
Int64 (<: Signed <: Integer <: Real <: Number <: Any), occupies 8B.
ERROR: MethodError: no method matching face!(::SubString{String}, ::Symbol)

Closest candidates are:
  face!(::Union{StyledStrings.AnnotatedStrings.AnnotatedString, SubString{<:StyledStrings.AnnotatedStrings.AnnotatedString}}, ::Union{Symbol, StyledStrings.Face, Vector{<:Union{Symbol, StyledStrings.Face}}})
   @ StyledStrings ~/.julia/packages/StyledStrings/4f63t/src/faces.jl:607

Stacktrace:
 [1] memorylayout(io::Base.TTY, value::Int64)
   @ About ~/.julia/packages/About/Y5VLD/src/values.jl:231
 [2] about(io::Base.TTY, value::Int64)
   @ About ~/.julia/packages/About/Y5VLD/src/values.jl:43
 [3] about(x::Int64)
   @ About ~/.julia/packages/About/Y5VLD/src/About.jl:76
 [4] top-level scope
   @ REPL[15]:1

`about(-1)` displays double negative

julia> about(-1)
Int64, 8B (<: Signed <: Integer <: Real <: Number <: Any)

 1111111111111111111111111111111111111111111111111111111111111111
 = --1

More informative string output

Currently, about seems to be defined for strings, but isn't able to compute the memory layout.

julia> str = "Hello, I am writing some text."
"Hello, I am wrinting some text."

julia> about(str)
51-codeunit String (mutable), 51B referencing 59B (<: AbstractString <: Any)
ERROR: ArgumentError: reducing over an empty collection is not allowed; consider supplying `init` to the reducer
Stacktrace:
  [1] _empty_reduce_error()
    @ Base ./reduce.jl:319
  [2] mapreduce_empty(f::Function, op::Function, T::Type)
    @ Base ./reduce.jl:321
[...]
 [10] maximum
    @ ./reducedim.jl:981 [inlined]
 [11] memorylayout(io::Base.TTY, value::String)
    @ About ~/.julia/packages/About/XPN7V/src/values.jl:60
 [12] about(io::Base.TTY, value::String)
    @ About ~/.julia/packages/About/XPN7V/src/values.jl:18
 [13] about(x::String)
    @ About ~/.julia/packages/About/XPN7V/src/About.jl:24
 [14] top-level scope
    @ REPL[13]:1

On About v0.1.0, julia 1.11.

Method effects description confusing when double negatives are used

Great job on this package!

If I can make a suggestion, here's a screenshot you shared on Slack:

image

When consistent has a X next to it, I can mentally parse it as not consistent

  • consistent - might not return or terminate consistently
  • terminates - guaranteed to always terminate

Should it should be the same for no undefined behaviour? When there's a X next to no undefined behaviour, I'm reading this as no no undefined behaviour.

  • no undefined behaviour - may execute undefined behaviour

Is there alternative naming that would help? Maybe safe instead of no undefined? It would read like so:

  • safe behaviour - may execute undefined behaviour

I believe you are choosing the property name to always remain the same across different invocations of this function, and checkbox and the description change based on the value of the property. Is there a way to make that more obvious? Perhaps the checkbox and description should be closer to each other? The checkbox in the middle of the property and the description? Color the description the same as the checkbox but leave the property names gray in color? fwiw, red and green are not so great for people with red green color blindness.

I like that you've chosen formatting and colors that are copy paste friendly, and would like to preserve that feature. I'm just wondering about more effective ways to communicate the same information.

Include a `dump`/`tree`?

Awesome package!! For SpeedyWeather.jl I recently implemented the tree function, which is similar to dump, but stays within a specified module by checking parentmodule. Otherwise you ending with base/stdlib Julia types that aren't necessarily of interest if you want to understand what a struct defined in a given package contains. I also found it super useful to print the size of objects with Base.summarysize, e.g. here.

Maybe it's helpful for this package or if this package starts to implement this functionality I'd be happy to piggy back on it.

(originally implemented here SpeedyWeather/SpeedyWeather.jl#492 and here SpeedyWeather/SpeedyWeather.jl#495)

`about` for `ComposedFunction`s

I wonder if here about should treat cos ∘ sin as a function or as a struct or as some combination thereof 😅

julia> about(cos  sin)
ERROR: "cos ∘ sin" is not defined in module Base
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] which
   @ ./reflection.jl:2246 [inlined]
 [3] about(io::Base.TTY, fn::Function)
   @ About ~/About.jl/src/functions.jl:2
 [4] about(x::Function)
   @ About ~/About.jl/src/About.jl:24
 [5] top-level scope
   @ REPL[27]:1

nothrow is reported backwards.

julia> x = Base.infer_effects(round, Tuple{Type{Float64}, Int})
(+c,+e,+n,+t,+s,+m,+u)

julia> x.nothrow
true

julia> about(x)
Method effects:
 ✔ consistent     guaranteed to return or terminate consistently
 ✔ effect free    guaranteed to be free from externally semantically visible side effects
 ✔ no throw       may throw an exception # Nope! It's "will not throw an exception".
 ✔ terminates     might not always terminate
 ✔ no task state  may access task state (preventing migration between tasks)
 ✔ inaccessible memory only  guaranteed to never access or modify externally accessible mutable memory
 ✔ no undefined behaviour  guaranteed to never execute undefined behaviour
 ✔ non-overlayed  never calls any methods from an overlayed method table

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.