Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils
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
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hyteg
pystencils
Commits
725c58ae
Commit
725c58ae
authored
4 months ago
by
Daniel Bauer
Browse files
Options
Downloads
Patches
Plain Diff
expose method to retrieve the original name of a duplicated symbol
parent
131fa9ca
No related branches found
No related tags found
No related merge requests found
Pipeline
#72021
passed
4 months ago
Stage: Code Quality
Stage: Unit Tests
Stage: legacy_test
Stage: docs
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pystencils/backend/kernelcreation/context.py
+11
-7
11 additions, 7 deletions
src/pystencils/backend/kernelcreation/context.py
with
11 additions
and
7 deletions
src/pystencils/backend/kernelcreation/context.py
+
11
−
7
View file @
725c58ae
...
@@ -126,7 +126,7 @@ class KernelCreationContext:
...
@@ -126,7 +126,7 @@ class KernelCreationContext:
symb
.
apply_dtype
(
dtype
)
symb
.
apply_dtype
(
dtype
)
return
symb
return
symb
def
get_new_symbol
(
self
,
name
:
str
,
dtype
:
PsType
|
None
=
None
)
->
PsSymbol
:
def
get_new_symbol
(
self
,
name
:
str
,
dtype
:
PsType
|
None
=
None
)
->
PsSymbol
:
"""
Always create a new symbol, deduplicating its name if another symbol with the same name already exists.
"""
"""
Always create a new symbol, deduplicating its name if another symbol with the same name already exists.
"""
...
@@ -173,15 +173,11 @@ class KernelCreationContext:
...
@@ -173,15 +173,11 @@ class KernelCreationContext:
)
->
PsSymbol
:
)
->
PsSymbol
:
"""
Canonically duplicates the given symbol.
"""
Canonically duplicates the given symbol.
A new symbol with the new name ``symb.name +
"
__<counter>
"
`` and optionally a different data type
A new symbol with the new name ``symb.name +
"
__<counter>
"
`` and optionally a different data type
is created, added to the symbol table, and returned.
is created, added to the symbol table, and returned.
The ``counter`` reflects the number of previously created duplicates of this symbol.
The ``counter`` reflects the number of previously created duplicates of this symbol.
"""
"""
if
(
result
:
=
self
.
_symbol_ctr_pattern
.
search
(
symb
.
name
))
is
not
None
:
basename
=
self
.
basename
(
symb
)
span
=
result
.
span
()
basename
=
symb
.
name
[:
span
[
0
]]
else
:
basename
=
symb
.
name
if
new_dtype
is
None
:
if
new_dtype
is
None
:
new_dtype
=
symb
.
dtype
new_dtype
=
symb
.
dtype
...
@@ -194,6 +190,14 @@ class KernelCreationContext:
...
@@ -194,6 +190,14 @@ class KernelCreationContext:
return
self
.
get_symbol
(
dup_name
,
new_dtype
)
return
self
.
get_symbol
(
dup_name
,
new_dtype
)
assert
False
,
"
unreachable code
"
assert
False
,
"
unreachable code
"
def
basename
(
self
,
symb
:
PsSymbol
)
->
str
:
"""
Returns the original name a symbol had before duplication.
"""
if
(
result
:
=
self
.
_symbol_ctr_pattern
.
search
(
symb
.
name
))
is
not
None
:
span
=
result
.
span
()
return
symb
.
name
[:
span
[
0
]]
else
:
return
symb
.
name
@property
@property
def
symbols
(
self
)
->
Iterable
[
PsSymbol
]:
def
symbols
(
self
)
->
Iterable
[
PsSymbol
]:
"""
Return an iterable of all symbols listed in the symbol table.
"""
"""
Return an iterable of all symbols listed in the symbol table.
"""
...
...
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