19b4b0bea9c63cadf71f387ea410f3548bff8e97,brian2/equations/equations.py,Equations,check_units,#Equations#,498
Before Change
for var in self._diff_equation_names:
dim_RHS = self._get_units_for_RHS(var)
dim_LHS = get_dimensions(self._units[var] / second)
if not dim_LHS is dim_RHS:
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,
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: 8
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: Scitator/catalyst
Commit Name: 1a73a1367fedfa8368b6c42103e60e1b370bc14a
Time: 2019-04-19
Author: scitator@gmail.com
File Name: catalyst/contrib/criterion/focal_loss.py
Class Name: FocalLoss
Method Name: forward
Project Name: pyannote/pyannote-audio
Commit Name: dc357b0e9d2bc40633f738997e8b7d17221c28fd
Time: 2018-06-29
Author: bredin@limsi.fr
File Name: pyannote/audio/util.py
Class Name:
Method Name: from_numpy