Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
add_ratelimit_rule
(range_seconds: int, num_requests: int, domain: str = "api_by_user")
Add a rate-limiting rule to the ratelimiter
Add a rate-limiting rule to the ratelimiter
def add_ratelimit_rule(range_seconds: int, num_requests: int, domain: str = "api_by_user") -> None: "Add a rate-limiting rule to the ratelimiter" global rules if domain not in rules: # If we don't have any rules for domain yet, the domain key needs to be # added to the rules dictionary. ...
[ "def", "add_ratelimit_rule", "(", "range_seconds", ":", "int", ",", "num_requests", ":", "int", ",", "domain", ":", "str", "=", "\"api_by_user\"", ")", "->", "None", ":", "global", "rules", "if", "domain", "not", "in", "rules", ":", "# If we don't have any rul...
[ 139, 0 ]
[ 149, 42 ]
python
en
['en', 'en', 'en']
True
RateLimitedObject.block_access
(self, seconds: int)
Manually blocks an entity for the desired number of seconds
Manually blocks an entity for the desired number of seconds
def block_access(self, seconds: int) -> None: "Manually blocks an entity for the desired number of seconds" self.backend.block_access(self.key(), seconds)
[ "def", "block_access", "(", "self", ",", "seconds", ":", "int", ")", "->", "None", ":", "self", ".", "backend", ".", "block_access", "(", "self", ".", "key", "(", ")", ",", "seconds", ")" ]
[ 66, 4 ]
[ 68, 54 ]
python
en
['en', 'en', 'en']
True
RateLimitedObject.max_api_calls
(self)
Returns the API rate limit for the highest limit
Returns the API rate limit for the highest limit
def max_api_calls(self) -> int: "Returns the API rate limit for the highest limit" return self.get_rules()[-1][1]
[ "def", "max_api_calls", "(", "self", ")", "->", "int", ":", "return", "self", ".", "get_rules", "(", ")", "[", "-", "1", "]", "[", "1", "]" ]
[ 76, 4 ]
[ 78, 38 ]
python
en
['en', 'en', 'en']
True
RateLimitedObject.max_api_window
(self)
Returns the API time window for the highest limit
Returns the API time window for the highest limit
def max_api_window(self) -> int: "Returns the API time window for the highest limit" return self.get_rules()[-1][0]
[ "def", "max_api_window", "(", "self", ")", "->", "int", ":", "return", "self", ".", "get_rules", "(", ")", "[", "-", "1", "]", "[", "0", "]" ]
[ 80, 4 ]
[ 82, 38 ]
python
en
['en', 'en', 'en']
True
RateLimitedObject.api_calls_left
(self)
Returns how many API calls in this range this client has, as well as when the rate-limit will be reset to 0
Returns how many API calls in this range this client has, as well as when the rate-limit will be reset to 0
def api_calls_left(self) -> Tuple[int, float]: """Returns how many API calls in this range this client has, as well as when the rate-limit will be reset to 0""" max_window = self.max_api_window() max_calls = self.max_api_calls() return self.backend.get_api_calls_left(self.key(), ...
[ "def", "api_calls_left", "(", "self", ")", "->", "Tuple", "[", "int", ",", "float", "]", ":", "max_window", "=", "self", ".", "max_api_window", "(", ")", "max_calls", "=", "self", ".", "max_api_calls", "(", ")", "return", "self", ".", "backend", ".", "...
[ 84, 4 ]
[ 89, 81 ]
python
en
['en', 'en', 'en']
True
RateLimitedObject.get_rules
(self)
This is a simple wrapper meant to protect against having to deal with an empty list of rules, as it would require fiddling with that special case all around this system. "9999 max request per seconds" should be a good proxy for "no rules".
This is a simple wrapper meant to protect against having to deal with an empty list of rules, as it would require fiddling with that special case all around this system. "9999 max request per seconds" should be a good proxy for "no rules".
def get_rules(self) -> List[Tuple[int, int]]: """ This is a simple wrapper meant to protect against having to deal with an empty list of rules, as it would require fiddling with that special case all around this system. "9999 max request per seconds" should be a good proxy for "n...
[ "def", "get_rules", "(", "self", ")", "->", "List", "[", "Tuple", "[", "int", ",", "int", "]", "]", ":", "rules_list", "=", "self", ".", "rules", "(", ")", "return", "rules_list", "or", "[", "(", "1", ",", "9999", ")", "]" ]
[ 91, 4 ]
[ 99, 40 ]
python
en
['en', 'error', 'th']
False
RateLimiterBackend.block_access
(cls, entity_key: str, seconds: int)
Manually blocks an entity for the desired number of seconds
Manually blocks an entity for the desired number of seconds
def block_access(cls, entity_key: str, seconds: int) -> None: "Manually blocks an entity for the desired number of seconds"
[ "def", "block_access", "(", "cls", ",", "entity_key", ":", "str", ",", "seconds", ":", "int", ")", "->", "None", ":" ]
[ 162, 4 ]
[ 163, 69 ]
python
en
['en', 'en', 'en']
True
TornadoInMemoryRateLimiterBackend.need_to_limit
(cls, entity_key: str, time_window: int, max_count: int)
Returns a tuple of `(rate_limited, time_till_free)`. For simplicity, we have loosened the semantics here from - each key may make atmost `count * (t / window)` request within any t time interval. to - each key may make atmost `count * [(t / window) + 1]` request within...
Returns a tuple of `(rate_limited, time_till_free)`. For simplicity, we have loosened the semantics here from - each key may make atmost `count * (t / window)` request within any t time interval. to - each key may make atmost `count * [(t / window) + 1]` request within...
def need_to_limit(cls, entity_key: str, time_window: int, max_count: int) -> Tuple[bool, float]: """ Returns a tuple of `(rate_limited, time_till_free)`. For simplicity, we have loosened the semantics here from - each key may make atmost `count * (t / window)` request within any t ...
[ "def", "need_to_limit", "(", "cls", ",", "entity_key", ":", "str", ",", "time_window", ":", "int", ",", "max_count", ":", "int", ")", "->", "Tuple", "[", "bool", ",", "float", "]", ":", "now", "=", "time", ".", "time", "(", ")", "# Remove all timestamp...
[ 224, 4 ]
[ 254, 25 ]
python
en
['en', 'error', 'th']
False
RedisRateLimiterBackend.block_access
(cls, entity_key: str, seconds: int)
Manually blocks an entity for the desired number of seconds
Manually blocks an entity for the desired number of seconds
def block_access(cls, entity_key: str, seconds: int) -> None: "Manually blocks an entity for the desired number of seconds" _, _, blocking_key = cls.get_keys(entity_key) with client.pipeline() as pipe: pipe.set(blocking_key, 1) pipe.expire(blocking_key, seconds) ...
[ "def", "block_access", "(", "cls", ",", "entity_key", ":", "str", ",", "seconds", ":", "int", ")", "->", "None", ":", "_", ",", "_", ",", "blocking_key", "=", "cls", ".", "get_keys", "(", "entity_key", ")", "with", "client", ".", "pipeline", "(", ")"...
[ 318, 4 ]
[ 324, 26 ]
python
en
['en', 'en', 'en']
True
RedisRateLimiterBackend.is_ratelimited
(cls, entity_key: str, rules: List[Tuple[int, int]])
Returns a tuple of (rate_limited, time_till_free)
Returns a tuple of (rate_limited, time_till_free)
def is_ratelimited(cls, entity_key: str, rules: List[Tuple[int, int]]) -> Tuple[bool, float]: "Returns a tuple of (rate_limited, time_till_free)" assert rules list_key, set_key, blocking_key = cls.get_keys(entity_key) # Go through the rules from shortest to longest, # seeing if ...
[ "def", "is_ratelimited", "(", "cls", ",", "entity_key", ":", "str", ",", "rules", ":", "List", "[", "Tuple", "[", "int", ",", "int", "]", "]", ")", "->", "Tuple", "[", "bool", ",", "float", "]", ":", "assert", "rules", "list_key", ",", "set_key", "...
[ 367, 4 ]
[ 409, 25 ]
python
en
['en', 'en', 'en']
True
RedisRateLimiterBackend.incr_ratelimit
(cls, entity_key: str, max_api_calls: int, max_api_window: int)
Increases the rate-limit for the specified entity
Increases the rate-limit for the specified entity
def incr_ratelimit(cls, entity_key: str, max_api_calls: int, max_api_window: int) -> None: """Increases the rate-limit for the specified entity""" list_key, set_key, _ = cls.get_keys(entity_key) now = time.time() # Start Redis transaction with client.pipeline() as pipe: ...
[ "def", "incr_ratelimit", "(", "cls", ",", "entity_key", ":", "str", ",", "max_api_calls", ":", "int", ",", "max_api_window", ":", "int", ")", "->", "None", ":", "list_key", ",", "set_key", ",", "_", "=", "cls", ".", "get_keys", "(", "entity_key", ")", ...
[ 412, 4 ]
[ 463, 28 ]
python
en
['en', 'en', 'en']
True
EditMessageTestCase.check_message
(self, msg_id: int, topic_name: str, content: str)
We assume our caller just edited a message. Next, we will make sure we properly cached the messages. We still have to do a query to hydrate recipient info, but we won't need to hit the zerver_message table.
We assume our caller just edited a message.
def check_message(self, msg_id: int, topic_name: str, content: str) -> None: # Make sure we saved the message correctly to the DB. msg = Message.objects.get(id=msg_id) self.assertEqual(msg.topic_name(), topic_name) self.assertEqual(msg.content, content) """ We assume our...
[ "def", "check_message", "(", "self", ",", "msg_id", ":", "int", ",", "topic_name", ":", "str", ",", "content", ":", "str", ")", "->", "None", ":", "# Make sure we saved the message correctly to the DB.", "msg", "=", "Message", ".", "objects", ".", "get", "(", ...
[ 31, 4 ]
[ 76, 13 ]
python
en
['en', 'error', 'th']
False
EditMessageTest.test_save_message
(self)
This is also tested by a client test, but here we can verify the cache against the database
This is also tested by a client test, but here we can verify the cache against the database
def test_save_message(self) -> None: """This is also tested by a client test, but here we can verify the cache against the database""" self.login("hamlet") msg_id = self.send_stream_message( self.example_user("hamlet"), "Scotland", topic_name="editing", content="before edit" ...
[ "def", "test_save_message", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "msg_id", "=", "self", ".", "send_stream_message", "(", "self", ".", "example_user", "(", "\"hamlet\"", ")", ",", "\"Scotland\"", ",", "topic_name"...
[ 262, 4 ]
[ 287, 53 ]
python
en
['en', 'en', 'en']
True
EditMessageTest.test_edit_cases
(self)
This test verifies the accuracy of construction of Zulip's edit history data structures.
This test verifies the accuracy of construction of Zulip's edit history data structures.
def test_edit_cases(self) -> None: """This test verifies the accuracy of construction of Zulip's edit history data structures.""" self.login("hamlet") hamlet = self.example_user("hamlet") msg_id = self.send_stream_message( self.example_user("hamlet"), "Scotland", topi...
[ "def", "test_edit_cases", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "hamlet", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "msg_id", "=", "self", ".", "send_stream_message", "(", "self", ".", "example_u...
[ 579, 4 ]
[ 719, 64 ]
python
en
['en', 'en', 'en']
True
EditMessageTest.test_inaccessible_msg_after_stream_change
(self)
Simulates the case where message is moved to a stream where user is not a subscribed
Simulates the case where message is moved to a stream where user is not a subscribed
def test_inaccessible_msg_after_stream_change(self) -> None: """Simulates the case where message is moved to a stream where user is not a subscribed""" (user_profile, old_stream, new_stream, msg_id, msg_id_lt) = self.prepare_move_topics( "iago", "test move stream", "new stream", "test" ...
[ "def", "test_inaccessible_msg_after_stream_change", "(", "self", ")", "->", "None", ":", "(", "user_profile", ",", "old_stream", ",", "new_stream", ",", "msg_id", ",", "msg_id_lt", ")", "=", "self", ".", "prepare_move_topics", "(", "\"iago\"", ",", "\"test move st...
[ 1639, 4 ]
[ 1751, 9 ]
python
en
['en', 'en', 'en']
True
DeleteMessageTest.test_delete_event_sent_after_transaction_commits
(self)
Tests that `send_event` is hooked to `transaction.on_commit`. This is important, because we don't want to end up holding locks on message rows for too long if the event queue runs into a problem.
Tests that `send_event` is hooked to `transaction.on_commit`. This is important, because we don't want to end up holding locks on message rows for too long if the event queue runs into a problem.
def test_delete_event_sent_after_transaction_commits(self) -> None: """ Tests that `send_event` is hooked to `transaction.on_commit`. This is important, because we don't want to end up holding locks on message rows for too long if the event queue runs into a problem. """ ...
[ "def", "test_delete_event_sent_after_transaction_commits", "(", "self", ")", "->", "None", ":", "hamlet", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "self", ".", "send_stream_message", "(", "hamlet", ",", "\"Scotland\"", ")", "message", "=", "self",...
[ 2070, 4 ]
[ 2085, 59 ]
python
en
['en', 'error', 'th']
False
RealmTest.test_do_set_realm_name_caching
(self)
The main complicated thing about setting realm names is fighting the cache, and we start by populating the cache for Hamlet, and we end by checking the cache to ensure that the new value is there.
The main complicated thing about setting realm names is fighting the cache, and we start by populating the cache for Hamlet, and we end by checking the cache to ensure that the new value is there.
def test_do_set_realm_name_caching(self) -> None: """The main complicated thing about setting realm names is fighting the cache, and we start by populating the cache for Hamlet, and we end by checking the cache to ensure that the new value is there.""" realm = get_realm("zulip") ...
[ "def", "test_do_set_realm_name_caching", "(", "self", ")", "->", "None", ":", "realm", "=", "get_realm", "(", "\"zulip\"", ")", "new_name", "=", "\"Zed You Elle Eye Pea\"", "do_set_realm_property", "(", "realm", ",", "\"name\"", ",", "new_name", ",", "acting_user", ...
[ 57, 4 ]
[ 65, 91 ]
python
en
['en', 'en', 'en']
True
RealmTest.test_do_deactivate_realm_clears_user_realm_cache
(self)
The main complicated thing about deactivating realm names is updating the cache, and we start by populating the cache for Hamlet, and we end by checking the cache to ensure that his realm appears to be deactivated. You can make this test fail by disabling cache.flush_realm().
The main complicated thing about deactivating realm names is updating the cache, and we start by populating the cache for Hamlet, and we end by checking the cache to ensure that his realm appears to be deactivated. You can make this test fail by disabling cache.flush_realm().
def test_do_deactivate_realm_clears_user_realm_cache(self) -> None: """The main complicated thing about deactivating realm names is updating the cache, and we start by populating the cache for Hamlet, and we end by checking the cache to ensure that his realm appears to be deactivated. Y...
[ "def", "test_do_deactivate_realm_clears_user_realm_cache", "(", "self", ")", "->", "None", ":", "hamlet_id", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", ".", "id", "get_user_profile_by_id", "(", "hamlet_id", ")", "realm", "=", "get_realm", "(", "\"zu...
[ 173, 4 ]
[ 184, 47 ]
python
en
['en', 'en', 'en']
True
RealmTest.test_do_change_realm_subdomain_clears_user_realm_cache
(self)
The main complicated thing about changing realm subdomains is updating the cache, and we start by populating the cache for Hamlet, and we end by checking the cache to ensure that his realm appears to be deactivated. You can make this test fail by disabling cache.flush_realm().
The main complicated thing about changing realm subdomains is updating the cache, and we start by populating the cache for Hamlet, and we end by checking the cache to ensure that his realm appears to be deactivated. You can make this test fail by disabling cache.flush_realm().
def test_do_change_realm_subdomain_clears_user_realm_cache(self) -> None: """The main complicated thing about changing realm subdomains is updating the cache, and we start by populating the cache for Hamlet, and we end by checking the cache to ensure that his realm appears to be deactiva...
[ "def", "test_do_change_realm_subdomain_clears_user_realm_cache", "(", "self", ")", "->", "None", ":", "hamlet_id", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", ".", "id", "user", "=", "get_user_profile_by_id", "(", "hamlet_id", ")", "realm", "=", "get...
[ 186, 4 ]
[ 209, 59 ]
python
en
['en', 'en', 'en']
True
RealmTest.test_do_deactivate_realm_on_deactivated_realm
(self)
Ensure early exit is working in realm deactivation
Ensure early exit is working in realm deactivation
def test_do_deactivate_realm_on_deactivated_realm(self) -> None: """Ensure early exit is working in realm deactivation""" realm = get_realm("zulip") self.assertFalse(realm.deactivated) do_deactivate_realm(realm, acting_user=None) self.assertTrue(realm.deactivated) do_de...
[ "def", "test_do_deactivate_realm_on_deactivated_realm", "(", "self", ")", "->", "None", ":", "realm", "=", "get_realm", "(", "\"zulip\"", ")", "self", ".", "assertFalse", "(", "realm", ".", "deactivated", ")", "do_deactivate_realm", "(", "realm", ",", "acting_user...
[ 239, 4 ]
[ 248, 42 ]
python
en
['en', 'en', 'en']
True
RealmTest.test_do_set_deactivated_redirect_on_deactivated_realm
(self)
Ensure that the redirect url is working when deactivating realm
Ensure that the redirect url is working when deactivating realm
def test_do_set_deactivated_redirect_on_deactivated_realm(self) -> None: """Ensure that the redirect url is working when deactivating realm""" realm = get_realm("zulip") redirect_url = "new_server.zulip.com" do_deactivate_realm(realm, acting_user=None) self.assertTrue(realm.deac...
[ "def", "test_do_set_deactivated_redirect_on_deactivated_realm", "(", "self", ")", "->", "None", ":", "realm", "=", "get_realm", "(", "\"zulip\"", ")", "redirect_url", "=", "\"new_server.zulip.com\"", "do_deactivate_realm", "(", "realm", ",", "acting_user", "=", "None", ...
[ 250, 4 ]
[ 263, 69 ]
python
en
['en', 'en', 'en']
True
RealmAPITest.do_test_realm_update_api
(self, name: str)
Test updating realm properties. If new realm properties have been added to the Realm model but the test_values dict below has not been updated, this will raise an assertion error.
Test updating realm properties.
def do_test_realm_update_api(self, name: str) -> None: """Test updating realm properties. If new realm properties have been added to the Realm model but the test_values dict below has not been updated, this will raise an assertion error. """ bool_tests: List[bool] = [Fa...
[ "def", "do_test_realm_update_api", "(", "self", ",", "name", ":", "str", ")", "->", "None", ":", "bool_tests", ":", "List", "[", "bool", "]", "=", "[", "False", ",", "True", "]", "test_values", ":", "Dict", "[", "str", ",", "Any", "]", "=", "dict", ...
[ 807, 4 ]
[ 901, 59 ]
python
en
['en', 'en', 'en']
True
RealmAPITest.test_update_realm_allow_message_editing
(self)
Tests updating the realm property 'allow_message_editing'.
Tests updating the realm property 'allow_message_editing'.
def test_update_realm_allow_message_editing(self) -> None: """Tests updating the realm property 'allow_message_editing'.""" self.set_up_db("allow_message_editing", False) self.set_up_db("message_content_edit_limit_seconds", 0) self.set_up_db("edit_topic_policy", Realm.POLICY_ADMINS_ONLY)...
[ "def", "test_update_realm_allow_message_editing", "(", "self", ")", "->", "None", ":", "self", ".", "set_up_db", "(", "\"allow_message_editing\"", ",", "False", ")", "self", ".", "set_up_db", "(", "\"message_content_edit_limit_seconds\"", ",", "0", ")", "self", ".",...
[ 908, 4 ]
[ 951, 67 ]
python
en
['en', 'en', 'en']
True
RealmAPITest.test_update_realm_allow_message_deleting
(self)
Tests updating the realm property 'allow_message_deleting'.
Tests updating the realm property 'allow_message_deleting'.
def test_update_realm_allow_message_deleting(self) -> None: """Tests updating the realm property 'allow_message_deleting'.""" self.set_up_db("allow_message_deleting", True) self.set_up_db("message_content_delete_limit_seconds", 0) realm = self.update_with_api("allow_message_deleting", Fa...
[ "def", "test_update_realm_allow_message_deleting", "(", "self", ")", "->", "None", ":", "self", ".", "set_up_db", "(", "\"allow_message_deleting\"", ",", "True", ")", "self", ".", "set_up_db", "(", "\"message_content_delete_limit_seconds\"", ",", "0", ")", "realm", ...
[ 953, 4 ]
[ 966, 73 ]
python
en
['en', 'en', 'en']
True
Lookahead.step
(self, closure: OptLossClosure = None)
r"""Performs a single optimization step. Arguments: closure: A closure that reevaluates the model and returns the loss.
r"""Performs a single optimization step.
def step(self, closure: OptLossClosure = None) -> OptFloat: r"""Performs a single optimization step. Arguments: closure: A closure that reevaluates the model and returns the loss. """ loss = self.optimizer.step(closure=closure) for group in self.param_groups: ...
[ "def", "step", "(", "self", ",", "closure", ":", "OptLossClosure", "=", "None", ")", "->", "OptFloat", ":", "loss", "=", "self", ".", "optimizer", ".", "step", "(", "closure", "=", "closure", ")", "for", "group", "in", "self", ".", "param_groups", ":",...
[ 66, 4 ]
[ 77, 19 ]
python
en
['en', 'en', 'en']
True
Lookahead.state_dict
(self)
r"""Returns the state of the optimizer as a :class:`dict`. It contains two entries: * state - a dict holding current optimization state. Its content differs between optimizer classes. * param_groups - a dict containing all parameter groups
r"""Returns the state of the optimizer as a :class:`dict`.
def state_dict(self) -> State: r"""Returns the state of the optimizer as a :class:`dict`. It contains two entries: * state - a dict holding current optimization state. Its content differs between optimizer classes. * param_groups - a dict containing all parameter groups ...
[ "def", "state_dict", "(", "self", ")", "->", "State", ":", "slow_state_dict", "=", "super", "(", "Lookahead", ",", "self", ")", ".", "state_dict", "(", ")", "fast_state_dict", "=", "self", ".", "optimizer", ".", "state_dict", "(", ")", "fast_state", "=", ...
[ 79, 4 ]
[ 95, 9 ]
python
en
['en', 'en', 'en']
True
Lookahead.load_state_dict
(self, state_dict: State)
r"""Loads the optimizer state. Arguments: state_dict: optimizer state. Should be an object returned from a call to :meth:`state_dict`.
r"""Loads the optimizer state.
def load_state_dict(self, state_dict: State) -> None: r"""Loads the optimizer state. Arguments: state_dict: optimizer state. Should be an object returned from a call to :meth:`state_dict`. """ slow_state_dict = { 'state': state_dict['slow_state'],...
[ "def", "load_state_dict", "(", "self", ",", "state_dict", ":", "State", ")", "->", "None", ":", "slow_state_dict", "=", "{", "'state'", ":", "state_dict", "[", "'slow_state'", "]", ",", "'param_groups'", ":", "state_dict", "[", "'param_groups'", "]", ",", "}...
[ 97, 4 ]
[ 114, 46 ]
python
en
['en', 'en', 'en']
True
Lookahead.zero_grad
(self)
r"""Clears the gradients of all optimized :class:`torch.Tensor` s.
r"""Clears the gradients of all optimized :class:`torch.Tensor` s.
def zero_grad(self) -> None: r"""Clears the gradients of all optimized :class:`torch.Tensor` s.""" self.optimizer.zero_grad()
[ "def", "zero_grad", "(", "self", ")", "->", "None", ":", "self", ".", "optimizer", ".", "zero_grad", "(", ")" ]
[ 116, 4 ]
[ 118, 34 ]
python
en
['en', 'en', 'en']
True
LocaleRegexDescriptor.__get__
(self, instance, cls=None)
Return a compiled regular expression based on the active language.
Return a compiled regular expression based on the active language.
def __get__(self, instance, cls=None): """ Return a compiled regular expression based on the active language. """ if instance is None: return self # As a performance optimization, if the given regex string is a regular # string (not a lazily-translated string ...
[ "def", "__get__", "(", "self", ",", "instance", ",", "cls", "=", "None", ")", ":", "if", "instance", "is", "None", ":", "return", "self", "# As a performance optimization, if the given regex string is a regular", "# string (not a lazily-translated string proxy), compile it on...
[ 82, 4 ]
[ 97, 50 ]
python
en
['en', 'error', 'th']
False
LocaleRegexDescriptor._compile
(self, regex)
Compile and return the given regular expression.
Compile and return the given regular expression.
def _compile(self, regex): """ Compile and return the given regular expression. """ try: return re.compile(regex, re.UNICODE) except re.error as e: raise ImproperlyConfigured( '"%s" is not a valid regular expression: %s' % (...
[ "def", "_compile", "(", "self", ",", "regex", ")", ":", "try", ":", "return", "re", ".", "compile", "(", "regex", ",", "re", ".", "UNICODE", ")", "except", "re", ".", "error", "as", "e", ":", "raise", "ImproperlyConfigured", "(", "'\"%s\" is not a valid ...
[ 99, 4 ]
[ 109, 13 ]
python
en
['en', 'error', 'th']
False
LocaleRegexProvider.describe
(self)
Format the URL pattern for display in warning messages.
Format the URL pattern for display in warning messages.
def describe(self): """ Format the URL pattern for display in warning messages. """ description = "'{}'".format(self.regex.pattern) if getattr(self, 'name', False): description += " [name='{}']".format(self.name) return description
[ "def", "describe", "(", "self", ")", ":", "description", "=", "\"'{}'\"", ".", "format", "(", "self", ".", "regex", ".", "pattern", ")", "if", "getattr", "(", "self", ",", "'name'", ",", "False", ")", ":", "description", "+=", "\" [name='{}']\"", ".", ...
[ 126, 4 ]
[ 133, 26 ]
python
en
['en', 'error', 'th']
False
LocaleRegexProvider._check_pattern_startswith_slash
(self)
Check that the pattern does not begin with a forward slash.
Check that the pattern does not begin with a forward slash.
def _check_pattern_startswith_slash(self): """ Check that the pattern does not begin with a forward slash. """ regex_pattern = self.regex.pattern if not settings.APPEND_SLASH: # Skip check as it can be useful to start a URL pattern with a slash # when APPE...
[ "def", "_check_pattern_startswith_slash", "(", "self", ")", ":", "regex_pattern", "=", "self", ".", "regex", ".", "pattern", "if", "not", "settings", ".", "APPEND_SLASH", ":", "# Skip check as it can be useful to start a URL pattern with a slash", "# when APPEND_SLASH=False."...
[ 135, 4 ]
[ 155, 21 ]
python
en
['en', 'error', 'th']
False
RegexURLPattern._check_pattern_name
(self)
Check that the pattern name does not contain a colon.
Check that the pattern name does not contain a colon.
def _check_pattern_name(self): """ Check that the pattern name does not contain a colon. """ if self.name is not None and ":" in self.name: warning = Warning( "Your URL pattern {} has a name including a ':'. Remove the colon, to " "avoid ambigu...
[ "def", "_check_pattern_name", "(", "self", ")", ":", "if", "self", ".", "name", "is", "not", "None", "and", "\":\"", "in", "self", ".", "name", ":", "warning", "=", "Warning", "(", "\"Your URL pattern {} has a name including a ':'. Remove the colon, to \"", "\"avoid...
[ 174, 4 ]
[ 186, 21 ]
python
en
['en', 'error', 'th']
False
RegexURLPattern.lookup_str
(self)
A string that identifies the view (e.g. 'path.to.view_function' or 'path.to.ClassBasedView').
A string that identifies the view (e.g. 'path.to.view_function' or 'path.to.ClassBasedView').
def lookup_str(self): """ A string that identifies the view (e.g. 'path.to.view_function' or 'path.to.ClassBasedView'). """ callback = self.callback # Python 3.5 collapses nested partials, so can change "while" to "if" # when it's the minimum supported version. ...
[ "def", "lookup_str", "(", "self", ")", ":", "callback", "=", "self", ".", "callback", "# Python 3.5 collapses nested partials, so can change \"while\" to \"if\"", "# when it's the minimum supported version.", "while", "isinstance", "(", "callback", ",", "functools", ".", "par...
[ 201, 4 ]
[ 217, 64 ]
python
en
['en', 'error', 'th']
False
RegexURLResolver._check_include_trailing_dollar
(self)
Check that include is not used with a regex ending with a dollar.
Check that include is not used with a regex ending with a dollar.
def _check_include_trailing_dollar(self): """ Check that include is not used with a regex ending with a dollar. """ regex_pattern = self.regex.pattern if regex_pattern.endswith('$') and not regex_pattern.endswith(r'\$'): warning = Warning( "Your URL pa...
[ "def", "_check_include_trailing_dollar", "(", "self", ")", ":", "regex_pattern", "=", "self", ".", "regex", ".", "pattern", "if", "regex_pattern", ".", "endswith", "(", "'$'", ")", "and", "not", "regex_pattern", ".", "endswith", "(", "r'\\$'", ")", ":", "war...
[ 259, 4 ]
[ 273, 21 ]
python
en
['en', 'error', 'th']
False
GeoFeedMixin.georss_coords
(self, coords)
In GeoRSS coordinate pairs are ordered by lat/lon and separated by a single white space. Given a tuple of coordinates, this will return a unicode GeoRSS representation.
In GeoRSS coordinate pairs are ordered by lat/lon and separated by a single white space. Given a tuple of coordinates, this will return a unicode GeoRSS representation.
def georss_coords(self, coords): """ In GeoRSS coordinate pairs are ordered by lat/lon and separated by a single white space. Given a tuple of coordinates, this will return a unicode GeoRSS representation. """ return ' '.join('%f %f' % (coord[1], coord[0]) for coord in c...
[ "def", "georss_coords", "(", "self", ",", "coords", ")", ":", "return", "' '", ".", "join", "(", "'%f %f'", "%", "(", "coord", "[", "1", "]", ",", "coord", "[", "0", "]", ")", "for", "coord", "in", "coords", ")" ]
[ 12, 4 ]
[ 18, 75 ]
python
en
['en', 'error', 'th']
False
GeoFeedMixin.add_georss_point
(self, handler, coords, w3c_geo=False)
Adds a GeoRSS point with the given coords using the given handler. Handles the differences between simple GeoRSS and the more popular W3C Geo specification.
Adds a GeoRSS point with the given coords using the given handler. Handles the differences between simple GeoRSS and the more popular W3C Geo specification.
def add_georss_point(self, handler, coords, w3c_geo=False): """ Adds a GeoRSS point with the given coords using the given handler. Handles the differences between simple GeoRSS and the more popular W3C Geo specification. """ if w3c_geo: lon, lat = coords[:2] ...
[ "def", "add_georss_point", "(", "self", ",", "handler", ",", "coords", ",", "w3c_geo", "=", "False", ")", ":", "if", "w3c_geo", ":", "lon", ",", "lat", "=", "coords", "[", ":", "2", "]", "handler", ".", "addQuickElement", "(", "'geo:lat'", ",", "'%f'",...
[ 20, 4 ]
[ 31, 82 ]
python
en
['en', 'error', 'th']
False
GeoFeedMixin.add_georss_element
(self, handler, item, w3c_geo=False)
This routine adds a GeoRSS XML element using the given item and handler.
This routine adds a GeoRSS XML element using the given item and handler.
def add_georss_element(self, handler, item, w3c_geo=False): """ This routine adds a GeoRSS XML element using the given item and handler. """ # Getting the Geometry object. geom = item.get('geometry') if geom is not None: if isinstance(geom, (list, tuple)): ...
[ "def", "add_georss_element", "(", "self", ",", "handler", ",", "item", ",", "w3c_geo", "=", "False", ")", ":", "# Getting the Geometry object.", "geom", "=", "item", ".", "get", "(", "'geometry'", ")", "if", "geom", "is", "not", "None", ":", "if", "isinsta...
[ 33, 4 ]
[ 80, 94 ]
python
en
['en', 'error', 'th']
False
lru_cache
(maxsize=100)
Least-recently-used cache decorator. Arguments to the cached function must be hashable. See: http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used
Least-recently-used cache decorator.
def lru_cache(maxsize=100): """Least-recently-used cache decorator. Arguments to the cached function must be hashable. See: http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used """ def decorating_function(user_function): cache = dict() stats = [0, 0] ...
[ "def", "lru_cache", "(", "maxsize", "=", "100", ")", ":", "def", "decorating_function", "(", "user_function", ")", ":", "cache", "=", "dict", "(", ")", "stats", "=", "[", "0", ",", "0", "]", "# make statistics updateable non-locally", "HITS", ",", "MISSES", ...
[ 14, 0 ]
[ 103, 30 ]
python
en
['en', 'en', 'en']
True
compatible_tags
()
Return (pyver, abi, arch) tuples compatible with this Python.
Return (pyver, abi, arch) tuples compatible with this Python.
def compatible_tags(): """ Return (pyver, abi, arch) tuples compatible with this Python. """ versions = [VER_SUFFIX] major = VER_SUFFIX[0] for minor in range(sys.version_info[1] - 1, - 1, -1): versions.append(''.join([major, str(minor)])) abis = [] for suffix, _, _ in imp.get_su...
[ "def", "compatible_tags", "(", ")", ":", "versions", "=", "[", "VER_SUFFIX", "]", "major", "=", "VER_SUFFIX", "[", "0", "]", "for", "minor", "in", "range", "(", "sys", ".", "version_info", "[", "1", "]", "-", "1", ",", "-", "1", ",", "-", "1", ")...
[ 940, 0 ]
[ 999, 22 ]
python
en
['en', 'error', 'th']
False
Wheel.__init__
(self, filename=None, sign=False, verify=False)
Initialise an instance using a (valid) filename.
Initialise an instance using a (valid) filename.
def __init__(self, filename=None, sign=False, verify=False): """ Initialise an instance using a (valid) filename. """ self.sign = sign self.should_verify = verify self.buildver = '' self.pyver = [PYVER] self.abi = ['none'] self.arch = ['any'] ...
[ "def", "__init__", "(", "self", ",", "filename", "=", "None", ",", "sign", "=", "False", ",", "verify", "=", "False", ")", ":", "self", ".", "sign", "=", "sign", "self", ".", "should_verify", "=", "verify", "self", ".", "buildver", "=", "''", "self",...
[ 144, 4 ]
[ 183, 49 ]
python
en
['en', 'error', 'th']
False
Wheel.filename
(self)
Build and return a filename from the various components.
Build and return a filename from the various components.
def filename(self): """ Build and return a filename from the various components. """ if self.buildver: buildver = '-' + self.buildver else: buildver = '' pyver = '.'.join(self.pyver) abi = '.'.join(self.abi) arch = '.'.join(self.arc...
[ "def", "filename", "(", "self", ")", ":", "if", "self", ".", "buildver", ":", "buildver", "=", "'-'", "+", "self", ".", "buildver", "else", ":", "buildver", "=", "''", "pyver", "=", "'.'", ".", "join", "(", "self", ".", "pyver", ")", "abi", "=", ...
[ 186, 4 ]
[ 200, 58 ]
python
en
['en', 'error', 'th']
False
Wheel.build
(self, paths, tags=None, wheel_version=None)
Build a wheel from files in specified paths, and use any specified tags when determining the name of the wheel.
Build a wheel from files in specified paths, and use any specified tags when determining the name of the wheel.
def build(self, paths, tags=None, wheel_version=None): """ Build a wheel from files in specified paths, and use any specified tags when determining the name of the wheel. """ if tags is None: tags = {} libkey = list(filter(lambda o: o in paths, ('purelib', 'p...
[ "def", "build", "(", "self", ",", "paths", ",", "tags", "=", "None", ",", "wheel_version", "=", "None", ")", ":", "if", "tags", "is", "None", ":", "tags", "=", "{", "}", "libkey", "=", "list", "(", "filter", "(", "lambda", "o", ":", "o", "in", ...
[ 333, 4 ]
[ 447, 23 ]
python
en
['en', 'error', 'th']
False
Wheel.skip_entry
(self, arcname)
Determine whether an archive entry should be skipped when verifying or installing.
Determine whether an archive entry should be skipped when verifying or installing.
def skip_entry(self, arcname): """ Determine whether an archive entry should be skipped when verifying or installing. """ # The signature file won't be in RECORD, # and we don't currently don't do anything with it # We also skip directories, as they won't be in R...
[ "def", "skip_entry", "(", "self", ",", "arcname", ")", ":", "# The signature file won't be in RECORD,", "# and we don't currently don't do anything with it", "# We also skip directories, as they won't be in RECORD", "# either. See:", "#", "# https://github.com/pypa/wheel/issues/294", "#...
[ 449, 4 ]
[ 463, 53 ]
python
en
['en', 'error', 'th']
False
Wheel.install
(self, paths, maker, **kwargs)
Install a wheel to the specified paths. If kwarg ``warner`` is specified, it should be a callable, which will be called with two tuples indicating the wheel version of this software and the wheel version in the file, if there is a discrepancy in the versions. This can be used to...
Install a wheel to the specified paths. If kwarg ``warner`` is specified, it should be a callable, which will be called with two tuples indicating the wheel version of this software and the wheel version in the file, if there is a discrepancy in the versions. This can be used to...
def install(self, paths, maker, **kwargs): """ Install a wheel to the specified paths. If kwarg ``warner`` is specified, it should be a callable, which will be called with two tuples indicating the wheel version of this software and the wheel version in the file, if there is a di...
[ "def", "install", "(", "self", ",", "paths", ",", "maker", ",", "*", "*", "kwargs", ")", ":", "dry_run", "=", "maker", ".", "dry_run", "warner", "=", "kwargs", ".", "get", "(", "'warner'", ")", "lib_only", "=", "kwargs", ".", "get", "(", "'lib_only'"...
[ 465, 4 ]
[ 693, 38 ]
python
en
['en', 'error', 'th']
False
Wheel.is_compatible
(self)
Determine if a wheel is compatible with the running system.
Determine if a wheel is compatible with the running system.
def is_compatible(self): """ Determine if a wheel is compatible with the running system. """ return is_compatible(self)
[ "def", "is_compatible", "(", "self", ")", ":", "return", "is_compatible", "(", "self", ")" ]
[ 738, 4 ]
[ 742, 34 ]
python
en
['en', 'error', 'th']
False
Wheel.is_mountable
(self)
Determine if a wheel is asserted as mountable by its metadata.
Determine if a wheel is asserted as mountable by its metadata.
def is_mountable(self): """ Determine if a wheel is asserted as mountable by its metadata. """ return True
[ "def", "is_mountable", "(", "self", ")", ":", "return", "True" ]
[ 744, 4 ]
[ 748, 19 ]
python
en
['en', 'error', 'th']
False
Wheel.update
(self, modifier, dest_dir=None, **kwargs)
Update the contents of a wheel in a generic way. The modifier should be a callable which expects a dictionary argument: its keys are archive-entry paths, and its values are absolute filesystem paths where the contents the corresponding archive entries can be found. The modifier ...
Update the contents of a wheel in a generic way. The modifier should be a callable which expects a dictionary argument: its keys are archive-entry paths, and its values are absolute filesystem paths where the contents the corresponding archive entries can be found. The modifier ...
def update(self, modifier, dest_dir=None, **kwargs): """ Update the contents of a wheel in a generic way. The modifier should be a callable which expects a dictionary argument: its keys are archive-entry paths, and its values are absolute filesystem paths where the contents the c...
[ "def", "update", "(", "self", ",", "modifier", ",", "dest_dir", "=", "None", ",", "*", "*", "kwargs", ")", ":", "def", "get_version", "(", "path_map", ",", "info_dir", ")", ":", "version", "=", "path", "=", "None", "key", "=", "'%s/%s'", "%", "(", ...
[ 839, 4 ]
[ 938, 23 ]
python
en
['en', 'error', 'th']
False
Feed.feed_extra_kwargs
(self, obj)
Returns an extra keyword arguments dictionary that is used when initializing the feed generator.
Returns an extra keyword arguments dictionary that is used when initializing the feed generator.
def feed_extra_kwargs(self, obj): """ Returns an extra keyword arguments dictionary that is used when initializing the feed generator. """ return {}
[ "def", "feed_extra_kwargs", "(", "self", ",", "obj", ")", ":", "return", "{", "}" ]
[ 96, 4 ]
[ 101, 17 ]
python
en
['en', 'error', 'th']
False
Feed.item_extra_kwargs
(self, item)
Returns an extra keyword arguments dictionary that is used with the `add_item` call of the feed generator.
Returns an extra keyword arguments dictionary that is used with the `add_item` call of the feed generator.
def item_extra_kwargs(self, item): """ Returns an extra keyword arguments dictionary that is used with the `add_item` call of the feed generator. """ return {}
[ "def", "item_extra_kwargs", "(", "self", ",", "item", ")", ":", "return", "{", "}" ]
[ 103, 4 ]
[ 108, 17 ]
python
en
['en', 'error', 'th']
False
Feed.get_context_data
(self, **kwargs)
Returns a dictionary to use as extra context if either ``self.description_template`` or ``self.item_template`` are used. Default implementation preserves the old behavior of using {'obj': item, 'site': current_site} as the context.
Returns a dictionary to use as extra context if either ``self.description_template`` or ``self.item_template`` are used.
def get_context_data(self, **kwargs): """ Returns a dictionary to use as extra context if either ``self.description_template`` or ``self.item_template`` are used. Default implementation preserves the old behavior of using {'obj': item, 'site': current_site} as the context. ...
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "{", "'obj'", ":", "kwargs", ".", "get", "(", "'item'", ")", ",", "'site'", ":", "kwargs", ".", "get", "(", "'site'", ")", "}" ]
[ 113, 4 ]
[ 121, 70 ]
python
en
['en', 'error', 'th']
False
Feed.get_feed
(self, obj, request)
Returns a feedgenerator.DefaultFeed object, fully populated, for this feed. Raises FeedDoesNotExist for invalid parameters.
Returns a feedgenerator.DefaultFeed object, fully populated, for this feed. Raises FeedDoesNotExist for invalid parameters.
def get_feed(self, obj, request): """ Returns a feedgenerator.DefaultFeed object, fully populated, for this feed. Raises FeedDoesNotExist for invalid parameters. """ current_site = get_current_site(request) link = self._get_dynamic_attr('link', obj) link = add_do...
[ "def", "get_feed", "(", "self", ",", "obj", ",", "request", ")", ":", "current_site", "=", "get_current_site", "(", "request", ")", "link", "=", "self", ".", "_get_dynamic_attr", "(", "'link'", ",", "obj", ")", "link", "=", "add_domain", "(", "current_site...
[ 123, 4 ]
[ 219, 19 ]
python
en
['en', 'error', 'th']
False
BaseDensityEstimator.fit
(self, X, Y, verbose=False)
Fits the conditional density model with provided data Args: X: numpy array to be conditioned on - shape: (n_samples, n_dim_x) Y: numpy array of y targets - shape: (n_samples, n_dim_y)
Fits the conditional density model with provided data
def fit(self, X, Y, verbose=False): """ Fits the conditional density model with provided data Args: X: numpy array to be conditioned on - shape: (n_samples, n_dim_x) Y: numpy array of y targets - shape: (n_samples, n_dim_y) """ raise NotImplementedError
[ "def", "fit", "(", "self", ",", "X", ",", "Y", ",", "verbose", "=", "False", ")", ":", "raise", "NotImplementedError" ]
[ 11, 2 ]
[ 18, 29 ]
python
en
['en', 'en', 'en']
True
BaseDensityEstimator.eval_by_cv
(self, X, Y, n_splits=5, verbose=True)
Fits the conditional density model with cross-validation by using the score function of the BaseDensityEstimator for scoring the various splits. Args: X: numpy array to be conditioned on - shape: (n_samples, n_dim_x) Y: numpy array of y targets - shape: (n_samples, n_dim_y) n_splits: number ...
Fits the conditional density model with cross-validation by using the score function of the BaseDensityEstimator for scoring the various splits.
def eval_by_cv(self, X, Y, n_splits=5, verbose=True): """ Fits the conditional density model with cross-validation by using the score function of the BaseDensityEstimator for scoring the various splits. Args: X: numpy array to be conditioned on - shape: (n_samples, n_dim_x) Y: numpy array of y ...
[ "def", "eval_by_cv", "(", "self", ",", "X", ",", "Y", ",", "n_splits", "=", "5", ",", "verbose", "=", "True", ")", ":", "X", ",", "Y", "=", "self", ".", "_handle_input_dimensionality", "(", "X", ",", "Y", ",", "fitting", "=", "True", ")", "cv_resul...
[ 20, 2 ]
[ 38, 18 ]
python
en
['en', 'en', 'en']
True
BaseDensityEstimator.fit_by_cv
(self, X, Y, n_folds=3, param_grid=None, verbose=True, n_jobs=-1, random_state=None)
Fits the conditional density model with hyperparameter search and cross-validation. - Determines the best hyperparameter configuration from a pre-defined set using cross-validation. Thereby, the conditional log-likelihood is used for simulation_eval. - Fits the model with the previously selected hyperpar...
Fits the conditional density model with hyperparameter search and cross-validation. - Determines the best hyperparameter configuration from a pre-defined set using cross-validation. Thereby, the conditional log-likelihood is used for simulation_eval. - Fits the model with the previously selected hyperpar...
def fit_by_cv(self, X, Y, n_folds=3, param_grid=None, verbose=True, n_jobs=-1, random_state=None): """ Fits the conditional density model with hyperparameter search and cross-validation. - Determines the best hyperparameter configuration from a pre-defined set using cross-validation. Thereby, the conditio...
[ "def", "fit_by_cv", "(", "self", ",", "X", ",", "Y", ",", "n_folds", "=", "3", ",", "param_grid", "=", "None", ",", "verbose", "=", "True", ",", "n_jobs", "=", "-", "1", ",", "random_state", "=", "None", ")", ":", "# save properties of data", "self", ...
[ 40, 2 ]
[ 77, 22 ]
python
en
['en', 'en', 'en']
True
BaseDensityEstimator.pdf
(self, X, Y)
Predicts the conditional likelihood p(y|x). Requires the model to be fitted. Args: X: numpy array to be conditioned on - shape: (n_samples, n_dim_x) Y: numpy array of y targets - shape: (n_samples, n_dim_y) Returns: conditional likelihood p(y|x) - numpy array of shape (n_que...
Predicts the conditional likelihood p(y|x). Requires the model to be fitted.
def pdf(self, X, Y): """ Predicts the conditional likelihood p(y|x). Requires the model to be fitted. Args: X: numpy array to be conditioned on - shape: (n_samples, n_dim_x) Y: numpy array of y targets - shape: (n_samples, n_dim_y) Returns: conditional likelihood p(y|x) -...
[ "def", "pdf", "(", "self", ",", "X", ",", "Y", ")", ":", "raise", "NotImplementedError" ]
[ 79, 2 ]
[ 90, 29 ]
python
en
['en', 'en', 'en']
True
BaseDensityEstimator.log_pdf
(self, X, Y)
Predicts the conditional log-probability log p(y|x). Requires the model to be fitted. Args: X: numpy array to be conditioned on - shape: (n_samples, n_dim_x) Y: numpy array of y targets - shape: (n_samples, n_dim_y) Returns: conditional log-probability log p(y|x) - numpy arr...
Predicts the conditional log-probability log p(y|x). Requires the model to be fitted.
def log_pdf(self, X, Y): """ Predicts the conditional log-probability log p(y|x). Requires the model to be fitted. Args: X: numpy array to be conditioned on - shape: (n_samples, n_dim_x) Y: numpy array of y targets - shape: (n_samples, n_dim_y) Returns: conditional log-pr...
[ "def", "log_pdf", "(", "self", ",", "X", ",", "Y", ")", ":", "# This method is numerically unfavorable and should be overwritten with a numerically stable method", "with", "warnings", ".", "catch_warnings", "(", ")", ":", "warnings", ".", "simplefilter", "(", "\"ignore\""...
[ 92, 2 ]
[ 107, 19 ]
python
en
['en', 'en', 'en']
True
BaseDensityEstimator.score
(self, X, Y)
Computes the mean conditional log-likelihood of the provided data (X, Y) Args: X: numpy array to be conditioned on - shape: (n_query_samples, n_dim_x) Y: numpy array of y targets - shape: (n_query_samples, n_dim_y) Returns: average log likelihood of data
Computes the mean conditional log-likelihood of the provided data (X, Y)
def score(self, X, Y): """Computes the mean conditional log-likelihood of the provided data (X, Y) Args: X: numpy array to be conditioned on - shape: (n_query_samples, n_dim_x) Y: numpy array of y targets - shape: (n_query_samples, n_dim_y) Returns: average log likelihood of data """...
[ "def", "score", "(", "self", ",", "X", ",", "Y", ")", ":", "return", "np", ".", "mean", "(", "self", ".", "log_pdf", "(", "X", ",", "Y", ")", ")" ]
[ 112, 2 ]
[ 122, 38 ]
python
en
['en', 'en', 'en']
True
BaseDensityEstimator.mean_
(self, x_cond, n_samples=10**6)
Mean of the fitted distribution conditioned on x_cond Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) Returns: Means E[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y)
Mean of the fitted distribution conditioned on x_cond Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
def mean_(self, x_cond, n_samples=10**6): """ Mean of the fitted distribution conditioned on x_cond Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) Returns: Means E[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y) """ asse...
[ "def", "mean_", "(", "self", ",", "x_cond", ",", "n_samples", "=", "10", "**", "6", ")", ":", "assert", "self", ".", "fitted", ",", "\"model must be fitted\"", "x_cond", "=", "self", ".", "_handle_input_dimensionality", "(", "x_cond", ")", "assert", "x_cond"...
[ 124, 2 ]
[ 139, 55 ]
python
en
['en', 'en', 'en']
True
BaseDensityEstimator.std_
(self, x_cond, n_samples=10 ** 6)
Standard deviation of the fitted distribution conditioned on x_cond Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) Returns: Standard deviations sqrt(Var[y|x]) corresponding to x_cond - numpy array of shape (n_values, ndim_y)
Standard deviation of the fitted distribution conditioned on x_cond
def std_(self, x_cond, n_samples=10 ** 6): """ Standard deviation of the fitted distribution conditioned on x_cond Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) Returns: Standard deviations sqrt(Var[y|x]) corresponding to x_cond - numpy array of sh...
[ "def", "std_", "(", "self", ",", "x_cond", ",", "n_samples", "=", "10", "**", "6", ")", ":", "assert", "self", ".", "fitted", ",", "\"model must be fitted\"", "x_cond", "=", "self", ".", "_handle_input_dimensionality", "(", "x_cond", ")", "assert", "x_cond",...
[ 141, 2 ]
[ 153, 53 ]
python
en
['en', 'en', 'en']
True
BaseDensityEstimator.covariance
(self, x_cond, n_samples=10**6)
Covariance of the fitted distribution conditioned on x_cond Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) Returns: Covariances Cov[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y, ndim_y)
Covariance of the fitted distribution conditioned on x_cond
def covariance(self, x_cond, n_samples=10**6): """ Covariance of the fitted distribution conditioned on x_cond Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) Returns: Covariances Cov[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim...
[ "def", "covariance", "(", "self", ",", "x_cond", ",", "n_samples", "=", "10", "**", "6", ")", ":", "assert", "self", ".", "fitted", ",", "\"model must be fitted\"", "x_cond", "=", "self", ".", "_handle_input_dimensionality", "(", "x_cond", ")", "assert", "x_...
[ 155, 2 ]
[ 167, 60 ]
python
en
['en', 'en', 'en']
True
BaseDensityEstimator.skewness
(self, x_cond, n_samples=10**6)
Skewness of the fitted distribution conditioned on x_cond Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) Returns: Skewness Skew[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y, ndim_y)
Skewness of the fitted distribution conditioned on x_cond
def skewness(self, x_cond, n_samples=10**6): """ Skewness of the fitted distribution conditioned on x_cond Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) Returns: Skewness Skew[y|x] corresponding to x_cond - numpy array of shape (n_values...
[ "def", "skewness", "(", "self", ",", "x_cond", ",", "n_samples", "=", "10", "**", "6", ")", ":", "assert", "self", ".", "fitted", ",", "\"model must be fitted\"", "x_cond", "=", "self", ".", "_handle_input_dimensionality", "(", "x_cond", ")", "assert", "x_co...
[ 169, 2 ]
[ 181, 58 ]
python
en
['en', 'en', 'en']
True
BaseDensityEstimator.kurtosis
(self, x_cond, n_samples=10**6)
Kurtosis of the fitted distribution conditioned on x_cond Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) Returns: Kurtosis Kurt[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y, ndim_y)
Kurtosis of the fitted distribution conditioned on x_cond
def kurtosis(self, x_cond, n_samples=10**6): """ Kurtosis of the fitted distribution conditioned on x_cond Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) Returns: Kurtosis Kurt[y|x] corresponding to x_cond - numpy array of shape (n_values...
[ "def", "kurtosis", "(", "self", ",", "x_cond", ",", "n_samples", "=", "10", "**", "6", ")", ":", "assert", "self", ".", "fitted", ",", "\"model must be fitted\"", "x_cond", "=", "self", ".", "_handle_input_dimensionality", "(", "x_cond", ")", "assert", "x_co...
[ 183, 2 ]
[ 195, 58 ]
python
en
['en', 'en', 'en']
True
BaseDensityEstimator.mean_std
(self, x_cond, n_samples=10 ** 6)
Computes Mean and Covariance of the fitted distribution conditioned on x_cond. Computationally more efficient than calling mean and covariance computatio separately Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) Returns: Means E[y|x] and Covaria...
Computes Mean and Covariance of the fitted distribution conditioned on x_cond. Computationally more efficient than calling mean and covariance computatio separately
def mean_std(self, x_cond, n_samples=10 ** 6): """ Computes Mean and Covariance of the fitted distribution conditioned on x_cond. Computationally more efficient than calling mean and covariance computatio separately Args: x_cond: different x values to condition on - numpy array of shape (n_values...
[ "def", "mean_std", "(", "self", ",", "x_cond", ",", "n_samples", "=", "10", "**", "6", ")", ":", "mean", "=", "self", ".", "mean_", "(", "x_cond", ",", "n_samples", "=", "n_samples", ")", "std", "=", "self", ".", "_std_pdf", "(", "x_cond", ",", "n_...
[ 197, 2 ]
[ 209, 20 ]
python
en
['en', 'en', 'en']
True
BaseDensityEstimator.value_at_risk
(self, x_cond, alpha=0.01, n_samples=10**6)
Computes the Value-at-Risk (VaR) of the fitted distribution. Only if ndim_y = 1 Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) alpha: quantile percentage of the distribution Returns: VaR values for each x to condition on - numpy array of shape (n...
Computes the Value-at-Risk (VaR) of the fitted distribution. Only if ndim_y = 1
def value_at_risk(self, x_cond, alpha=0.01, n_samples=10**6): """ Computes the Value-at-Risk (VaR) of the fitted distribution. Only if ndim_y = 1 Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) alpha: quantile percentage of the distribution Returns: ...
[ "def", "value_at_risk", "(", "self", ",", "x_cond", ",", "alpha", "=", "0.01", ",", "n_samples", "=", "10", "**", "6", ")", ":", "assert", "self", ".", "fitted", ",", "\"model must be fitted\"", "assert", "self", ".", "ndim_y", "==", "1", ",", "\"Value a...
[ 211, 2 ]
[ 233, 14 ]
python
en
['en', 'en', 'en']
True
BaseDensityEstimator.conditional_value_at_risk
(self, x_cond, alpha=0.01, n_samples=10**6)
Computes the Conditional Value-at-Risk (CVaR) / Expected Shortfall of the fitted distribution. Only if ndim_y = 1 Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) alpha: quantile percentage of the distribution Returns: CVaR values for...
Computes the Conditional Value-at-Risk (CVaR) / Expected Shortfall of the fitted distribution. Only if ndim_y = 1
def conditional_value_at_risk(self, x_cond, alpha=0.01, n_samples=10**6): """ Computes the Conditional Value-at-Risk (CVaR) / Expected Shortfall of the fitted distribution. Only if ndim_y = 1 Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) alpha: ...
[ "def", "conditional_value_at_risk", "(", "self", ",", "x_cond", ",", "alpha", "=", "0.01", ",", "n_samples", "=", "10", "**", "6", ")", ":", "assert", "self", ".", "fitted", ",", "\"model must be fitted\"", "assert", "self", ".", "ndim_y", "==", "1", ",", ...
[ 235, 2 ]
[ 257, 115 ]
python
en
['en', 'en', 'en']
True
BaseDensityEstimator.get_configuration
(self, deep=True)
Get parameter configuration for this estimator. Args: deep: boolean, optional If True, will return the parameters for this estimator and \ contained subobjects that are estimators. Returns: params - mapping of string to any Parameter names mapped to their values.
Get parameter configuration for this estimator.
def get_configuration(self, deep=True): """ Get parameter configuration for this estimator. Args: deep: boolean, optional If True, will return the parameters for this estimator and \ contained subobjects that are estimators. Returns: params - mapping of string to any Parameter nam...
[ "def", "get_configuration", "(", "self", ",", "deep", "=", "True", ")", ":", "param_dict", "=", "super", "(", "BaseDensityEstimator", ",", "self", ")", ".", "get_params", "(", "deep", "=", "deep", ")", "param_dict", "[", "'estimator'", "]", "=", "self", ...
[ 259, 2 ]
[ 280, 21 ]
python
en
['en', 'la', 'en']
True
BaseDensityEstimator.tail_risk_measures
(self, x_cond, alpha=0.01, n_samples=10 ** 6)
Computes the Value-at-Risk (VaR) and Conditional Value-at-Risk (CVaR) Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) alpha: quantile percentage of the distribution n_samples: number of samples for monte carlo model_fitting Retu...
Computes the Value-at-Risk (VaR) and Conditional Value-at-Risk (CVaR)
def tail_risk_measures(self, x_cond, alpha=0.01, n_samples=10 ** 6): """ Computes the Value-at-Risk (VaR) and Conditional Value-at-Risk (CVaR) Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) alpha: quantile percentage of the distribution ...
[ "def", "tail_risk_measures", "(", "self", ",", "x_cond", ",", "alpha", "=", "0.01", ",", "n_samples", "=", "10", "**", "6", ")", ":", "assert", "self", ".", "fitted", ",", "\"model must be fitted\"", "assert", "self", ".", "ndim_y", "==", "1", ",", "\"Va...
[ 282, 2 ]
[ 308, 22 ]
python
en
['en', 'en', 'en']
True
SemaphoreHookTests.get_unknown_event
(self, fixture_name: str)
Return modified payload with revision.reference_type changed
Return modified payload with revision.reference_type changed
def get_unknown_event(self, fixture_name: str) -> str: """Return modified payload with revision.reference_type changed""" fixture_data = orjson.loads( self.webhook_fixture_data("semaphore", fixture_name, file_type="json") ) fixture_data["revision"]["reference_type"] = "unknow...
[ "def", "get_unknown_event", "(", "self", ",", "fixture_name", ":", "str", ")", "->", "str", ":", "fixture_data", "=", "orjson", ".", "loads", "(", "self", ".", "webhook_fixture_data", "(", "\"semaphore\"", ",", "fixture_name", ",", "file_type", "=", "\"json\""...
[ 131, 4 ]
[ 137, 27 ]
python
en
['en', 'en', 'en']
True
pack
(directory, dest_dir, build_number)
Repack a previously unpacked wheel directory into a new wheel file. The .dist-info/WHEEL file must contain one or more tags so that the target wheel file name can be determined. :param directory: The unpacked wheel directory :param dest_dir: Destination directory (defaults to the current directory) ...
Repack a previously unpacked wheel directory into a new wheel file.
def pack(directory, dest_dir, build_number): """Repack a previously unpacked wheel directory into a new wheel file. The .dist-info/WHEEL file must contain one or more tags so that the target wheel file name can be determined. :param directory: The unpacked wheel directory :param dest_dir: Destinat...
[ "def", "pack", "(", "directory", ",", "dest_dir", ",", "build_number", ")", ":", "# Find the .dist-info directory", "dist_info_dirs", "=", "[", "fn", "for", "fn", "in", "os", ".", "listdir", "(", "directory", ")", "if", "os", ".", "path", ".", "isdir", "("...
[ 13, 0 ]
[ 78, 15 ]
python
en
['en', 'en', 'en']
True
dependency_graph
(page, *provided_dependencies)
Creates a dependency graph of the form {page: set(page.dependencies[0:i]), page.dependencies[0]: set(page.dependencies[0][0:j] ... page.dependencies[i][j][...][n]: set(page.dependencies[i][j][...][n][0:z]), ...} Any optional provided_dependencies will be included as if they were dependencies...
Creates a dependency graph of the form {page: set(page.dependencies[0:i]), page.dependencies[0]: set(page.dependencies[0][0:j] ... page.dependencies[i][j][...][n]: set(page.dependencies[i][j][...][n][0:z]), ...} Any optional provided_dependencies will be included as if they were dependencies...
def dependency_graph(page, *provided_dependencies): """Creates a dependency graph of the form {page: set(page.dependencies[0:i]), page.dependencies[0]: set(page.dependencies[0][0:j] ... page.dependencies[i][j][...][n]: set(page.dependencies[i][j][...][n][0:z]), ...} Any optional provided...
[ "def", "dependency_graph", "(", "page", ",", "*", "provided_dependencies", ")", ":", "graph", "=", "{", "}", "dependencies", "=", "set", "(", "getattr", "(", "page", ",", "'dependencies'", ",", "[", "]", ")", ")", "# Some HasCreate's can claim generic Base's w/o...
[ 8, 0 ]
[ 23, 16 ]
python
en
['en', 'en', 'en']
True
optional_dependency_graph
(page, *provided_dependencies)
Creates a dependency graph for a page including all dependencies and optional_dependencies Any optional provided_dependencies will be included as if they were dependencies, without affecting the value of each keyed page.
Creates a dependency graph for a page including all dependencies and optional_dependencies Any optional provided_dependencies will be included as if they were dependencies, without affecting the value of each keyed page.
def optional_dependency_graph(page, *provided_dependencies): """Creates a dependency graph for a page including all dependencies and optional_dependencies Any optional provided_dependencies will be included as if they were dependencies, without affecting the value of each keyed page. """ graph = {} ...
[ "def", "optional_dependency_graph", "(", "page", ",", "*", "provided_dependencies", ")", ":", "graph", "=", "{", "}", "dependencies", "=", "set", "(", "getattr", "(", "page", ",", "'dependencies'", ",", "[", "]", ")", "+", "getattr", "(", "page", ",", "'...
[ 26, 0 ]
[ 36, 16 ]
python
en
['en', 'en', 'en']
True
creation_order
(graph)
returns a list of sets of HasCreate subclasses representing the order of page creation that will resolve the dependencies of subsequent pages for any non-cyclic dependency_graph ex: [set(Organization), set(Inventory), set(Group)] **The result is based entirely on the passed dependency graph and should ...
returns a list of sets of HasCreate subclasses representing the order of page creation that will resolve the dependencies of subsequent pages for any non-cyclic dependency_graph ex: [set(Organization), set(Inventory), set(Group)]
def creation_order(graph): """returns a list of sets of HasCreate subclasses representing the order of page creation that will resolve the dependencies of subsequent pages for any non-cyclic dependency_graph ex: [set(Organization), set(Inventory), set(Group)] **The result is based entirely on the p...
[ "def", "creation_order", "(", "graph", ")", ":", "return", "list", "(", "toposort", "(", "graph", ")", ")" ]
[ 39, 0 ]
[ 48, 32 ]
python
en
['en', 'en', 'en']
True
separate_async_optionals
(creation_order)
In cases where creation group items share dependencies but as asymetric optionals, those that create them as actual dependencies to be later sourced as optionals need to be listed first
In cases where creation group items share dependencies but as asymetric optionals, those that create them as actual dependencies to be later sourced as optionals need to be listed first
def separate_async_optionals(creation_order): """In cases where creation group items share dependencies but as asymetric optionals, those that create them as actual dependencies to be later sourced as optionals need to be listed first """ actual_order = [] for group in creation_order: if...
[ "def", "separate_async_optionals", "(", "creation_order", ")", ":", "actual_order", "=", "[", "]", "for", "group", "in", "creation_order", ":", "if", "len", "(", "group", ")", "<=", "1", ":", "actual_order", ".", "append", "(", "group", ")", "continue", "b...
[ 51, 0 ]
[ 73, 23 ]
python
en
['en', 'en', 'en']
True
page_creation_order
(page=None, *provided_dependencies)
returns a creation_order() where HasCreate subclasses do not share creation group sets with members of their optional_dependencies. All provided_dependencies and their dependencies will also be included in the creation
returns a creation_order() where HasCreate subclasses do not share creation group sets with members of their optional_dependencies. All provided_dependencies and their dependencies will also be included in the creation
def page_creation_order(page=None, *provided_dependencies): """returns a creation_order() where HasCreate subclasses do not share creation group sets with members of their optional_dependencies. All provided_dependencies and their dependencies will also be included in the creation """ if not page: ...
[ "def", "page_creation_order", "(", "page", "=", "None", ",", "*", "provided_dependencies", ")", ":", "if", "not", "page", ":", "return", "[", "]", "# dependency_graphs only care about class type", "provided_dependencies", "=", "[", "x", "[", "0", "]", "if", "isi...
[ 76, 0 ]
[ 97, 23 ]
python
en
['en', 'en', 'en']
True
all_instantiated_dependencies
(*potential_parents)
returns a list of all instantiated dependencies including parents themselves. Will be in page_creation_order
returns a list of all instantiated dependencies including parents themselves. Will be in page_creation_order
def all_instantiated_dependencies(*potential_parents): """returns a list of all instantiated dependencies including parents themselves. Will be in page_creation_order """ scope_provided_dependencies = [] instantiated = set([x for x in potential_parents if not isinstance(x, type) and not isinstance(...
[ "def", "all_instantiated_dependencies", "(", "*", "potential_parents", ")", ":", "scope_provided_dependencies", "=", "[", "]", "instantiated", "=", "set", "(", "[", "x", "for", "x", "in", "potential_parents", "if", "not", "isinstance", "(", "x", ",", "type", "...
[ 100, 0 ]
[ 132, 27 ]
python
en
['en', 'en', 'en']
True
HasCreate._update_dependencies
(self, dependency_candidates)
updates self._dependency_store to reflect instantiated dependencies, if any.
updates self._dependency_store to reflect instantiated dependencies, if any.
def _update_dependencies(self, dependency_candidates): """updates self._dependency_store to reflect instantiated dependencies, if any.""" if self._dependency_store: potentials = [] # in case the candidate is an instance of a desired base class # (e.g. Project for sel...
[ "def", "_update_dependencies", "(", "self", ",", "dependency_candidates", ")", ":", "if", "self", ".", "_dependency_store", ":", "potentials", "=", "[", "]", "# in case the candidate is an instance of a desired base class", "# (e.g. Project for self._dependency_store = {'UnifiedJ...
[ 222, 4 ]
[ 248, 78 ]
python
en
['en', 'en', 'en']
True
HasCreate.create_and_update_dependencies
(self, *provided_and_desired_dependencies)
in order creation of dependencies and updating of self._dependency_store to include instances, indexed by page class. If a (HasCreate, dict()) tuple is provided as a desired dependency, the dict() will be unpacked as kwargs for the `HasCreate.create(**dict())` call. *** Providi...
in order creation of dependencies and updating of self._dependency_store to include instances, indexed by page class. If a (HasCreate, dict()) tuple is provided as a desired dependency, the dict() will be unpacked as kwargs for the `HasCreate.create(**dict())` call.
def create_and_update_dependencies(self, *provided_and_desired_dependencies): """in order creation of dependencies and updating of self._dependency_store to include instances, indexed by page class. If a (HasCreate, dict()) tuple is provided as a desired dependency, the dict() will be unpacked ...
[ "def", "create_and_update_dependencies", "(", "self", ",", "*", "provided_and_desired_dependencies", ")", ":", "if", "not", "any", "(", "(", "self", ".", "dependencies", ",", "self", ".", "optional_dependencies", ")", ")", ":", "return", "# remove falsy values", "...
[ 250, 4 ]
[ 368, 64 ]
python
en
['en', 'en', 'en']
True
HasCreate.teardown
(self)
Calls `silent_cleanup()` on all dependencies and self in reverse page creation order.
Calls `silent_cleanup()` on all dependencies and self in reverse page creation order.
def teardown(self): """Calls `silent_cleanup()` on all dependencies and self in reverse page creation order.""" to_teardown = all_instantiated_dependencies(self) to_teardown_types = set(map(get_class_if_instance, to_teardown)) order = [ set([potential for potential in (get_cl...
[ "def", "teardown", "(", "self", ")", ":", "to_teardown", "=", "all_instantiated_dependencies", "(", "self", ")", "to_teardown_types", "=", "set", "(", "map", "(", "get_class_if_instance", ",", "to_teardown", ")", ")", "order", "=", "[", "set", "(", "[", "pot...
[ 370, 4 ]
[ 387, 59 ]
python
en
['en', 'en', 'en']
True
msvc9_find_vcvarsall
(version)
Patched "distutils.msvc9compiler.find_vcvarsall" to use the standalone compiler build for Python (VCForPython / Microsoft Visual C++ Compiler for Python 2.7). Fall back to original behavior when the standalone compiler is not available. Redirect the path of "vcvarsall.bat". Parameters ...
Patched "distutils.msvc9compiler.find_vcvarsall" to use the standalone compiler build for Python (VCForPython / Microsoft Visual C++ Compiler for Python 2.7).
def msvc9_find_vcvarsall(version): """ Patched "distutils.msvc9compiler.find_vcvarsall" to use the standalone compiler build for Python (VCForPython / Microsoft Visual C++ Compiler for Python 2.7). Fall back to original behavior when the standalone compiler is not available. Redirect the p...
[ "def", "msvc9_find_vcvarsall", "(", "version", ")", ":", "vc_base", "=", "r'Software\\%sMicrosoft\\DevDiv\\VCForPython\\%0.1f'", "key", "=", "vc_base", "%", "(", "''", ",", "version", ")", "try", ":", "# Per-user installs register the compiler path here", "productdir", "=...
[ 63, 0 ]
[ 102, 55 ]
python
en
['en', 'error', 'th']
False
msvc9_query_vcvarsall
(ver, arch='x86', *args, **kwargs)
Patched "distutils.msvc9compiler.query_vcvarsall" for support extra Microsoft Visual C++ 9.0 and 10.0 compilers. Set environment without use of "vcvarsall.bat". Parameters ---------- ver: float Required Microsoft Visual C++ version. arch: str Target architecture. Retu...
Patched "distutils.msvc9compiler.query_vcvarsall" for support extra Microsoft Visual C++ 9.0 and 10.0 compilers.
def msvc9_query_vcvarsall(ver, arch='x86', *args, **kwargs): """ Patched "distutils.msvc9compiler.query_vcvarsall" for support extra Microsoft Visual C++ 9.0 and 10.0 compilers. Set environment without use of "vcvarsall.bat". Parameters ---------- ver: float Required Microsoft Visu...
[ "def", "msvc9_query_vcvarsall", "(", "ver", ",", "arch", "=", "'x86'", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Try to get environment from vcvarsall.bat (Classical way)", "try", ":", "orig", "=", "get_unpatched", "(", "msvc9_query_vcvarsall", ")", ...
[ 105, 0 ]
[ 140, 13 ]
python
en
['en', 'error', 'th']
False
_msvc14_find_vc2015
()
Python 3.8 "distutils/_msvccompiler.py" backport
Python 3.8 "distutils/_msvccompiler.py" backport
def _msvc14_find_vc2015(): """Python 3.8 "distutils/_msvccompiler.py" backport""" try: key = winreg.OpenKey( winreg.HKEY_LOCAL_MACHINE, r"Software\Microsoft\VisualStudio\SxS\VC7", 0, winreg.KEY_READ | winreg.KEY_WOW64_32KEY ) except OSError: ...
[ "def", "_msvc14_find_vc2015", "(", ")", ":", "try", ":", "key", "=", "winreg", ".", "OpenKey", "(", "winreg", ".", "HKEY_LOCAL_MACHINE", ",", "r\"Software\\Microsoft\\VisualStudio\\SxS\\VC7\"", ",", "0", ",", "winreg", ".", "KEY_READ", "|", "winreg", ".", "KEY_W...
[ 143, 0 ]
[ 170, 33 ]
python
ceb
['fi', 'ceb', 'en']
False
_msvc14_find_vc2017
()
Python 3.8 "distutils/_msvccompiler.py" backport Returns "15, path" based on the result of invoking vswhere.exe If no install is found, returns "None, None" The version is returned to avoid unnecessarily changing the function result. It may be ignored when the path is not None. If vswhere.exe is ...
Python 3.8 "distutils/_msvccompiler.py" backport
def _msvc14_find_vc2017(): """Python 3.8 "distutils/_msvccompiler.py" backport Returns "15, path" based on the result of invoking vswhere.exe If no install is found, returns "None, None" The version is returned to avoid unnecessarily changing the function result. It may be ignored when the path is...
[ "def", "_msvc14_find_vc2017", "(", ")", ":", "root", "=", "environ", ".", "get", "(", "\"ProgramFiles(x86)\"", ")", "or", "environ", ".", "get", "(", "\"ProgramFiles\"", ")", "if", "not", "root", ":", "return", "None", ",", "None", "try", ":", "path", "=...
[ 173, 0 ]
[ 205, 21 ]
python
ceb
['fi', 'ceb', 'en']
False
_msvc14_find_vcvarsall
(plat_spec)
Python 3.8 "distutils/_msvccompiler.py" backport
Python 3.8 "distutils/_msvccompiler.py" backport
def _msvc14_find_vcvarsall(plat_spec): """Python 3.8 "distutils/_msvccompiler.py" backport""" _, best_dir = _msvc14_find_vc2017() vcruntime = None if plat_spec in PLAT_SPEC_TO_RUNTIME: vcruntime_plat = PLAT_SPEC_TO_RUNTIME[plat_spec] else: vcruntime_plat = 'x64' if 'amd64' in plat_s...
[ "def", "_msvc14_find_vcvarsall", "(", "plat_spec", ")", ":", "_", ",", "best_dir", "=", "_msvc14_find_vc2017", "(", ")", "vcruntime", "=", "None", "if", "plat_spec", "in", "PLAT_SPEC_TO_RUNTIME", ":", "vcruntime_plat", "=", "PLAT_SPEC_TO_RUNTIME", "[", "plat_spec", ...
[ 216, 0 ]
[ 252, 31 ]
python
ceb
['fi', 'ceb', 'en']
False
_msvc14_get_vc_env
(plat_spec)
Python 3.8 "distutils/_msvccompiler.py" backport
Python 3.8 "distutils/_msvccompiler.py" backport
def _msvc14_get_vc_env(plat_spec): """Python 3.8 "distutils/_msvccompiler.py" backport""" if "DISTUTILS_USE_SDK" in environ: return { key.lower(): value for key, value in environ.items() } vcvarsall, vcruntime = _msvc14_find_vcvarsall(plat_spec) if not vcvarsall:...
[ "def", "_msvc14_get_vc_env", "(", "plat_spec", ")", ":", "if", "\"DISTUTILS_USE_SDK\"", "in", "environ", ":", "return", "{", "key", ".", "lower", "(", ")", ":", "value", "for", "key", ",", "value", "in", "environ", ".", "items", "(", ")", "}", "vcvarsall...
[ 255, 0 ]
[ 288, 14 ]
python
ceb
['fi', 'ceb', 'en']
False
msvc14_get_vc_env
(plat_spec)
Patched "distutils._msvccompiler._get_vc_env" for support extra Microsoft Visual C++ 14.X compilers. Set environment without use of "vcvarsall.bat". Parameters ---------- plat_spec: str Target architecture. Return ------ dict environment
Patched "distutils._msvccompiler._get_vc_env" for support extra Microsoft Visual C++ 14.X compilers.
def msvc14_get_vc_env(plat_spec): """ Patched "distutils._msvccompiler._get_vc_env" for support extra Microsoft Visual C++ 14.X compilers. Set environment without use of "vcvarsall.bat". Parameters ---------- plat_spec: str Target architecture. Return ------ dict ...
[ "def", "msvc14_get_vc_env", "(", "plat_spec", ")", ":", "# Always use backport from CPython 3.8", "try", ":", "return", "_msvc14_get_vc_env", "(", "plat_spec", ")", "except", "distutils", ".", "errors", ".", "DistutilsPlatformError", "as", "exc", ":", "_augment_exceptio...
[ 291, 0 ]
[ 314, 13 ]
python
en
['en', 'error', 'th']
False
msvc14_gen_lib_options
(*args, **kwargs)
Patched "distutils._msvccompiler.gen_lib_options" for fix compatibility between "numpy.distutils" and "distutils._msvccompiler" (for Numpy < 1.11.2)
Patched "distutils._msvccompiler.gen_lib_options" for fix compatibility between "numpy.distutils" and "distutils._msvccompiler" (for Numpy < 1.11.2)
def msvc14_gen_lib_options(*args, **kwargs): """ Patched "distutils._msvccompiler.gen_lib_options" for fix compatibility between "numpy.distutils" and "distutils._msvccompiler" (for Numpy < 1.11.2) """ if "numpy.distutils" in sys.modules: import numpy as np if LegacyVersion(np.__...
[ "def", "msvc14_gen_lib_options", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "\"numpy.distutils\"", "in", "sys", ".", "modules", ":", "import", "numpy", "as", "np", "if", "LegacyVersion", "(", "np", ".", "__version__", ")", "<", "LegacyVersi...
[ 317, 0 ]
[ 327, 65 ]
python
en
['en', 'error', 'th']
False
_augment_exception
(exc, version, arch='')
Add details to the exception message to help guide the user as to what action will resolve it.
Add details to the exception message to help guide the user as to what action will resolve it.
def _augment_exception(exc, version, arch=''): """ Add details to the exception message to help guide the user as to what action will resolve it. """ # Error if MSVC++ directory not found or environment not set message = exc.args[0] if "vcvarsall" in message.lower() or "visual c" in message...
[ "def", "_augment_exception", "(", "exc", ",", "version", ",", "arch", "=", "''", ")", ":", "# Error if MSVC++ directory not found or environment not set", "message", "=", "exc", ".", "args", "[", "0", "]", "if", "\"vcvarsall\"", "in", "message", ".", "lower", "(...
[ 330, 0 ]
[ 364, 26 ]
python
en
['en', 'error', 'th']
False
PlatformInfo.target_cpu
(self)
Return Target CPU architecture. Return ------ str Target CPU
Return Target CPU architecture.
def target_cpu(self): """ Return Target CPU architecture. Return ------ str Target CPU """ return self.arch[self.arch.find('_') + 1:]
[ "def", "target_cpu", "(", "self", ")", ":", "return", "self", ".", "arch", "[", "self", ".", "arch", ".", "find", "(", "'_'", ")", "+", "1", ":", "]" ]
[ 382, 4 ]
[ 391, 50 ]
python
en
['en', 'error', 'th']
False
PlatformInfo.target_is_x86
(self)
Return True if target CPU is x86 32 bits.. Return ------ bool CPU is x86 32 bits
Return True if target CPU is x86 32 bits..
def target_is_x86(self): """ Return True if target CPU is x86 32 bits.. Return ------ bool CPU is x86 32 bits """ return self.target_cpu == 'x86'
[ "def", "target_is_x86", "(", "self", ")", ":", "return", "self", ".", "target_cpu", "==", "'x86'" ]
[ 393, 4 ]
[ 402, 39 ]
python
en
['en', 'error', 'th']
False
PlatformInfo.current_is_x86
(self)
Return True if current CPU is x86 32 bits.. Return ------ bool CPU is x86 32 bits
Return True if current CPU is x86 32 bits..
def current_is_x86(self): """ Return True if current CPU is x86 32 bits.. Return ------ bool CPU is x86 32 bits """ return self.current_cpu == 'x86'
[ "def", "current_is_x86", "(", "self", ")", ":", "return", "self", ".", "current_cpu", "==", "'x86'" ]
[ 404, 4 ]
[ 413, 40 ]
python
en
['en', 'error', 'th']
False
PlatformInfo.current_dir
(self, hidex86=False, x64=False)
Current platform specific subfolder. Parameters ---------- hidex86: bool return '' and not '\x86' if architecture is x86. x64: bool return '\x64' and not '\amd64' if architecture is amd64. Return ------ str subfolder:...
Current platform specific subfolder.
def current_dir(self, hidex86=False, x64=False): """ Current platform specific subfolder. Parameters ---------- hidex86: bool return '' and not '\x86' if architecture is x86. x64: bool return '\x64' and not '\amd64' if architecture is amd64. ...
[ "def", "current_dir", "(", "self", ",", "hidex86", "=", "False", ",", "x64", "=", "False", ")", ":", "return", "(", "''", "if", "(", "self", ".", "current_cpu", "==", "'x86'", "and", "hidex86", ")", "else", "r'\\x64'", "if", "(", "self", ".", "curren...
[ 415, 4 ]
[ 435, 9 ]
python
en
['en', 'error', 'th']
False
PlatformInfo.target_dir
(self, hidex86=False, x64=False)
r""" Target platform specific subfolder. Parameters ---------- hidex86: bool return '' and not '\x86' if architecture is x86. x64: bool return '\x64' and not '\amd64' if architecture is amd64. Return ------ str subfold...
r""" Target platform specific subfolder.
def target_dir(self, hidex86=False, x64=False): r""" Target platform specific subfolder. Parameters ---------- hidex86: bool return '' and not '\x86' if architecture is x86. x64: bool return '\x64' and not '\amd64' if architecture is amd64. ...
[ "def", "target_dir", "(", "self", ",", "hidex86", "=", "False", ",", "x64", "=", "False", ")", ":", "return", "(", "''", "if", "(", "self", ".", "target_cpu", "==", "'x86'", "and", "hidex86", ")", "else", "r'\\x64'", "if", "(", "self", ".", "target_c...
[ 437, 4 ]
[ 457, 9 ]
python
cy
['en', 'cy', 'hi']
False
PlatformInfo.cross_dir
(self, forcex86=False)
r""" Cross platform specific subfolder. Parameters ---------- forcex86: bool Use 'x86' as current architecture even if current architecture is not x86. Return ------ str subfolder: '' if target architecture is current architec...
r""" Cross platform specific subfolder.
def cross_dir(self, forcex86=False): r""" Cross platform specific subfolder. Parameters ---------- forcex86: bool Use 'x86' as current architecture even if current architecture is not x86. Return ------ str subfolder: ...
[ "def", "cross_dir", "(", "self", ",", "forcex86", "=", "False", ")", ":", "current", "=", "'x86'", "if", "forcex86", "else", "self", ".", "current_cpu", "return", "(", "''", "if", "self", ".", "target_cpu", "==", "current", "else", "self", ".", "target_d...
[ 459, 4 ]
[ 479, 9 ]
python
cy
['en', 'cy', 'hi']
False
RegistryInfo.visualstudio
(self)
Microsoft Visual Studio root registry key. Return ------ str Registry key
Microsoft Visual Studio root registry key.
def visualstudio(self): """ Microsoft Visual Studio root registry key. Return ------ str Registry key """ return 'VisualStudio'
[ "def", "visualstudio", "(", "self", ")", ":", "return", "'VisualStudio'" ]
[ 500, 4 ]
[ 509, 29 ]
python
en
['en', 'error', 'th']
False
RegistryInfo.sxs
(self)
Microsoft Visual Studio SxS registry key. Return ------ str Registry key
Microsoft Visual Studio SxS registry key.
def sxs(self): """ Microsoft Visual Studio SxS registry key. Return ------ str Registry key """ return join(self.visualstudio, 'SxS')
[ "def", "sxs", "(", "self", ")", ":", "return", "join", "(", "self", ".", "visualstudio", ",", "'SxS'", ")" ]
[ 512, 4 ]
[ 521, 45 ]
python
en
['en', 'error', 'th']
False
RegistryInfo.vc
(self)
Microsoft Visual C++ VC7 registry key. Return ------ str Registry key
Microsoft Visual C++ VC7 registry key.
def vc(self): """ Microsoft Visual C++ VC7 registry key. Return ------ str Registry key """ return join(self.sxs, 'VC7')
[ "def", "vc", "(", "self", ")", ":", "return", "join", "(", "self", ".", "sxs", ",", "'VC7'", ")" ]
[ 524, 4 ]
[ 533, 36 ]
python
en
['en', 'error', 'th']
False
RegistryInfo.vs
(self)
Microsoft Visual Studio VS7 registry key. Return ------ str Registry key
Microsoft Visual Studio VS7 registry key.
def vs(self): """ Microsoft Visual Studio VS7 registry key. Return ------ str Registry key """ return join(self.sxs, 'VS7')
[ "def", "vs", "(", "self", ")", ":", "return", "join", "(", "self", ".", "sxs", ",", "'VS7'", ")" ]
[ 536, 4 ]
[ 545, 36 ]
python
en
['en', 'error', 'th']
False
RegistryInfo.vc_for_python
(self)
Microsoft Visual C++ for Python registry key. Return ------ str Registry key
Microsoft Visual C++ for Python registry key.
def vc_for_python(self): """ Microsoft Visual C++ for Python registry key. Return ------ str Registry key """ return r'DevDiv\VCForPython'
[ "def", "vc_for_python", "(", "self", ")", ":", "return", "r'DevDiv\\VCForPython'" ]
[ 548, 4 ]
[ 557, 36 ]
python
en
['en', 'error', 'th']
False
RegistryInfo.microsoft_sdk
(self)
Microsoft SDK registry key. Return ------ str Registry key
Microsoft SDK registry key.
def microsoft_sdk(self): """ Microsoft SDK registry key. Return ------ str Registry key """ return 'Microsoft SDKs'
[ "def", "microsoft_sdk", "(", "self", ")", ":", "return", "'Microsoft SDKs'" ]
[ 560, 4 ]
[ 569, 31 ]
python
en
['en', 'error', 'th']
False