code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
merged = {}
left_keys = frozenset(left)
right_keys = frozenset(right)
# Items only in the left Mapping
for key in left_keys - right_keys:
merged[key] = left[key]
# Items only in the right Mapping
for key in right_keys - left_keys:
merged[key] = right[key]
# in bo... | def merge(left, right) | Merge two mappings objects together, combining overlapping Mappings,
and favoring right-values
left: The left Mapping object.
right: The right (favored) Mapping object.
NOTE: This is not commutative (merge(a,b) != merge(b,a)). | 1.99991 | 2.020388 | 0.989864 |
sequence_type, default_factory, pass_key = configuration
return cls(default_factory, mapping, sequence_type=sequence_type,
pass_key=pass_key) | def _constructor(cls, mapping, configuration) | A standardized constructor. | 7.750447 | 6.707417 | 1.155504 |
attr = cls(mapping)
attr._setattr('_sequence_type', configuration)
return attr | def _constructor(cls, mapping, configuration) | A standardized constructor. | 21.673733 | 19.591349 | 1.106291 |
if pen is None:
pen = np.log(length)
F = np.zeros(length + 1)
R = np.array([0], dtype=np.int)
candidates = np.zeros(length + 1, dtype=np.int)
F[0] = -pen
for tstar in range(2, length + 1):
cpt_cands = R
seg_costs = np.zeros(len(cpt_cands))
for i in range(0... | def pelt(cost, length, pen=None) | PELT algorithm to compute changepoints in time series
Ported from:
https://github.com/STOR-i/Changepoints.jl
https://github.com/rkillick/changepoint/
Reference:
Killick R, Fearnhead P, Eckley IA (2012) Optimal detection
of changepoints with a linear computational cost, JASA
... | 3.024658 | 2.950594 | 1.025101 |
if not isinstance(data, np.ndarray):
data = np.array(data)
i_variance_2 = 1 / (variance ** 2)
cmm = [0.0]
cmm.extend(np.cumsum(data))
cmm2 = [0.0]
cmm2.extend(np.cumsum(np.abs(data)))
def cost(start, end):
cmm2_diff = cmm2[end] - cmm2[start]
cmm_diff ... | def normal_mean(data, variance) | Creates a segment cost function for a time series with a
Normal distribution with changing mean
Args:
data (:obj:`list` of float): 1D time series data
variance (float): variance
Returns:
function: Function with signature
(int, int) -> float
where the firs... | 3.155712 | 2.956167 | 1.067501 |
if not isinstance(data, np.ndarray):
data = np.array(data)
cumm = [0.0]
cumm.extend(np.cumsum(np.power(np.abs(data - mean), 2)))
def cost(s, t):
dist = float(t - s)
diff = cumm[t] - cumm[s]
return dist * np.log(diff/dist)
return cost | def normal_var(data, mean) | Creates a segment cost function for a time series with a
Normal distribution with changing variance
Args:
data (:obj:`list` of float): 1D time series data
variance (float): variance
Returns:
function: Function with signature
(int, int) -> float
where the ... | 3.840559 | 3.592891 | 1.068933 |
data = np.hstack(([0.0], np.array(data)))
cumm = np.cumsum(data)
cumm_sq = np.cumsum([val**2 for val in data])
def cost(s, t):
ts_i = 1.0 / (t-s)
mu = (cumm[t] - cumm[s]) * ts_i
sig = (cumm_sq[t] - cumm_sq[s]) * ts_i - mu**2
sig_i = 1.0 / sig
retur... | def normal_meanvar(data) | Creates a segment cost function for a time series with a
Normal distribution with changing mean and variance
Args:
data (:obj:`list` of float): 1D time series data
Returns:
function: Function with signature
(int, int) -> float
where the first arg is the starting ... | 3.186142 | 3.279772 | 0.971452 |
data = np.hstack(([0.0], np.array(data)))
cumm = np.cumsum(data)
def cost(s, t):
diff = cumm[t]-cumm[s]
if diff == 0:
return -2 * diff * (- np.log(t-s) - 1)
else:
return -2 * diff * (np.log(diff) - np.log(t-s) - 1)
return cost | def poisson(data) | Creates a segment cost function for a time series with a
poisson distribution with changing mean
Args:
data (:obj:`list` of float): 1D time series data
Returns:
function: Function with signature
(int, int) -> float
where the first arg is the starting index, and t... | 4.10081 | 4.030559 | 1.01743 |
data = np.hstack(([0.0], np.array(data)))
cumm = np.cumsum(data)
def cost(s, t):
return -1*(t-s) * (np.log(t-s) - np.log(cumm[t] - cumm[s]))
return cost | def exponential(data) | Creates a segment cost function for a time series with a
exponential distribution with changing mean
Args:
data (:obj:`list` of float): 1D time series data
Returns:
function: Function with signature
(int, int) -> float
where the first arg is the starting index, a... | 4.378576 | 4.648497 | 0.941934 |
query_args = self._build_query_args({
'f': 'json',
'outFields': '',
'outStatistics': json.dumps([
dict(statisticType='min', onStatisticField=oid_field_name, outStatisticFieldName='THE_MIN'),
dict(statisticType='max', onStatisticField=o... | def _get_layer_min_max(self, oid_field_name) | Find the min and max values for the OID field. | 2.40549 | 2.392604 | 1.005386 |
total = 0
for (pt1, pt2) in pairwise(ring):
total += (pt2[0] - pt1[0]) * (pt2[1] + pt1[1])
return total >= 0 | def ring_is_clockwise(ring) | Determine if polygon ring coordinates are clockwise. Clockwise signifies
outer ring, counter-clockwise an inner ring or hole. this logic was found
at http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clockwise-order
this code taken from http://esri.github.com/geo... | 2.22576 | 2.440962 | 0.911837 |
if not isinstance(date_element, (datetime.datetime, datetime.date)):
# TODO:
if "T" in date_element:
_date = datetime.datetime.strptime(date_element, "%Y-%m-%dT%H:%M:%S")
else:
_date = datetime.datetime.strptime(date_element, "%Y-%m-%d").date()
else:
... | def format_date_argument(date_element) | Take a date as either a datetime.date/datetime or a string and return it as a iso8601 formatted value
:param Union[datetime.date, datetime.datetime] date_element: passed argument
:rtype str
:return: | 2.151425 | 2.196785 | 0.979352 |
base = "/".join(args)
if kwargs:
return "%s?%s" % (base, urlencode(kwargs))
else:
return base | def make_url(*args, **kwargs) | Makes a URL from component parts | 2.907283 | 2.759368 | 1.053605 |
kw = {}
for key in self.KNOWN_QUERY_OPTIONS:
val = getattr(self, key)
if val is not None:
kw[key] = val
return kw | def _querystring(self) | Get additional keyword arguments | 4.819557 | 3.622005 | 1.330632 |
kw = {}
if self.status:
kw["status"] = "all"
if self.links:
kw["links"] = "all"
if self.include is not None:
kw["include"] = self.include
if self.subject_key_type != "SubjectName":
kw["subjectKeyType"] = self.subject_key_... | def _querystring(self) | Additional keyword arguments | 4.780916 | 4.619643 | 1.03491 |
if self.dataset_format:
return ".".join([self.dataset_name, self.dataset_format])
return self.dataset_name | def dataset(self) | Qualify the dataset_name with the dataset_format if supplied
:return: dataset name
:rtype: str | 4.33495 | 2.784321 | 1.556915 |
if ds_format.lower() not in DATASET_FORMATS.keys():
raise ValueError(
"dataset_format is expected to be one of %s. '%s' is not valid"
% (", ".join(DATASET_FORMATS.keys()), ds_format)
) | def check_dataset_format(ds_format) | Ensure dataset format is XML or CSV
:param str ds_format: Format of the Dataset (expected to be one of `csv` or `xml`) | 2.805116 | 3.057898 | 0.917335 |
try:
return DATASET_FORMATS[ds_format]
except KeyError:
raise ValueError(
"dataset_format is expected to be one of %s. '%s' is not valid"
% (", ".join(DATASET_FORMATS.keys()), ds_format)
) | def dataset_format_to_extension(ds_format) | Get the preferred Dataset format extension
:param str ds_format: Format of the Dataset (expected to be one of `csv` or `xml`)
:rtype: str | 2.740251 | 2.904303 | 0.943514 |
cfg = GetDataConfigurableDataset(GET_DATA_DATASET,
study,
environment,
subject,
params=dict(IncludeIDs=0,
IncludeV... | def get_data(ctx, study, environment, subject) | Call rwscmd_getdata custom dataset to retrieve currently enterable, empty fields | 6.365921 | 5.83866 | 1.090305 |
try:
response = ctx.obj['RWS'].send_request(method)
if ctx.obj['RAW']: # use response from RWS
result = ctx.obj['RWS'].last_result.text
elif default_attr is not None: # human-readable summary
result = ""
for item in response:
result... | def rws_call(ctx, method, default_attr=None) | Make request to RWS | 3.383578 | 3.242845 | 1.043398 |
_rws = partial(rws_call, ctx)
if len(path) == 0:
_rws(ClinicalStudiesRequest(), default_attr='oid')
elif len(path) == 1:
_rws(StudySubjectsRequest(path[0], 'Prod'), default_attr='subjectkey')
elif len(path) == 2:
_rws(StudySubjectsRequest(path[0], path[1]), default_attr='sub... | def data(ctx, path) | List EDC data for [STUDY] [ENV] [SUBJECT] | 3.516205 | 3.235907 | 1.086621 |
try:
ctx.obj['RWS'].send_request(PostDataRequest(odm.read()))
if ctx.obj['RAW']:
click.echo(ctx.obj['RWS'].last_result.text)
except RWSException as e:
click.echo(e.message) | def post(ctx, odm) | Post ODM clinical data | 5.447339 | 5.338258 | 1.020434 |
_rws = partial(rws_call, ctx)
if len(path) == 0:
_rws(MetadataStudiesRequest(), default_attr='oid')
elif len(path) == 1:
if drafts:
_rws(StudyDraftsRequest(path[0]), default_attr='oid')
else:
_rws(StudyVersionsRequest(path[0]), default_attr='oid')
eli... | def metadata(ctx, drafts, path) | List metadata for [PROJECT] [VERSION] | 3.625491 | 3.592132 | 1.009287 |
try:
url = make_url(ctx.obj['RWS'].base_url, path)
resp = requests.get(url, auth=HTTPBasicAuth(ctx.obj['USERNAME'], ctx.obj['PASSWORD']))
click.echo(resp.text)
except RWSException as e:
click.echo(e.message)
except requests.exceptions.HTTPError as e:
click.echo(e... | def direct(ctx, path) | Make direct call to RWS, bypassing rwslib | 2.868717 | 2.453519 | 1.169225 |
if metadata is not None: # Read metadata from file, if supplied
odm_metadata = metadata.read()
meta_v = etree.fromstring(odm_metadata).find('.//' + E_ODM.METADATA_VERSION.value).get(A_ODM.OID.value)
else:
odm_metadata = None
meta_v = None
fixed_values = {}
if fixe... | def autofill(ctx, steps, metadata, fixed, study, environment, subject) | Request enterable data for a subject, generate data values and post back to Rave.
Requires 'rwscmd_getdata' configurable dataset to be installed on the Rave URL. | 3.007471 | 2.894599 | 1.038994 |
params = dict(OID=self.oid)
params["mdsol:ProjectType"] = self.project_type
builder.start("Study", params)
# Ask children
if self.global_variables is not None:
self.global_variables.build(builder)
if self.basic_definitions is not None:
... | def build(self, builder) | Build XML by appending to builder | 4.69871 | 4.295067 | 1.093978 |
builder.start("GlobalVariables", {})
make_element(builder, "StudyName", self.name)
make_element(builder, "StudyDescription", self.description)
make_element(builder, "ProtocolName", self.protocol_name)
builder.end("GlobalVariables") | def build(self, builder) | Build XML by appending to builder | 3.716428 | 3.49309 | 1.063937 |
builder.start("BasicDefinitions", {})
for child in self.measurement_units:
child.build(builder)
builder.end("BasicDefinitions") | def build(self, builder) | Build XML by appending to builder | 9.633617 | 7.609169 | 1.266054 |
params = dict(OID=self.oid, Name=self.name)
if self.unit_dictionary_name:
params["mdsol:UnitDictionaryName"] = self.unit_dictionary_name
for suffix in ["A", "B", "C", "K"]:
val = getattr(self, "constant_{0}".format(suffix.lower()))
params["mdsol:Co... | def build(self, builder) | Build XML by appending to builder | 3.991509 | 3.93631 | 1.014023 |
builder.start("Symbol", {})
for child in self.translations:
child.build(builder)
builder.end("Symbol") | def build(self, builder) | Build XML by appending to builder | 7.715713 | 6.102571 | 1.264338 |
params = {}
if self.lang is not None:
params["xml:lang"] = self.lang
builder.start("TranslatedText", params)
builder.data(self.text)
builder.end("TranslatedText") | def build(self, builder) | Build XML by appending to builder | 4.076563 | 3.264999 | 1.248565 |
params = dict(OID=self.oid, Name=self.name)
if self.description is not None:
params["Description"] = self.description
if self.signature_prompt is not None:
params["mdsol:SignaturePrompt"] = self.signature_prompt
if self.primary_formoid is not None:
... | def build(self, builder) | Build XML by appending to builder | 2.74166 | 2.696807 | 1.016632 |
builder.start("Protocol", {})
for child in self.study_event_refs:
child.build(builder)
for alias in self.aliases:
alias.build(builder)
builder.end("Protocol") | def build(self, builder) | Build XML by appending to builder | 6.518727 | 5.34178 | 1.220329 |
params = dict(StudyEventOID=self.oid, Mandatory=bool_to_yes_no(self.mandatory))
if self._order_number is not None:
params["OrderNumber"] = self._order_number
builder.start("StudyEventRef", params)
builder.end("StudyEventRef") | def build(self, builder) | Build XML by appending to builder | 5.466023 | 4.944693 | 1.105432 |
params = dict(
OID=self.oid,
Name=self.name,
Repeating=bool_to_yes_no(self.repeating),
Type=self.event_type,
)
if self.category is not None:
params["Category"] = self.category
if self.access_days is not None:
... | def build(self, builder) | Build XML by appending to builder | 2.339108 | 2.271498 | 1.029764 |
params = dict(
OID=self.oid, Name=self.name, Repeating=bool_to_yes_no(self.repeating)
)
if self.order_number is not None:
params["mdsol:OrderNumber"] = str(self.order_number)
if self.active is not None:
params["mdsol:Active"] = bool_to_yes_n... | def build(self, builder) | Build XML by appending to builder | 2.569214 | 2.498448 | 1.028324 |
params = dict(
OID=self.oid,
Name=self.name,
Repeating=bool_to_yes_no(self.repeating),
IsReferenceData=bool_to_yes_no(self.is_reference_data),
)
if self.sas_dataset_name is not None:
params["SASDatasetName"] = self.sas_datase... | def build(self, builder) | Build XML by appending to builder | 2.831106 | 2.733763 | 1.035608 |
params = dict(ItemOID=self.oid, Mandatory=bool_to_yes_no(self.mandatory))
if self.order_number is not None:
params["OrderNumber"] = str(self.order_number)
if self.key_sequence is not None:
params["KeySequence"] = str(self.key_sequence)
if self.imputat... | def build(self, builder) | Build XML by appending to builder | 2.678993 | 2.591815 | 1.033636 |
params = dict(
OID=self.oid,
Name=self.name,
DataType=self.datatype.value,
Length=str(self.length),
)
if self.date_time_format is not None:
params["mdsol:DateTimeFormat"] = self.date_time_format
params["mdsol:Active"... | def build(self, builder) | Build XML by appending to builder | 2.090899 | 2.07181 | 1.009214 |
builder.start("Question", {})
for translation in self.translations:
translation.build(builder)
builder.end("Question") | def build(self, builder) | Build XML by appending to builder
.. note:: Questions can contain translations | 6.07619 | 4.722428 | 1.286667 |
if not isinstance(value, RangeCheckComparatorType):
raise AttributeError("%s comparator is invalid in RangeCheck." % (value,))
self._comparator = value | def comparator(self, value) | sets the comparator (with validation of input) | 15.162107 | 11.219634 | 1.351391 |
if not isinstance(value, RangeCheckType):
raise AttributeError("%s soft_hard invalid in RangeCheck." % (value,))
self._soft_hard = value | def soft_hard(self, value) | sets the Soft or Hard range setting (with validation of input) | 12.308493 | 10.920687 | 1.12708 |
params = dict(SoftHard=self.soft_hard.value, Comparator=self.comparator.value)
builder.start("RangeCheck", params)
if self.check_value is not None:
self.check_value.build(builder)
if self.measurement_unit_ref is not None:
self.measurement_unit_ref.build(b... | def build(self, builder) | Build XML by appending to builder | 4.179865 | 3.847915 | 1.086267 |
builder.start("CheckValue", {})
builder.data(str(self.value))
builder.end("CheckValue") | def build(self, builder) | Build XML by appending to builder | 7.812255 | 5.076022 | 1.539051 |
params = dict(OID=self.oid, Name=self.name, DataType=self.datatype.value)
if self.sas_format_name is not None:
params["SASFormatName"] = self.sas_format_name
builder.start("CodeList", params)
for item in self.codelist_items:
item.build(builder)
... | def build(self, builder) | Build XML by appending to builder | 3.457864 | 3.300919 | 1.047546 |
params = dict(CodedValue=self.coded_value)
if self.order_number is not None:
params["mdsol:OrderNumber"] = str(self.order_number)
if self.specify:
params["mdsol:Specify"] = "Yes"
builder.start("CodeListItem", params)
if self.decode is not None:... | def build(self, builder) | Build XML by appending to builder | 4.213747 | 3.865105 | 1.090202 |
params = dict(Context=self.context, Name=self.name)
builder.start("Alias", params)
builder.end("Alias") | def build(self, builder) | Build this item
:param builder:
:return: | 7.488818 | 8.588493 | 0.871959 |
params = dict(LabelOID=self.oid, OrderNumber=str(self.order_number))
builder.start("mdsol:LabelRef", params)
builder.end("mdsol:LabelRef") | def build(self, builder) | Build XML by appending to builder | 9.22611 | 8.610004 | 1.071557 |
params = dict(
Namespace=self.namespace,
Name=self.name,
Value=self.value,
TransactionType=self.transaction_type,
)
builder.start("mdsol:Attribute", params)
builder.end("mdsol:Attribute") | def build(self, builder) | Build XML by appending to builder | 5.894694 | 4.361428 | 1.351551 |
params = dict(OID=self.oid, Language=self.language)
builder.start("mdsol:CustomFunctionDef", params)
builder.data(self.code)
builder.end("mdsol:CustomFunctionDef") | def build(self, builder) | Build XML by appending to builder | 7.012192 | 6.332459 | 1.107341 |
params = dict(
OID=self.oid,
Active=bool_to_true_false(self.active),
BypassDuringMigration=bool_to_true_false(self.bypass_during_migration),
NeedsRetesting=bool_to_true_false(self.needs_retesting),
)
if self.variable_oid is not None:
... | def build(self, builder) | Build XML by appending to builder | 2.158668 | 2.117721 | 1.019335 |
params = dict()
if self.variable_oid is not None:
params["VariableOID"] = self.variable_oid
if self.data_format is not None:
params["DataFormat"] = self.data_format
if self.folder_oid is not None:
params["FolderOID"] = self.folder_oid
... | def build(self, builder) | Build XML by appending to builder | 2.039642 | 1.981354 | 1.029418 |
if value is not None:
if not isinstance(value, ActionType):
raise AttributeError("Invalid check action %s" % value)
self._check_action_type = value | def check_action_type(self, value) | Set the value for the CheckActionType, validating input | 3.808933 | 3.674318 | 1.036637 |
params = dict(
OID=self.oid,
Active=bool_to_true_false(self.active),
BypassDuringMigration=bool_to_true_false(self.bypass_during_migration),
NeedsRetesting=bool_to_true_false(self.needs_retesting),
)
builder.start("mdsol:EditCheckDef", pa... | def build(self, builder) | Build XML by appending to builder | 4.49697 | 4.157536 | 1.081643 |
params = dict(OID=self.oid, Name=self.name)
if self.field_number is not None:
params["FieldNumber"] = str(self.field_number)
builder.start("mdsol:LabelDef", params)
for translation in self.translations:
translation.build(builder)
for view_rest... | def build(self, builder) | Build XML by appending to builder | 3.86492 | 3.810828 | 1.014194 |
builder.start("mdsol:ReviewGroup", {})
builder.data(self.name)
builder.end("mdsol:ReviewGroup") | def build(self, builder) | Build XML by appending to builder | 10.274371 | 7.013226 | 1.464999 |
params = dict(MetaDataVersionOID=str(self.metadata_version_oid),
StudyOID="%s (%s)" % (self.projectname, self.environment,),
)
# mixins
self.mixin_params(params)
builder.start("ClinicalData", params)
# Ask children
if... | def build(self, builder) | Build XML by appending to builder | 6.972608 | 6.521338 | 1.069199 |
params = dict(SubjectKey=self.subject_key)
params['mdsol:SubjectKeyType'] = self.subject_key_type
if self.transaction_type is not None:
params["TransactionType"] = self.transaction_type
# mixins
self.mixin()
self.mixin_params(params)
builde... | def build(self, builder) | Build XML by appending to builder | 4.592394 | 4.38077 | 1.048308 |
params = dict(StudyEventOID=self.study_event_oid)
if self.transaction_type is not None:
params["TransactionType"] = self.transaction_type
if self.study_event_repeat_key is not None:
params["StudyEventRepeatKey"] = str(self.study_event_repeat_key)
# mix... | def build(self, builder) | Build XML by appending to builder
:Example:
<StudyEventData StudyEventOID="SCREENING" StudyEventRepeatKey="1" TransactionType="Update"> | 3.783142 | 2.897913 | 1.305471 |
params = dict(FormOID=self.formoid)
if self.transaction_type is not None:
params["TransactionType"] = self.transaction_type
if self.form_repeat_key is not None:
params["FormRepeatKey"] = str(self.form_repeat_key)
# mixins
self.mixin()
s... | def build(self, builder) | Build XML by appending to builder
:Example:
<FormData FormOID="MH" TransactionType="Update"> | 4.146358 | 3.706471 | 1.118681 |
params = dict(ItemGroupOID=formname if formname else self.itemgroupoid)
if self.transaction_type is not None:
params["TransactionType"] = self.transaction_type
if self.item_group_repeat_key is not None:
params["ItemGroupRepeatKey"] = str(
self.... | def build(self, builder, formname=None) | Build XML by appending to builder | 6.041036 | 5.866835 | 1.029693 |
params = dict(ItemOID=self.itemoid)
if self.transaction_type is not None:
params["TransactionType"] = self.transaction_type
if self.value in [None, '']:
params['IsNull'] = 'Yes'
else:
params['Value'] = str(self.value)
if self.specif... | def build(self, builder) | Build XML by appending to builder | 3.183722 | 3.131331 | 1.016731 |
params = {}
if self.signature_id is not None:
# If a Signature element is contained within a Signatures element, the ID attribute is required.
params['ID'] = self.signature_id
builder.start("Signature", params)
if self.user_ref is None:
rai... | def build(self, builder) | Build XML by appending to builder | 2.683265 | 2.614166 | 1.026433 |
if value in [None, ''] or str(value).strip() == '':
raise AttributeError("Invalid ID value supplied")
self._id = value | def annotation_id(self, value) | Set ID for Annotation | 7.361708 | 7.643421 | 0.963143 |
if not re.match(r'\d+', str(value)) or value < 0:
raise AttributeError("Invalid SeqNum value supplied")
self._seqnum = value | def seqnum(self, value) | Set SeqNum for Annotation
:param value: SeqNum value
:type value: int | 4.811131 | 5.427521 | 0.886432 |
params = {}
# Add in the transaction type
if self.transaction_type is not None:
params["TransactionType"] = self.transaction_type
if self.seqnum is None:
# SeqNum is not optional (and defaulted)
raise ValueError("SeqNum is not set.") # prag... | def build(self, builder) | Build XML by appending to builder | 4.41707 | 4.220752 | 1.046512 |
builder.start("Annotations")
# populate the flags
for annotation in self.annotations:
annotation.build(builder)
builder.end("Annotations") | def build(self, builder) | Build XML by appending to builder | 6.967962 | 5.591239 | 1.246229 |
if value in (None, '') or value.strip() == "":
raise AttributeError("Empty text value is invalid.")
self._text = value | def text(self, value) | Set Text content for Comment (validation of input) | 7.113375 | 6.203377 | 1.146694 |
if value not in Comment.VALID_SPONSOR_OR_SITE_RESPONSES:
raise AttributeError("%s sponsor_or_site value of %s is not valid" % (self.__class__.__name__,
value))
self._sponsor_or_site = value | def sponsor_or_site(self, value) | Set Originator with validation of input | 3.919145 | 3.845439 | 1.019167 |
if self.text is None:
raise ValueError("Text is not set.")
params = {}
if self.sponsor_or_site is not None:
params['SponsorOrSite'] = self.sponsor_or_site
builder.start("Comment", params)
builder.data(self.text)
builder.end("Comment") | def build(self, builder) | Build XML by appending to builder | 4.44195 | 3.874464 | 1.146468 |
builder.start("Flag", {})
if self.flag_type is not None:
self.flag_type.build(builder)
if self.flag_value is None:
raise ValueError('FlagValue is not set.')
self.flag_value.build(builder)
builder.end("Flag") | def build(self, builder) | Build XML by appending to builder | 3.717387 | 3.139259 | 1.184161 |
if self.codelist_oid is None:
raise ValueError("CodeListOID not set.")
builder.start("FlagValue", dict(CodeListOID=self.codelist_oid))
builder.data(self.flag_value)
builder.end("FlagValue") | def build(self, builder) | Build XML by appending to builder | 5.680935 | 4.774274 | 1.189906 |
builder.start("UserRef", dict(UserOID=self.oid))
builder.end("UserRef") | def build(self, builder) | Build XML by appending to builder | 16.102709 | 10.753113 | 1.497493 |
builder.start("LocationRef", dict(LocationOID=str(self.oid)))
builder.end("LocationRef") | def build(self, builder) | Build XML by appending to builder | 14.211922 | 9.769179 | 1.454771 |
params = dict(LocationOID=self.oid)
# mixins
self.mixin()
self.mixin_params(params)
builder.start("SiteRef", params)
builder.end("SiteRef") | def build(self, builder) | Build XML by appending to builder | 12.941104 | 11.193826 | 1.156093 |
builder.start("SignatureRef", dict(SignatureOID=self.oid))
builder.end("SignatureRef") | def build(self, builder) | Build XML by appending to builder | 17.731895 | 12.869968 | 1.377773 |
builder.start("ReasonForChange", {})
builder.data(self.reason)
builder.end("ReasonForChange") | def build(self, builder) | Build XML by appending to builder | 8.633817 | 5.351113 | 1.613462 |
builder.start("DateTimeStamp", {})
if isinstance(self.date_time, datetime):
builder.data(dt_to_iso8601(self.date_time))
else:
builder.data(self.date_time)
builder.end("DateTimeStamp") | def build(self, builder) | Build XML by appending to builder | 3.39667 | 2.864798 | 1.185658 |
builder.start("SourceID", {})
builder.data(self.source_id)
builder.end("SourceID") | def build(self, builder) | Build XML by appending to builder | 6.642818 | 4.335991 | 1.532018 |
params = {}
if self.edit_point is not None:
params["EditPoint"] = self.edit_point
if self.used_imputation_method is not None:
params['UsedImputationMethod'] = bool_to_yes_no(self.used_imputation_method)
if self.audit_id is not None:
params[... | def build(self, builder) | Build XML by appending to builder | 2.935336 | 2.813535 | 1.043291 |
params = dict(Value=self.value,
Status=self.status.value,
ProtocolDeviationRepeatKey=self.repeat_key
)
if self.code:
params['Code'] = self.code
if self.pdclass:
params['Class'] = self.pdclass
... | def build(self, builder) | Build XML by appending to builder | 5.452683 | 5.009537 | 1.08846 |
if value is not None:
if not isinstance(value, QueryStatusType):
raise AttributeError("%s action type is invalid in mdsol:Query." % (value,))
self._status = value | def status(self, value) | Set Query Status | 17.1182 | 13.47648 | 1.270228 |
params = {}
if self.value is not None:
params['Value'] = str(self.value)
if self.query_repeat_key is not None:
params['QueryRepeatKey'] = str(self.query_repeat_key)
if self.recipient is not None:
params['Recipient'] = str(self.recipient)
... | def build(self, builder) | Build XML by appending to builder | 2.947475 | 2.774288 | 1.062426 |
builder = ET.TreeBuilder()
self.build(builder)
return builder.close() | def getroot(self) | Build XML object, return the root | 8.121606 | 6.404789 | 1.268052 |
params = dict(ODMVersion="1.3",
FileType=self.filetype,
CreationDateTime=self.creationdatetime,
Originator=self.originator,
FileOID=self.fileoid,
xmlns="http://www.cdisc.org/ns/odm/v1.3",
... | def build(self, builder) | Build XML object, return the root, this is a copy for consistency and testing | 2.757957 | 2.605221 | 1.058627 |
kw = {"studyoid": self.studyoid}
if self.location_oid is not None:
kw["locationoid"] = self.location_oid
return kw | def _querystring(self) | Additional keyword arguments | 8.358994 | 6.465485 | 1.292864 |
if isinstance(self.raw_value, (datetime.datetime, datetime.date)):
return self.raw_value.isoformat()
elif isinstance(self.raw_value, (bool,)):
return 'Yes' if self.raw_value else 'No'
return self.raw_value | def value(self) | Normalise the Attribute value and return
.. note: `datetime` objects are normalised to ISO datestring, `bool` objects are normalised to Yes or No
:rtype: str
:return: The normalised value | 2.527482 | 2.206431 | 1.145507 |
class_name = self.__class__.__name__
if class_name.startswith('ItemData'):
# ItemData* Elements
class_name = 'ItemData'
if attribute not in MODMExtensionRegistry[class_name].value:
raise ValueError("Can't add {} to {}".format(attribute, self.__class__... | def add_attribute(self, attribute, value) | Add an attribute to the current instance
:param str attribute: Attribute name
:type value: Union[datetime,bool,str]
:param value: Attribute value | 6.750877 | 6.897169 | 0.97879 |
if not isinstance(params, (dict,)):
raise AttributeError("Cannot mixin to object of type {}".format(type(params)))
for attribute in self.attributes:
params.update({attribute.tag: attribute.value}) | def mixin_params(self, params) | Merge in the MdsolAttribute for the passed parameter
:param dict params: dictionary of object parameters | 5.707387 | 6.165591 | 0.925684 |
if isinstance(value, (datetime.datetime,)):
self._last_update_time = value
else:
raise ValueError("Expect last_update_time to be a datetime") | def last_update_time(self, value) | Setter for the last_update_time attribute
:param datetime.datetime value: value to set for the element | 3.240768 | 4.292277 | 0.755023 |
if update_time and isinstance(update_time, (datetime.datetime,)):
self.last_update_time = update_time
else:
self.last_update_time = datetime.datetime.utcnow() | def set_update_time(self, update_time=None) | Set the Update Time from the local clock (in UTC) | 2.380427 | 2.236851 | 1.064187 |
super(LastUpdateMixin, self).mixin_params(params)
if self.last_update_time is not None:
params.update({"mdsol:LastUpdateTime": self.last_update_time.isoformat()}) | def mixin_params(self, params) | Add the mdsol:LastUpdateTime attribute
:return: | 4.950578 | 2.553063 | 1.939074 |
if milestone not in self.milestones.get(codelistoid, []):
self._milestones.setdefault(codelistoid, []).append(milestone) | def add_milestone(self,
milestone,
codelistoid="MILESTONES") | Add a milestone
:param codelistoid: specify the CodeListOID (defaults to MILESTONES)
:param str milestone: Milestone to add | 3.362789 | 4.026988 | 0.835063 |
if self.milestones:
from rwslib.builders.clinicaldata import Annotation, Flag, FlagValue
annotation = Annotation()
for codelist, milestones in self.milestones.items():
for milestone in milestones:
annotation << Flag() << FlagValue(... | def mixin(self) | Add the annotations to the ODM Element (if defined)
:return: | 8.889188 | 8.945083 | 0.993751 |
# StudyName = "TEST (1) (DEV)"
# ProtocolName = "TEST (1)"
# Raw Env = "(DEV)"
raw_env = studyname[len(protocolname) :].strip()
if "(" in raw_env:
l_brace_pos = raw_env.rfind("(")
r_brace_pos = raw_env.rfind(")")
return raw_env[l_brace_pos + 1 : r_bra... | def getEnvironmentFromNameAndProtocol(studyname, protocolname) | Extract environment name using studyname and protocolname to guide
:param str studyname: Name of the study (including Env)
:param str protocolname: Name of the study | 4.6443 | 4.59967 | 1.009703 |
# Remove BOM if it exists (different requests seem to have different BOMs)
unichr_captured = ""
if not xml.strip():
return u""
while xml[0] != u"<":
unichr_captured += xml[0]
xml = xml[1:]
parser = etree.XMLParser(ns_clean=True, collect_ids=False, huge_tree=True)
... | def parseXMLString(xml) | Parse XML string, return root
:param str: Passed in XML | 4.799776 | 5.025372 | 0.955109 |
e_global_variables = elem.find(ODM_NS + "GlobalVariables")
studyname = e_global_variables.find(ODM_NS + "StudyName").text
protocolname = e_global_variables.find(ODM_NS + "ProtocolName").text
self = cls(
oid=elem.get("OID"),
projecttype=elem.get(MEDI_NS + ... | def fromElement(cls, elem) | Read properties from an XML Element to build a StudyList Item
:param lxml.etree.Element elem: The source Study XML Element
.. code-block:: xml
<Study OID="Fixitol(Dev)" mdsol:ProjectType="GlobalLibraryVolume">
<GlobalVariables>
<StudyName>Fixitol (Dev)<... | 4.531342 | 3.687124 | 1.228964 |
self = cls()
self.oid = elem.get("OID")
self.name = elem.get("Name")
return self | def fromElement(cls, elem) | Read properties from a MetaDataVersion element
:param lxml.etree._Element elem: Source etree Element | 4.910414 | 4.58905 | 1.070029 |
if self.subjectkeytype and self.subjectkeytype == "SubjectUUID".lower():
# if the SubjectKeyType is "SubjectUUID", then return the SubjectName
return self.subjectname
else:
return self.subjectkey | def subject_name(self) | Get the subject name consistently
:rtype str
:return: The Subject ID for the subject
.. note::
* If the `SubjectKeyType` is `SubjectUUID` then the subject name lives in the `mdsol:SubjectName` attribute
* If the `SubjectKeyType` is `SubjectName` then the subject name lives i... | 8.273885 | 4.753226 | 1.740688 |
self = cls()
self.studyoid = elem.get("StudyOID")
self.metadataversionoid = elem.get("MetaDataVersionOID")
e_subjectdata = elem.findall(ODM_NS + "SubjectData")[0]
self.subjectkey = e_subjectdata.get("SubjectKey")
e_siteref = e_subjectdata.findall(ODM_NS + "SiteRe... | def fromElement(cls, elem) | Read properties from an XML Element | 3.629339 | 3.560123 | 1.019442 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.