|
453 | 453 | tree_ro_ter = Node{Float64,3}(; op=1, children=(x1_ro, x2_ro, x3_ro)) |
454 | 454 |
|
455 | 455 | expr_ro = Expression(tree_ro_ter; operators=operators_ro) |
456 | | - readonly_tree = DynamicExpressions.get_tree(expr_ro) |
| 456 | + readonly_tree = DynamicExpressions.ReadOnlyNode(DynamicExpressions.get_tree(expr_ro)) |
457 | 457 |
|
458 | 458 | @test readonly_tree isa DynamicExpressions.ReadOnlyNodeModule.AbstractReadOnlyNode |
459 | 459 | inner_node_ro = DynamicExpressions.ReadOnlyNodeModule.inner(readonly_tree) |
|
472 | 472 | @test readonly_tree.r.feature == 2 |
473 | 473 | end |
474 | 474 |
|
475 | | -@testitem "Expression.jl default_node_type for N-ary" tags = [:narity] begin |
476 | | - using DynamicExpressions |
477 | | - using Test |
478 | | - |
479 | | - DefaultNodeForExprT = DynamicExpressions.ExpressionModule.default_node_type( |
480 | | - Expression{Float64} |
481 | | - ) |
482 | | - @test DefaultNodeForExprT == Node{Float64,2} |
483 | | - |
484 | | - dt_expr_node3 = DynamicExpressions.ExpressionModule.default_node_type( |
485 | | - Expression{Float64,Node{Float64,3}} |
486 | | - ) |
487 | | - @test dt_expr_node3 == Node{Float64,3} |
488 | | - |
489 | | - abstract type AbstractMyCustomExpr{T,N<:AbstractExpressionNode{T}} <: |
490 | | - AbstractExpression{T,N} end |
491 | | - struct MyCustomExprWithArity{T,N_NODE<:AbstractExpressionNode{T,NODE_D},EXPR_ARITY} <: |
492 | | - AbstractMyCustomExpr{T,N_NODE} where {NODE_D} |
493 | | - tree::N_NODE |
494 | | - end |
495 | | - DynamicExpressions.ExpressionModule.has_node_type(::Type{<:MyCustomExprWithArity}) = |
496 | | - true |
497 | | - DynamicExpressions.ExpressionModule.node_type( |
498 | | - ::Type{<:MyCustomExprWithArity{T,N_NODE,EXPR_ARITY}} |
499 | | - ) where {T,N_NODE,EXPR_ARITY} = N_NODE |
500 | | - DynamicExpressions.NodeModule.max_degree( |
501 | | - ::Type{<:MyCustomExprWithArity{T,N_NODE,EXPR_ARITY}} |
502 | | - ) where {T,N_NODE,EXPR_ARITY} = EXPR_ARITY |
503 | | - |
504 | | - dt_custom_overall_arity = DynamicExpressions.ExpressionModule.default_node_type( |
505 | | - MyCustomExprWithArity{Float32,Node{Float32,2},4} |
506 | | - ) |
507 | | - @test dt_custom_overall_arity == Node{Float32,4} |
508 | | - |
509 | | - struct MySimpleExprNoNodeParam{T} <: AbstractExpression{T,Nothing} end |
510 | | - DynamicExpressions.ExpressionModule.has_node_type(::Type{<:MySimpleExprNoNodeParam}) = |
511 | | - false |
512 | | - dt_my_simple_expr = DynamicExpressions.ExpressionModule.default_node_type( |
513 | | - MySimpleExprNoNodeParam{Float64} |
514 | | - ) |
515 | | - @test dt_my_simple_expr == Node{Float64,2} |
516 | | -end |
517 | | - |
518 | 475 | @testitem "NodeUtils.jl NodeIndex for N-ary" tags = [:narity] begin |
519 | 476 | using DynamicExpressions |
520 | 477 | using Test |
|
534 | 491 |
|
535 | 492 | @test idx_tree isa NodeIndex{UInt16,3} |
536 | 493 | @test DynamicExpressions.NodeModule.max_degree(typeof(idx_tree)) == 3 |
| 494 | + @test tree_idx.degree == 3 |
537 | 495 | @test idx_tree.degree == 3 |
538 | 496 | @test idx_tree.children[1].degree == 0 && idx_tree.children[1].val == UInt16(1) |
539 | 497 | @test idx_tree.children[2].degree == 0 && idx_tree.children[2].val == UInt16(0) |
|
0 commit comments