Skip to content

Commit

Permalink
Improve plot output
Browse files Browse the repository at this point in the history
  • Loading branch information
mole99 committed Aug 15, 2024
1 parent d5b016c commit 198c590
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 23 deletions.
9 changes: 9 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 2.4.5

## Common

- Improve plots
- Sort minimum/typical/maximum labels
- Connect points with the same condition on the x-axis
- Print when netlists do not need regeneration

# 2.4.4

## Common
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.4'
__version__ = '2.4.5'

if __name__ == '__main__':
print(__version__, end='')
10 changes: 9 additions & 1 deletion cace/common/cace_regenerate.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,9 @@ def regenerate_rcx_netlist(datasheet, runtime_options):
):
return False

else:
info('Not extracting netlist with parasitics from layout. Up to date.')

return rcx_netlist


Expand Down Expand Up @@ -615,6 +618,9 @@ def regenerate_lvs_netlist(datasheet, runtime_options, pex=False):
):
return False

else:
info('Not extracting LVS netlist from layout. Up to date.')

return lvs_netlist


Expand Down Expand Up @@ -923,7 +929,7 @@ def regenerate_testbench(datasheet, runtime_options, testbenchpath, testbench):
)

if not need_testbench_netlist:
# Testbench exists and is up-to-date; nothing to do
# Testbench exists and is up-to-date; nothing to do
return 0

if not os.path.isfile(source_file):
Expand Down Expand Up @@ -1108,6 +1114,8 @@ def regenerate_gds(datasheet, runtime_options):

if mproc.returncode != 0:
err(f'Magic process returned error code {mproc.returncode}.')
else:
info('Not regenerating GDSII from magic layout. Up to date.')

if not os.path.isfile(gdspath):
err(f'Could not generate gds layout: {gdspath}')
Expand Down
102 changes: 81 additions & 21 deletions cace/parameter/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import os
import re
import sys
import copy
import traceback
import subprocess
from statistics import median, mean
Expand Down Expand Up @@ -176,10 +177,10 @@ def condition_gen(self):
else:
if 'minimum' in self.spec:
yield self.spec['minimum']
if 'maximum' in self.spec:
yield self.spec['maximum']
if 'typical' in self.spec:
yield self.spec['typical']
if 'maximum' in self.spec:
yield self.spec['maximum']


class Parameter(ABC, Thread):
Expand Down Expand Up @@ -1033,50 +1034,99 @@ def makeplot(
if len(condition_sets) > 1:
opacity = 0.5

# If a condition is used as x-axis, merge same entries TODO
# If the xvariable is a condition, remove it from the condition set
# since it is displayed on the xaxis anyways and merge the results

xvalues_list = []
yvalues_list = []
label_list = []

if xvariable in conditions:

condition = conditions[xvariable]
# print(condition)
new_condition_sets = []
new_results_for_plot = []
hashes = []

for value in condition.values:
# print(value)
pass
# We only want ticks at certain locations
try:
ax.set_xticks(
ticks=conditions[xvariable].values,
labels=conditions[xvariable].values,
)
except:
ax.set_xticks(
ticks=range(len(conditions[xvariable].values)),
labels=conditions[xvariable].values,
)

# Get the result
for condition_set, results in zip(
condition_sets, results_for_plot
):

# Get the result
for index, condition_set in enumerate(condition_sets):
# Create a deep copy of the condition set
condition_set = copy.deepcopy(condition_set)

# Get the results for this plot
collated_variable_values = results_for_plot[index]
# Remove the condition at the xaxis from the condition_set
condition_set.pop(xvariable)

# We also need to remove unique elements, or else no hash will match
condition_set.pop('N')
condition_set.pop('simpath')

cur_hash = hash(frozenset(condition_set.items()))

# Let' see if the condition set is not yet in the new condition sets
if not cur_hash in hashes:
new_condition_sets.append(condition_set)
new_results_for_plot.append(copy.deepcopy(results))
hashes.append(cur_hash)

# If it is already, we need to extend the results
else:
for index, this_hash in enumerate(hashes):
# Found the condition set
if cur_hash == this_hash:
# Append to results
for key in new_results_for_plot[index].keys():
new_results_for_plot[index][key].extend(
list(results[key])
)

condition_sets = new_condition_sets
results_for_plot = new_results_for_plot

# Generate the x and y values
for condition_set, results in zip(condition_sets, results_for_plot):

xvalues = None
if xvariable:
# Is the variable a simulation result?
if xvariable in collated_variable_values:
xvalues = collated_variable_values[xvariable]
if xvariable in results:
xvalues = results[xvariable]
# Else it may be a condition?
elif xvariable in condition_set:
xvalues = condition_set[xvariable]
elif xvariable in conditions:
xvalues = conditions[xvariable].values
else:
err(f'Unknown variable: {xvariable}')
return None

xvalues_list.append(xvalues)

yvalues = []
for yvariable in yvariables:
if yvariable:
# Is the variable a simulation result?
if yvariable in collated_variable_values:
yvalues.append(collated_variable_values[yvariable])
if yvariable in results:
yvalues.append(results[yvariable])
# Else it may be a condition?
elif yvariable in condition_set:
yvalues.append(condition_set[yvariable])
else:
err(f'Unknown variable: {yvariable}')
return None

marker = None
if not isinstance(xvalues, list) or len(xvalues) == 1:
marker = 'o'
yvalues_list.append(yvalues)

# Get the label for the legend
label = []
Expand All @@ -1089,6 +1139,16 @@ def makeplot(
)
label = ', '.join(label)

label_list.append(label)

for xvalues, yvalues, label in zip(
xvalues_list, yvalues_list, label_list
):

marker = None
if not isinstance(xvalues, list) or len(xvalues) == 1:
marker = 'o'

for yvalue in yvalues:
self.plot(
xvalues,
Expand Down

0 comments on commit 198c590

Please sign in to comment.