Skip to content

Commit

Permalink
Merge pull request #94 from mole99/sub-fixes
Browse files Browse the repository at this point in the history
Substitution Improvement
  • Loading branch information
mole99 authored Aug 12, 2024
2 parents 5b34734 + e4af432 commit 051aeea
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 2.4.2

## Common

- Do not perform substitutions if the conditions is not defined.

# 2.4.1

## CLI
Expand Down
2 changes: 1 addition & 1 deletion cace/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
__version__ = '2.4.1'
__version__ = '2.4.2'

if __name__ == '__main__':
print(__version__, end='')
4 changes: 2 additions & 2 deletions cace/common/cace_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def generate_documentation(datasheet):
layout_path = os.path.join(layout_directory, layoutname)
# Search for compressed layout
if not os.path.exists(layout_path):
layoutname = projname + '.gds.gz'
layoutname = datasheet['name'] + '.gds.gz'
layout_path = os.path.join(layout_directory, layoutname)
else:
err('No "layout" specified in datasheet paths.')
Expand Down Expand Up @@ -244,7 +244,7 @@ def generate_documentation(datasheet):
layout_path = os.path.join(layout_directory, layoutname)
# Search for compressed layout
if not os.path.exists(layout_path):
layoutname = projname + '.gds.gz'
layoutname = datasheet['name'] + '.gds.gz'
layout_path = os.path.join(layout_directory, layoutname)
else:
err('Neither "magic" nor "layout" specified in datasheet paths.')
Expand Down
9 changes: 8 additions & 1 deletion cace/parameter/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,11 @@ def varex_sub(matchobj):

# Check whether the condition is in the set
if cond_name in conditions_set:

# Condition not defined
if conditions_set[cond_name] == None:
return matchobj.group(0)

# Simply replace with the full value
if not indices:
replace = str(conditions_set[cond_name])
Expand Down Expand Up @@ -718,7 +723,9 @@ def varex_sub(matchobj):
return replace
else:
err(f'Could not find {cond_name} in condition set.')
return ''

# Error, do not change the condition value
return matchobj.group(0)

def sweepex_sub(matchobj):
cond_name = matchobj.group(1)
Expand Down
2 changes: 1 addition & 1 deletion cace/parameter/parameter_ngspice.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def implementation(self):
# have a value
for cond in condition_set:
if condition_set[cond] == None:
err(f'Condition {cond} not defined')
warn(f'Condition {cond} not defined')

# Write conditions set
with open(
Expand Down

0 comments on commit 051aeea

Please sign in to comment.