Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MRIBuilder.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michiel Cottaar
MRIBuilder.jl
Commits
762df45e
Verified
Commit
762df45e
authored
1 year ago
by
Michiel Cottaar
Browse files
Options
Downloads
Patches
Plain Diff
Fix printing of namedtuples
parent
f63ee18b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/printing.jl
+6
-9
6 additions, 9 deletions
src/printing.jl
with
6 additions
and
9 deletions
src/printing.jl
+
6
−
9
View file @
762df45e
...
@@ -6,13 +6,13 @@ import ..Variables: VariableType, variables, AbstractBlock, VariableNotAvailable
...
@@ -6,13 +6,13 @@ import ..Variables: VariableType, variables, AbstractBlock, VariableNotAvailable
function
_robust_value
(
possible_number
::
VariableType
)
function
_robust_value
(
possible_number
::
VariableType
)
try
try
return
value
(
possible_number
)
return
round
(
value
(
possible_number
)
,
sigdigits
=
3
)
catch
catch
return
nothing
return
nothing
end
end
end
end
function
_robust_value
(
possible_vector
::
Abstract
Vector
)
function
_robust_value
(
possible_vector
::
Abstract
Array
)
result
=
_robust_value
.
(
possible_vector
)
result
=
_robust_value
.
(
possible_vector
)
if
any
(
isnothing
.
(
result
))
if
any
(
isnothing
.
(
result
))
return
nothing
return
nothing
...
@@ -21,6 +21,7 @@ function _robust_value(possible_vector::AbstractVector)
...
@@ -21,6 +21,7 @@ function _robust_value(possible_vector::AbstractVector)
end
end
_robust_value
(
possible_tuple
::
Tuple
)
=
_robust_value
([
possible_tuple
...
])
_robust_value
(
possible_tuple
::
Tuple
)
=
_robust_value
([
possible_tuple
...
])
_robust_value
(
possible_tuple
::
NamedTuple
)
=
NamedTuple
(
k
=>
_robust_value
(
v
)
for
(
k
,
v
)
in
pairs
(
possible_tuple
))
function
Base.show
(
io
::
IO
,
block
::
AbstractBlock
)
function
Base.show
(
io
::
IO
,
block
::
AbstractBlock
)
...
@@ -36,7 +37,8 @@ function Base.show(io::IO, block::AbstractBlock)
...
@@ -36,7 +37,8 @@ function Base.show(io::IO, block::AbstractBlock)
end
end
if
(
if
(
ft
<:
Union
{
Nothing
,
AbstractBlock
}
||
ft
<:
Union
{
Nothing
,
AbstractBlock
}
||
(
ft
<:
AbstractVector
&&
eltype
(
ft
)
<:
AbstractBlock
)
(
ft
<:
AbstractVector
&&
eltype
(
ft
)
<:
AbstractBlock
)
||
(
ft
<:
AbstractVector
&&
eltype
(
ft
)
<:
Pair
)
)
)
continue
continue
end
end
...
@@ -53,12 +55,7 @@ function Base.show(io::IO, block::AbstractBlock)
...
@@ -53,12 +55,7 @@ function Base.show(io::IO, block::AbstractBlock)
if
isnothing
(
numeric_value
)
if
isnothing
(
numeric_value
)
continue
continue
end
end
if
numeric_value
isa
AbstractVector
print
(
io
,
"
$
(nameof(fn))=
$(numeric_value)
, "
)
printed_value
=
"["
*
join
(
map
(
v
->
@sprintf
(
"%.3g"
,
v
),
numeric_value
),
", "
)
*
"]"
else
printed_value
=
@sprintf
(
"%.3g"
,
numeric_value
)
end
print
(
io
,
"
$
(nameof(fn))=
$(printed_value)
, "
)
catch
e
catch
e
if
e
isa
VariableNotAvailable
if
e
isa
VariableNotAvailable
continue
continue
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment