Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Based on the snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst """ 8. Pressure increasing test This test requires that the profile has pressures that are monotonically increasing (assuming the pressures are ordered from smallest to lar...
class MonotonicZ(QCCheckVar):
Given the following code snippet before the placeholder: <|code_start|> ] ), "tukey53H_norm": np.array( [ np.nan, np.nan, np.nan, np.nan, 0.04145785, 0.00274101, 0.07846...
y = Tukey53H(profile, "TEMP", cfg, autoflag=True)
Next line prediction: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- """ """ def test_tukey53H(): """Basic test on feature rate of change """ x = [0, 1, -1, 2, -2, 3, 2, 4, 0, np.nan] y = tukey53H(x) output = [np.nan, np.nan, np.nan, np.nan, -3.75, np.nan, np.nan, np.nan, np.nan,...
profile = DummyData()
Predict the next line after this snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- """ """ def test_tukey53H(): """Basic test on feature rate of change """ x = [0, 1, -1, 2, -2, 3, 2, 4, 0, np.nan] y = tukey53H(x) output = [np.nan, np.nan, np.nan, np.nan, -3.75, np.nan, np....
compare_feature_input_types(tukey53H, x)
Given snippet: <|code_start|> -0.045912, 0.0599597, -0.03974471, np.nan, np.nan, np.nan, np.nan, np.nan, ] ), } flags = { "tukey53H": np.array( [...
compare_input_types(Tukey53H, cfg)
Using the snippet: <|code_start|> def test_standard_dataset(): profile = DummyData() features = { "gradient": np.array( [ np.nan, 0.01, 0.015, 0.145, 0.605, 0.04, 1.145, ...
y = Gradient(profile, "TEMP", cfg)
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst """ """ def test_curvature(): """Basic test on feature curvature """ x = [1, -1, 2, 2, 3, 2, 4] y = curvature(x) output = [np.nan, -2....
profile = DummyData()
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst """ """ def test_curvature(): """Basic test on feature curvature """ x = [1, -1, 2, 2, 3, 2, 4] y = curvature(x) output = [np.nan, -2.5, 1.5, -0.5, 1...
compare_feature_input_types(curvature, x)
Given snippet: <|code_start|> 0.015, 0.145, 0.605, 0.04, 1.145, -0.67, 0.875, -0.08, -2.575, 1.61, -0.045, np.nan, ...
compare_input_types(Gradient, cfg)
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst """ ATENTION: Create test for global_range - masked values - input np.array - properly handle inf, nan? """ module_l...
class GlobalRange(QCCheckVar):
Given snippet: <|code_start|># -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst """ """ def test_input_types(): cfg = {"threshold": 3} compare_input_types(DigitRollOver, cfg) def test_standard_dataset(): <|code_end|> , continue by predicting the next line. Consider c...
profile = DummyData()
Using the snippet: <|code_start|> "low": {"type": "trimf", "params": [0.0, 0.225, 0.45]}, "medium": {"type": "trimf", "params": [0.275, 0.5, 0.725]}, "high": {"type": "smf", "params": [0.55, 0.775]}, }, "features": { "f1": { "weight": 1, "low": {"type": "zm...
uncertainty = fuzzy_uncertainty(features, **CFG)
Based on the snippet: <|code_start|> The default is to require all features, thus if anyone is NaN the outcome uncertainty will be NaN. If require is defined as any, one single valid feature will be enough to define an uncertainty. In both cases it returns NaN if all features are NaN. """ feature...
compare_compound_feature_input_types(fuzzy_uncertainty, data=data, **CFG)
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst """Validate Deepest Pressure test """ def test_default(): profile = DummyData() cfg = {'threshold': 1000} <|code_end|> , generate the next line using the imports in this file: im...
y = DeepestPressure(profile, 'TEMP', cfg)
Here is a snippet: <|code_start|> try: PANDAS_AVAILABLE = True except ImportError: PANDAS_AVAILABLE = False try: SUPPORTDATA_AVAILABLE = True except ImportError: SUPPORTDATA_AVAILABLE = True def load_ctd(): """ """ DATA_URL = "https://raw.githubusercontent.com/castelao/CoTeDe/master/sa...
filename = os.path.join(cotederc("sampledata"), "dPIRX010.npz")
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst """ Argo, test #12. (10C, 5PSU) """ module_logger = logging.getLogger(__name__) class DigitRollOver(QCCheckVar): def set_features(self): <|code_end|> . Use current file impor...
self.features = {"rate_of_change": rate_of_change(self.data[self.varname])}
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst """ Missing tests: - validate explicitly giver time varname - check for type of the output - Does it work with timezone? """ try: except: pass def te...
profile = DummyData()
Continue the code snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- """ Verify the Cummulative Rate of Change QC test """ def test_cum_rate_of_change(): x = [1, -1, 2, 2, 3, 2, 4] memory = 0.8 <|code_end|> . Use current file imports: import numpy as np from cotede.qctests import CumRateO...
y = cum_rate_of_change(x, memory)
Predict the next line after this snippet: <|code_start|> def test_standard_dataset(): """Test CumRateOfChange with a standard dataset """ profile = DummyData() features = { "cum_rate_of_change": [ np.nan, 0.02, 0.016, 0.03, 0.32, ...
y = CumRateOfChange(profile, "TEMP", cfg)
Based on the snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- """ Verify the Cummulative Rate of Change QC test """ def test_cum_rate_of_change(): x = [1, -1, 2, 2, 3, 2, 4] memory = 0.8 y = cum_rate_of_change(x, memory) output = [np.nan, 2.0, 3.0, 2.4, 2.12, 1.896, 2.0] as...
profile = DummyData()
Based on the snippet: <|code_start|># -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst """ """ def test_default(): profile = DummyData() cfg = {'flag_good': 1, 'flag_bad': 4} <|code_end|> , predict the immediate next line with the help of imports: import numpy as np fr...
y = StuckValue(profile, 'TEMP', cfg)
Continue the code snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- """ Verify Rate of Change QC test """ def test_standard_dataset(): """Test GlobalRange procedure with a standard dataset """ profile = DummyData() flags = {"global_range": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,...
y = GlobalRange(profile, "TEMP", cfg)
Using the snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- """ Verify Rate of Change QC test """ def test_standard_dataset(): """Test GlobalRange procedure with a standard dataset """ profile = DummyData() flags = {"global_range": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9]} ...
compare_input_types(GlobalRange, cfg)
Using the snippet: <|code_start|> def notest_profile_envelop(): profile = DummyData() cfg = {"layers": [["> 0", "<= 25", -2, 37], ["> 25", "<= 50", -2, 36]]} flags = profile_envelop(profile, cfg, "TEMP") # Check for BUG #9. assert 9 in flags def test_standard_dataset(): """Test ProfileEnvel...
y = ProfileEnvelop(profile, varname="TEMP", cfg=cfg)
Predict the next line for this snippet: <|code_start|> """ profile = DummyData() flags = {"profile_envelop": [1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 4, 1, 9]} cfg = { "layers": [ ["> 0", "<= 149", -2, 37], ["> 150", "<= 999", -2, 33], ["> 999", "<= 12000", -1.5,...
compare_input_types(ProfileEnvelop, cfg)
Given snippet: <|code_start|># -*- coding: utf-8 -*- """Resources related to QC configuration """ module_logger = logging.getLogger(__name__) def list_cfgs(): """List the available QC procedures, builtin + local Full QC procedures, defining which tests and respective parameters to be used, can be sav...
ucfg = os.listdir(cotederc("cfg"))
Continue the code snippet: <|code_start|> u2[n + 1] = np.median(u1[n : n + 3]) u3 = np.nan * np.ones(N) u3[1:-1] = 0.25 * (u2[:-2] + 2 * u2[1:-1] + u2[2:]) delta = np.nan * np.ones(N) delta[1:-1] = x[1:-1] - u3[1:-1] if not normalize: return delta idx = ~np.isnan(u1) if id...
class Tukey53H(QCCheckVar):
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst """ """ def test(): profile = DummyData() cfg = { "pressure_threshold": 400, "shallow_max": 9, "deep_max": 2.5, "f...
y = GradientDepthConditional(profile, "TEMP", cfg)
Continue the code snippet: <|code_start|> def test(): profile = DummyData() cfg = { "pressure_threshold": 400, "shallow_max": 9, "deep_max": 2.5, "flag_good": 1, "flag_bad": 4, } y = GradientDepthConditional(profile, "TEMP", cfg) assert isinstance(y.featu...
compare_input_types(GradientDepthConditional, cfg)
Based on the snippet: <|code_start|> """ Threshold - |median(v0..v4)| + |sigma(v0..v4)| y = ma.masked_all_like(x) yy = np.stack([x[:-4], x[1:-3], x[2:-2], x[3:-1], x[4:]]) y[2:-2] = np.median(yy, axis=0) + yy.std(axis=0) y = np.stack([x[:-4], x[1:-3], x[2:-2], x[3:-1], x[4:]]) """ module_logger = logging.getLogge...
class Spike(QCCheckVar):
Based on the snippet: <|code_start|># -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst """Provile Envelop QC test I believe that this test was first described by GTSPP, which define minimum and maximum ranges for different depth layers. The concept is that near the surface one sho...
class ProfileEnvelop(QCCheckVar):
Using the snippet: <|code_start|> def test_standard_dataset(): """Test Spike procedure with a standard dataset """ profile = DummyData() features = { "spike": [ np.nan, 1.78e-15, 0.0, -0.03, -0.32, -1.53, -1.61...
y = Spike(profile, "TEMP", cfg)
Given snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- """ Verify Spike QC test """ def test_spike(): """Basic test on feature spike """ x = [1, -1, 2, 2, 3, 2, 4] y = spike(x) output = [np.nan, 2.0, 0.0, 0.0, 1.0, 1.0, np.nan] assert isinstance(y, np.ndarray) asse...
profile = DummyData()
Here is a snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- """ Verify Spike QC test """ def test_spike(): """Basic test on feature spike """ x = [1, -1, 2, 2, 3, 2, 4] y = spike(x) output = [np.nan, 2.0, 0.0, 0.0, 1.0, 1.0, np.nan] assert isinstance(y, np.ndarray) ...
compare_feature_input_types(spike, x)
Here is a snippet: <|code_start|> 1.78e-15, 0.0, -0.03, -0.32, -1.53, -1.61, -2.56, -2.56, -4.15, 1.00, 1.00, -2.13, np.nan, np.nan, ] } ...
compare_input_types(Spike, cfg)
Predict the next line after this snippet: <|code_start|> def constant_cluster_size(x, tol=0): """Estimate the cluster size with (nearly) constant value Returns how many consecutive neighbor values are within a given tolerance range. Note that invalid values, like NaN, are ignored. """ asser...
class ConstantClusterSize(QCCheckVar):
Using the snippet: <|code_start|>except ImportError: module_logger.debug("Missing package GSW, used to estimate density when needed.") GSW_AVAILABLE = False def densitystep(SA, t, p, auto_rotate=False): """Estimates the potential density step of successive mesurements Expects the data to be record...
class DensityInversion(QCCheck):
Based on the snippet: <|code_start|> def test_standard_dataset(): """Test RateOfChange procedure with a standard dataset """ profile = DummyData() features = { "rate_of_change": [ np.nan, 0.02, 0.0, -0.03, -0.32, -1.53, ...
y = RateOfChange(profile, "TEMP", cfg)
Given the code snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- """ Verify Rate of Change QC test """ def test_rate_of_change(): """Basic test on feature rate of change """ x = [1, -1, 2, 2, 3, 2, 4] y = rate_of_change(x) output = [np.nan, -2.0, 3.0, 0.0, 1.0, -1.0, 2.0] ...
profile = DummyData()
Using the snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- """ Verify Rate of Change QC test """ def test_rate_of_change(): """Basic test on feature rate of change """ x = [1, -1, 2, 2, 3, 2, 4] y = rate_of_change(x) output = [np.nan, -2.0, 3.0, 0.0, 1.0, -1.0, 2.0] as...
compare_feature_input_types(rate_of_change, x)
Predict the next line after this snippet: <|code_start|> 0.02, 0.0, -0.03, -0.32, -1.53, -1.61, -3.9, -2.56, -4.31, -4.15, 1, -2.22, -2.13, np.nan, ...
compare_input_types(RateOfChange, cfg)
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst """ """ def test(): profile = DummyData() cfg = { "pressure_threshold": 400, "shallow_max": 6, "deep_max": 0.05, "flag_good": 1, "flag_b...
y = SpikeDepthConditional(profile, "TEMP", cfg)
Based on the snippet: <|code_start|> def test(): profile = DummyData() cfg = { "pressure_threshold": 400, "shallow_max": 6, "deep_max": 0.05, "flag_good": 1, "flag_bad": 4, } y = SpikeDepthConditional(profile, "TEMP", cfg) assert isinstance(y.features, di...
compare_input_types(SpikeDepthConditional, cfg)
Predict the next line for this snippet: <|code_start|> XARRAY_AVAILABLE = False """ Tests to implement: - missing lat, missing lon, missing both - single point - list - array - masked array - single point with NaN (lat, lon, lat & lon) - list with some NaN - lat lon coincident ...
assert valid_geolocation(lat, lon) == True
Predict the next line after this snippet: <|code_start|> def test_nan_single_coordinate(): coords = [[np.nan, -30], [10, np.nan]] for lat, lon in coords: assert valid_geolocation(lat, lon) == False def test_valid_coordinate_list(): lat = [10, 10, -15] lon = [-30, 330, 30] assert np.all(va...
y = ValidGeolocation(profile)
Next line prediction: <|code_start|> coords = [[99, 0], [-91.1, 0], [99, 361], [0, -181], [0, 361]] for lat, lon in coords: assert valid_geolocation(lat, lon) == False def test_nan_single_coordinate(): coords = [[np.nan, -30], [10, np.nan]] for lat, lon in coords: assert valid_geolocati...
profile = DummyData()
Given the following code snippet before the placeholder: <|code_start|> assert valid_geolocation(lat, lon) == True def test_invalid_single_coordinate(): coords = [[99, 0], [-91.1, 0], [99, 361], [0, -181], [0, 361]] for lat, lon in coords: assert valid_geolocation(lat, lon) == False def test_...
compare_feature_input_types(valid_geolocation, lat, lon)
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst """ """ module_logger = logging.getLogger(__name__) class GradientDepthConditional(QCCheckVar): def set_features(self): <|code_...
self.features = {"gradient": curvature(self.data[self.varname])}
Next line prediction: <|code_start|> """ Consistency check for location at sea QC test. Create tests to evaluate lat > 90, lat < -90, lon < -180, lon > 360 for get_bathymetry and for LocationAtSea """ try: PANDAS_AVAILABLE = True except ImportError: PANDAS_AVAILABLE = False try: XARRAY_AVAILABLE = ...
lat, lon = extract_coordinates(profile)
Predict the next line after this snippet: <|code_start|> return data = DummyData() coords = [[None, 1, 0], [1, None, 0]] for lat, lon, flag in coords: data.attrs["LATITUDE"] = lat data.attrs["LONGITUDE"] = lon assert location_at_sea(data) == flag del data.attrs["LATITUD...
y = LocationAtSea(data, cfg={"resolution": "5min"})
Predict the next line for this snippet: <|code_start|> assert "bathymetry" in etopo, "Missing bathymetry from get_bathymetry" assert ma.allclose(etopo["bathymetry"], z), "Unexpected value" def test_bathymetry_greenwich(): """Check elevation that includes 0 """ if not OCEANSDB_AVAILABLE: re...
assert location_at_sea(data) == flag
Given the following code snippet before the placeholder: <|code_start|> lat = [0, 0, 8] lon = [-32, -38, -38] df = pd.DataFrame({"lat": lat, "lon": lon}) lat2, lon2 = extract_coordinates(df) assert np.allclose(lat, lat2, equal_nan=True) assert np.allclose(lon, lon2, equal_nan=True) def test_ex...
etopo = get_bathymetry(lat, lon, resolution="5min")
Using the snippet: <|code_start|># -*- coding: utf-8 -*- """ Consistency check for location at sea QC test. Create tests to evaluate lat > 90, lat < -90, lon < -180, lon > 360 for get_bathymetry and for LocationAtSea """ try: PANDAS_AVAILABLE = True except ImportError: PANDAS_AVAILABLE = False try: ...
profile = DummyData()
Predict the next line after this snippet: <|code_start|> assert type(kwargs[x]) != type(da_kwargs[da]) assert isinstance(y, np.ndarray) assert np.allclose(y, y2, equal_nan=True) def compare_compound_feature_dataset(feature, data, *args, **kwargs): if not XARRAY_AVAILABLE: return ds = x...
profile = DummyData()
Using the snippet: <|code_start|># -*- coding: utf-8 -*- """ Quality Control based on anomaly detection """ #from numpy import ma module_logger = logging.getLogger(__name__) def anomaly_detection(features, cfg): """ Must decide where to set the flags. """ <|code_end|> , determine the next li...
prob = estimate_anomaly(features, params = cfg['features'])
Given the code snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst """ Based on Timms 2011, p9597 RoC(t) = x(t) - x(t-1) """ module_logger = logging.getLogger(__name__) def rate_of_change(x): if isinstance(x, ma.Mask...
class RateOfChange(QCCheckVar):
Predict the next line after this snippet: <|code_start|> } } def test_standard_dataset(): features = { "fuzzylogic": np.array([np.nan, 0.22222222, 0.22222222, 0.22222222, 0.23232323, 0.22222222, 0.26262626, 0.22222222, 0.24242424, 0.22222222, 0.29292929, 0.43434343, 0.22222222, ...
compare_compound_feature_input_types(fuzzylogic, features, cfg=CFG)
Based on the snippet: <|code_start|> "high": {'type': 'smf', 'params': [2, 6]} }, "woa_normbias": { "weight": 1, "low": {'type': 'zmf', 'params': [3, 4]}, "medium": {'type': 'trapmf', '...
y = FuzzyLogic(profile, "TEMP", cfg=CFG)
Continue the code snippet: <|code_start|> } } def test_standard_dataset(): features = { "fuzzylogic": np.array([np.nan, 0.22222222, 0.22222222, 0.22222222, 0.23232323, 0.22222222, 0.26262626, 0.22222222, 0.24242424, 0.22222222, 0.29292929, 0.43434343, 0.22222222, np.nan, np.nan]...
compare_compound_feature_input_types(fuzzylogic, features, cfg=CFG)
Predict the next line for this snippet: <|code_start|># Copyright 2011 Liftoff Software Corporation # __doc__ = """\ playback.py - A plugin for Gate One that adds support for saving and playing back session recordings. .. note:: Yes this only contains one function and it is exposed to clients through a WebSocke...
_ = get_translation()
Here is a snippet: <|code_start|> def save_recording(self, settings): """ Handles uploads of session recordings and returns them to the client in a self-contained HTML file that will auto-start playback. ..note:: The real crux of the code that handles this is in the template. """ #import tornad...
rendered_recording = render_string(recording_template_path,**dict(recording=recording,
Predict the next line after this snippet: <|code_start|> 9: u'^I', #10: u'^J', # Newline (\n) 11: u'^K', 12: u'^L', #13: u'^M', # Carriage return (\r) 14: u'^N', 15: u'^O', 16: u'^P', 17: u'^Q', 18: u'^R', 19: u'^S', 20: u'^T', 21: u'^U', 22: u'^V', 23: u'^W', ...
_ = get_translation()
Using the snippet: <|code_start|> TIME_ZONE = 'Asia/Shanghai' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.11/howto/static-files/ STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static"), ] # Channels setting...
generate_server_conf(installed=False)
Using the snippet: <|code_start|> #from applications.auth.authentication import PAMAuthHandler, KerberosAuthHandler #if KerberosAuthHandler: #auths += ", kerberos" #if PAMAuthHandler: #auths += ", pam" ## Simplify the syslog_facility option help message #facilities = list(FACILITIES.k...
mkdir_p(settings_dir)
Given snippet: <|code_start|> # and call tornado.options.parse_config_file(*some_config_path*). After you # do that the options will wind up in tornado.options.options # Simplify the auth option help message auths = "none, api, cas, google, ssl" #from applications.auth.authentication import PAMAuthH...
settings_base = getsettings('BASE_DIR')
Given the code snippet: <|code_start|> pam_realm = os.uname()[1] pam_service = "login" embedded = False js_init = "" https_redirect = False url_prefix = "/" origins = default_origins pid_file = pid_default api_keys = "" combine_js = "" combine_css = "" combine_css_containe...
TIMEOUT = convert_to_timedelta(session_timeout)
Given snippet: <|code_start|> embedded = False js_init = "" https_redirect = False url_prefix = "/" origins = default_origins pid_file = pid_default api_keys = "" combine_js = "" combine_css = "" combine_css_container = "gateone" multiprocessing_workers = None configure = ...
auth = none_fix(auth)
Based on the snippet: <|code_start|> combine_css = "" combine_css_container = "gateone" multiprocessing_workers = None configure = False login_url ='/auth' static_url_prefix = '/static/' log_rotate_mode = 'size' logging = 'info' static_url = os.path.join(settings_base, 'static') s...
gen_self_signed_ssl(path=ssl_base)
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals # Create your views here. class basehttphander(View): def user_login(self,request): self.request.session.clear_expired() if self.request.META.has_key('HTTP_X_FORWARDED_FOR'): ip = s...
'session': generate_session_id()
Using the snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals # Create your views here. class basehttphander(View): def user_login(self,request): self.request.session.clear_expired() if self.request.META.has_key('HTTP_X_FORWARDED_FOR'): ip = self.r...
mkdir_p(user_dir)
Next line prediction: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals # Create your views here. class basehttphander(View): def user_login(self,request): self.request.session.clear_expired() if self.request.META.has_key('HTTP_X_FORWARDED_FOR'): ip = sel...
user_dir = os.path.join(getsettings('BASE_DIR'),'users')
Continue the code snippet: <|code_start|># coding: utf-8 from __future__ import unicode_literals from __future__ import absolute_import try: except ImportError: raise RuntimeError('django is required in django simple serializer') class JsonResponseMixin(object): datetime_type = 'string' foreign = Fal...
return serializer(data=context,
Using the snippet: <|code_start|># coding: utf-8 from __future__ import unicode_literals from __future__ import absolute_import try: except ImportError: raise RuntimeError('django is required in django simple serializer') class JsonResponseMixin(object): datetime_type = 'string' foreign = False m...
time_func = TimeFormatFactory.get_time_func(self.datetime_type)
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- @back_log(BACK_GET_PROXY) def get_proxy(args = None): a = NetProcess() a.Host = 'www.hao123.com' errmsg = '' in_queue = 0 myproxy = SProxy() ip_list = myproxy.renew_proxy() newitems = 0 for it...
ishave = Proxy.objects.filter(ip = str(item))
Here is a snippet: <|code_start|>""" WSGI config for NewRaPo project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/ """ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "NewRaPo.setti...
uwsgi.register_signal(82, "", get_proxy)
Given the code snippet: <|code_start|>""" WSGI config for NewRaPo project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/ """ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "NewRaPo....
uwsgi.register_signal(84, "", check_proxy)
Using the snippet: <|code_start|> def doit(): token = 'vf3kDL6bIx1lYjPeT+HuXorgtRZSdNBU' ip_list = [] <|code_end|> , determine the next line of code. You have imports: from app.NetProcess import NetProcess import simplejson import time and context (class names, function names, or code) available: # Path: ap...
net = NetProcess()
Given the code snippet: <|code_start|># coding: utf-8 from __future__ import unicode_literals __author__ = 'RaPoSpectre' class Test_Serializer(TestCase): def setUp(self): <|code_end|> , generate the next line using the imports in this file: import json import datetime from unittest import TestCase from django....
self.time_func = TimeFormatFactory.get_time_func('string')
Predict the next line after this snippet: <|code_start|> # name = models.CharField(default='test_author') # # def __unicode__(self): # return self.name # # class TestTags(models.Model): # tag = models.CharField(default='test_tag') # ...
result = _include_check(include_attr, attr_dict)
Given snippet: <|code_start|> # content = models.CharField(default='test') # author = models.ForeignKey(TestAuthor, related_name='author_art') # tags = models.ManyToManyField(TestTags, related_name='tag_art') # create_time = models.DateTimeField(auto_now=True) # ...
result = _exclude_check(exclude_attr, attr_dict)
Predict the next line for this snippet: <|code_start|> def test_include_check(self): include_attr = ['title', 'name', 'xx'] attr_dict = {'title': 'test', 'name': 'attr', 'time': '20150909'} result = _include_check(include_attr, attr_dict) sel...
result = _data_convert(test_data, time_func=self.time_func, foreign=False, many=False,
Given the code snippet: <|code_start|> def test_exclude_check(self): exclude_attr = ['title', 'xx'] attr_dict = {'title': 'test', 'name': 'attr', 'time': '20150909'} result = _exclude_check(exclude_attr, attr_dict) self.assertIn('name', resul...
result = _output_convert('raw', test_data)
Using the snippet: <|code_start|> 'name': 'attr', 'time': datetime.datetime(2015, 10, 10, 12), 'list': [{'content': 'list_content', 'time': datetime.datetime(2015, 10, 11, 9)}, {'content': 'list_co...
result = serializer(test_data, datetime_format='string', output_type='raw')
Given the code snippet: <|code_start|> for i in range(1, 1000000): num_str = '%06i' % i if not (int(num_str[0:2]) in range(0, 100) and int(num_str[2:4]) in range(1, 13) and int(num_str[4:6]) in range(1, 32)): f1.writelines('%s\n' % num_str) #生日简写 for year ...
net = NetProcess()
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- # Create your views here. def proxy(req): return render_to_response("proxy.html") def monitor(req): return render_to_response("monitor.html") def get_lab_info(req): body={} now = timezone.now() start = now - datetime.timedelta(ho...
total_use = ProxyUser.objects.all().count()
Here is a snippet: <|code_start|># -*- coding: utf-8 -*- # Create your views here. def proxy(req): return render_to_response("proxy.html") def monitor(req): return render_to_response("monitor.html") def get_lab_info(req): body={} now = timezone.now() start = now - datetime.timedelta(hours=2...
proxy_count = Proxy.objects.all().count()
Here is a snippet: <|code_start|># -*- coding: utf-8 -*- # Create your views here. def proxy(req): return render_to_response("proxy.html") def monitor(req): return render_to_response("monitor.html") def get_lab_info(req): body={} now = timezone.now() start = now - datetime.timedelta(hours=2...
day_req = ReqRecord.objects.filter(uri='/lab/get_proxy/', create_time__gt=start).count()
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*- # Create your views here. def proxy(req): return render_to_response("proxy.html") def monitor(req): return render_to_response("monitor.html") def get_lab_info(req): body={} now = timezone.now() start = now - datetime.timedelta...
back_log = BackLog.objects.all()
Given snippet: <|code_start|># -*- coding: utf-8 -*- # Create your views here. def proxy(req): return render_to_response("proxy.html") def monitor(req): return render_to_response("monitor.html") def get_lab_info(req): body={} now = timezone.now() start = now - datetime.timedelta(hours=23, m...
new_time = datetime_to_string(back_log[0].create_time)
Using the snippet: <|code_start|># Create your views here. def proxy(req): return render_to_response("proxy.html") def monitor(req): return render_to_response("monitor.html") def get_lab_info(req): body={} now = timezone.now() start = now - datetime.timedelta(hours=23, minutes=59, seconds=59) ...
return HttpResponse(encodejson(1, body), content_type="application/json")
Given snippet: <|code_start|> urlpatterns = patterns('', url(r'^create_token/$', create_permission), url(r'^get_proxy/$', get_ip), url(r'^proxy/$', proxy), url(r'^monitor/$', monitor), url(r'^get_lab_info/$', get_lab_info), url(r'^get_chart_info/$', get_chart_message), url(r'^hy/$', hy_sig...
url(r'^get_test_cbv/(?P<id>(\d)+)/$', ArticleDetailView.as_view()),
Predict the next line after this snippet: <|code_start|> neighbour_list = [[1], # 0 [2], # 1 [3], # 2 [4, 1], # 3 [1], # 4 ] weights = {(0,1): 20, (1,2) : 1,...
_, negative_cycle = spfa(*self.example_graph)
Continue the code snippet: <|code_start|> ub_cost = constraint_obj.find('UB-RELAX-COST-RATIO').text constraint.relax_cost_ub = float(ub_cost) # Next we deal with the guard conditions # the approach is identical to that for decision variables f...
cc_constraint = ChanceConstraint("CC-1", "CC-Constraint", risk_bound)
Based on the snippet: <|code_start|> for guard_obj in variable_obj.findall('GUARD'): # guard_id = guard_obj.find('ID').text guard_variable = guard_obj.find('GUARD-VARIABLE').text guard_value = guard_obj.find('GUARD-VALUE').text # retrieve the a...
constraint = TemporalConstraint(constraint_id, constraint_name, tpnu.node_id_to_number[from_event], tpnu.node_id_to_number[to_event], lower_bound, upper_bound)
Given the following code snippet before the placeholder: <|code_start|> for event_obj in e.findall('EVENT'): eid, ename = event_obj.find('ID').text, event_obj.find('NAME').text event_ids.add(eid) tpnu.node_id_to_name[eid] = ename for eid in event_ids: next...
decision_variable = DecisionVariable(dv_id,dv_name)
Here is a snippet: <|code_start|> tpnu.node_number_to_id[next_number] = eid tpnu.node_id_to_number[eid] = next_number tpnu.num_nodes = len(tpnu.node_number_to_id) start_id = e.find('START').text tpnu.start_node = tpnu.node_id_to_number[start_id] if (tpnu.num_nod...
assignment = Assignment(decision_variable, value_name, value_utility)
Next line prediction: <|code_start|> # print("CON: ", prob.constraints[c]) # print("OBJ: ", prob.objective) # Solve the problem try: status = prob.solve(solvers.GUROBI(mip=False,msg=False)) except ImportError: pass # Gurobi ...
relaxation = TemporalRelaxation(constraint)
Given the following code snippet before the placeholder: <|code_start|>__author__ = 'yupeng' class Conflict(object): def __init__(self): self.assignments = set() self.negative_cycles = set() def add_assignment(self,assignment): self.assignments.add(assignment) self.add_guard_...
if constraint_type == EdgeSupport.LOWER:
Using the snippet: <|code_start|> # print("OBJ: ", prob.objective) # Solve the problem try: status = prob.solve(solvers.GUROBI(mip=False,msg=False)) except ImportError: # pass # Gurobi doesn't exist, use default Pulp solver. ...
relaxation = TemporalRelaxation(constraint)
Given the following code snippet before the placeholder: <|code_start|> # print("Cycles: " + str(len(all_cycles))) for cycle in all_cycles: # cycle.pretty_print() lp_ncycle_constraint = [] for constraint, bound in cycle.constraints.keys(): # The const...
if constraint.controllable or feasibility_type == FeasibilityType.CONSISTENCY: