code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
class MinimaxAgent(MultiAgentSearchAgent): <NEW_LINE> <INDENT> def value(self, gameState, depth, agentIndex): <NEW_LINE> <INDENT> if depth == -1 or gameState.isLose() or gameState.isWin(): <NEW_LINE> <INDENT> return self.evaluationFunction(gameState) <NEW_LINE> <DEDENT> if agentIndex % gameState.getNumAgents() == 0: <N... | Your minimax agent (question 2) | 62598f8507d97122c4216774 |
class TestFsaApi(unittest.TestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> self.api = isi_sdk_8_1_1.api.fsa_api.FsaApi() <NEW_LINE> <DEDENT> def tearDown(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def test_delete_fsa_result(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def test_delete_... | FsaApi unit test stubs | 62598f85d53ae8145f917f5f |
class TestConnection(unittest.TestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> self.connection_args = {'host':'localhost' , 'port': '5672', 'userid':'guest', 'password':'ch@ng3m3', 'virtual_host':'/', 'insist': False, 'ssl':False} <NEW_LINE> self.conn = CallCenterVectorConnection(**self.connection_ar... | Units tests for the call center vector connection class | 62598f8530c21e258be982da |
class Graph: <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.graph=nx.empty_graph() <NEW_LINE> <DEDENT> def buildGraph(self,fileName): <NEW_LINE> <INDENT> line='' <NEW_LINE> f = open(fileName,'r') <NEW_LINE> while True: <NEW_LINE> <INDENT> line=f.readline()[24:] <NEW_LINE> if not line: <NEW_LINE> <INDE... | The graph to be built from co-authorship | 62598f85b7558d5895463104 |
class SpatialDropout1D(Dropout): <NEW_LINE> <INDENT> def __init__(self, rate, **kwargs): <NEW_LINE> <INDENT> super(SpatialDropout1D, self).__init__(rate, **kwargs) <NEW_LINE> self.input_spec = InputSpec(ndim=3) <NEW_LINE> <DEDENT> def _get_noise_shape(self, inputs): <NEW_LINE> <INDENT> input_shape = K.shape(inputs) <NE... | Spatial 1D version of Dropout.
This version performs the same function as Dropout, however it drops
entire 1D feature maps instead of individual elements. If adjacent frames
within feature maps are strongly correlated (as is normally the case in
early convolution layers) then regular dropout will not regularize the
ac... | 62598f856e29344779b00135 |
class BaseTestCase(TestCase): <NEW_LINE> <INDENT> @classmethod <NEW_LINE> def create_app(cls): <NEW_LINE> <INDENT> app.config.from_object('instance.config.TestingConfig') <NEW_LINE> return app <NEW_LINE> <DEDENT> def setUp(self): <NEW_LINE> <INDENT> self.db = Database(testing="testing") <NEW_LINE> self.cursor = self.db... | Base Tests | 62598f8573bcbd0ca4bc9d22 |
class CacheClassificationLoss(AbstractCacheClassificationLoss): <NEW_LINE> <INDENT> def __init__(self, embedding_key, data_keys, score_transform = None, top_k = None, reducer = tf.math.reduce_mean): <NEW_LINE> <INDENT> self.embedding_key = embedding_key <NEW_LINE> self.data_keys = data_keys <NEW_LINE> self.score_transf... | Implements an efficient way to train with a cache classification loss.
The cache classification loss is the negative log probability of the positive
document when the distribution is the softmax of all documents. This object
allows calculating:
(1) An efficient stochastic loss function whose gradient is approximatel... | 62598f85e64d504609df9119 |
@total_ordering <NEW_LINE> class Nonterminal(object): <NEW_LINE> <INDENT> def __init__(self, symbol): <NEW_LINE> <INDENT> self._symbol = symbol <NEW_LINE> self._hash = hash(symbol) <NEW_LINE> <DEDENT> def symbol(self): <NEW_LINE> <INDENT> return self._symbol <NEW_LINE> <DEDENT> def __eq__(self, other): <NEW_LINE> <INDE... | A non-terminal symbol for a context free grammar. ``Nonterminal``
is a wrapper class for node values; it is used by ``Production``
objects to distinguish node values from leaf values.
The node value that is wrapped by a ``Nonterminal`` is known as its
"symbol". Symbols are typically strings representing phrasal
categ... | 62598f85379a373c97d98ae3 |
class UserRetrieveUpdateView(RetrieveUpdateAPIView): <NEW_LINE> <INDENT> permission_classes = (IsAuthenticated,) <NEW_LINE> renderer_classes = (UserJSONRenderer,) <NEW_LINE> serializer_class = UserSerializer <NEW_LINE> lookup_field = "pk" <NEW_LINE> queryset = User.objects.all() <NEW_LINE> def update(self, request, *ar... | retrieve: fetch a user's details.
update: Modif a user's details. | 62598f8530dc7b766599f329 |
class IdSet(BaseObject): <NEW_LINE> <INDENT> def __init__(self, **kwargs): <NEW_LINE> <INDENT> BaseObject.__init__(self, "IdSet", "idSet") <NEW_LINE> if kwargs: <NEW_LINE> <INDENT> for n, v in ucsgenutils.iteritems(kwargs): <NEW_LINE> <INDENT> self.attr_set(n, v) | This is IdSet class. | 62598f8515baa72349461a4f |
class MyCompany(object): <NEW_LINE> <INDENT> url = 'mycompany.com' | Let access different entities of mycompany.com | 62598f85287bf620b6271685 |
class TestData: <NEW_LINE> <INDENT> def __init__(self, artifact_dir): <NEW_LINE> <INDENT> self.modules = [] <NEW_LINE> self.total = None <NEW_LINE> self.artifact_dir = artifact_dir <NEW_LINE> <DEDENT> def collect(self): <NEW_LINE> <INDENT> print('Generating summary...') <NEW_LINE> data_dict = {} <NEW_LINE> for root, di... | Model for testing results | 62598f8550485f2cf55daa44 |
class CompoundAgent(IxleAgent): <NEW_LINE> <INDENT> subagents = [] <NEW_LINE> def __init__(self, *args, **kargs): <NEW_LINE> <INDENT> self.my_init = [args,kargs] <NEW_LINE> super(CompoundAgent, self).__init__(*args,**kargs) <NEW_LINE> <DEDENT> def __call__(self): <NEW_LINE> <INDENT> args, kargs = self.my_init <NEW_LINE... | Simple agent that executes one or more
agents in certain sequence. The agents
involved should all take the same init
arguments | 62598f850a366e3fb87dc49f |
class IPrincipalInformation(interface.Interface): <NEW_LINE> <INDENT> title = interface.Attribute('Title') <NEW_LINE> firstname = interface.Attribute('First name') <NEW_LINE> lastname = interface.Attribute('Last name') <NEW_LINE> email = interface.Attribute('Email') <NEW_LINE> readonly = interface.Attribute('Readonly i... | principal information for IPrincipal | 62598f8582261d6c5272fc3d |
class AbstractTemplateLoader(Generic[Input, Output]): <NEW_LINE> <INDENT> __metaclass__ = ABCMeta <NEW_LINE> @abstractmethod <NEW_LINE> def load(self, handler_input, template_name, **kwargs): <NEW_LINE> <INDENT> pass | Given template name, load template from data source and store
it as string on TemplateContent object. | 62598f850a50d4780f704eaa |
class AT_030: <NEW_LINE> <INDENT> combo = Hit(TARGET, 1) | Undercity Valiant | 62598f8526068e7796d4c42e |
class UsuarioViewSet(viewsets.ModelViewSet): <NEW_LINE> <INDENT> queryset = Usuario.objects.all() <NEW_LINE> serializer_class = UsuarioSerializer <NEW_LINE> def get_permissions(self): <NEW_LINE> <INDENT> if self.request.method in permissions.SAFE_METHODS: <NEW_LINE> <INDENT> return (permissions.AllowAny(),) <NEW_LINE> ... | Conjunto de vistas que maneja el ABM de usuarios. | 62598f85f8510a7c17d7dee0 |
class Greater(Comparison): <NEW_LINE> <INDENT> compare = operator.gt <NEW_LINE> tag = "greater than" | Constraint that is satisfied when a candidate is greater than a given value | 62598f85d53ae8145f917f61 |
class ShareDB(metaclass=Singleton): <NEW_LINE> <INDENT> block_file = None <NEW_LINE> n = None <NEW_LINE> rate = RateMeter() <NEW_LINE> def __init__(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.n = os.path.getsize(BLOCK_FILE) // 16 <NEW_LINE> <DEDENT> except FileNotFoundError: <NEW_LINE> <INDENT> self.n = 0 ... | store mined shares in a binary file | 62598f8507d97122c4216777 |
class Predictor(object): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.allow_soft_placement = True <NEW_LINE> self.log_device_placement = False <NEW_LINE> self.out_dir = os.path.abspath(os.path.join(os.path.curdir, "runs", "current")) <NEW_LINE> self.checkpoint_dir=os.path.join(self.out_dir, "checkpo... | Loads a trained model and makes predictions | 62598f8515fb5d323ce7e7fe |
class PageMiddleware(object): <NEW_LINE> <INDENT> def process_view(self, request, view_func, view_args, view_kwargs): <NEW_LINE> <INDENT> slug = path_to_slug(request.path_info) <NEW_LINE> pages = Page.objects.with_ascendants_for_slug(slug, for_user=request.user, include_login_required=True) <NEW_LINE> if pages: <NEW_LI... | Adds a page to the template context for the current response.
If no page matches the URL, and the view function is not the
fall-back page view, we try and find the page with the deepest
URL that matches within the current URL, as in this situation,
the app's urlpattern is considered to sit "under" a given page,
for ex... | 62598f857b25080760ed6f79 |
class MplWidget(QWidget): <NEW_LINE> <INDENT> def __init__(self, parent=None): <NEW_LINE> <INDENT> QWidget.__init__(self, parent) <NEW_LINE> self.canvas = MplCanvas() <NEW_LINE> self.vbl = QVBoxLayout() <NEW_LINE> self.ntb = NavigationToolbar(self.canvas, self) <NEW_LINE> self.vbl.addWidget(self.canvas) <NEW_LINE> self... | Widget defined in Qt Designer | 62598f856e29344779b00137 |
class unitDictionary(dict): <NEW_LINE> <INDENT> def __init__(self, inputDictionary = {}): <NEW_LINE> <INDENT> dict.__init__(self, inputDictionary) <NEW_LINE> <DEDENT> def __mul__(self, inputUnitDict): <NEW_LINE> <INDENT> outputUnitDict = copy.copy(self) <NEW_LINE> if type(inputUnitDict) == unitDictionary or type(inputU... | A dictionary subclass used to store units and their powers. | 62598f85e76e3b2f99fd8509 |
class ModuleList(Module): <NEW_LINE> <INDENT> def __init__(self, modules=None): <NEW_LINE> <INDENT> super(ModuleList, self).__init__() <NEW_LINE> if modules is not None: <NEW_LINE> <INDENT> self += modules <NEW_LINE> <DEDENT> <DEDENT> def _get_abs_string_index(self, idx): <NEW_LINE> <INDENT> idx = operator.index(idx) <... | Holds submodules in a list.
:class:`~torch.nn.ModuleList` can be indexed like a regular Python list, but
modules it contains are properly registered, and will be visible by all
:class:`~torch.nn.Module` methods.
Arguments:
modules (iterable, optional): an iterable of modules to add
Example::
class MyModule(... | 62598f858e71fb1e983bb58e |
class Explosion(Effect): <NEW_LINE> <INDENT> def __init__(self, game, pos, images, delay, **kwargs): <NEW_LINE> <INDENT> super().__init__(game, pos, images, delay) <NEW_LINE> self.damage = kwargs['damage'] <NEW_LINE> if 'hit_rect' in kwargs: <NEW_LINE> <INDENT> self.hit_rect = kwargs['hit_rect'] <NEW_LINE> <DEDENT> e... | Effect that also damages enemies or the player | 62598f850fa83653e46f49c0 |
class SessionAffinityValueValuesEnum(_messages.Enum): <NEW_LINE> <INDENT> CLIENT_IP = 0 <NEW_LINE> CLIENT_IP_PROTO = 1 <NEW_LINE> GENERATED_COOKIE = 2 <NEW_LINE> NONE = 3 | Type of session affinity to use.
Values:
CLIENT_IP: <no description>
CLIENT_IP_PROTO: <no description>
GENERATED_COOKIE: <no description>
NONE: <no description> | 62598f8530dc7b766599f32b |
class URLPredictor(BasePredictor): <NEW_LINE> <INDENT> def __init__(self, prediction_api, image): <NEW_LINE> <INDENT> self.prediction_api = prediction_api <NEW_LINE> self.image = image <NEW_LINE> <DEDENT> @property <NEW_LINE> def image_path(self): <NEW_LINE> <INDENT> return self.image.path | This is a URL class predictor for the ResNet model
:param prediction_api: url of the prediction api to send requests to
:type prediction_api: str
:param image: image to be predicted
:type image: `django.db.models.fields.files.ImageFieldFile`
Example:
>>> from ImageQ.search.models import Prediction
>> predict... | 62598f851d351010ab8f360f |
class PawnMovementSpecification(MovementCompositeSpecification): <NEW_LINE> <INDENT> def is_satisfied_by(self, position_from, position_to): <NEW_LINE> <INDENT> piece = position_from.piece <NEW_LINE> if piece is not None and piece.symbol == 'P': <NEW_LINE> <INDENT> specification = ForwardMovementSpecification() ... | Movement specification for valid pawn movements.
| 62598f858a43f66fc4bf1c55 |
class McConochieWindField(WindFieldModel): <NEW_LINE> <INDENT> def field(self, R, lam, vFm, thetaFm, thetaMax=0.): <NEW_LINE> <INDENT> V = self.velocity(R) <NEW_LINE> inflow = 25. * np.ones(np.shape(R)) <NEW_LINE> mid = np.where(R < 1.2 * self.rMax) <NEW_LINE> inflow[mid] = 10. + 75. * (R[mid] / self.rMax - 1.) <NEW_LI... | McConochie, J.D., T.A. Hardy and L.B. Mason, 2004:
Modelling tropical cyclone over-water wind and pressure fields.
Ocean Engineering, 31, 1757-1782 | 62598f85287bf620b6271687 |
class MarketEvent(AbstractEvent): <NEW_LINE> <INDENT> def __init__(self, symbol: str, date_str: str, previous_date: str): <NEW_LINE> <INDENT> super(MarketEvent, self).__init__(symbol, date_str, EventTypeEnum.MARKET) <NEW_LINE> self.previous_date = previous_date <NEW_LINE> <DEDENT> def __str__(self) -> str: <NEW_LINE> <... | Handles the event of receiving a new market update with
corresponding bars. | 62598f85b5575c28eb712a31 |
class City(BaseModel): <NEW_LINE> <INDENT> state_id = "" <NEW_LINE> name = "" | City class that inherits from BaseModel class
| 62598f8524f1403a92685617 |
class IObjectWillBeMovedEvent: <NEW_LINE> <INDENT> pass | An object will be moved. | 62598f85925a0f43d25e7b08 |
class Calculator(object): <NEW_LINE> <INDENT> def __init__(self, adder, subtracter, multiplier, divider): <NEW_LINE> <INDENT> self.adder = adder <NEW_LINE> self.subtracter = subtracter <NEW_LINE> self.multiplier = multiplier <NEW_LINE> self.divider = divider <NEW_LINE> self.stack = [] <NEW_LINE> <DEDENT> def enter_numb... | Calculator class | 62598f853eb6a72ae038a10a |
class MCollective22x(object): <NEW_LINE> <INDENT> rev = '2.2.x' | Mcollective 2.2.x branch integration tests with RabbitMQ | 62598f850a50d4780f704eac |
class Adjunto(models.Model): <NEW_LINE> <INDENT> content_type = models.ForeignKey(ContentType) <NEW_LINE> object_id = models.IntegerField(db_index=True) <NEW_LINE> content_object = generic.GenericForeignKey() <NEW_LINE> nombre = models.CharField(max_length = 150) <NEW_LINE> adjunto = ContentTypeRestrictedFileField(uplo... | Modelo Generico para subir archivos adjuntos a diferentes tipos de contenidos | 62598f85596a897236127747 |
class Rectangle: <NEW_LINE> <INDENT> number_of_instances = 0 <NEW_LINE> print_symbol = "#" <NEW_LINE> def __init__(self, width=0, height=0): <NEW_LINE> <INDENT> self.__width = width <NEW_LINE> self.__height = height <NEW_LINE> Rectangle.number_of_instances += 1 <NEW_LINE> <DEDENT> def __str__(self): <NEW_LINE> <INDENT>... | empty rectangle
| 62598f8591af0d3eaad398d0 |
class CKANQUERYHarvester(Harvester): <NEW_LINE> <INDENT> pageCount = 0 <NEW_LINE> totalCount = 0 <NEW_LINE> rows = 400 <NEW_LINE> numberOfRecordsReturned = 0 <NEW_LINE> def harvest(self): <NEW_LINE> <INDENT> self.setupdirs() <NEW_LINE> self.updateHarvestRequest() <NEW_LINE> self.setUpCrosswalk() <NEW_LINE> self.startPo... | {
"id": "CKANQUERYHarvester",
"title": "CKANQUERY Harvester",
"description": "Retrieving JSON from CKAN by rows of 400",
"params": [
{"name": "uri", "required": "true"},
{"name": "xsl_file", "required": "false"}
]
} | 62598f85d4950a0f3b110b9f |
class BaseShortCodeDefinition(BaseSegment): <NEW_LINE> <INDENT> BITNESS_CODE = None <NEW_LINE> SEGMENT_CODE = None <NEW_LINE> def __init__(self, path_name, short_code): <NEW_LINE> <INDENT> self.path_name = path_name.decode('utf8') if isinstance(path_name, six.binary_type) else path_name <NEW_LINE> self.short_code = sho... | Base class for short code definitions (0x00 - 0x02) | 62598f85f8510a7c17d7dee1 |
class SqlAlchemyModelWrapper(BaseModelWrapper): <NEW_LINE> <INDENT> db = None <NEW_LINE> @classmethod <NEW_LINE> def init(cls, db): <NEW_LINE> <INDENT> cls.db = db <NEW_LINE> <DEDENT> def create(self, **attrs): <NEW_LINE> <INDENT> instance = self.modelClass(**attrs) <NEW_LINE> self.db.session.add(instance) <NEW_LINE> s... | Wrapper for sqlalchemt model | 62598f85d99f1b3c44d05182 |
class AmpBase(AnalogBase): <NEW_LINE> <INDENT> def __init__(self, temp_db, lib_name, params, used_names, **kwargs): <NEW_LINE> <INDENT> super(AmpBase, self).__init__(temp_db, lib_name, params, used_names, **kwargs) <NEW_LINE> <DEDENT> @classmethod <NEW_LINE> def get_params_info(cls): <NEW_LINE> <INDENT> return dict( lc... | A single diff amp.
Parameters
----------
temp_db : TemplateDB
the template database.
lib_name : str
the layout library name.
params : Dict[str, Any]
the parameter values.
used_names : Set[str]
a set of already used cell names.
**kwargs
dictionary of optional parameters. See documentation of
... | 62598f858a349b6b43685d19 |
class Graph: <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.adj: Dict[int, List[Neighbor]] = defaultdict(list) <NEW_LINE> <DEDENT> def _find_neighbor(self, root, neighbor): <NEW_LINE> <INDENT> neighbors = self.adj[root] <NEW_LINE> try: <NEW_LINE> <INDENT> i = neighbors.index(Neighbor(id=neighbor, weig... | Graph ADT | 62598f8538b623060ffa8b6b |
class Author(Person): <NEW_LINE> <INDENT> def __init__(self, first_name, last_name, age, years): <NEW_LINE> <INDENT> Person.__init__(self, first_name, last_name, age) <NEW_LINE> self.years = years <NEW_LINE> <DEDENT> def show_all_information(self): <NEW_LINE> <INDENT> pprint("Author name - {}".format(self.__dict__['nam... | Class which represent author
Attributes:
Person attributes
years (str): Years of authors life. | 62598f850fa83653e46f49c3 |
class ColoredFormatter (Formatter): <NEW_LINE> <INDENT> def __init__ (self, format, datefmt=None, log_colors=default_log_colors, reset=True, style='%'): <NEW_LINE> <INDENT> if version_info > (3, 2): <NEW_LINE> <INDENT> super(ColoredFormatter, self).__init__(format, datefmt, style=style) <NEW_LINE> <DEDENT> elif version... | A formatter that allows colors to be placed in the format string, intended to help in creating prettier, more readable logging output. | 62598f85c432627299fa2aa4 |
class HpfToolbarSpinner(FloatSpin): <NEW_LINE> <INDENT> def __init__(self, parent_toolbar, hpfcutoff, delta, minValue=0, maxValue=100, digits=1, style=FS_CENTRE|FS_READONLY): <NEW_LINE> <INDENT> FloatSpin.__init__(self, parent_toolbar, value=hpfcutoff, min_val=minValue, max_val=maxValue, increment=delta, digits=digits,... | A spinner box for HPF control embedded in a toolbar | 62598f851d351010ab8f3611 |
class ClientListView(LoginRequiredMixin, ListView): <NEW_LINE> <INDENT> model = Client | List of clients. | 62598f8507f4c71912baef19 |
class Welcome(BlogHandler): <NEW_LINE> <INDENT> def get(self): <NEW_LINE> <INDENT> if self.user: <NEW_LINE> <INDENT> self.render('welcome.html', username=self.user.name) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.redirect('/signup') | Welcome: Handler for Welcome
Args:
BlogHandler: Blog Handler | 62598f8515baa72349461a53 |
class TestReadIds(TestCase): <NEW_LINE> <INDENT> @classmethod <NEW_LINE> def setUpClass(cls): <NEW_LINE> <INDENT> cls.temp_dir = tempfile.mkdtemp() <NEW_LINE> <DEDENT> @classmethod <NEW_LINE> def tearDownClass(cls): <NEW_LINE> <INDENT> shutil.rmtree(cls.temp_dir) <NEW_LINE> <DEDENT> def get_temp_file(self): <NEW_LINE> ... | Exercise read_ids() | 62598f8545492302aabfbfb3 |
class AddIssues(IssuesMixin, FormSetView, NotificationMixin): <NEW_LINE> <INDENT> formset_model = Issue <NEW_LINE> formset_form_class = IssueForm <NEW_LINE> msg_tpl = "New Issue '%s' was created <%s%s>\n\n%s" <NEW_LINE> extra = 5 <NEW_LINE> template_name = "add_issues.html" <NEW_LINE> ... | Create new issues. | 62598f8524f1403a92685618 |
class Piece(BaseObj): <NEW_LINE> <INDENT> def __init__(self, nom, couleur, points, fem=True): <NEW_LINE> <INDENT> BaseObj.__init__(self) <NEW_LINE> self.nom = nom <NEW_LINE> self._couleur = couleur <NEW_LINE> self.points = points <NEW_LINE> self.fem = fem <NEW_LINE> self._construire() <NEW_LINE> <DEDENT> def __getnewar... | Classe représentant une pièce du poquiir. | 62598f85442bda511e95bf31 |
class ApplicationError(Exception): <NEW_LINE> <INDENT> pass | Raised by application logic.l | 62598f855f7d997b871f9143 |
class ReverseData(PairSequenceData): <NEW_LINE> <INDENT> @staticmethod <NEW_LINE> def make_data(num_data, num_symbols, length, tf_ratio=0.5): <NEW_LINE> <INDENT> lst = [x+1 for x in range(num_symbols)] <NEW_LINE> def make_true(): <NEW_LINE> <INDENT> seq1 = [random.choice(lst) for _ in range(length)] <NEW_LINE> seq2 = s... | Toy data for determining if the pair is reverse or not | 62598f85d4950a0f3b110ba0 |
class TaskManager(DependencyGraph): <NEW_LINE> <INDENT> def __init__(self, tasks, file_context): <NEW_LINE> <INDENT> DependencyGraph.__init__(self, tasks, "taskmanager") <NEW_LINE> self.__file_context = file_context <NEW_LINE> self.__locked = True <NEW_LINE> <DEDENT> def apply(self, input_args): <NEW_LINE> <INDENT> if ... | Uses the json file to fetch the data then performs a list of tasks.
This works the same way as a Preprocessor except that the file context
is used as input and it runs once. | 62598f858da39b475be02cbc |
class WrappedJSONRenderer(JSONRenderer): <NEW_LINE> <INDENT> def render(self, data, accepted_media_type=None, renderer_context=None): <NEW_LINE> <INDENT> if isinstance(data, list): <NEW_LINE> <INDENT> view = renderer_context.get('view') <NEW_LINE> serializer = view.get_serializer() <NEW_LINE> wrapper_name = getattr(ser... | This Renderer wraps array responses in a JSON object. The goal is to prevent attacks like:
http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx/ | 62598f85a4f1c619b294e0c3 |
class LayerNorm(nn.Module): <NEW_LINE> <INDENT> def __init__(self, last_dim_size, eps=1e-6): <NEW_LINE> <INDENT> super(LayerNorm, self).__init__() <NEW_LINE> self._a_2 = nn.Parameter(torch.ones(last_dim_size)) <NEW_LINE> self._b_2 = nn.Parameter(torch.zeros(last_dim_size)) <NEW_LINE> self._eps = eps <NEW_LINE> <DEDENT>... | Layer Normalization (https://arxiv.org/pdf/1607.06450.pdf). | 62598f85a4f1c619b294e0c4 |
class Float(Typed): <NEW_LINE> <INDENT> _expected_type = float | Add float data building block. | 62598f857c178a314d78cf83 |
class Editor(object): <NEW_LINE> <INDENT> def __init__(self, filename, hlptext=None, vb=None, master=None, initialdir="CFG/ltu/SLM", suffix="*.slm"): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> f= open(filename); <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> print("File %s cannot be opened"%filename) <NEW_LINE> retu... | Usage:
fe= Editor("WORK/SSMa.txt", helptext) | 62598f858e71fb1e983bb590 |
class Client_Test(unittest.TestCase): <NEW_LINE> <INDENT> URL = 'http://dashboard.example/' <NEW_LINE> CANONICAL_URL = 'http://dashboard.example' <NEW_LINE> def setUp(self): <NEW_LINE> <INDENT> super(Client_Test, self).setUp() <NEW_LINE> self.client = Client(self.URL, other='data') <NEW_LINE> <DEDENT> def test_base_url... | Tests for the generic client base class. | 62598f85462c4b4f79dbb4da |
class RandomAgentDownloaderMiddleware(object): <NEW_LINE> <INDENT> agent_manager = AgentManager() <NEW_LINE> def process_request(self, request, spider): <NEW_LINE> <INDENT> agent = self.agent_manager.random_agent() <NEW_LINE> request.headers.setdefault('User-Agent', agent) | 随机 agent | 62598f85507cdc57c63a4864 |
class Glm(Package): <NEW_LINE> <INDENT> homepage = "https://github.com/g-truc/glm" <NEW_LINE> url = "https://github.com/g-truc/glm/archive/0.9.7.1.tar.gz" <NEW_LINE> version('0.9.7.1', '61af6639cdf652d1cdd7117190afced8') <NEW_LINE> depends_on('cmake', type='build') <NEW_LINE> def install(self, spec, prefix): <NEW_LINE>... | OpenGL Mathematics (GLM) is a header only C++ mathematics library for graphics software based on
the OpenGL Shading Language (GLSL) specification. | 62598f85287bf620b627168b |
class SVC(BaseLibSVM, ClassifierMixin): <NEW_LINE> <INDENT> def __init__(self, C=1.0, kernel='rbf', degree=3, gamma=0.0, coef0=0.0, shrinking=True, probability=False, tol=1e-3, cache_size=100.0): <NEW_LINE> <INDENT> BaseLibSVM.__init__(self, 'c_svc', kernel, degree, gamma, coef0, cache_size, tol, C, 0., 0., shrinking, ... | C-Support Vector Classification.
Parameters
----------
C : float, optional (default=1.0)
penalty parameter C of the error term.
kernel : string, optional
Specifies the kernel type to be used in the algorithm.
one of 'linear', 'poly', 'rbf', 'sigmoid', 'precomputed'.
If none is given 'rbf' will be u... | 62598f85ec188e330fdf8375 |
class Python(Package): <NEW_LINE> <INDENT> def __init__(self, version: str): <NEW_LINE> <INDENT> self.version = version <NEW_LINE> <DEDENT> def ident(self): <NEW_LINE> <INDENT> return 'python-' + self.version <NEW_LINE> <DEDENT> def binary(self) -> str: <NEW_LINE> <INDENT> return 'python' + self.version <NEW_LINE> <DED... | Artificial dependency package for arbitrary Python version. Just checks if
the version is installed.
:param version: which version to check for | 62598f85656771135c489152 |
class BaseThread(Thread): <NEW_LINE> <INDENT> def __init__(self, **kw): <NEW_LINE> <INDENT> Thread.__init__(self, **kw) <NEW_LINE> self._ev_stop = Event() <NEW_LINE> self.log = logging.getLogger() <NEW_LINE> <DEDENT> def need_stop(self): <NEW_LINE> <INDENT> self._ev_stop.isSet() <NEW_LINE> <DEDENT> def stop(self): <NEW... | 基础的线程类
实现停止功能和日志记录 | 62598f85cad5886f8bdc4df5 |
class BlockAwareTemplateResponseMixin(TemplateResponseMixin): <NEW_LINE> <INDENT> response_class = BlockAwareTemplateResponse | A mixin to enable partial (block) rendering in class based views
You can use it like this::
class MyView(BlockAwareTemplateResponseMixin, TemplateView):
pass | 62598f8529b78933be269e46 |
class SingleNode(object): <NEW_LINE> <INDENT> def __init__(self, elem): <NEW_LINE> <INDENT> self.elem = elem <NEW_LINE> self.next = None <NEW_LINE> <DEDENT> def __repr__(self): <NEW_LINE> <INDENT> return str(self.elem) + "(单向链表节点:后(" + str(self.next.elem if self.next else None) + "))" | 单向链表节点 | 62598f85925a0f43d25e7b0c |
class krb5_fatype(Enum): <NEW_LINE> <INDENT> _enumdict = const.krb5_fatype | enum krb5_fatype | 62598f85fb3f5b602db47f1c |
class TxRcvType(Serializable): <NEW_LINE> <INDENT> _fields = ('TxWFId', 'RcvId') <NEW_LINE> _required = _fields <NEW_LINE> _collections_tags = { 'TxWFId': {'array': False, 'child_tag': 'TxWFId'}, 'RcvId': {'array': False, 'child_tag': 'RcvId'}} <NEW_LINE> TxWFId = StringListDescriptor( 'TxWFId', _required, strict=DEFAU... | Parameters to identify the Transmit and Receive parameter sets used to collect the signal array. | 62598f8526068e7796d4c434 |
class TestDestinyDefinitionsDestinyBubbleDefinition(unittest.TestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def tearDown(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def testDestinyDefinitionsDestinyBubbleDefinition(self): <NEW_LINE> <INDENT> pass | DestinyDefinitionsDestinyBubbleDefinition unit test stubs | 62598f8507d97122c421677c |
class ApiTestCase(TestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> super(ApiTestCase, self).setUp() <NEW_LINE> self.api_url = reverse('chatterbot:chatterbot') <NEW_LINE> <DEDENT> def test_post(self): <NEW_LINE> <INDENT> data = { 'text': 'How are you?' } <NEW_LINE> response = self.client.post( self.ap... | Tests to make sure that the ChatterBot app is
properly working with the Django example app. | 62598f85004d5f362081ed65 |
class Robot(object): <NEW_LINE> <INDENT> def __init__(self, room, speed = 1): <NEW_LINE> <INDENT> self.room = room <NEW_LINE> self.speed = speed <NEW_LINE> self.direction = random.randrange(360) <NEW_LINE> self.location = room.getRandomPosition() <NEW_LINE> self.room.cleanTileAtPosition(self.location) <NEW_LINE> <DEDEN... | Represents a robot cleaning a particular room.
At all times the robot has a particular position and direction in the room.
The robot also has a fixed speed.
Subclasses of Robot should provide movement strategies by implementing
updatePositionAndClean(), which simulates a single time-step. | 62598f858da39b475be02cbe |
class ICPSkinAgendaLayer(IBrowserLayer): <NEW_LINE> <INDENT> pass | Marker interface that defines a ZTK browser layer. | 62598f85b7558d589546310c |
class ConnectorMeta(ABCMeta, type(BaseClass)): <NEW_LINE> <INDENT> pass | Connector metaclass wrapper.
This trick is needed when you want to use more than one metaclass
for a given class. | 62598f856e29344779b0013d |
class TypedListSequence(ListSequence): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.sequence = TypedList() | A typed sequence with a wrapper for a list under the hood. | 62598f85e76e3b2f99fd850f |
class Expression20(Expression): <NEW_LINE> <INDENT> def get(self, instance): <NEW_LINE> <INDENT> raise NotImplementedError('%s not implemented' % ( str(self))) | System->CPU speed (MHz)
Return type: Int | 62598f859b70327d1c57e876 |
class PdfFileWriter(BasePdfFileWriter): <NEW_LINE> <INDENT> def __init__(self, stream_xrefs=True, init_page_tree=True): <NEW_LINE> <INDENT> root = generic.DictionaryObject({ pdf_name("/Type"): pdf_name("/Catalog"), }) <NEW_LINE> id1 = generic.ByteStringObject(os.urandom(16)) <NEW_LINE> id2 = generic.ByteStringObject(os... | Class to write new PDF files. | 62598f8507f4c71912baef1c |
class AbstractMonitor(object): <NEW_LINE> <INDENT> def __init__(self, eventTypes, pathMode, pathString, whitelist, blacklist, ignoreSysFiles, ignoreDirEvents, proxy, monitorId): <NEW_LINE> <INDENT> self.log = logging.getLogger("fsclient." + __name__) <NEW_LINE> self.proxy = proxy <NEW_LINE> self.monitorId = monitorId <... | Abstract Monitor.
:group Constructor: __init__
:group Other methods: run, stop, callback | 62598f8521a7993f00c65a4c |
class PostViewSet(BaseRedirectListViewSet): <NEW_LINE> <INDENT> queryset = Post.objects.all().order_by('-date') <NEW_LINE> serializer_class = PostSerializer <NEW_LINE> def perform_create(self, serializer): <NEW_LINE> <INDENT> serializer.save(user=self.request.user) <NEW_LINE> <DEDENT> def create(self, request): <NEW_LI... | REST API endpoint for viewing/editing Threads.
Inherits from BaseRedirectViewSet as listing all posts regardless of thread should not be possible. | 62598f856fb2d068a7693b9b |
class Context(commands.Context): <NEW_LINE> <INDENT> class Color(enum.IntEnum): <NEW_LINE> <INDENT> GOOD = 0x7DB358 <NEW_LINE> I_GUESS = 0xF9AE36 <NEW_LINE> BAD = 0xD52D48 <NEW_LINE> AUTOMATIC_BLUE = 0x1C669B <NEW_LINE> <DEDENT> @property <NEW_LINE> def log(self) -> logging.Logger: <NEW_LINE> <INDENT> name = self.comma... | A context that does other useful things. | 62598f858a43f66fc4bf1c5b |
class TestingConfig(Config): <NEW_LINE> <INDENT> TESTING = True <NEW_LINE> SQLALCHEMY_DATABASE_URI = 'sqlite:///test_bucketlist.db' <NEW_LINE> DEBUG = True | Configurations for Testing, with a separate test database. | 62598f85ec188e330fdf8377 |
class PrivateTagsApiTests(TestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> self.user = get_user_model().objects.create_user( email='teste@email.com', password='senhasenhada' ) <NEW_LINE> self.client = APIClient() <NEW_LINE> self.client.force_authenticate(self.user) <NEW_LINE> <DEDENT> def test_retrie... | Testa recursos privados do endpoit de Tags | 62598f8550485f2cf55daa4c |
class SequenceParameter(Parameter): <NEW_LINE> <INDENT> _type = tuple <NEW_LINE> def __init__(self, element_type, default=(), aliases=(), validation=None, string_delimiter=','): <NEW_LINE> <INDENT> self._element_type = element_type <NEW_LINE> self.string_delimiter = string_delimiter <NEW_LINE> super(SequenceParameter, ... | Parameter type for a Configuration class that holds a sequence (i.e. list) of python
primitive values. | 62598f8526238365f5fac647 |
class Session(BaseKeychainSession): <NEW_LINE> <INDENT> _adapter_class = SecureTransportAdapter | Requests session using the SecureTransport | 62598f85dc8b845886d5308f |
@dataclass <NEW_LINE> class ToadsAndFrogsRow: <NEW_LINE> <INDENT> spaces: List[int] <NEW_LINE> def __post_init__(self): <NEW_LINE> <INDENT> assert set(self.spaces) == {1, 0, -1} <NEW_LINE> <DEDENT> def move(self, idx): <NEW_LINE> <INDENT> direction = self.spaces[idx] <NEW_LINE> try: <NEW_LINE> <INDENT> self._move(idx, ... | A row in toads and frogs. 0
represents a blank space, 1 represents
a Toad, -1 represents a frog. | 62598f8563b5f9789fe84c4a |
class DataGenerator(seq): <NEW_LINE> <INDENT> def __init__(self, figure_path, label_path, file_names, num_classes, dimensions=(224,224), batch_size=16, n_channels=1, shuffle=True): <NEW_LINE> <INDENT> self.dimensions = dimensions <NEW_LINE> self.batch_size = batch_size <NEW_LINE> self.n_channels = n_channels <NEW_LINE>... | this class is handled using a lot of function overloading, I believe
determination of how the generation will parse batches
essentially, pass the contents of a folder (specifically a list of file names)
it will then
Heavily influenced by https://stanford.edu/~shervine/blog/keras-how-to-generate-data-on-the-fly
by Afsh... | 62598f850a366e3fb87dc4a7 |
class LogRouter(): <NEW_LINE> <INDENT> def db_for_read(self, model, **hints): <NEW_LINE> <INDENT> if model._meta.app_label == 'logs': <NEW_LINE> <INDENT> return 'logs' <NEW_LINE> <DEDENT> return None <NEW_LINE> <DEDENT> def db_for_write(self, model, **hints): <NEW_LINE> <INDENT> if model._meta.app_label == 'logs': <NEW... | A router to control all database operations on models in the
logs application. | 62598f85925a0f43d25e7b0e |
class TimestampedModel(models.Model): <NEW_LINE> <INDENT> created_at = models.DateTimeField(_('Created at'), default=timezone.now) <NEW_LINE> updated_at = models.DateTimeField(_('Updated at'), auto_now=True) <NEW_LINE> class Meta: <NEW_LINE> <INDENT> abstract = True | Provides self-updating created_at and updated_at fields.
| 62598f85b57a9660fecd1556 |
class TFmini(object): <NEW_LINE> <INDENT> NOHEADER = 1 <NEW_LINE> BADCHECKSUM = 2 <NEW_LINE> TOO_MANY_TRIES = 3 <NEW_LINE> def __init__(self, port, retry=25): <NEW_LINE> <INDENT> self.serial = Serial() <NEW_LINE> self.serial.port = port <NEW_LINE> self.serial.baudrate = 115200 <NEW_LINE> self.serial.timeout = 0.005 <NE... | TFMini - Micro LiDAR Module
https://www.sparkfun.com/products/14577
http://www.benewake.com/en/tfmini.html | 62598f85baa26c4b54d4ed8c |
class StudentBodyMovementResult(AbstractModel): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.Confidence = None <NEW_LINE> self.HandupConfidence = None <NEW_LINE> self.HandupStatus = None <NEW_LINE> self.Height = None <NEW_LINE> self.Left = None <NEW_LINE> self.Movements = None <NEW_LINE> self.StandC... | 学生肢体动作结果
| 62598f858da39b475be02cc0 |
class Data(object): <NEW_LINE> <INDENT> def __init__(self, d): <NEW_LINE> <INDENT> self._dict = d <NEW_LINE> <DEDENT> def __getattribute__(self, *args, **kw): <NEW_LINE> <INDENT> name = args[0] <NEW_LINE> if name == "_dict": <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> d = object.__getattribute__(self, *args, **kw) <NE... | 假装自己是row-object | 62598f85498bea3a75a575fe |
class MarkdownModel(ChartVisualization): <NEW_LINE> <INDENT> def get_data(self): <NEW_LINE> <INDENT> text = self.params.get('text') <NEW_LINE> if text is None: <NEW_LINE> <INDENT> raise ValueError( _("Parameter '{}' must be informed for task {}").format( 'text', 'Markdown')) <NEW_LINE> <DEDENT> return {'data': {'text':... | Markdown visualization. | 62598f8507f4c71912baef1e |
class UserFollowedView(View): <NEW_LINE> <INDENT> @login_required <NEW_LINE> def get(self, request): <NEW_LINE> <INDENT> id = request.session['user']['id'] <NEW_LINE> user = User.objects.get(id=id) <NEW_LINE> followed_users = User.objects.filter(follow__follow_user_id=id) <NEW_LINE> follow_users = User.objects.filter(f... | 关注我的 视图 | 62598f85a17c0f6771d5bd1d |
class Id3tool: <NEW_LINE> <INDENT> def __init__(self, fn): <NEW_LINE> <INDENT> if fnmatch.fnmatch(fn, '*.ogg'): <NEW_LINE> <INDENT> self.tag_obj = OggVorbis(fn) <NEW_LINE> <DEDENT> elif fnmatch.fnmatch(fn, '*.flac'): <NEW_LINE> <INDENT> self.tag_obj = FLAC(fn) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.tag_obj ... | class to read/write mp3 tags | 62598f85f7d966606f747ac3 |
class LimeObjects: <NEW_LINE> <INDENT> def __init__(self, lime_client): <NEW_LINE> <INDENT> self.lime_client = lime_client <NEW_LINE> <DEDENT> def get_object_by_url(self, url): <NEW_LINE> <INDENT> parsed = urlparse(url) <NEW_LINE> if not parsed.query: <NEW_LINE> <INDENT> url += '?_embed=all' <NEW_LINE> <DEDENT> r = sel... | Get, update or delete one or multiple lime objects.
:param lime_client: a logged in :class:`LimeClient` instance | 62598f8550485f2cf55daa4e |
@register_unpacker(('application/zip', None)) <NEW_LINE> class ZipFileUnpacker(UnpackerImplementation): <NEW_LINE> <INDENT> def unpack(self, archive_path, target_path, progress): <NEW_LINE> <INDENT> if not zipfile.is_zipfile(archive_path): <NEW_LINE> <INDENT> raise TeapotError( "%s is not a valid zip archive.", hl(arch... | An unpacker class that deals with .zip files. | 62598f8507f4c71912baef1f |
class nC_APD(mb.Compound): <NEW_LINE> <INDENT> def __init__(self, chain_length): <NEW_LINE> <INDENT> super(nC_APD, self).__init__() <NEW_LINE> alkane = Alkane(chain_length, cap_end=False) <NEW_LINE> self.add(alkane, 'alkane') <NEW_LINE> apd = APD() <NEW_LINE> self.add(apd, 'apd') <NEW_LINE> mb.force_overlap(self['alkan... | Aminopropyl dopamine functionalized with an alkane chain. | 62598f85b57a9660fecd1557 |
class RectangularRoom(object): <NEW_LINE> <INDENT> def __init__(self, width, height, dirt_amount): <NEW_LINE> <INDENT> raise NotImplementedError <NEW_LINE> <DEDENT> def clean_tile_at_position(self, pos, capacity): <NEW_LINE> <INDENT> raise NotImplementedError <NEW_LINE> <DEDENT> def is_tile_cleaned(self, m, n): <NEW_LI... | A RectangularRoom represents a rectangular region containing clean or dirty
tiles.
A room has a width and a height and contains (width * height) tiles. Each tile
has some fixed amount of dirt. The tile is considered clean only when the amount
of dirt on this tile is 0. | 62598f85b5575c28eb712a35 |
class IFtwFooterLayer(Interface): <NEW_LINE> <INDENT> pass | Request marker interface | 62598f8545492302aabfbfb9 |
class HideMixinsFilter(logging.Filter): <NEW_LINE> <INDENT> def filter(self, record): <NEW_LINE> <INDENT> if record.filename.endswith('mixins.py'): <NEW_LINE> <INDENT> record.filename, record.lineno, record.funcName = self.find_caller() <NEW_LINE> <DEDENT> return True <NEW_LINE> <DEDENT> def find_caller(self): <NEW_LIN... | A logging.Filter that hides mixins.py in log messages.
Using the HideMixinsFilter in a logging adapter will cause the filename and line numbers
in log messages to be set to the caller of mixins functions, rather than just seeing
the line number in mixings.py that calls logger.error | 62598f8523e79379d538bfd6 |
class InvalidXMLError(MinioError): <NEW_LINE> <INDENT> pass | InvalidXMLError is raised when an unexpected XML tag or
a missing tag is found during parsing. | 62598f8523849d37ff850b99 |
class InvalidConfigFileError(Exception): <NEW_LINE> <INDENT> pass | An exception for when the config file is invalid. | 62598f85009cb60464d01007 |
class MediaPlayerImageView(HomeAssistantView): <NEW_LINE> <INDENT> requires_auth = False <NEW_LINE> url = '/api/media_player_proxy/{entity_id}' <NEW_LINE> name = 'api:media_player:image' <NEW_LINE> def __init__(self, component): <NEW_LINE> <INDENT> self.component = component <NEW_LINE> <DEDENT> async def get(self, requ... | Media player view to serve an image. | 62598f8523e79379d538bfd7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.