Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user-defined printing #40

Merged
merged 12 commits into from
Jun 19, 2023
Merged

Allow user-defined printing #40

merged 12 commits into from
Jun 19, 2023

Conversation

MilesCranmer
Copy link
Member

@MilesCranmer MilesCranmer commented Jun 19, 2023

This creates keyword arguments for string_tree (and print_tree) which can take a custom function for printing variables and constants in a tree. e.g.,

    operators = OperatorEnum(;
        binary_operators=(+, *, /, -), unary_operators=(cos, sin)
    )
    x1, x2, x3 = [Node(Float64; feature=i) for i in 1:3]
    tree = x1 * x1 + π
    f_constant(val::Float64, args...) = string(round(val; digits=4))
    @test string_tree(tree, operators; f_constant=f_constant) == "((x1 * x1) + 3.1416)"

@coveralls
Copy link

coveralls commented Jun 19, 2023

Pull Request Test Coverage Report for Build 5306782871

  • 28 of 33 (84.85%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.01%) to 92.421%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/Equation.jl 25 27 92.59%
src/Utils.jl 3 6 50.0%
Totals Coverage Status
Change from base Build 5095018727: -0.01%
Covered Lines: 878
Relevant Lines: 950

💛 - Coveralls

@github-actions
Copy link
Contributor

github-actions bot commented Jun 19, 2023

Benchmark Results

master e5494ea... t[master]/t[e5494ea...]
eval/ComplexF32/evaluation 13.5 ± 0.88 ms 13.4 ± 0.98 ms 1.01
eval/ComplexF64/evaluation 16.8 ± 1.2 ms 16.8 ± 1.6 ms 1
eval/Float32/derivative 25 ± 3.8 ms 25.3 ± 3.2 ms 0.989
eval/Float32/derivative_turbo 25.4 ± 3.8 ms 25.2 ± 3.1 ms 1.01
eval/Float32/evaluation 4.68 ± 0.4 ms 4.51 ± 0.41 ms 1.04
eval/Float32/evaluation_turbo 1.48 ± 0.15 ms 1.42 ± 0.14 ms 1.04
eval/Float64/derivative 0.0346 ± 0.0014 s 0.0336 ± 0.0012 s 1.03
eval/Float64/derivative_turbo 0.0383 ± 0.0016 s 0.0368 ± 0.0014 s 1.04
eval/Float64/evaluation 5.04 ± 0.45 ms 4.98 ± 0.44 ms 1.01
eval/Float64/evaluation_turbo 2.71 ± 0.22 ms 2.67 ± 0.2 ms 1.02
time_to_load 2.3 ± 0.014 s 2.26 ± 0.033 s 1.01
utils/combine_operators 0.0691 ± 0.015 ms 0.067 ± 0.013 ms 1.03
utils/convert/break_sharing 0.0644 ± 0.017 ms 0.0656 ± 0.02 ms 0.982
utils/convert/preserve_sharing 0.27 ± 0.053 ms 0.269 ± 0.061 ms 1
utils/copy/break_sharing 0.0631 ± 0.015 ms 0.0638 ± 0.014 ms 0.989
utils/copy/preserve_sharing 0.279 ± 0.044 ms 0.277 ± 0.041 ms 1.01
utils/count_constants 30.2 ± 4.1 μs 0.0326 ± 0.0042 ms 0.926
utils/count_depth 0.0331 ± 0.0053 ms 0.0319 ± 0.0051 ms 1.04
utils/count_nodes 28.8 ± 5.3 μs 30.7 ± 4.7 μs 0.938
utils/get_set_constants! 0.109 ± 0.02 ms 0.114 ± 0.019 ms 0.957
utils/has_constants 9.82 ± 2 μs 9.96 ± 1.7 μs 0.986
utils/has_operators 3.07 ± 0.37 μs 2.8 ± 0.4 μs 1.1
utils/index_constants 0.0905 ± 0.019 ms 0.096 ± 0.017 ms 0.943
utils/is_constant 9.52 ± 2.1 μs 14.8 ± 2.5 μs 0.642
utils/simplify_tree 0.206 ± 0.041 ms 0.205 ± 0.039 ms 1
utils/string_tree 1.39 ± 0.17 ms 0.432 ± 0.072 ms 3.21

Benchmark Plots

A plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR.
Go to "Actions"->"Benchmark a pull request"->[the most recent run]->"Artifacts" (at the bottom).

@MilesCranmer
Copy link
Member Author

Fixes #38

@MilesCranmer MilesCranmer merged commit 132e97a into master Jun 19, 2023
8 checks passed
@MilesCranmer MilesCranmer deleted the custom-printing branch June 19, 2023 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants