Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_uband(self):
from omas.omas_plot import uband
ax = plt.gca()
ub1 = uband(self.x, self.u, ax)
ub2 = uband(self.x, -self.u, fill_kw=dict(alpha=0.15, color='k'), color='r')
assert ub1 != ub2
ub3 = uband(self.ux, self.u)
ub4 = uband(self.ux, self.y)
assert ub3 != ub4
assert ub1 != ub3
def test_uband(self):
from omas.omas_plot import uband
ax = plt.gca()
ub1 = uband(self.x, self.u, ax)
ub2 = uband(self.x, -self.u, fill_kw=dict(alpha=0.15, color='k'), color='r')
assert ub1 != ub2
ub3 = uband(self.ux, self.u)
ub4 = uband(self.ux, self.y)
assert ub3 != ub4
assert ub1 != ub3
def test_uband(self):
from omas.omas_plot import uband
ax = plt.gca()
ub1 = uband(self.x, self.u, ax)
ub2 = uband(self.x, -self.u, fill_kw=dict(alpha=0.15, color='k'), color='r')
assert ub1 != ub2
ub3 = uband(self.ux, self.u)
ub4 = uband(self.ux, self.y)
assert ub3 != ub4
assert ub1 != ub3
def test_uband(self):
from omas.omas_plot import uband
ax = plt.gca()
ub1 = uband(self.x, self.u, ax)
ub2 = uband(self.x, -self.u, fill_kw=dict(alpha=0.15, color='k'), color='r')
assert ub1 != ub2
ub3 = uband(self.ux, self.u)
ub4 = uband(self.ux, self.y)
assert ub3 != ub4
assert ub1 != ub3
# access database
db = client[database]
# access collection
coll = db[collection]
# find all the matching records
found = coll.find(find)
if limit is not None:
found = found.limit(limit)
# populate ODSs
results = {}
for record in found:
ods = ODS(consistency_check=consistency_check, imas_version=imas_version)
_id = record['_id']
del record['_id']
ods.from_structure(record)
results[_id] = ods
return results
:param structures: list with ids names or string with ids name of which to retrieve the info
if None, then all structures are returned
:return: ods
'''
if not structures:
structures = sorted(list(dict_structures(imas_version).keys()))
elif isinstance(structures, str):
structures = [structures]
# caching
if imas_version not in _info_structures:
from omas import ODS
_info_structures[imas_version] = ODS(imas_version=imas_version, consistency_check=False)
ods = _info_structures[imas_version]
for structure in structures:
if structure not in ods:
tmp = load_structure(structure, imas_version)[0]
lst = sorted(tmp.keys())
for k, item in enumerate(lst):
if re.match('.*_error_(index|lower|upper)$', item.split('.')[-1]):
continue
parent = False
for item1 in lst[k + 1:]:
if l2u(item1.split('.')[:-1]).rstrip('[:]') == item:
parent = True
break
if parent:
continue
'''
Utility to generate the omas/omas_cocos.py file
'''
import os, sys
sys.path.insert(0,os.path.split(os.path.split(os.path.split(os.path.abspath(__file__))[0])[0])[0])
from omas.omas_utils import list_structures, omas_rcparams
from omas.omas_physics import generate_cocos_signals
generate_cocos_signals(list_structures(imas_version=omas_rcparams['default_imas_version']), threshold=0, write=True)
:param info: output of omas_info_node
:param consistency_check: True, False, 'warn'
:param imas_version: IMAS version
:return: value
'''
# force type consistent with data dictionary
txt = ''
if numpy.atleast_1d(is_uncertain(value)).any() or 'data_type' not in info:
pass
elif isinstance(value, numpy.ndarray):
if 'STRUCT_ARRAY' in info['data_type'] and not len(value):
value = ODS()
value.omas_data = []
elif 'FLT' in info['data_type']:
value = value.astype(float)
elif 'INT' in info['data_type']:
value = value.astype(int)
elif 'STR' in info['data_type']:
value = value.astype(str)
elif isinstance(value, (int, float, numpy.integer, numpy.floating)):
if 'FLT' in info['data_type']:
value = float(value)
elif 'INT' in info['data_type']:
value = int(value)
elif 'STR' in info['data_type']:
value = str(value)
elif isinstance(value, bytes):
if 'STR' in info['data_type']:
if not omas_rcparams['allow_fake_imas_fallback']:
raise
filename = os.sep.join([omas_rcparams['fake_imas_dir'], '%s_%s_%d_%d_v%s.pkl' % (user, machine, pulse, run, imas_versions.get(imas_version, imas_version))])
printe('Overloaded load_omas_imas: %s' % filename)
from . import load_omas_pkl
ods = load_omas_pkl(filename, consistency_check=False)
else:
try:
# see what paths have data
# NOTE: this is where the IDS.get operation occurs
fetch_paths, joined_fetch_paths = infer_fetch_paths(ids, occurrence=occurrence, paths=paths, time=time,
imas_version=imas_version, verbose=verbose)
# build omas data structure
ods = ODS(imas_version=imas_version, consistency_check=False)
for k, path in enumerate(fetch_paths):
if path[-1].endswith('_error_upper') or path[-1].endswith('_error_lower') or path[-1].endswith('_error_index'):
continue
if verbose and (k % int(numpy.ceil(len(fetch_paths) / 10)) == 0 or k == len(fetch_paths) - 1):
print('Loading {0:3.1f}%'.format(100 * float(k) / (len(fetch_paths) - 1)))
# get data from IDS
data = imas_get(ids, path, None)
# continue for empty data
if data is None:
continue
# add uncertainty
if not skip_uncertainties and l2i(path[:-1] + [path[-1] + '_error_upper']) in joined_fetch_paths:
stdata = imas_get(ids, path[:-1] + [path[-1] + '_error_upper'], None)
if stdata is not None:
try:
data = uarray(data, stdata)
requested_paths = [[structure] for structure in list_structures(imas_version=imas_version)]
else:
requested_paths = map(p2l, paths)
available_ds = []
for ds in numpy.unique([p[0] for p in requested_paths]):
if uda_get(client, [ds, 'ids_properties', 'homogeneous_time'], pulse, run) is None:
if verbose:
print('- ', ds)
continue
if verbose:
print('* ', ds)
available_ds.append(ds)
ods = ODS(consistency_check=False)
for k, ds in enumerate(available_ds):
filled_paths_in_uda(ods, client, pulse, run, load_structure(ds, imas_version=imas_version)[1],
path=[], paths=[], requested_paths=requested_paths, skip_uncertainties=skip_uncertainties,
perc=[float(k) / len(available_ds) * 100, float(k + 1) / len(available_ds) * 100, float(k) / len(available_ds) * 100])
ods.consistency_check = True
ods.prune()
if verbose:
print()
return ods