Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mem = int(mem * ncpus * 1024)
mem = '{}MB'.format(mem)
walltime = normalise_walltime(p.get('walltime'))
extra_qsub_args = p.get('extra_qsub_args', [])
if isinstance(extra_qsub_args, str):
extra_qsub_args = extra_qsub_args.split(' ')
pp = dict(ncpus=ncpus,
mem=mem,
walltime=walltime,
extra_qsub_args=extra_qsub_args)
pp.update(pick(p, PASS_THRU_KEYS))
return pp
def check_comp_spec(comp_spec, comp_spec_format):
'''Base method to check component spec'''
for spec_k, spec_format_v in comp_spec_format.items():
comp_spec_v = comp_spec[spec_k]
if ps.is_list(spec_format_v):
v_set = spec_format_v
assert comp_spec_v in v_set, f'Component spec value {ps.pick(comp_spec, spec_k)} needs to be one of {util.to_json(v_set)}'
else:
v_type = spec_format_v
assert isinstance(comp_spec_v, v_type), f'Component spec {ps.pick(comp_spec, spec_k)} needs to be of type: {v_type}'
if isinstance(v_type, tuple) and int in v_type and isinstance(comp_spec_v, float):
# cast if it can be int
comp_spec[spec_k] = int(comp_spec_v)
def set_attr(obj, attr_dict, keys=None):
'''Set attribute of an object from a dict'''
if keys is not None:
attr_dict = ps.pick(attr_dict, keys)
for attr, val in attr_dict.items():
setattr(obj, attr, val)
return obj
fig = viz.plot_scatter(df, ['b', 'a'])
fig = viz.plot_histogram(df, ['b'])
# pull plots to make multiple subplots
fig1 = viz.plot_area(df, ['a'], y2_col=['b'], draw=False)
fig2 = viz.plot_area(df, ['b'], draw=False)
fig = viz.tools.make_subplots(rows=3, cols=1, shared_xaxes=True)
fig.append_trace(fig1.data[0], 1, 1)
fig.append_trace(fig1.data[1], 2, 1)
fig.append_trace(fig2.data[0], 3, 1)
fig.layout['yaxis1'].update(fig1.layout['yaxis'])
fig.layout['yaxis2'].update(fig1.layout['yaxis2'])
fig.layout['yaxis1'].update(domain=[0.55, 1])
fig.layout['yaxis3'].update(fig2.layout['yaxis'])
fig.layout['yaxis3'].update(domain=[0, 0.45])
fig.layout.update(ps.pick(fig1.layout, ['legend']))
fig.layout.update(title='total_rewards vs time', width=500, height=400)
viz.plot(fig)
Latex(r'''\begin{eqnarray}
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
\nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
\nabla \cdot \vec{\mathbf{B}} & = 0
\end{eqnarray}''')
Latex(r'''\begin{eqnarray}
\text{A policy is a function } \pi: S \rightarrow A \\
\text{Find a policy } \pi^* \text{that max. the cum. discounted reward } \sum_{t \geq 0}\gamma^t r_t \\
\pi^* = arg\max\limits_{\pi} E\big[\sum_{t\geq0}\gamma^t r_t|\pi\big] \\
\text{with } s_0 \sim p(s_0), a_t \sim \pi(\cdot|s_t),s_{t+1} \sim p(s_t, a_t) \\
def check_comp_spec(comp_spec, comp_spec_format):
'''Base method to check component spec'''
for spec_k, spec_format_v in comp_spec_format.items():
comp_spec_v = comp_spec[spec_k]
if ps.is_list(spec_format_v):
v_set = spec_format_v
assert comp_spec_v in v_set, f'Component spec value {ps.pick(comp_spec, spec_k)} needs to be one of {util.to_json(v_set)}'
else:
v_type = spec_format_v
assert isinstance(comp_spec_v, v_type), f'Component spec {ps.pick(comp_spec, spec_k)} needs to be of type: {v_type}'
if isinstance(v_type, tuple) and int in v_type and isinstance(comp_spec_v, float):
# cast if it can be int
comp_spec[spec_k] = int(comp_spec_v)
def set_attr(obj, attr_dict, keys=None):
'''Set attribute of an object from a dict'''
if keys is not None:
attr_dict = ps.pick(attr_dict, keys)
for attr, val in attr_dict.items():
setattr(obj, attr, val)
return obj
"""
btc_price = 1
is_tracked = False
if balance_item["Currency"] != "BTC":
coin_pair = "BTC-" + balance_item["Currency"]
is_tracked = coin_pair in self.Database.trades["trackedCoinPairs"]
btc_price = self.get_current_price(coin_pair, "bid")
try:
btc_value = round(btc_price * balance_item["Balance"], 8)
except TypeError as exception:
logger.exception(exception)
btc_value = 0
return py_.assign(
py_.pick(balance_item, "Currency", "Balance"),
{"BtcValue": btc_value, "IsTracked": is_tracked}
)
def __on_battle_player_added(self, player):
database.insert_battle_player(**_.pick(player, 'id', 'name'))
database.insert_vehicle(id=player['vehicle_id'], player_id=player['id'], is_alive=player['is_alive'])