19b4b0bea9c63cadf71f387ea410f3548bff8e97,brian2/equations/equations.py,Equations,check_units,#Equations#,498
Before Change
raise DimensionMismatchError(("Differential equation defining "
"%s is not homogeneous") % var,
dim_LHS, dim_RHS)
for var in self._static_equation_names:
dim_RHS = self._get_units_for_RHS(var)
dim_LHS = get_dimensions(self._units[var])
if not dim_LHS is dim_RHS:
raise DimensionMismatchError(("Static equation defining "
"%s is not homogeneous") % var,
dim_LHS, dim_RHS)
//
// Representation
//
def __str__(self):
s = ""
for var in self._diff_equation_names:
s += ("d" + var + "/dt = " + self._string_expressions[var] + ": " +
After Change
//TODO: Check for dependencies and reorder static equations
def check_units(self):
for var, eq in self._equations.iteritems():
if eq.eq_type == "parameter":
// no need to check units for parameters
continue
if eq.eq_type == "diff_equation":
try:
eq.expr.check_unit_against(self._units[var] / second,
self._units)
except DimensionMismatchError as dme:
raise DimensionMismatchError(("Differential equation defining "
"%s does not use consistent units: %s") %
(var, dme.desc), *dme._dims)
elif eq.eq_type == "static_equation":
try:
eq.expr.check_unit_against(self._units[var],
self._units)
except DimensionMismatchError as dme:
raise DimensionMismatchError(("Static equation defining "
"%s does not use consistent units: %s") %
(var, dme.desc), *dme._dims)
else:
raise AssertionError("Unknown equation type: "%s"" % eq.eq_type)
//
// Representation
//
def __str__(self):
strings = [str(eq) for eq in self._equations.itervalues()]
return "\n".join(strings)
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 11
Instances
Project Name: brian-team/brian2
Commit Name: 19b4b0bea9c63cadf71f387ea410f3548bff8e97
Time: 2012-09-06
Author: marcel.stimberg@ens.fr
File Name: brian2/equations/equations.py
Class Name: Equations
Method Name: check_units
Project Name: nilmtk/nilmtk
Commit Name: 7f007ac656dc5d24606f06544d11dc50748324ef
Time: 2014-05-01
Author: jack-list@xlk.org.uk
File Name: nilmtk/pipeline/energynode.py
Class Name: EnergyNode
Method Name: process
Project Name: brian-team/brian2
Commit Name: 19b4b0bea9c63cadf71f387ea410f3548bff8e97
Time: 2012-09-06
Author: marcel.stimberg@ens.fr
File Name: brian2/equations/equations.py
Class Name: Equations
Method Name: check_units
Project Name: Pinafore/qb
Commit Name: b34a1085165933fcffc6d863c2f7274b87bd2b09
Time: 2017-06-01
Author: jordanbg@gmail.com
File Name: qanta/reranker/svm.py
Class Name: Reranker
Method Name: create_train