input stringlengths 11 7.65k | target stringlengths 22 8.26k |
|---|---|
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def memoized(*args):
try:
return stored_results[args]
except KeyError:
result = stored_results[args] = fn(*args)
return result |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_basic(self):
table2, table1 = self.tables.table2, self.tables.table1
Session = scoped_session(sa.orm.sessionmaker(testing.db))
class CustomQuery(query.Query):
pass
class SomeObject(fixtures.ComparableEntity):
query = Session.query_property()
c... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def get_folder_size(folder):
total_size = os.path.getsize(folder)
for item in os.listdir(folder):
itempath = os.path.join(folder, item)
if os.path.isfile(itempath):
total_size += os.path.getsize(itempath)
elif os.path.isdir(itempath):
total_size += get_folder_size... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_config_errors(self):
Session = scoped_session(sa.orm.sessionmaker())
s = Session() # noqa
assert_raises_message(
sa.exc.InvalidRequestError,
"Scoped session is already present",
Session,
bind=testing.db,
)
assert_warns_m... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def usage_iter(root):
root = os.path.abspath(root)
root_size = get_folder_size(root)
root_string = "{0}\n{1}".format(root, root_size)
yield [root_string, None, root_size] |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_call_with_kwargs(self):
mock_scope_func = Mock()
SessionMaker = sa.orm.sessionmaker()
Session = scoped_session(sa.orm.sessionmaker(), mock_scope_func)
s0 = SessionMaker()
assert s0.autoflush == True
mock_scope_func.return_value = 0
s1 = Session()
... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def json_usage(root):
root = os.path.abspath(root)
result = [['Path', 'Parent', 'Usage']]
result.extend(entry for entry in usage_iter(root))
return json.dumps(result) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_methods_etc(self):
mock_session = Mock()
mock_session.bind = "the bind"
sess = scoped_session(lambda: mock_session)
sess.add("add")
sess.delete("delete")
sess.get("Cls", 5)
eq_(sess.bind, "the bind")
eq_(
mock_session.mock_calls,
... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def main(args):
'''Populates an html template using JSON-formatted output from the
Linux 'du' utility and prints the result'''
html = ''' |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def get_bind(self, mapper=None, **kwargs):
return super().get_bind(mapper=mapper, **kwargs) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def get_bind(self, mapper=None, *args, **kwargs):
return super().get_bind(mapper, *args, **kwargs) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def get_bind(self, mapper=None, *args, **kwargs):
return super(MySession, self).get_bind(
mapper, *args, **kwargs
) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def get_bind(self, mapper=None, **kwargs):
return super(MySession, self).get_bind(
mapper=mapper, **kwargs
) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_reverse_rfc822_datetime():
dates = [
("Sat, 01 Jan 2011 00:00:00 -0000", datetime(2011, 1, 1, tzinfo=pytz.utc)),
("Sat, 01 Jan 2011 23:59:59 -0000", datetime(2011, 1, 1, 23, 59, 59, tzinfo=pytz.utc)),
("Sat, 01 Jan 2011 21:59:59 -0200", datetime(2011, 1, 1, 23, 59, 59, tzinfo=pytz.u... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_reverse_iso8601_datetime():
dates = [
("2011-01-01T00:00:00+00:00", datetime(2011, 1, 1, tzinfo=pytz.utc)),
("2011-01-01T23:59:59+00:00", datetime(2011, 1, 1, 23, 59, 59, tzinfo=pytz.utc)),
("2011-01-01T23:59:59.001000+00:00", datetime(2011, 1, 1, 23, 59, 59, 1000, tzinfo=pytz.utc))... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_urls():
urls = [
'http://www.djangoproject.com/',
'http://localhost/',
'http://example.com/',
'http://www.example.com/',
'http://www.example.com:8000/test',
'http://valid-with-hyphens.com/',
'http://subdomain.example.com/',
'http://200.8.9.10/... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def check_bad_url_raises(value):
try:
inputs.url(value)
assert False, "shouldn't get here"
except ValueError as e:
assert_equal(six.text_type(e), u"{0} is not a valid URL".format(value)) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_bad_urls():
values = [
'foo',
'http://',
'http://example',
'http://example.',
'http://.com',
'http://invalid-.com',
'http://-invalid.com',
'http://inv-.alid-.com',
'http://inv-.-alid.com',
'foo bar baz',
u'foo \u2713',
... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_bad_url_error_message():
values = [
'google.com',
'domain.google.com',
'kevin:pass@google.com/path?query',
u'google.com/path?\u2713',
]
for value in values:
yield check_url_error_message, value |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def check_url_error_message(value):
try:
inputs.url(value)
assert False, u"inputs.url({0}) should raise an exception".format(value)
except ValueError as e:
assert_equal(six.text_type(e),
(u"{0} is not a valid URL. Did you mean: http://{0}".format(value))) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_regex_bad_input():
cases = (
'abc',
'123abc',
'abc123',
'',
)
num_only = inputs.regex(r'^[0-9]+$')
for value in cases:
yield assert_raises, ValueError, lambda: num_only(value) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_regex_good_input():
cases = (
'123',
'1234567890',
'00000',
)
num_only = inputs.regex(r'^[0-9]+$')
for value in cases:
yield assert_equal, num_only(value), value |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_regex_bad_pattern():
"""Regex error raised immediately when regex input parser is created."""
assert_raises(re.error, inputs.regex, '[') |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_regex_flags_good_input():
cases = (
'abcd',
'ABCabc',
'ABC',
)
case_insensitive = inputs.regex(r'^[A-Z]+$', re.IGNORECASE)
for value in cases:
yield assert_equal, case_insensitive(value), value |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_regex_flags_bad_input():
cases = (
'abcd',
'ABCabc'
)
case_sensitive = inputs.regex(r'^[A-Z]+$')
for value in cases:
yield assert_raises, ValueError, lambda: case_sensitive(value) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_boolean_with_python_bool(self):
"""Input that is already a native python `bool` should be passed through
without extra processing."""
assert_equal(inputs.boolean(True), True)
assert_equal(inputs.boolean(False), False) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_bad_boolean(self):
assert_raises(ValueError, lambda: inputs.boolean("blah")) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_date_later_than_1900(self):
assert_equal(inputs.date("1900-01-01"), datetime(1900, 1, 1)) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_date_input_error(self):
assert_raises(ValueError, lambda: inputs.date("2008-13-13")) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_date_input(self):
assert_equal(inputs.date("2008-08-01"), datetime(2008, 8, 1)) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_natual_negative(self):
assert_raises(ValueError, lambda: inputs.natural(-1)) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_natural(self):
assert_equal(3, inputs.natural(3)) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_natual_string(self):
assert_raises(ValueError, lambda: inputs.natural('foo')) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_positive(self):
assert_equal(1, inputs.positive(1))
assert_equal(10000, inputs.positive(10000)) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_positive_zero(self):
assert_raises(ValueError, lambda: inputs.positive(0)) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_positive_negative_input(self):
assert_raises(ValueError, lambda: inputs.positive(-1)) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_int_range_good(self):
int_range = inputs.int_range(1, 5)
assert_equal(3, int_range(3)) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_int_range_inclusive(self):
int_range = inputs.int_range(1, 5)
assert_equal(5, int_range(5)) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_int_range_low(self):
int_range = inputs.int_range(0, 5)
assert_raises(ValueError, lambda: int_range(-1)) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_int_range_high(self):
int_range = inputs.int_range(0, 5)
assert_raises(ValueError, lambda: int_range(6)) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_isointerval():
intervals = [
(
# Full precision with explicit UTC.
"2013-01-01T12:30:00Z/P1Y2M3DT4H5M6S",
(
datetime(2013, 1, 1, 12, 30, 0, tzinfo=pytz.utc),
datetime(2014, 3, 5, 16, 35, 6, tzinfo=pytz.utc),
),
... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_invalid_isointerval_error():
try:
inputs.iso8601interval('2013-01-01/blah')
except ValueError as error:
assert_equal(
str(error),
"Invalid argument: 2013-01-01/blah. argument must be a valid ISO8601 "
"date/time interval.",
)
return
... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def test_bad_isointervals():
bad_intervals = [
'2013-01T14:',
'',
'asdf',
'01/01/2013',
]
for bad_interval in bad_intervals:
yield (
assert_raises,
Exception,
inputs.iso8601interval,
bad_interval,
) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def _create_3d_axis():
"""creates a subplot with 3d projection if one does not already exist"""
from matplotlib.projections import get_projection_class
from matplotlib import _pylab_helpers
create_axis = True
if _pylab_helpers.Gcf.get_active() is not None:
if isinstance(plt.gca(), get_proje... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def _plot_surface(ax, x, y, z, labels, azim=None):
"""helper function for surface plots"""
# ax.tick_params(axis='both', which='major', pad=-3)
assert np.size(x) > 1 and np.size(y) > 1 and np.size(z) > 1
if azim is not None:
ax.azim = azim
X, Y = np.meshgrid(x, y)
Z = np.ma.masked_invali... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def label_line(ax, X, Y, U, V, label, color='k', size=8):
"""Add a label to a line, at the proper angle.
Arguments
---------
line : matplotlib.lines.Line2D object,
label : str
x : float
x-position to place center of text (in data coordinated
y : float
... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def i1beta_phasor(up, i1, beta, r1, xd, xq, ax=0):
"""creates a phasor plot
up: internal voltage
i1: current
beta: angle i1 vs up [deg]
r1: resistance
xd: reactance in direct axis
xq: reactance in quadrature axis"""
i1d, i1q = (i1*np.sin(beta/180*np.pi), i1*np.cos(beta/180*np.pi))
u... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def iqd_phasor(up, iqd, uqd, ax=0):
"""creates a phasor plot
up: internal voltage
iqd: current
uqd: terminal voltage"""
uxdq = (uqd[1]/np.sqrt(2), (uqd[0]/np.sqrt(2)-up))
__phasor_plot(ax, up, (iqd[1]/np.sqrt(2), iqd[0]/np.sqrt(2)), uxdq) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def phasor(bch, ax=0):
"""create phasor plot from bch"""
f1 = bch.machine['p']*bch.dqPar['speed']
w1 = 2*np.pi*f1
xd = w1*bch.dqPar['ld'][-1]
xq = w1*bch.dqPar['lq'][-1]
r1 = bch.machine['r1']
i1beta_phasor(bch.dqPar['up'][-1],
bch.dqPar['i1'][-1], bch.dqPar['beta'][-1],
... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def airgap(airgap, ax=0):
"""creates plot of flux density in airgap"""
if ax == 0:
ax = plt.gca()
ax.set_title('Airgap Flux Density [T]')
ax.plot(airgap['pos'], airgap['B'],
label='Max {:4.2f} T'.format(max(airgap['B'])))
ax.plot(airgap['pos'], airgap['B_fft'],
label=... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def airgap_fft(airgap, bmin=1e-2, ax=0):
"""plot airgap harmonics"""
unit = 'T'
if ax == 0:
ax = plt.gca()
ax.set_title('Airgap Flux Density Harmonics / {}'.format(unit))
ax.grid(True)
order, fluxdens = np.array([(n, b) for n, b in zip(airgap['nue'],
... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def torque(pos, torque, ax=0):
"""creates plot from torque vs position"""
k = 20
alpha = np.linspace(pos[0], pos[-1],
k*len(torque))
f = ip.interp1d(pos, torque, kind='quadratic')
unit = 'Nm'
scale = 1
if np.min(torque) < -9.9e3 or np.max(torque) > 9.9e3:
scal... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def torque_fft(order, torque, ax=0):
"""plot torque harmonics"""
unit = 'Nm'
scale = 1
if np.min(torque) < -9.9e3 or np.max(torque) > 9.9e3:
scale = 1e-3
unit = 'kNm'
if ax == 0:
ax = plt.gca()
ax.set_title('Torque Harmonics / {}'.format(unit))
ax.grid(True)
try:... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def force(title, pos, force, xlabel='', ax=0):
"""plot force vs position"""
unit = 'N'
scale = 1
if min(force) < -9.9e3 or max(force) > 9.9e3:
scale = 1e-3
unit = 'kN'
if ax == 0:
ax = plt.gca()
ax.set_title('{} / {}'.format(title, unit))
ax.grid(True)
ax.plot(pos... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def force_fft(order, force, ax=0):
"""plot force harmonics"""
unit = 'N'
scale = 1
if min(force) < -9.9e3 or max(force) > 9.9e3:
scale = 1e-3
unit = 'kN'
if ax == 0:
ax = plt.gca()
ax.set_title('Force Harmonics / {}'.format(unit))
ax.grid(True)
try:
bw = 2... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def forcedens(title, pos, fdens, ax=0):
"""plot force densities"""
if ax == 0:
ax = plt.gca()
ax.set_title(title)
ax.grid(True)
ax.plot(pos, [1e-3*ft for ft in fdens[0]], label='F tang')
ax.plot(pos, [1e-3*fn for fn in fdens[1]], label='F norm')
ax.legend()
ax.set_xlabel('Pos / ... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def forcedens_surface(fdens, ax=0):
if ax == 0:
_create_3d_axis()
ax = plt.gca()
xpos = [p for p in fdens.positions[0]['X']]
ypos = [p['position'] for p in fdens.positions]
z = 1e-3*np.array([p['FN']
for p in fdens.positions])
_plot_surface(ax, xpos, ypos, z,
... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def forcedens_fft(title, fdens, ax=0):
"""plot force densities FFT
Args:
title: plot title
fdens: force density object
"""
if ax == 0:
ax = plt.axes(projection="3d")
F = 1e-3*fdens.fft()
fmin = 0.2
num_bars = F.shape[0] + 1
_xx, _yy = np.meshgrid(np.arange(1, num_bar... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def winding_flux(pos, flux, ax=0):
"""plot flux vs position"""
if ax == 0:
ax = plt.gca()
ax.set_title('Winding Flux / Vs')
ax.grid(True)
for p, f in zip(pos, flux):
ax.plot(p, f) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def winding_current(pos, current, ax=0):
"""plot winding currents"""
if ax == 0:
ax = plt.gca()
ax.set_title('Winding Currents / A')
ax.grid(True)
for p, i in zip(pos, current):
ax.plot(p, i) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def voltage(title, pos, voltage, ax=0):
"""plot voltage vs. position"""
if ax == 0:
ax = plt.gca()
ax.set_title('{} / V'.format(title))
ax.grid(True)
ax.plot(pos, voltage) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def voltage_fft(title, order, voltage, ax=0):
"""plot FFT harmonics of voltage"""
if ax == 0:
ax = plt.gca()
ax.set_title('{} / V'.format(title))
ax.grid(True)
if max(order) < 5:
order += [5]
voltage += [0]
try:
bw = 2.5E-2*max(order)
ax.bar(order, voltage... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def mcv_hbj(mcv, log=True, ax=0):
"""plot H, B, J of mcv dict"""
import femagtools.mcv
MUE0 = 4e-7*np.pi
ji = []
csiz = len(mcv['curve'])
if ax == 0:
ax = plt.gca()
ax.set_title(mcv['name'])
for k, c in enumerate(mcv['curve']):
bh = [(bi, hi*1e-3)
for bi, h... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def mcv_muer(mcv, ax=0):
"""plot rel. permeability vs. B of mcv dict"""
MUE0 = 4e-7*np.pi
bi, ur = zip(*[(bx, bx/hx/MUE0)
for bx, hx in zip(mcv['curve'][0]['bi'],
mcv['curve'][0]['hi']) if not hx == 0])
if ax == 0:
ax = plt.gca()
ax.plo... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def mtpa(pmrel, i1max, title='', projection='', ax=0):
"""create a line or surface plot with torque and mtpa curve"""
nsamples = 10
i1 = np.linspace(0, i1max, nsamples)
iopt = np.array([pmrel.mtpa(x) for x in i1]).T
iqmax, idmax = pmrel.iqdmax(i1max)
iqmin, idmin = pmrel.iqdmin(i1max)
if p... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def mtpv(pmrel, u1max, i1max, title='', projection='', ax=0):
"""create a line or surface plot with voltage and mtpv curve"""
w1 = pmrel.w2_imax_umax(i1max, u1max)
nsamples = 20
if projection == '3d':
nsamples = 50
iqmax, idmax = pmrel.iqdmax(i1max)
iqmin, idmin = pmrel.iqdmin(i1max)
... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def __get_linearForce_title_keys(lf):
if 'force_r' in lf:
return ['Force r', 'Force z'], ['force_r', 'force_z']
return ['Force x', 'Force y'], ['force_x', 'force_y'] |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def pmrelsim(bch, title=''):
"""creates a plot of a PM/Rel motor simulation"""
cols = 2
rows = 4
if len(bch.flux['1']) > 1:
rows += 1
htitle = 1.5 if title else 0
fig, ax = plt.subplots(nrows=rows, ncols=cols,
figsize=(10, 3*rows + htitle))
if title:
... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def multcal(bch, title=''):
"""creates a plot of a MULT CAL simulation"""
cols = 2
rows = 4
htitle = 1.5 if title else 0
fig, ax = plt.subplots(nrows=rows, ncols=cols,
figsize=(10, 3*rows + htitle))
if title:
fig.suptitle(title, fontsize=16)
row = 1
pl... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def fasttorque(bch, title=''):
"""creates a plot of a Fast Torque simulation"""
cols = 2
rows = 4
if len(bch.flux['1']) > 1:
rows += 1
htitle = 1.5 if title else 0
fig, ax = plt.subplots(nrows=rows, ncols=cols,
figsize=(10, 3*rows + htitle))
if title:
... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def cogging(bch, title=''):
"""creates a cogging plot"""
cols = 2
rows = 3
htitle = 1.5 if title else 0
fig, ax = plt.subplots(nrows=rows, ncols=cols,
figsize=(10, 3*rows + htitle))
if title:
fig.suptitle(title, fontsize=16)
row = 1
plt.subplot(rows, ... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def transientsc(bch, title=''):
"""creates a transient short circuit plot"""
cols = 1
rows = 2
htitle = 1.5 if title else 0
fig, ax = plt.subplots(nrows=rows, ncols=cols,
figsize=(10, 3*rows + htitle))
if title:
fig.suptitle(title, fontsize=16)
row = 1
... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def i1beta_torque(i1, beta, torque, title='', ax=0):
"""creates a surface plot of torque vs i1, beta"""
if ax == 0:
_create_3d_axis()
ax = plt.gca()
azim = 210
if 0 < np.mean(beta) or -90 > np.mean(beta):
azim = -60
unit = 'Nm'
scale = 1
if np.min(torque) < -9.9e3 or ... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def i1beta_ld(i1, beta, ld, ax=0):
"""creates a surface plot of ld vs i1, beta"""
if ax == 0:
_create_3d_axis()
ax = plt.gca()
_plot_surface(ax, i1, beta, np.asarray(ld)*1e3,
(u'I1/A', u'Beta/°', u'Ld/mH'),
azim=60) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def i1beta_lq(i1, beta, lq, ax=0):
"""creates a surface plot of ld vs i1, beta"""
if ax == 0:
_create_3d_axis()
ax = plt.gca()
azim = 60
if 0 < np.mean(beta) or -90 > np.mean(beta):
azim = -120
_plot_surface(ax, i1, beta, np.asarray(lq)*1e3,
(u'I1/A', u'Beta... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def i1beta_psim(i1, beta, psim, ax=0):
"""creates a surface plot of psim vs i1, beta"""
if ax == 0:
_create_3d_axis()
ax = plt.gca()
_plot_surface(ax, i1, beta, psim,
(u'I1/A', u'Beta/°', u'Psi m/Vs'),
azim=60) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def i1beta_up(i1, beta, up, ax=0):
"""creates a surface plot of up vs i1, beta"""
if ax == 0:
_create_3d_axis()
ax = plt.gca()
_plot_surface(ax, i1, beta, up,
(u'I1/A', u'Beta/°', u'Up/V'),
azim=60) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def i1beta_psid(i1, beta, psid, ax=0):
"""creates a surface plot of psid vs i1, beta"""
if ax == 0:
_create_3d_axis()
ax = plt.gca()
azim = -60
if 0 < np.mean(beta) or -90 > np.mean(beta):
azim = 60
_plot_surface(ax, i1, beta, psid,
(u'I1/A', u'Beta/°', u'Ps... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def i1beta_psiq(i1, beta, psiq, ax=0):
"""creates a surface plot of psiq vs i1, beta"""
if ax == 0:
_create_3d_axis()
ax = plt.gca()
azim = 210
if 0 < np.mean(beta) or -90 > np.mean(beta):
azim = -60
_plot_surface(ax, i1, beta, psiq,
(u'I1/A', u'Beta/°', u'P... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def idq_torque(id, iq, torque, ax=0):
"""creates a surface plot of torque vs id, iq"""
if ax == 0:
_create_3d_axis()
ax = plt.gca()
unit = 'Nm'
scale = 1
if np.min(torque) < -9.9e3 or np.max(torque) > 9.9e3:
scale = 1e-3
unit = 'kNm'
_plot_surface(ax, id, iq, scal... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def idq_psid(id, iq, psid, ax=0):
"""creates a surface plot of psid vs id, iq"""
if ax == 0:
_create_3d_axis()
ax = plt.gca()
_plot_surface(ax, id, iq, psid,
(u'Id/A', u'Iq/A', u'Psi d/Vs'),
azim=210) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def idq_psiq(id, iq, psiq, ax=0):
"""creates a surface plot of psiq vs id, iq"""
if ax == 0:
_create_3d_axis()
ax = plt.gca()
_plot_surface(ax, id, iq, psiq,
(u'Id/A', u'Iq/A', u'Psi q/Vs'),
azim=210) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def idq_psim(id, iq, psim, ax=0):
"""creates a surface plot of psim vs. id, iq"""
if ax == 0:
_create_3d_axis()
ax = plt.gca()
_plot_surface(ax, id, iq, psim,
(u'Id/A', u'Iq/A', u'Psi m [Vs]'),
azim=120) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def idq_ld(id, iq, ld, ax=0):
"""creates a surface plot of ld vs. id, iq"""
if ax == 0:
_create_3d_axis()
ax = plt.gca()
_plot_surface(ax, id, iq, np.asarray(ld)*1e3,
(u'Id/A', u'Iq/A', u'L d/mH'),
azim=120) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def idq_lq(id, iq, lq, ax=0):
"""creates a surface plot of lq vs. id, iq"""
if ax == 0:
_create_3d_axis()
ax = plt.gca()
_plot_surface(ax, id, iq, np.asarray(lq)*1e3,
(u'Id/A', u'Iq/A', u'L q/mH'),
azim=120) |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def ldlq(bch):
"""creates the surface plots of a BCH reader object
with a ld-lq identification"""
beta = bch.ldq['beta']
i1 = bch.ldq['i1']
torque = bch.ldq['torque']
ld = np.array(bch.ldq['ld'])
lq = np.array(bch.ldq['lq'])
psid = bch.ldq['psid']
psiq = bch.ldq['psiq']
rows = 3... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def psidq(bch):
"""creates the surface plots of a BCH reader object
with a psid-psiq identification"""
id = bch.psidq['id']
iq = bch.psidq['iq']
torque = bch.psidq['torque']
ld = np.array(bch.psidq_ldq['ld'])
lq = np.array(bch.psidq_ldq['lq'])
psim = bch.psidq_ldq['psim']
psid = bch.... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def felosses(losses, coeffs, title='', log=True, ax=0):
"""plot iron losses with steinmetz or jordan approximation
Args:
losses: dict with f, B, pfe values
coeffs: list with steinmetz (cw, alpha, beta) or
jordan (cw, alpha, ch, beta, gamma) coeffs
title: title string
log: l... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def spel(isa, with_axis=False, ax=0):
"""plot super elements of I7/ISA7 model
Args:
isa: Isa7 object
"""
from matplotlib.patches import Polygon
if ax == 0:
ax = plt.gca()
ax.set_aspect('equal')
for se in isa.superelements:
ax.add_patch(Polygon([n.xy
... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def mesh(isa, with_axis=False, ax=0):
"""plot mesh of I7/ISA7 model
Args:
isa: Isa7 object
"""
from matplotlib.lines import Line2D
if ax == 0:
ax = plt.gca()
ax.set_aspect('equal')
for el in isa.elements:
pts = [list(i) for i in zip(*[v.xy for v in el.vertices])]
... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def _contour(ax, title, elements, values, label='', isa=None):
from matplotlib.patches import Polygon
from matplotlib.collections import PatchCollection
if ax == 0:
ax = plt.gca()
ax.set_aspect('equal')
ax.set_title(title, fontsize=18)
if isa:
for se in isa.superelements:
... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def demag(isa, ax=0):
"""plot demag of NC/I7/ISA7 model
Args:
isa: Isa7/NC object
"""
emag = [e for e in isa.elements if e.is_magnet()]
demag = np.array([e.demagnetization(isa.MAGN_TEMPERATURE) for e in emag])
_contour(ax, f'Demagnetization at {isa.MAGN_TEMPERATURE} °C',
emag,... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def demag_pos(isa, pos, icur=-1, ibeta=-1, ax=0):
"""plot demag of NC/I7/ISA7 model at rotor position
Args:
isa: Isa7/NC object
pos: rotor position in degree
icur: cur amplitude index or last index if -1
ibeta: beta angle index or last index if -1
"""
emag = [e for e in isa.eleme... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def flux_density(isa, subreg=[], ax=0):
"""plot flux density of NC/I7/ISA7 model
Args:
isa: Isa7/NC object
"""
if subreg:
if isinstance(subreg, list):
sr = subreg
else:
sr = [subreg]
elements = [e for s in sr for se in isa.get_subregion(s).elements()... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def loss_density(isa, subreg=[], ax=0):
"""plot loss density of NC/I7/ISA7 model
Args:
isa: Isa7/NC object
"""
if subreg:
if isinstance(subreg, list):
sr = subreg
else:
sr = [subreg]
elements = [e for s in sr for sre in isa.get_subregion(s).elements(... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def mmf(f, title='', ax=0):
"""plot magnetomotive force (mmf) of winding"""
if ax == 0:
ax = plt.gca()
if title:
ax.set_title(title)
ax.plot(np.array(f['pos'])/np.pi*180, f['mmf'])
ax.plot(np.array(f['pos_fft'])/np.pi*180, f['mmf_fft'])
ax.set_xlabel('Position / Deg')
phi = ... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def mmf_fft(f, title='', mmfmin=1e-2, ax=0):
"""plot winding mmf harmonics"""
if ax == 0:
ax = plt.gca()
if title:
ax.set_title(title)
else:
ax.set_title('MMF Harmonics')
ax.grid(True)
order, mmf = np.array([(n, m) for n, m in zip(f['nue'],
... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def zoneplan(wdg, ax=0):
"""plot zone plan of winding wdg"""
from matplotlib.patches import Rectangle
upper, lower = wdg.zoneplan()
Qb = len([n for l in upper for n in l])
from femagtools.windings import coil_color
rh = 0.5
if lower:
yl = rh
ymax = 2*rh + 0.2
else:
... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def winding_factors(wdg, n=8, ax=0):
"""plot winding factors"""
ax = plt.gca()
ax.set_title(f'Winding factors Q={wdg.Q}, p={wdg.p}, q={round(wdg.q,4)}')
ax.grid(True)
order, kwp, kwd, kw = np.array([(n, k1, k2, k3)
for n, k1, k2, k3 in zip(wdg.kw_order(n),
... |
def emit(self, level, message):
raise NotImplementedError('Please implement an emit method') | def winding(wdg, ax=0):
"""plot coils of windings wdg"""
from matplotlib.patches import Rectangle
from matplotlib.lines import Line2D
from femagtools.windings import coil_color
coil_len = 25
coil_height = 4
dslot = 8
arrow_head_length = 2
arrow_head_width = 2
if ax == 0:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.