function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def __init__( self, plotly_name="tickvals", parent_name="sunburst.marker.colorbar", **kwargs
plotly/python-api
[ 13052, 2308, 13052, 1319, 1385013188 ]
def __init__(self, breakingCapacity=0.0, ProtectionEquipments=None, RecloseSequences=None, *args, **kw_args): """Initialises a new 'ProtectedSwitch' instance. @param breakingCapacity: The maximum fault current a breaking device can break safely under prescribed conditions of use. @param Protec...
rwl/PyCIM
[ 68, 33, 68, 7, 1238978196 ]
def getProtectionEquipments(self): """Protection equipments that operate this ProtectedSwitch. """ return self._ProtectionEquipments
rwl/PyCIM
[ 68, 33, 68, 7, 1238978196 ]
def addProtectionEquipments(self, *ProtectionEquipments): for obj in ProtectionEquipments: if self not in obj._ProtectedSwitches: obj._ProtectedSwitches.append(self) self._ProtectionEquipments.append(obj)
rwl/PyCIM
[ 68, 33, 68, 7, 1238978196 ]
def getRecloseSequences(self): """A breaker may have zero or more automatic reclosures after a trip occurs. """ return self._RecloseSequences
rwl/PyCIM
[ 68, 33, 68, 7, 1238978196 ]
def addRecloseSequences(self, *RecloseSequences): for obj in RecloseSequences: obj.ProtectedSwitch = self
rwl/PyCIM
[ 68, 33, 68, 7, 1238978196 ]
def test_equal(self): self.assertEqual(KeySignature(name='C major'), KeySignature(name='C major')) self.assertNotEqual(KeySignature(name='C major'), KeySignature(name='G major'))
odahoda/noisicaa
[ 10, 2, 10, 2, 1448313403 ]
def returnToQueriersLocationWithReply( querier, reply ): """ @summary : Changes location back to the querier + returns the reply of the query to the querier.
khosrow/metpx
[ 1, 1, 1, 1, 1446661693 ]
def getQuerierLocation( form ): """ @param form : Form with whom this programm was called.
khosrow/metpx
[ 1, 1, 1, 1, 1446661693 ]
def handlePlotRequest( form, language ): """ @param form: form wich contains the parameters to use for the query.
khosrow/metpx
[ 1, 1, 1, 1, 1446661693 ]
def getPlotterType( form ): """ @param form : Form with whom this programm was called.
khosrow/metpx
[ 1, 1, 1, 1, 1446661693 ]
def getForm(): """ @summary: Returns the form with whom this page was called.
khosrow/metpx
[ 1, 1, 1, 1, 1446661693 ]
def getLanguage( form ): """ @summary : Returns the language in which the page should be generated.
khosrow/metpx
[ 1, 1, 1, 1, 1446661693 ]
def setGlobalLanguageParameters( language ): """ @summary : Sets up all the needed global language variables so that they can be used everywhere in this program.
khosrow/metpx
[ 1, 1, 1, 1, 1446661693 ]
def main(): """ @summary: Based on the plotter specified in the received form, executes query using a broker that's specific to the said plotter. """
khosrow/metpx
[ 1, 1, 1, 1, 1446661693 ]
def before(self, form): query = ActivityType.query() types = query.filter_by(active=True) modes = ActivityMode.query() query = ActivityAction.query() query = query.filter_by(parent_id=None) actions = query.filter_by(active=True) activity_appstruct = { ...
CroissanceCommune/autonomie
[ 21, 14, 21, 284, 1381245170 ]
def __init__(self, *args, **kw): BaseCommand.__init__(self, *args, **kw) ESData.__init__(self)
StamusNetworks/scirius
[ 525, 142, 525, 111, 1399230932 ]
def __init__(self, long_strings: bool = False, **kwargs: Any) -> None: """Initialize Strcmp95 instance. Parameters ---------- long_strings : bool Set to True to increase the probability of a match when the number of matched characters is large. This option allows...
chrislit/abydos
[ 154, 26, 154, 63, 1398235847 ]
def _in_range(char: str) -> bool: """Return True if char is in the range (0, 91). Parameters ---------- char : str The character to check Returns ------- bool True if char is in the range (0, 91) ...
chrislit/abydos
[ 154, 26, 154, 63, 1398235847 ]
def T1197_telem_test_instance(): return T1197Telem(STATUS, MACHINE, USAGE_STR)
guardicore/monkey
[ 6098, 725, 6098, 196, 1440919371 ]
def binned_statistic(x, values, statistic='mean', bins=10, range=None): """ Compute a binned statistic for a set of data.
beiko-lab/gengis
[ 28, 14, 28, 18, 1363614616 ]
def binned_statistic_2d(x, y, values, statistic='mean', bins=10, range=None): """ Compute a bidimensional binned statistic for a set of data.
beiko-lab/gengis
[ 28, 14, 28, 18, 1363614616 ]
def binned_statistic_dd(sample, values, statistic='mean', bins=10, range=None): """ Compute a multidimensional binned statistic for a set of data.
beiko-lab/gengis
[ 28, 14, 28, 18, 1363614616 ]
def action_import(self, cr, uid, ids, context=None): wizard = self.browse(cr, uid, ids[0]) invoice_id = util.active_id(context, "account.invoice") if not invoice_id: raise osv.except_osv(_("Error!"), _("No invoice found")) report_obj = self.pool.get("ir.actions.report.xml")...
funkring/fdoo
[ 1, 5, 1, 8, 1400249085 ]
def css_class(self): return self._meta.module_name
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def update_or_create(self, filter_attrs, attrs): """Given unique look-up attributes, and extra data attributes, either updates the entry referred to if it exists, or creates it if it doesn't.
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def __unicode__(self): return self.name
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def __unicode__(self): return "%s (%s for %s)" % (self.value, self.kind, self.content_object)
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def __unicode__(self): return "%s: %s" % (self.source, self.content_object)
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def is_politician(self, when=None): # FIXME - Don't like the look of this, rather a big subquery. return self.filter(position__in=Position.objects.all().current_politician_positions(when))
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def get_query_set(self): return PersonQuerySet(self.model)
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def loose_match_name(self, name): """Search for a loose match on a name. May not be too reliable""" # import here to avoid creating an import loop from haystack.query import SearchQuerySet # Try matching all the bits results = SearchQuerySet().filter_and(content=name).model...
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def get_next_featured(self, current_slug, want_previous=False): """ Returns the next featured person, in slug order: using slug order because it's unique and easy to exclude the current person.
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def clean(self): # strip other_names and flatten multiple newlines self.other_names = re.sub(r"\n+", "\n", self.other_names).strip()
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def name(self): if self.other_names: return self.other_names.split("\n")[0] else: return self.legal_name
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def additional_names(self): if self.other_names: return self.other_names.split("\n")[1:] else: return []
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def aspirant_positions(self): return self.position_set.all().current_aspirant_positions()
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def politician_positions(self): return self.position_set.all().current_politician_positions()
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def parties(self): """Return list of parties that this person is currently a member of""" party_memberships = self.position_set.all().currently_active().filter(title__slug='member').filter(organisation__kind__slug='party') return Organisation.objects.filter(position__in=party_memberships)
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def constituencies(self): """Return list of constituencies that this person is currently an politician for""" return Place.objects.filter(position__in=self.politician_positions())
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def get_absolute_url(self): return ('person', [self.slug])
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def generate_tasks(self): """Generate tasks for missing contact details etc""" task_slugs = []
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def scorecard_overall(self): total_count = super(Person, self).active_scorecards().count() total_score = super(Person, self).active_scorecards().aggregate(models.Sum('score'))['score__sum'] for constituency in self.constituencies(): constituency_count = constituency.active_scorecard...
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def has_scorecards(self): # We're only showing scorecards for current MPs if self.is_politician(): return super(Person, self).has_scorecards() or any([x.has_scorecards() for x in self.constituencies()])
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def __unicode__(self): return self.name
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def parties(self): return self.filter(kind__slug='party')
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def get_query_set(self): return OrganisationQuerySet(self.model)
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def __unicode__(self): return "%s (%s)" % (self.name, self.kind)
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def get_absolute_url(self): return ('organisation', [self.slug])
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def __unicode__(self): return self.name
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def constituencies(self): return self.filter(kind__slug='constituency')
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def get_query_set(self): return PlaceQuerySet(self.model)
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def position_with_organisation_set(self): return self.position_set.filter(organisation__isnull=False)
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def is_constituency(self): return self.kind.slug == 'constituency'
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def current_politician_position(self): """Return the current politician position, or None""" qs = self.position_set.all().current_politician_positions() try: return qs[0] except IndexError: return None
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def get_absolute_url(self): return ('place', [self.slug])
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def __unicode__(self): return self.name
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def get_absolute_url(self): return ('position', [self.slug])
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def organisations(self): """ Return a qs of organisations, with the most frequently related first. Each organisation is also annotated with 'position_count' which might be useful. This is intended as an alternative to assigning a org to each position_title. Instead we c...
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def currently_active(self, when=None): """Filter on start and end dates to limit to currently active postitions""" if when == None: when = datetime.date.today() now_approx = repr(ApproximateDate(year=when.year, month=when.month, day=when.day)) qs = ( self ...
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def aspirant_positions(self): """ Filter down to only positions which are aspirant ones. This uses the convention that the slugs always start with 'aspirant-'. """ return self.filter( title__slug__startswith='aspirant-' )
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def politician_positions(self): """Filter down to only positions which are one of the two kinds of politician (those with constituencies, and nominated ones). """ return self.filter(title__slug__in=settings.POLITICIAN_TITLE_SLUGS)
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def political(self): """Filter down to only the political category""" return self.filter(category='political')
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def other(self): """Filter down to only the other category""" return self.filter(category='other')
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def order_by_place(self): """Sort by the place name""" return self.order_by('place__name')
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def get_query_set(self): return PositionQuerySet(self.model)
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def clean(self): if not (self.organisation or self.title or self.place): raise exceptions.ValidationError('Must have at least one of organisation, title or place.') if self.title and self.title.requires_place and not self.place: raise exceptions.ValidationError("The job title '%...
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def display_dates(self): """Nice HTML for the display of dates""" # no dates if not (self.start_date or self.end_date): return '' # start but no end if self.start_date and not self.end_date: return "Started %s" % self.start_date # both dates ...
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def display_start_date(self): """Return text that represents the start date""" if self.start_date: return str(self.start_date) return '?'
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def display_end_date(self): """Return text that represents the end date""" if self.end_date: return str(self.end_date) return '?'
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def has_known_dates(self): """Is there at least one known (not future) date?""" return (self.start_date and not self.start_date.future) or \ (self.end_date and not self.end_date.future)
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def _set_sorting_dates(self): """Set the sorting dates from the actual dates (does not call save())""" # value can be yyyy-mm-dd, future or None start = repr(self.start_date) if self.start_date else '' end = repr(self.end_date) if self.end_date else ''
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def is_nominated_politician(self): return self.title.slug == 'nominated-member-parliament'
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def __unicode__(self): title = self.title or '???' if self.organisation: organisation = self.organisation.name else: organisation = '???' return "%s (%s at %s)" % ( self.person.name, title, organisation)
Hutspace/odekro
[ 1, 5, 1, 7, 1337882548 ]
def __str__(self): return 'Abstract Class'
rosenvladimirov/addons
[ 3, 6, 3, 2, 1484327648 ]
def __str__(self): return 'Abstract Method'
rosenvladimirov/addons
[ 3, 6, 3, 2, 1484327648 ]
def __str__(self): return 'Unknown Class'
rosenvladimirov/addons
[ 3, 6, 3, 2, 1484327648 ]
def __init__(self, value): self.curr = value
rosenvladimirov/addons
[ 3, 6, 3, 2, 1484327648 ]
def __repr__(self): return 'Unsupported currency %s' % self.curr
rosenvladimirov/addons
[ 3, 6, 3, 2, 1484327648 ]
def test_preview_fragment(self): """ Test for calling get_preview_html. Ensures data-usage-id is correctly set and asides are correctly included. """ course = CourseFactory.create(default_store=ModuleStoreEnum.Type.split) html = ItemFactory.create( parent_loca...
edx/edx-platform
[ 6290, 3437, 6290, 280, 1369945238 ]
def test_preview_no_asides(self): """ Test for calling get_preview_html. Ensures data-usage-id is correctly set and asides are correctly excluded because they are not enabled. """ course = CourseFactory.create(default_store=ModuleStoreEnum.Type.split) html = ItemFactory.c...
edx/edx-platform
[ 6290, 3437, 6290, 280, 1369945238 ]
def test_preview_conditional_module_children_context(self, mock_is_condition_satisfied): """ Tests that when empty context is pass to children of ConditionalBlock it will not raise KeyError. """ mock_is_condition_satisfied.return_value = True client = Client() client.logi...
edx/edx-platform
[ 6290, 3437, 6290, 280, 1369945238 ]
def test_block_branch_not_changed_by_preview_handler(self, default_store): """ Tests preview_handler should not update blocks being previewed """ client = Client() client.login(username=self.user.username, password=self.user_password) with self.store.default_store(defaul...
edx/edx-platform
[ 6290, 3437, 6290, 280, 1369945238 ]
def student_view(self, context): """ Renders the output that a student will see. """ fragment = Fragment() fragment.add_content(self.runtime.service(self, 'mako').render_template('edxmako.html', context)) return fragment
edx/edx-platform
[ 6290, 3437, 6290, 280, 1369945238 ]
def setUp(self): """ Set up the user and request that will be used. """ super().setUp() self.user = UserFactory() self.course = CourseFactory.create() self.request = mock.Mock() self.field_data = mock.Mock()
edx/edx-platform
[ 6290, 3437, 6290, 280, 1369945238 ]
def test_expected_services_exist(self, expected_service): """ Tests that the 'user' and 'i18n' services are provided by the Studio runtime. """ descriptor = ItemFactory(category="pure", parent=self.course) runtime = _preview_module_system( self.request, de...
edx/edx-platform
[ 6290, 3437, 6290, 280, 1369945238 ]
def setUp(self): """ Set up the user and other fields that will be used to instantiate the runtime. """ super().setUp() self.course = CourseFactory.create() self.user = UserFactory() self.request = RequestFactory().get('/dummy-url') self.request.user = sel...
edx/edx-platform
[ 6290, 3437, 6290, 280, 1369945238 ]
def test_render_template(self): descriptor = ItemFactory(category="pure", parent=self.course) html = get_preview_fragment(self.request, descriptor, {'element_id': 142}).content assert '<div id="142" ns="main">Testing the MakoService</div>' in html
edx/edx-platform
[ 6290, 3437, 6290, 280, 1369945238 ]
def create_custom_fields_as_needed(): CustomField.objects.get_or_create( name='record_id', defaults={ "label": 'Citrix DNS Record ID', "type": 'STR', } ) CustomField.objects.get_or_create( name='record_value', defaults={ "label": 'C...
CloudBoltSoftware/cloudbolt-forge
[ 34, 32, 34, 16, 1437063482 ]
def get_citrix_api_token(): # Citrix api uses tokens to authorise requests. The tokens expires after a short while and has to be regenerated. ci = ConnectionInfo.objects.get(name=API_CLIENT_CI) url = get_citrix_url() response = requests.get( "{url}/api/oauth/token?client_id={client_id}&client_se...
CloudBoltSoftware/cloudbolt-forge
[ 34, 32, 34, 16, 1437063482 ]
def generate_options_for_editRecordType(**kwargs): return [(True, "Yes"), (False, "No")]
CloudBoltSoftware/cloudbolt-forge
[ 34, 32, 34, 16, 1437063482 ]
def generate_options_for_editTTL(**kwargs): return [(True, "Yes"), (False, "No")]
CloudBoltSoftware/cloudbolt-forge
[ 34, 32, 34, 16, 1437063482 ]
def sample_append_rows(): # Create a client client = bigquery_storage_v1beta2.BigQueryWriteClient() # Initialize request argument(s) request = bigquery_storage_v1beta2.AppendRowsRequest( write_stream="write_stream_value", ) # This method expects an iterator which contains # 'bigque...
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def keras_model_builder_with_zeros(): # Create a simple linear regression model, single output. # We initialize all weights to zero. model = tf.keras.Sequential([ tf.keras.layers.Dense( 1, kernel_initializer='zeros', bias_initializer='zeros', input_shape=(1,)) ]) ...
google-research/federated
[ 505, 161, 505, 11, 1600124947 ]
def create_dataset(): # Create data satisfying y = 2*x + 1 x = [[1.0], [2.0], [3.0]] y = [[3.0], [5.0], [7.0]] return tf.data.Dataset.from_tensor_slices((x, y)).batch(1)
google-research/federated
[ 505, 161, 505, 11, 1600124947 ]
def get_input_spec(): return create_dataset().element_spec
google-research/federated
[ 505, 161, 505, 11, 1600124947 ]
def tff_model_builder(): return tff.learning.from_keras_model( keras_model=keras_model_builder_with_zeros(), input_spec=get_input_spec(), loss=tf.keras.losses.MeanSquaredError(), metrics=metrics_builder())
google-research/federated
[ 505, 161, 505, 11, 1600124947 ]
def test_create_federated_eval_fns(self, use_test_cd): """Test for create_federated_eval_fns.""" (part_train_eval_fn, part_val_fn, unpart_fn, test_fn) = trainer_utils.create_federated_eval_fns( tff_model_builder=tff_model_builder, metrics_builder=metrics_builder, part_train_eval...
google-research/federated
[ 505, 161, 505, 11, 1600124947 ]
def test_create_federated_eval_fns_skips_rounds(self, rounds_per_eval, round_num): """Test that create_federated_eval_fns skips the appropriate rounds.""" part_train_eval_fn, part_val_fn, unpart_fn, _ = trainer_utils.create_federated_eval_fns( tff_model...
google-research/federated
[ 505, 161, 505, 11, 1600124947 ]
def test_create_centralized_eval_fns(self, use_test_cd): """Test for create_centralized_eval_fns.""" (part_train_eval_fn, part_val_fn, unpart_fn, test_fn) = trainer_utils.create_centralized_eval_fns( tff_model_builder=tff_model_builder, metrics_builder=metrics_builder, part_trai...
google-research/federated
[ 505, 161, 505, 11, 1600124947 ]