text
stringlengths 0
828
|
---|
for name, field in self.representation.fields.items():
|
fields[name] = self._get_field_doc(field)
|
return fields"
|
4947,"def _get_field_doc(self, field):
|
"""""" Return documentation for a field in the representation. """"""
|
fieldspec = dict()
|
fieldspec['type'] = field.__class__.__name__
|
fieldspec['required'] = field.required
|
fieldspec['validators'] = [{validator.__class__.__name__: validator.__dict__} for validator in field.validators]
|
return fieldspec"
|
4948,"def _get_url_doc(self):
|
"""""" Return a list of URLs that map to this resource. """"""
|
resolver = get_resolver(None)
|
possibilities = resolver.reverse_dict.getlist(self)
|
urls = [possibility[0] for possibility in possibilities]
|
return urls"
|
4949,"def _get_method_doc(self):
|
"""""" Return method documentations. """"""
|
ret = {}
|
for method_name in self.methods:
|
method = getattr(self, method_name, None)
|
if method:
|
ret[method_name] = method.__doc__
|
return ret"
|
4950,"def clean(df,error_rate = 0):
|
"""""" Superficially cleans data, i.e. changing simple things about formatting.
|
Parameters:
|
df - DataFrame
|
DataFrame to clean
|
error_rate - float {0 <= error_rate <= 1}, default 0
|
Maximum amount of errors/inconsistencies caused explicitly by cleaning, expressed
|
as a percentage of total dataframe rows (0 = 0%, .5 = 50%, etc.)
|
Ex: na values from coercing a column of data to numeric
|
""""""
|
df = df.copy()
|
# Change colnames
|
basics.clean_colnames(df)
|
# Eventually use a more advanced function to clean colnames
|
print('Changed colnames to {}'.format(df.columns))
|
# Remove extra whitespace
|
obj_col_list = df.select_dtypes(include = 'object').columns
|
for col_name in obj_col_list:
|
df[col_name] = basics.col_strip(df,col_name)
|
print(""Stripped extra whitespace from '{}'"".format(col_name))
|
# Coerce columns if possible
|
for col_name in obj_col_list:
|
new_dtype = coerce_col(df,col_name,error_rate)
|
if new_dtype is not None:
|
print(""Coerced '{}' to datatype '{}'"".format(col_name, new_dtype))
|
# Scrub columns
|
obj_col_list = df.select_dtypes(include = 'object').columns
|
for col_name in obj_col_list:
|
scrubf, scrubb = smart_scrub(df,col_name,1-error_rate)
|
if scrubf is not None or scrubb is not None:
|
print(""Scrubbed '{}' from the front and '{}' from the back of column '{}'"" \
|
.format(scrubf,scrubb,col_name))
|
# Coerice columns if possible
|
for col_name in obj_col_list:
|
new_dtype = coerce_col(df,col_name,error_rate)
|
if new_dtype is not None:
|
print(""Coerced '{}' to datatype '{}'"".format(col_name, new_dtype))
|
return df"
|
4951,"def create_process(self, command, shell=True, stdout=None, stderr=None,
|
env=None):
|
""""""
|
Execute a process using subprocess.Popen, setting the backend's DISPLAY
|
""""""
|
env = env if env is not None else dict(os.environ)
|
env['DISPLAY'] = self.display
|
return subprocess.Popen(command, shell=shell,
|
stdout=stdout, stderr=stderr,
|
env=env)"
|
4952,"def pause(self, instance_id, keep_provisioned=True):
|
""""""shuts down the instance without destroying it.
|
The AbstractCloudProvider class uses 'stop' to refer to destroying
|
a VM, so use 'pause' to mean powering it down while leaving it
|
allocated.
|
:param str instance_id: instance identifier
|
:return: None
|
""""""
|
try:
|
if self._paused:
|
log.debug(""node %s is already paused"", instance_id)
|
return
|
self._paused = True
|
post_shutdown_action = 'Stopped' if keep_provisioned else \
|
'StoppedDeallocated'
|
result = self._subscription._sms.shutdown_role(
|
service_name=self._cloud_service._name,
|
deployment_name=self._cloud_service._name,
|
role_name=self._qualified_name,
|
post_shutdown_action=post_shutdown_action)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.