uid stringlengths 24 24 | split stringclasses 1
value | category stringclasses 2
values | content stringlengths 5 482k | signature stringlengths 1 14k | suffix stringlengths 1 482k | prefix stringlengths 9 14k | prefix_token_count int64 3 5.01k | prefix_token_budget int64 64 256 | element_token_count int64 1 292k | signature_token_count int64 1 5.01k | prefix_context_token_count int64 0 255 | repo stringlengths 7 112 | path stringlengths 4 208 | language stringclasses 1
value | name stringlengths 1 218 | qualname stringlengths 1 218 | start_line int64 1 26.7k | end_line int64 1 26.7k | signature_start_line int64 1 26.7k | signature_end_line int64 1 26.7k | source_hash stringlengths 40 40 | source_dataset stringclasses 1
value | source_split stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
bf69d825a266e98ab64e39c8 | train | function | def cast(value, dtype):
if is_constant(value):
return dtype(value)
if is_numpy(value):
dtypes = {
float: np.float32,
int: np.int32,
bool: np.bool,
}
return np.cast[dtypes[dtype]](value)
dtypes = {
float: tf.float32,
int: tf.... | def cast(value, dtype):
| if is_constant(value):
return dtype(value)
if is_numpy(value):
dtypes = {
float: np.float32,
int: np.int32,
bool: np.bool,
}
return np.cast[dtypes[dtype]](value)
dtypes = {
float: tf.float32,
int: tf.int32,
bool: tf.... | instance(
a, (bool, int, float, np.ndarray, np.float32, np.int32, np.bool_))
for a in args)
def is_tensor(*args):
return any(isinstance(a, (tf.Tensor, tf.Variable)) for a in args)
def cast(value, dtype):
| 64 | 64 | 100 | 6 | 58 | deep-fry/mayo | mayo/override/util.py | Python | cast | cast | 24 | 39 | 24 | 24 | 0a1e03b37b48856d04e7ab20de654652bb41f5ad | bigcode/the-stack | train |
464b2687cc2ada5a70f185ff | train | function | def top_k(tensor, k):
if is_tensor(tensor):
tensor = tf.reshape(tensor, [-1])
topk = tf.nn.top_k(tensor, k)
return tf.reduce_min(cast(topk.values, float))
return sorted(tensor)[k]
| def top_k(tensor, k):
| if is_tensor(tensor):
tensor = tf.reshape(tensor, [-1])
topk = tf.nn.top_k(tensor, k)
return tf.reduce_min(cast(topk.values, float))
return sorted(tensor)[k]
| ), maximum)
omap = {}
if transparent_backprop:
omap = {'Minimum': 'Identity', 'Maximum': 'Identity'}
with tf.get_default_graph().gradient_override_map(omap):
return tf.clip_by_value(tensor, minimum, maximum)
def top_k(tensor, k):
| 64 | 64 | 60 | 8 | 56 | deep-fry/mayo | mayo/override/util.py | Python | top_k | top_k | 206 | 211 | 206 | 206 | c068d13a15dec96307d41c6ee53491a393b1c294 | bigcode/the-stack | train |
af20aff2da2fb804bfff6601 | train | function | def get_shape(tensor):
if is_tensor(tensor):
return tensor.get_shape()
return tensor.shape
| def get_shape(tensor):
| if is_tensor(tensor):
return tensor.get_shape()
return tensor.shape
| if is_tensor(tensor):
return tf.nn.moments(tf.abs(tensor), axes=axes)
mean = np.mean(tensor, axis=tuple(axes))
var = np.var(tensor, axis=tuple(axes))
return (mean, var)
def get_shape(tensor):
| 64 | 64 | 24 | 6 | 58 | deep-fry/mayo | mayo/override/util.py | Python | get_shape | get_shape | 222 | 225 | 222 | 222 | 24b9c452a510e944793ef1baa1bd4798c55528b9 | bigcode/the-stack | train |
65e867cbad7df1d4edd0ee5e | train | function | def where(bool_expr, true_value=None, false_value=None):
args = [a for a in (bool_expr, true_value, false_value) if a is not None]
if is_constant(*args):
_constants_not_accepted(where)
if is_numpy(*args):
if true_value is None and false_value is None:
return np.where(bool_expr)
... | def where(bool_expr, true_value=None, false_value=None):
| args = [a for a in (bool_expr, true_value, false_value) if a is not None]
if is_constant(*args):
_constants_not_accepted(where)
if is_numpy(*args):
if true_value is None and false_value is None:
return np.where(bool_expr)
return np.where(bool_expr, true_value, false_value... | int: tf.int32,
bool: tf.bool,
}
return tf.cast(value, dtypes[dtype])
def _constants_not_accepted(func):
raise TypeError('{} does not accept constants as argmuents.'.format(func))
def where(bool_expr, true_value=None, false_value=None):
| 64 | 64 | 104 | 13 | 51 | deep-fry/mayo | mayo/override/util.py | Python | where | where | 46 | 54 | 46 | 46 | e2f4de3ad12d3524e68b9f095c68014ebc090647 | bigcode/the-stack | train |
bd8bf89c14b3deb8efe5a504 | train | function | def is_tensor(*args):
return any(isinstance(a, (tf.Tensor, tf.Variable)) for a in args)
| def is_tensor(*args):
| return any(isinstance(a, (tf.Tensor, tf.Variable)) for a in args)
| a in args)
def is_numpy(*args):
if is_constant(*args):
return False
return all(isinstance(
a, (bool, int, float, np.ndarray, np.float32, np.int32, np.bool_))
for a in args)
def is_tensor(*args):
| 64 | 64 | 25 | 6 | 58 | deep-fry/mayo | mayo/override/util.py | Python | is_tensor | is_tensor | 20 | 21 | 20 | 20 | 187c8c7b7cd43494dce51f4de8ba1569124654e4 | bigcode/the-stack | train |
11e086a445fd2eae6ed451f0 | train | function | def floor(value):
if is_constant(value):
return math.floor(value)
if is_numpy(value):
return np.floor(value)
omap = {'Floor': 'Identity'}
with tf.get_default_graph().gradient_override_map(omap):
return tf.floor(value)
| def floor(value):
| if is_constant(value):
return math.floor(value)
if is_numpy(value):
return np.floor(value)
omap = {'Floor': 'Identity'}
with tf.get_default_graph().gradient_override_map(omap):
return tf.floor(value)
| _not_accepted(where)
if is_numpy(value):
return np.mean(value)
return tf.reduce_mean(value)
def count(value):
if is_constant(value):
_constants_not_accepted(where)
if is_numpy(value):
return value.size
return value.shape.num_elements()
def floor(value):
| 64 | 64 | 57 | 4 | 60 | deep-fry/mayo | mayo/override/util.py | Python | floor | floor | 90 | 97 | 90 | 90 | 7f19b5f4fc5633b8f7a4dca8ae5ac9c0a9d6a161 | bigcode/the-stack | train |
b8255b59da9950133efdfc4f | train | function | def clip_by_value(tensor, minimum, maximum, transparent_backprop=False):
if not is_tensor(tensor, minimum, maximum):
return min(max(tensor, minimum), maximum)
omap = {}
if transparent_backprop:
omap = {'Minimum': 'Identity', 'Maximum': 'Identity'}
with tf.get_default_graph().gradient_ove... | def clip_by_value(tensor, minimum, maximum, transparent_backprop=False):
| if not is_tensor(tensor, minimum, maximum):
return min(max(tensor, minimum), maximum)
omap = {}
if transparent_backprop:
omap = {'Minimum': 'Identity', 'Maximum': 'Identity'}
with tf.get_default_graph().gradient_override_map(omap):
return tf.clip_by_value(tensor, minimum, maximum... | (*args) if min_max else np.maximum(*args)
return tf.minimum(*args) if min_max else tf.maximum(*args)
min = partial(_clip, min_max=True)
max = partial(_clip, min_max=False)
def clip_by_value(tensor, minimum, maximum, transparent_backprop=False):
| 64 | 64 | 92 | 16 | 48 | deep-fry/mayo | mayo/override/util.py | Python | clip_by_value | clip_by_value | 196 | 203 | 196 | 196 | 393015bb81702515615010ef34f8c484d03f62ee | bigcode/the-stack | train |
279ad14138fb6f2b6c591e67 | train | function | def sum(value):
if is_constant(value):
_constants_not_accepted(where)
if is_numpy(value):
return np.sum(value)
return tf.reduce_sum(value)
| def sum(value):
| if is_constant(value):
_constants_not_accepted(where)
if is_numpy(value):
return np.sum(value)
return tf.reduce_sum(value)
| true_value, false_value)
def nonzero(value):
if is_constant(value):
_constants_not_accepted(nonzero)
if is_numpy(value):
return np.nonzero(value)
raise TypeError(
'Tensorflow does not implement a function to compute non-zero values.')
def sum(value):
| 63 | 64 | 37 | 4 | 59 | deep-fry/mayo | mayo/override/util.py | Python | sum | sum | 66 | 71 | 66 | 66 | f012ce4b887a7376c6c764d34c9e746b62e35406 | bigcode/the-stack | train |
0e1a22312f0ae41446ce154f | train | function | def nonzero(value):
if is_constant(value):
_constants_not_accepted(nonzero)
if is_numpy(value):
return np.nonzero(value)
raise TypeError(
'Tensorflow does not implement a function to compute non-zero values.')
| def nonzero(value):
| if is_constant(value):
_constants_not_accepted(nonzero)
if is_numpy(value):
return np.nonzero(value)
raise TypeError(
'Tensorflow does not implement a function to compute non-zero values.')
| _constants_not_accepted(where)
if is_numpy(*args):
if true_value is None and false_value is None:
return np.where(bool_expr)
return np.where(bool_expr, true_value, false_value)
return tf.where(bool_expr, true_value, false_value)
def nonzero(value):
| 64 | 64 | 53 | 5 | 59 | deep-fry/mayo | mayo/override/util.py | Python | nonzero | nonzero | 57 | 63 | 57 | 57 | b932eba18b04e7a73d80f0e40a2b6b91345a4e9b | bigcode/the-stack | train |
a8ae3d9fe7ad2e4c86da5fcf | train | function | def round(value):
if is_constant(value):
return math.floor(value + 0.5)
if is_numpy(value):
return np.round(value)
omap = {'Round': 'Identity'}
with tf.get_default_graph().gradient_override_map(omap):
return tf.round(value)
| def round(value):
| if is_constant(value):
return math.floor(value + 0.5)
if is_numpy(value):
return np.round(value)
omap = {'Round': 'Identity'}
with tf.get_default_graph().gradient_override_map(omap):
return tf.round(value)
| (value)
def ceil(value):
if is_constant(value):
return math.ceil(value)
if is_numpy(value):
return np.ceil(value)
omap = {'Ceil': 'Identity'}
with tf.get_default_graph().gradient_override_map(omap):
return tf.ceil(value)
def round(value):
| 64 | 64 | 62 | 4 | 60 | deep-fry/mayo | mayo/override/util.py | Python | round | round | 110 | 117 | 110 | 110 | 7d7d81f1e28199e86a5e2b51b5f2333ccde55b3c | bigcode/the-stack | train |
f41bc403cf9f013491763cc5 | train | function | def _binary_bool_operation(a, b, op):
if is_constant(a, b):
_constants_not_accepted('Element-wise operation')
if is_numpy(a, b):
return getattr(np, op)(a, b)
return getattr(tf, op)(a, b)
| def _binary_bool_operation(a, b, op):
| if is_constant(a, b):
_constants_not_accepted('Element-wise operation')
if is_numpy(a, b):
return getattr(np, op)(a, b)
return getattr(tf, op)(a, b)
| base=None):
if is_constant(value, base):
return math.log(value, base)
if is_numpy(value, base):
return np.log(value) / np.log(base)
return tf.log(value) / tf.log(cast(base, float))
def _binary_bool_operation(a, b, op):
| 64 | 64 | 60 | 11 | 53 | deep-fry/mayo | mayo/override/util.py | Python | _binary_bool_operation | _binary_bool_operation | 164 | 169 | 164 | 164 | cb767fa3633d00542d3ccbc6add91d1efaabcb24 | bigcode/the-stack | train |
a6defc46603860d8988b512c | train | function | def selection_6():
# Library import
import numpy
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
# Library version
matplotlib_version = matplotlib.__version__
numpy_version = numpy.__version__
# Histo binning
xBinning = numpy.lin... | def selection_6():
# Library import
| import numpy
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
# Library version
matplotlib_version = matplotlib.__version__
numpy_version = numpy.__version__
# Histo binning
xBinning = numpy.linspace(0.0,15.0,76,endpoint=True)
# C... | def selection_6():
# Library import
| 10 | 256 | 10,250 | 10 | 0 | sheride/axion_pheno | optimization/first_sdEta_mjj_optimization/sdEta_mistake_analyses/dEta_mmjj_cuts_plots/tight_analysis_sdeta_3.6_mmjj_1250/Output/Histos/MadAnalysis5job_0/selection_6.py | Python | selection_6 | selection_6 | 1 | 189 | 1 | 3 | 9cb4e30bd23e3a004ba4032c79c810b923b97c7d | bigcode/the-stack | train |
2189a0b0fc3e26d626b384d0 | train | class | class BaseWorkTests(CommonCommonTests, unittest.TestCase):
"""
Tests for scheduling work.
"""
@inlineCallbacks
def setUp(self):
yield super(BaseWorkTests, self).setUp()
yield self.buildStoreAndDirectory()
yield self.populate()
@inlineCallbacks
def populate(self):
... | class BaseWorkTests(CommonCommonTests, unittest.TestCase):
| """
Tests for scheduling work.
"""
@inlineCallbacks
def setUp(self):
yield super(BaseWorkTests, self).setUp()
yield self.buildStoreAndDirectory()
yield self.populate()
@inlineCallbacks
def populate(self):
yield populateCalendarsFrom(self.requirements, self.... | License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See ... | 243 | 243 | 810 | 12 | 230 | eventable/CalendarServer | txdav/caldav/datastore/scheduling/test/test_work.py | Python | BaseWorkTests | BaseWorkTests | 35 | 186 | 35 | 35 | d3aed13a6fa6c0d49e9d78d246b7413277159ac6 | bigcode/the-stack | train |
21e0892a76b6d1d8bcc29377 | train | class | class TestScheduleWork(BaseWorkTests):
"""
Test various scheduling work scenarios that are potential race conditions and could give rise to
partstat mismatches between organizer and attendee, or cause work items to fail.
"""
def configure(self):
super(TestScheduleWork, self).configure()
... | class TestScheduleWork(BaseWorkTests):
| """
Test various scheduling work scenarios that are potential race conditions and could give rise to
partstat mismatches between organizer and attendee, or cause work items to fail.
"""
def configure(self):
super(TestScheduleWork, self).configure()
# Enable the queue and make it sl... | d" % i for i in range(1, 100)])))
@inlineCallbacks
def test_create(self):
"""
Test that jobs associated with L{txdav.caldav.datastore.scheduling.work.ScheduleOrganizerSendWork}
can be created and correctly removed.
"""
txn = self.transactionUnderTest()
home = y... | 256 | 256 | 6,488 | 8 | 248 | eventable/CalendarServer | txdav/caldav/datastore/scheduling/test/test_work.py | Python | TestScheduleWork | TestScheduleWork | 379 | 967 | 379 | 379 | 7d57d40f480b63d1ad8cc3f8ba6cb76e90368fb8 | bigcode/the-stack | train |
92997e2039f08547f68a9a02 | train | class | class TestScheduleOrganizerSendWork(BaseWorkTests):
"""
Test creation of L{ScheduleOrganizerSendWork} items.
"""
itip_new = Component.fromString("""BEGIN:VCALENDAR
VERSION:2.0
METHOD:REQUEST
PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
BEGIN:VEVENT
UID:12345-67890
DTSTART:20080601T130000Z
DURATI... | class TestScheduleOrganizerSendWork(BaseWorkTests):
| """
Test creation of L{ScheduleOrganizerSendWork} items.
"""
itip_new = Component.fromString("""BEGIN:VCALENDAR
VERSION:2.0
METHOD:REQUEST
PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
BEGIN:VEVENT
UID:12345-67890
DTSTART:20080601T130000Z
DURATION:PT1H
ORGANIZER:urn:x-uid:user01
{attendees}
END:V... | 0].workItem()
self.assertTrue(work is None)
yield self.commit()
yield JobItem.waitEmpty(self.storeUnderTest().newTransaction, reactor, 60)
jobs = yield JobItem.all(self.transactionUnderTest())
self.assertEqual(len(jobs), 0)
work = yield ScheduleOrganizerWork.all(self.tr... | 117 | 117 | 391 | 10 | 107 | eventable/CalendarServer | txdav/caldav/datastore/scheduling/test/test_work.py | Python | TestScheduleOrganizerSendWork | TestScheduleOrganizerSendWork | 321 | 375 | 321 | 321 | 2ad6876154d92c929fbd34114ac93674e5c78d46 | bigcode/the-stack | train |
b370643e2596475efd85fdd9 | train | class | class TestScheduleOrganizerWork(BaseWorkTests):
"""
Test creation of L{ScheduleOrganizerWork} items.
"""
calendar_old = Component.fromString("""BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
BEGIN:VEVENT
UID:12345-67890
DTSTART:20080601T120000Z
DURATION:PT1H
ORGANIZER:u... | class TestScheduleOrganizerWork(BaseWorkTests):
| """
Test creation of L{ScheduleOrganizerWork} items.
"""
calendar_old = Component.fromString("""BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
BEGIN:VEVENT
UID:12345-67890
DTSTART:20080601T120000Z
DURATION:PT1H
ORGANIZER:urn:uuid:user01
ATTENDEE:urn:uuid:user01
ATTENDEE... | """
Get the organizer's event.
"""
calobj = yield self.getOrganizerResource(organizer)
comp = yield calobj.componentForUser()
yield self.commit()
returnValue(comp)
@inlineCallbacks
def getAttendeeResource(self, attendee):
"""
Get the atte... | 256 | 256 | 945 | 9 | 247 | eventable/CalendarServer | txdav/caldav/datastore/scheduling/test/test_work.py | Python | TestScheduleOrganizerWork | TestScheduleOrganizerWork | 190 | 317 | 190 | 190 | 5f76600da2b02fdb5121905d6ff1401c23f46e3c | bigcode/the-stack | train |
b49198c584370c71fb75095e | train | class | class Objects(object):
VOID = Object('void')
BOOL = Object('bool')
INT = Object('int')
STRING = Object('string')
FLOAT = Object('float')
| class Objects(object):
| VOID = Object('void')
BOOL = Object('bool')
INT = Object('int')
STRING = Object('string')
FLOAT = Object('float')
| == 'float':
self.initial_value = "0.0"
elif self.type == 'bool':
self.initial_value = "false"
elif self.type == 'string':
self.initial_value = '""'
elif self.is_pointer:
self.initial_value = "nullptr"
class Objects(obje... | 64 | 64 | 39 | 4 | 60 | mlc-tools/mlc-tools | mlc_tools/core/object.py | Python | Objects | Objects | 131 | 136 | 131 | 131 | 4d1fee115dd2f28e5d457017793259f2330ea1b4 | bigcode/the-stack | train |
4214add0cc74c3f0c30a0144 | train | class | class AccessSpecifier(Enum):
public = 0
protected = 1
private = 2
@staticmethod
def find_access(object_or_fucntion, string):
if Modifiers.private in string:
object_or_fucntion.access = AccessSpecifier.private
string = string.replace(Modifiers.private, '')
eli... | class AccessSpecifier(Enum):
| public = 0
protected = 1
private = 2
@staticmethod
def find_access(object_or_fucntion, string):
if Modifiers.private in string:
object_or_fucntion.access = AccessSpecifier.private
string = string.replace(Modifiers.private, '')
elif Modifiers.protected in stri... | from enum import Enum
from .modifiers import Modifiers
from ..utils.error import Error
class AccessSpecifier(Enum):
| 25 | 64 | 183 | 5 | 19 | mlc-tools/mlc-tools | mlc_tools/core/object.py | Python | AccessSpecifier | AccessSpecifier | 6 | 30 | 6 | 6 | 8fd52adb1b5a3b4340917fa64e4d4e84274690ac | bigcode/the-stack | train |
8abc4e935bf48c4fc59bb61e | train | class | class Object(object):
def __init__(self, type_=''):
self.type = type_
self.template_args = []
self.callable_args = None
self.name = ''
self.initial_value = None
self.is_pointer = False
self.is_ref = False
self.is_runtime = False
self.is_static... | class Object(object):
| def __init__(self, type_=''):
self.type = type_
self.template_args = []
self.callable_args = None
self.name = ''
self.initial_value = None
self.is_pointer = False
self.is_ref = False
self.is_runtime = False
self.is_static = False
self.i... | from enum import Enum
from .modifiers import Modifiers
from ..utils.error import Error
class AccessSpecifier(Enum):
public = 0
protected = 1
private = 2
@staticmethod
def find_access(object_or_fucntion, string):
if Modifiers.private in string:
object_or_fucntion.access = Acces... | 207 | 225 | 753 | 4 | 203 | mlc-tools/mlc-tools | mlc_tools/core/object.py | Python | Object | Object | 33 | 128 | 33 | 34 | 7bce4f3de3c681b2500042b0ff1ed65130ab4b20 | bigcode/the-stack | train |
ed91d7b76f0d36a29696167f | train | class | class GitShareGroup(object):
def __init__(self):
self.group_id = None
self.group_name = None
self.group_access_level = 10
@classmethod
def load(cls, json):
instance = GitShareGroup()
if 'group_id' in json:
instance.group_id = json['group_id']
if '... | class GitShareGroup(object):
| def __init__(self):
self.group_id = None
self.group_name = None
self.group_access_level = 10
@classmethod
def load(cls, json):
instance = GitShareGroup()
if 'group_id' in json:
instance.group_id = json['group_id']
if 'group_name' in json:
... | by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class GitShareGroup(o... | 64 | 64 | 125 | 6 | 58 | msleprosy/cloud-pipeline | scripts/git-role-management/internal/model/git_share_group.py | Python | GitShareGroup | GitShareGroup | 15 | 30 | 15 | 15 | 57ff0d9ce7a5a405edaa4657ef8217c523fc76b3 | bigcode/the-stack | train |
916d94a32bf6f6fe78a794e7 | train | class | class FileInputWidget(ClearableFileInput):
template_name = "manifest/forms/file_input_widget.html"
| class FileInputWidget(ClearableFileInput):
| template_name = "manifest/forms/file_input_widget.html"
| ", "last_name", "gender", "birth_date"]
class RegionUpdateForm(forms.ModelForm):
""" Base form used for fields that are always required """
class Meta:
model = get_user_model()
fields = ["timezone", "locale"]
class FileInputWidget(ClearableFileInput):
| 63 | 64 | 22 | 10 | 53 | ozgurgunes/django-manifest | manifest/forms.py | Python | FileInputWidget | FileInputWidget | 286 | 287 | 286 | 286 | 175203a4040535454af0e2809faf3790404454db | bigcode/the-stack | train |
1d9aadcc45e10b9c7d7e5d06 | train | class | class RegisterForm(UserCreationForm):
"""
Form for creating a new user account.
Validates that the requested username and email is not already in use.
Also requires the password to be entered twice.
"""
username = forms.RegexField(
label=_("Username"),
regex=r"^\w+$",
... | class RegisterForm(UserCreationForm):
| """
Form for creating a new user account.
Validates that the requested username and email is not already in use.
Also requires the password to be entered twice.
"""
username = forms.RegexField(
label=_("Username"),
regex=r"^\w+$",
max_length=30,
widget=forms.Te... | Custom init to set ``request`` to ``None``.
"""
self.user_cache = None
self.request = kwargs.pop("request", None)
super().__init__(*args, **kwargs)
def clean(self):
"""
Checks for the identification and password.
If the combination can't be found wi... | 178 | 178 | 595 | 7 | 170 | ozgurgunes/django-manifest | manifest/forms.py | Python | RegisterForm | RegisterForm | 77 | 178 | 77 | 77 | 4a674852a3889cb5bc40ecbd5d221e1ac424d601 | bigcode/the-stack | train |
6ec9040528012145346a709a | train | class | class RegionUpdateForm(forms.ModelForm):
""" Base form used for fields that are always required """
class Meta:
model = get_user_model()
fields = ["timezone", "locale"]
| class RegionUpdateForm(forms.ModelForm):
| """ Base form used for fields that are always required """
class Meta:
model = get_user_model()
fields = ["timezone", "locale"]
| datetime.today().year - 10, datetime.today().year - 99, -1
)
),
)
class Meta:
model = get_user_model()
fields = ["first_name", "last_name", "gender", "birth_date"]
class RegionUpdateForm(forms.ModelForm):
| 63 | 64 | 40 | 8 | 55 | ozgurgunes/django-manifest | manifest/forms.py | Python | RegionUpdateForm | RegionUpdateForm | 278 | 283 | 278 | 278 | 99a8b85492da06a815e82bec1845ebfd0720761d | bigcode/the-stack | train |
213cde7656ba1e049ae5edcd | train | class | class RegisterFormToS(RegisterForm):
"""
Add a Terms of Service button to the ``RegisterForm``.
"""
tos = forms.BooleanField(
widget=forms.CheckboxInput(attrs=ATTRS_DICT),
label=_("I have read and agree to the Terms of Service."),
error_messages={
"required": _("You... | class RegisterFormToS(RegisterForm):
| """
Add a Terms of Service button to the ``RegisterForm``.
"""
tos = forms.BooleanField(
widget=forms.CheckboxInput(attrs=ATTRS_DICT),
label=_("I have read and agree to the Terms of Service."),
error_messages={
"required": _("You must agree to the terms to register.... | newly created user.
"""
user = get_user_model().objects.create_user(
self.cleaned_data["username"],
self.cleaned_data["email"],
self.cleaned_data["password1"],
not defaults.MANIFEST_ACTIVATION_REQUIRED,
)
return user
class RegisterFormTo... | 64 | 64 | 81 | 8 | 55 | ozgurgunes/django-manifest | manifest/forms.py | Python | RegisterFormToS | RegisterFormToS | 181 | 193 | 181 | 181 | 1c682b9632cfcc45f4912126810c464a6cf48ac8 | bigcode/the-stack | train |
edab593903c8592f85dffa2c | train | class | class PictureUploadForm(forms.ModelForm):
""" Base form used for fields that are always required """
class Meta:
model = get_user_model()
fields = [
# pylint: disable=all # duplicate-code
"picture"
]
widgets = {"picture": FileInputWidget()}
def clean... | class PictureUploadForm(forms.ModelForm):
| """ Base form used for fields that are always required """
class Meta:
model = get_user_model()
fields = [
# pylint: disable=all # duplicate-code
"picture"
]
widgets = {"picture": FileInputWidget()}
def clean_picture(self):
"""
Valida... | ):
""" Base form used for fields that are always required """
class Meta:
model = get_user_model()
fields = ["timezone", "locale"]
class FileInputWidget(ClearableFileInput):
template_name = "manifest/forms/file_input_widget.html"
class PictureUploadForm(forms.ModelForm):
| 64 | 64 | 98 | 8 | 56 | ozgurgunes/django-manifest | manifest/forms.py | Python | PictureUploadForm | PictureUploadForm | 290 | 306 | 290 | 290 | 23b29a8d2cebe962d573f7d488f8754152f3af1b | bigcode/the-stack | train |
e13cda908116a091ee474a66 | train | class | class EmailChangeForm(forms.Form):
"""
Form for changing user email address.
"""
email = forms.EmailField(
label=_("New email"),
required=True,
widget=forms.TextInput(attrs=dict(ATTRS_DICT, maxlength=75)),
)
def __init__(self, *args, user=None, **kwargs):
"""
... | class EmailChangeForm(forms.Form):
| """
Form for changing user email address.
"""
email = forms.EmailField(
label=_("New email"),
required=True,
widget=forms.TextInput(attrs=dict(ATTRS_DICT, maxlength=75)),
)
def __init__(self, *args, user=None, **kwargs):
"""
The current ``user`` is need... | .MANIFEST_ACTIVATION_REQUIRED,
)
return user
class RegisterFormToS(RegisterForm):
"""
Add a Terms of Service button to the ``RegisterForm``.
"""
tos = forms.BooleanField(
widget=forms.CheckboxInput(attrs=ATTRS_DICT),
label=_("I have read and agree to the Terms of Serv... | 102 | 102 | 342 | 7 | 95 | ozgurgunes/django-manifest | manifest/forms.py | Python | EmailChangeForm | EmailChangeForm | 196 | 246 | 196 | 196 | f732c181f349e7c9fb16e3714f336a9234b3bf72 | bigcode/the-stack | train |
5838a82074c548784310011b | train | class | class LoginForm(forms.Form):
"""
A custom form where the identification can be a email address or username.
"""
identification = forms.CharField(
label=_("Username or Email"),
widget=forms.TextInput(attrs=ATTRS_DICT),
max_length=75,
error_messages={
"require... | class LoginForm(forms.Form):
| """
A custom form where the identification can be a email address or username.
"""
identification = forms.CharField(
label=_("Username or Email"),
widget=forms.TextInput(attrs=ATTRS_DICT),
max_length=75,
error_messages={
"required": _("Please enter your user... |
from django.contrib.auth import authenticate, get_user_model
from django.contrib.auth.forms import UserCreationForm
from django.db.models import Q
from django.forms.widgets import ClearableFileInput
from django.utils.translation import ugettext_lazy as _
from manifest import defaults
from manifest.messages import EMA... | 87 | 88 | 294 | 6 | 81 | ozgurgunes/django-manifest | manifest/forms.py | Python | LoginForm | LoginForm | 21 | 74 | 21 | 21 | 7b60af841b861a305f8a265bfd7125ce27c0445d | bigcode/the-stack | train |
d6009382dcffa92a58ea88cf | train | class | class ProfileUpdateForm(forms.ModelForm):
""" Base form used for fields that are always required """
GENDER_CHOICES = (("F", _("Female")), ("M", _("Male")))
first_name = forms.CharField(
label=_("First name"), max_length=30, required=True
)
last_name = forms.CharField(
label=_("Las... | class ProfileUpdateForm(forms.ModelForm):
| """ Base form used for fields that are always required """
GENDER_CHOICES = (("F", _("Female")), ("M", _("Male")))
first_name = forms.CharField(
label=_("First name"), max_length=30, required=True
)
last_name = forms.CharField(
label=_("Last name"), max_length=30, required=True
... | save(self):
"""
Save method calls :func:`user.change_email()` method which sends out
an email with a verification key to verify and with it enable this
new email address.
"""
return self.user.change_email(self.cleaned_data["email"])
class ProfileUpdateForm(forms.ModelFo... | 63 | 64 | 196 | 8 | 55 | ozgurgunes/django-manifest | manifest/forms.py | Python | ProfileUpdateForm | ProfileUpdateForm | 249 | 275 | 249 | 249 | 3b897f529716b8323ac0474a53cd96fd8e0442f3 | bigcode/the-stack | train |
d72bfef2c663971022c5f808 | train | class | class Plugin(FMT, Badges, Colors, Parser, Tables):
details = {
'Name': "",
'Authors': [
''
],
'Description': "",
'Dependencies': [
''
],
'Comments': [
''
]
}
def run(self):
pass
| class Plugin(FMT, Badges, Colors, Parser, Tables):
| details = {
'Name': "",
'Authors': [
''
],
'Description': "",
'Dependencies': [
''
],
'Comments': [
''
]
}
def run(self):
pass
| USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
from core.cli.badges import Badges
from core.cli.colors import Colors
from core.cli.fmt import FMT
from core.cli.parser import Parser
from core.cli.tables import Tables
class Plugin(FMT, Badges, Colors, Parser, Tables):
| 64 | 64 | 65 | 14 | 49 | sandeepkumarmishra2002/HatSploit | core/lib/plugin.py | Python | Plugin | Plugin | 34 | 50 | 34 | 34 | 3294bad9b7c55d32697ee5a04c5d9b29058ce37f | bigcode/the-stack | train |
aaf794cd28c05d7f002f55ac | train | class | class V1PersistentVolumeClaimVolumeSource(object):
"""
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
"""
Attributes:
swagger_types (dict): The key is attribute name
and the value is attribute type... | class V1PersistentVolumeClaimVolumeSource(object):
| """
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
"""
Attributes:
swagger_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute ... | # coding: utf-8
"""
Kubernetes
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
OpenAPI spec version: v1.8.1
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from pprint import pformat
from six import iteritems
import re
... | 85 | 256 | 912 | 10 | 74 | dix000p/kubernetes-client-python | kubernetes/client/models/v1_persistent_volume_claim_volume_source.py | Python | V1PersistentVolumeClaimVolumeSource | V1PersistentVolumeClaimVolumeSource | 19 | 155 | 19 | 19 | 1862e59c8e5422a019bca506433c7e105bb0f7ba | bigcode/the-stack | train |
0e362aeb2fc694ad596010ff | train | function | def test_envi_2():
tst = gdaltest.GDALTest('envi', 'aea.dat', 1, 14823)
return tst.testCreateCopy(check_gt=1)
| def test_envi_2():
| tst = gdaltest.GDALTest('envi', 'aea.dat', 1, 14823)
return tst.testCreateCopy(check_gt=1)
| .testOpen(check_prj=prj,
check_gt=(-936408.178, 28.5, 0.0,
2423902.344, 0.0, -28.5))
###############################################################################
# Verify this can be exported losslessly.
def test_envi_2():
| 64 | 64 | 42 | 7 | 57 | ajolma/gdal | autotest/gdrivers/envi.py | Python | test_envi_2 | test_envi_2 | 71 | 74 | 71 | 72 | dc1cc350d197438023d03ffc146f8ddd2ea28f41 | bigcode/the-stack | train |
5574c7f446ebc90a4411e07d | train | function | def test_envi_12():
src_ds = gdal.Open('data/testenviclasses')
out_ds = gdal.GetDriverByName('ENVI').CreateCopy('/vsimem/testenviclasses', src_ds)
src_ds = None
del out_ds
gdal.Unlink('/vsimem/testenviclasses.aux.xml')
ds = gdal.Open('/vsimem/testenviclasses')
category = ds.GetRasterBand(... | def test_envi_12():
| src_ds = gdal.Open('data/testenviclasses')
out_ds = gdal.GetDriverByName('ENVI').CreateCopy('/vsimem/testenviclasses', src_ds)
src_ds = None
del out_ds
gdal.Unlink('/vsimem/testenviclasses.aux.xml')
ds = gdal.Open('/vsimem/testenviclasses')
category = ds.GetRasterBand(1).GetCategoryNames()... | .GetRasterBand(1).GetStatistics(0, 0)
ds = None
assert val == [1.0, 3.0, 2.0, 0.5], 'bad stats'
###############################################################################
# Test category names reading and writing
def test_envi_12():
| 64 | 64 | 204 | 7 | 56 | ajolma/gdal | autotest/gdrivers/envi.py | Python | test_envi_12 | test_envi_12 | 253 | 273 | 253 | 254 | 38eadc32e996cd8bffc3520580ea09daf2711d5f | bigcode/the-stack | train |
58043e6284767e8b9b4abd04 | train | function | def test_envi_15():
src_ds = gdal.Open('data/rotation.img')
got_gt = src_ds.GetGeoTransform()
expected_gt = [736600.089, 1.0981889363046606, -2.4665727356350224,
4078126.75, -2.4665727356350224, -1.0981889363046606]
assert max([abs((got_gt[i] - expected_gt[i]) / expected_gt[i]) for i... | def test_envi_15():
| src_ds = gdal.Open('data/rotation.img')
got_gt = src_ds.GetGeoTransform()
expected_gt = [736600.089, 1.0981889363046606, -2.4665727356350224,
4078126.75, -2.4665727356350224, -1.0981889363046606]
assert max([abs((got_gt[i] - expected_gt[i]) / expected_gt[i]) for i in range(6)]) <= 1e-... | ')
assert gdal.VSIStatL('/vsimem/envi_14.dat').size == 3 * 4 * 5 * 2
gdal.GetDriverByName('ENVI').Delete('/vsimem/envi_14.dat')
###############################################################################
# Test reading and writing geotransform matrix with rotation
def test_envi_15():
| 76 | 76 | 256 | 7 | 68 | ajolma/gdal | autotest/gdrivers/envi.py | Python | test_envi_15 | test_envi_15 | 315 | 331 | 315 | 316 | 95a73fe28b54b3e12b3721ccddb6eef56704027a | bigcode/the-stack | train |
ae75cef54504e0745a2fe616 | train | function | def test_envi_13():
ds = gdal.GetDriverByName('ENVI').Create('/vsimem/envi_13.dat', 1, 1)
ds.SetMetadata(['lines=100', 'sensor_type=Landsat TM', 'foo'], 'ENVI')
ds = None
gdal.Unlink('/vsimem/envi_13.dat.aux.xml')
ds = gdal.Open('/vsimem/envi_13.dat')
lines = ds.RasterYSize
val = ds.GetMe... | def test_envi_13():
| ds = gdal.GetDriverByName('ENVI').Create('/vsimem/envi_13.dat', 1, 1)
ds.SetMetadata(['lines=100', 'sensor_type=Landsat TM', 'foo'], 'ENVI')
ds = None
gdal.Unlink('/vsimem/envi_13.dat.aux.xml')
ds = gdal.Open('/vsimem/envi_13.dat')
lines = ds.RasterYSize
val = ds.GetMetadataItem('sensor_ty... | 0, 255), 'bad color entry'
ds = None
gdal.GetDriverByName('ENVI').Delete('/vsimem/testenviclasses')
###############################################################################
# Test writing of metadata from the ENVI metadata domain and read it back (#4957)
def test_envi_13():
| 64 | 64 | 168 | 7 | 57 | ajolma/gdal | autotest/gdrivers/envi.py | Python | test_envi_13 | test_envi_13 | 279 | 295 | 279 | 280 | 16b05fc28d483e46cc9373131fa5648ae2606565 | bigcode/the-stack | train |
90fbd74b2f60226316932823 | train | function | def test_envi_10():
src_ds = gdal.Open('data/envirpc.img')
out_ds = gdal.GetDriverByName('ENVI').CreateCopy('/vsimem/envirpc.img', src_ds)
src_ds = None
del out_ds
gdal.Unlink('/vsimem/envirpc.img.aux.xml')
ds = gdal.Open('/vsimem/envirpc.img')
md = ds.GetMetadata('RPC')
ds = None
... | def test_envi_10():
| src_ds = gdal.Open('data/envirpc.img')
out_ds = gdal.GetDriverByName('ENVI').CreateCopy('/vsimem/envirpc.img', src_ds)
src_ds = None
del out_ds
gdal.Unlink('/vsimem/envirpc.img.aux.xml')
ds = gdal.Open('/vsimem/envirpc.img')
md = ds.GetMetadata('RPC')
ds = None
gdal.GetDriverByNam... | a compressed file
def test_envi_9():
tst = gdaltest.GDALTest('envi', 'aea_compressed.dat', 1, 14823)
return tst.testCreateCopy(check_gt=1)
###############################################################################
# Test RPC reading and writing
def test_envi_10():
| 64 | 64 | 139 | 7 | 56 | ajolma/gdal | autotest/gdrivers/envi.py | Python | test_envi_10 | test_envi_10 | 220 | 235 | 220 | 221 | f6d982df72dc914cfee9d7d02ed9c5673c68ad85 | bigcode/the-stack | train |
dd29fc890ac5bc7770e85501 | train | function | def test_envi_9():
tst = gdaltest.GDALTest('envi', 'aea_compressed.dat', 1, 14823)
return tst.testCreateCopy(check_gt=1)
| def test_envi_9():
| tst = gdaltest.GDALTest('envi', 'aea_compressed.dat', 1, 14823)
return tst.testCreateCopy(check_gt=1)
| = ds.GetGeoTransform()
assert set_gt == got_gt, 'did not get expected geotransform'
ds = None
gdal.GetDriverByName('ENVI').Delete('/vsimem/foo.bsq')
###############################################################################
# Verify reading a compressed file
def test_envi_9():
| 64 | 64 | 44 | 7 | 56 | ajolma/gdal | autotest/gdrivers/envi.py | Python | test_envi_9 | test_envi_9 | 211 | 214 | 211 | 212 | 0ff25fc2bd692b8952219a4dd49f74a0f53c4118 | bigcode/the-stack | train |
25bfe332a1db86e32db419bb | train | function | def test_envi_4():
tst = gdaltest.GDALTest('envi', 'aea.dat', 1, 24)
prj = """PROJCS["unnamed",
GEOGCS["NAD83",
DATUM["North_American_Datum_1983",
SPHEROID["GRS 1980",6378137,298.257222101],
TOWGS84[0,0,0,0,0,0,0]],
PRIMEM["Greenwich",0],
UNIT["degree",0.017... | def test_envi_4():
| tst = gdaltest.GDALTest('envi', 'aea.dat', 1, 24)
prj = """PROJCS["unnamed",
GEOGCS["NAD83",
DATUM["North_American_Datum_1983",
SPHEROID["GRS 1980",6378137,298.257222101],
TOWGS84[0,0,0,0,0,0,0]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433]],
... | return tst.testCreateCopy(check_gt=1)
###############################################################################
# Try the Create interface with an RGB image.
def test_envi_3():
tst = gdaltest.GDALTest('envi', 'rgbsmall.tif', 2, 21053)
return tst.testCreate()
#########################################... | 76 | 76 | 256 | 7 | 69 | ajolma/gdal | autotest/gdrivers/envi.py | Python | test_envi_4 | test_envi_4 | 89 | 109 | 89 | 90 | 5eddb9de63bdbfb987ce41c1ed245ae73d3bcc8b | bigcode/the-stack | train |
b3680d519e3648cd95bc0223 | train | function | def test_envi_truncated():
gdal.GetDriverByName('ENVI').CreateCopy('/vsimem/envi_truncated.dat',
gdal.Open('data/byte.tif'))
f = gdal.VSIFOpenL('/vsimem/envi_truncated.dat', 'wb+')
gdal.VSIFTruncateL(f, int(20 * 20 / 2))
gdal.VSIFCloseL(f)
with gdaltest... | def test_envi_truncated():
| gdal.GetDriverByName('ENVI').CreateCopy('/vsimem/envi_truncated.dat',
gdal.Open('data/byte.tif'))
f = gdal.VSIFOpenL('/vsimem/envi_truncated.dat', 'wb+')
gdal.VSIFTruncateL(f, int(20 * 20 / 2))
gdal.VSIFCloseL(f)
with gdaltest.config_option('RAW_CHECK_FI... | e-5, \
'did not get expected geotransform'
ds = None
gdal.GetDriverByName('ENVI').Delete('/vsimem/envi_15.dat')
###############################################################################
# Test reading a truncated ENVI dataset (see #915)
def test_envi_truncated():
| 64 | 64 | 175 | 7 | 57 | ajolma/gdal | autotest/gdrivers/envi.py | Python | test_envi_truncated | test_envi_truncated | 337 | 352 | 337 | 338 | e65e60096806516e808f8f76f54d4b9c4c151f8a | bigcode/the-stack | train |
391d5f66dfff922306d81c2b | train | function | def test_envi_6():
gdaltest.envi_tst = gdaltest.GDALTest('envi', 'aea.dat', 1, 24)
prj = """PROJCS["unnamed",
GEOGCS["Unknown datum based upon the Authalic Sphere",
DATUM["D_Ellipse_Based",
SPHEROID["Sphere",6370997,0]],
PRIMEM["Greenwich",0],
UNIT["Degree",0.0174532925... | def test_envi_6():
| gdaltest.envi_tst = gdaltest.GDALTest('envi', 'aea.dat', 1, 24)
prj = """PROJCS["unnamed",
GEOGCS["Unknown datum based upon the Authalic Sphere",
DATUM["D_Ellipse_Based",
SPHEROID["Sphere",6370997,0]],
PRIMEM["Greenwich",0],
UNIT["Degree",0.0174532925199433]],
PROJEC... | 6012717],
PARAMETER["false_easting",400000],
PARAMETER["false_northing",-100000],
UNIT["Meter",1]]"""
return tst.testSetProjection(prj=prj, expected_prj=expected_prj)
###############################################################################
# Test LAEA Projection.
def test_envi_6():
| 70 | 70 | 234 | 7 | 63 | ajolma/gdal | autotest/gdrivers/envi.py | Python | test_envi_6 | test_envi_6 | 161 | 181 | 161 | 162 | c53ff764b8625e4e288a140acfd196bf01861131 | bigcode/the-stack | train |
47f8d58168035cf7d7de6ef2 | train | function | def test_envi_11():
ds = gdal.Open('data/envistat')
val = ds.GetRasterBand(1).GetStatistics(0, 0)
ds = None
assert val == [1.0, 3.0, 2.0, 0.5], 'bad stats'
| def test_envi_11():
| ds = gdal.Open('data/envistat')
val = ds.GetRasterBand(1).GetStatistics(0, 0)
ds = None
assert val == [1.0, 3.0, 2.0, 0.5], 'bad stats'
| .img')
md = ds.GetMetadata('RPC')
ds = None
gdal.GetDriverByName('ENVI').Delete('/vsimem/envirpc.img')
assert md['HEIGHT_OFF'] == '3355'
###############################################################################
# Check .sta reading
def test_envi_11():
| 64 | 64 | 69 | 7 | 56 | ajolma/gdal | autotest/gdrivers/envi.py | Python | test_envi_11 | test_envi_11 | 241 | 247 | 241 | 242 | 520c7d58595049677332a9f4a0300da59f265492 | bigcode/the-stack | train |
2ed41e8eb848aaaf58533ece | train | function | def test_envi_1():
tst = gdaltest.GDALTest('envi', 'aea.dat', 1, 14823)
prj = """PROJCS["unnamed",
GEOGCS["Ellipse Based",
DATUM["Ellipse Based",
SPHEROID["Unnamed",6378206.4,294.9786982139109]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433]],
PROJECTION[... | def test_envi_1():
| tst = gdaltest.GDALTest('envi', 'aea.dat', 1, 14823)
prj = """PROJCS["unnamed",
GEOGCS["Ellipse Based",
DATUM["Ellipse Based",
SPHEROID["Unnamed",6378206.4,294.9786982139109]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433]],
PROJECTION["Albers_Conic_Equal_... | DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
###############################################################################
from osgeo import gdal
import gdaltest
#######... | 72 | 72 | 242 | 7 | 65 | ajolma/gdal | autotest/gdrivers/envi.py | Python | test_envi_1 | test_envi_1 | 44 | 65 | 44 | 45 | 1ee30fab93daf7361ec94931c91de6e7208dfe33 | bigcode/the-stack | train |
b789a710b68cab39f80f43bc | train | function | def test_envi_7():
tst = gdaltest.GDALTest('envi', 'aea.dat', 1, 14823)
return tst.testCreateCopy(check_gt=1, vsimem=1)
| def test_envi_7():
| tst = gdaltest.GDALTest('envi', 'aea.dat', 1, 14823)
return tst.testCreateCopy(check_gt=1, vsimem=1)
| ORITY["EPSG","9001"]],
AXIS["Easting",EAST],
AXIS["Northing",NORTH]]"""
return gdaltest.envi_tst.testSetProjection(prj=prj)
###############################################################################
# Verify VSIF*L capacity
def test_envi_7():
| 64 | 64 | 48 | 7 | 56 | ajolma/gdal | autotest/gdrivers/envi.py | Python | test_envi_7 | test_envi_7 | 187 | 190 | 187 | 188 | d16d5d7cf9d4b9162737d0d7fc5e00844f667424 | bigcode/the-stack | train |
25da1104a9dcda7a2ccbd497 | train | function | def test_envi_5():
tst = gdaltest.GDALTest('envi', 'aea.dat', 1, 24)
prj = """PROJCS["OSGB 1936 / British National Grid",
GEOGCS["OSGB 1936",
DATUM["OSGB_1936",
SPHEROID["Airy 1830",6377563.396,299.3249646,
AUTHORITY["EPSG","7001"]],
TOWGS84[446.448,-125.157,... | def test_envi_5():
| tst = gdaltest.GDALTest('envi', 'aea.dat', 1, 24)
prj = """PROJCS["OSGB 1936 / British National Grid",
GEOGCS["OSGB 1936",
DATUM["OSGB_1936",
SPHEROID["Airy 1830",6377563.396,299.3249646,
AUTHORITY["EPSG","7001"]],
TOWGS84[446.448,-125.157,542.06,0.15,0.247,0.... | ",0.0174532925199433]],
PROJECTION["Lambert_Conformal_Conic_2SP"],
PARAMETER["standard_parallel_1",33.90363402775256],
PARAMETER["standard_parallel_2",33.62529002776137],
PARAMETER["latitude_of_origin",33.76446202775696],
PARAMETER["central_meridian",-117.4745428888127],
PARAMETER["false_easting... | 149 | 149 | 499 | 7 | 142 | ajolma/gdal | autotest/gdrivers/envi.py | Python | test_envi_5 | test_envi_5 | 115 | 155 | 115 | 116 | eebbb5f564cfbf878370225028448e0de089a620 | bigcode/the-stack | train |
f5d8724007e52747a46d5f4c | train | function | def test_envi_3():
tst = gdaltest.GDALTest('envi', 'rgbsmall.tif', 2, 21053)
return tst.testCreate()
| def test_envi_3():
| tst = gdaltest.GDALTest('envi', 'rgbsmall.tif', 2, 21053)
return tst.testCreate()
| losslessly.
def test_envi_2():
tst = gdaltest.GDALTest('envi', 'aea.dat', 1, 14823)
return tst.testCreateCopy(check_gt=1)
###############################################################################
# Try the Create interface with an RGB image.
def test_envi_3():
| 64 | 64 | 39 | 7 | 57 | ajolma/gdal | autotest/gdrivers/envi.py | Python | test_envi_3 | test_envi_3 | 80 | 83 | 80 | 81 | debb9eb17df0eeffb39e9e7f2d342c4b4a063abf | bigcode/the-stack | train |
5aef2836c841ed1418940931 | train | function | def test_envi_14():
gdal.GetDriverByName('ENVI').Create('/vsimem/envi_14.dat', 3, 4, 5, gdal.GDT_Int16)
gdal.Unlink('/vsimem/envi_14.dat.aux.xml')
assert gdal.VSIStatL('/vsimem/envi_14.dat').size == 3 * 4 * 5 * 2
gdal.GetDriverByName('ENVI').Delete('/vsimem/envi_14.dat')
| def test_envi_14():
| gdal.GetDriverByName('ENVI').Create('/vsimem/envi_14.dat', 3, 4, 5, gdal.GDT_Int16)
gdal.Unlink('/vsimem/envi_14.dat.aux.xml')
assert gdal.VSIStatL('/vsimem/envi_14.dat').size == 3 * 4 * 5 * 2
gdal.GetDriverByName('ENVI').Delete('/vsimem/envi_14.dat')
| gdal.GetDriverByName('ENVI').Delete('/vsimem/envi_13.dat')
assert lines == 1
assert val == 'Landsat TM'
###############################################################################
# Test that the image file is at the expected size on closing (#6662)
def test_envi_14():
| 64 | 64 | 117 | 7 | 57 | ajolma/gdal | autotest/gdrivers/envi.py | Python | test_envi_14 | test_envi_14 | 301 | 309 | 301 | 302 | 6604d4f01a69d8955d167622e335a695cfe06fd5 | bigcode/the-stack | train |
fca83f64c34887bf77d88f7f | train | function | def test_envi_8():
ds = gdal.GetDriverByName('ENVI').Create('/vsimem/foo.bsq', 10, 10, 1)
set_gt = (50000, 1, 0, 4500000, 0, -1)
ds.SetGeoTransform(set_gt)
got_gt = ds.GetGeoTransform()
assert set_gt == got_gt, 'did not get expected geotransform'
ds = None
gdal.GetDriverByName('ENVI').Dele... | def test_envi_8():
| ds = gdal.GetDriverByName('ENVI').Create('/vsimem/foo.bsq', 10, 10, 1)
set_gt = (50000, 1, 0, 4500000, 0, -1)
ds.SetGeoTransform(set_gt)
got_gt = ds.GetGeoTransform()
assert set_gt == got_gt, 'did not get expected geotransform'
ds = None
gdal.GetDriverByName('ENVI').Delete('/vsimem/foo.bsq'... | test_envi_7():
tst = gdaltest.GDALTest('envi', 'aea.dat', 1, 14823)
return tst.testCreateCopy(check_gt=1, vsimem=1)
###############################################################################
# Test fix for #3751
def test_envi_8():
| 64 | 64 | 122 | 7 | 56 | ajolma/gdal | autotest/gdrivers/envi.py | Python | test_envi_8 | test_envi_8 | 196 | 205 | 196 | 197 | 694ad5829c4ec9753dd87a701f6586da61401556 | bigcode/the-stack | train |
aaaed10998060079459ea038 | train | class | class AdminTaskCreateResponse(object):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
"""
Attributes:
swagger_types (dict): The key is attribute name
and the value is attribute type.
attribute... | class AdminTaskCreateResponse(object):
| """NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
"""
Attributes:
swagger_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
... | # coding: utf-8
"""
flyteidl/service/admin.proto
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501
OpenAPI spec version: version not set
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
import pprint
import r... | 91 | 134 | 449 | 7 | 83 | SmritiSatyanV/flyteidl | gen/pb_python/flyteidl/service/flyteadmin/flyteadmin/models/admin_task_create_response.py | Python | AdminTaskCreateResponse | AdminTaskCreateResponse | 20 | 87 | 20 | 20 | 53e67cfdd19644187015c7507ea71109122bda0c | bigcode/the-stack | train |
08684bce77eb3e407b491b93 | train | class | class XLinearModel(pecos.BaseClass):
"""Linear models for extreme multi-label classification.
See more details in Algorithm 2 of PECOS paper (Yu et al., 2020).
PECOS: Prediction for Enormous and Correlated Output Spaces
Hsiang-Fu Yu, Kai Zhong, Inderjit S. Dhillon
https://arxiv.org/abs/201... | class XLinearModel(pecos.BaseClass):
| """Linear models for extreme multi-label classification.
See more details in Algorithm 2 of PECOS paper (Yu et al., 2020).
PECOS: Prediction for Enormous and Correlated Output Spaces
Hsiang-Fu Yu, Kai Zhong, Inderjit S. Dhillon
https://arxiv.org/abs/2010.05878
"""
@dc.dataclass
... | # Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
# with the License. A copy of the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file acco... | 216 | 256 | 4,329 | 10 | 205 | yuhchenlin/pecos | pecos/xmc/xlinear/model.py | Python | XLinearModel | XLinearModel | 24 | 473 | 24 | 24 | 7c714e40586ea8a594bb4cd11bb303f7c532e3dc | bigcode/the-stack | train |
3e1d520c058e84a2e5d53281 | train | class | class Evaluator:
def __init__(self):
self._localization_metrics = [CameraOrientationError('loc-angle'),
CameraPositionError('loc-dist'),
CameraOrientationMedian('loc-angle-med'),
CameraPositionM... | class Evaluator:
| def __init__(self):
self._localization_metrics = [CameraOrientationError('loc-angle'),
CameraPositionError('loc-dist'),
CameraOrientationMedian('loc-angle-med'),
CameraPositionMedian('loc-dist-m... | import quaternion_average
from viewformer.data.loaders import SevenScenesLoader
from viewformer.data.loaders.sevenscenes import ALL_SCENES
from viewformer.utils.metrics import CameraOrientationError, CameraPositionError, CameraOrientationMedian, CameraPositionMedian
from viewformer.utils import geometry_tf as geometry... | 66 | 66 | 221 | 4 | 61 | jkulhanek/viewformer | viewformer/evaluate/evaluate_sevenscenes_baseline.py | Python | Evaluator | Evaluator | 18 | 40 | 18 | 18 | 139a4df4d543dae9d88cc09786f7a235557ad3d3 | bigcode/the-stack | train |
f8e0569fbc7178cdc3254c74 | train | function | def load_image_match_map(image_match_map_filepath):
top_map = defaultdict(list)
with open(image_match_map_filepath, 'r') as f:
for line in f:
fr, to = line.strip('\n\r').split()
top_map[fr].append(to)
return top_map
| def load_image_match_map(image_match_map_filepath):
| top_map = defaultdict(list)
with open(image_match_map_filepath, 'r') as f:
for line in f:
fr, to = line.strip('\n\r').split()
top_map[fr].append(to)
return top_map
| self._lookup = {x: i for i, x in enumerate(self.files)}
def __getitem__(self, name):
idx = self._lookup[name]
return self.cameras[idx]
def __len__(self):
return len(self.files)
def load_image_match_map(image_match_map_filepath):
| 64 | 64 | 64 | 10 | 54 | jkulhanek/viewformer | viewformer/evaluate/evaluate_sevenscenes_baseline.py | Python | load_image_match_map | load_image_match_map | 75 | 81 | 75 | 75 | 2cf8cf6d06b21ab9741796361aa58ca5efd76659 | bigcode/the-stack | train |
455456e115926a7653e16f63 | train | function | def compute_camera_distances(db_cameras, camera, position):
assert camera.shape == (1, 7,)
if position:
return tf.norm(db_cameras[..., :3] - camera[..., :3], axis=-1)
else:
x1 = geometry.quaternion_normalize(db_cameras[..., 3:])
x2 = geometry.quaternion_normalize(camera[..., 3:])
... | def compute_camera_distances(db_cameras, camera, position):
| assert camera.shape == (1, 7,)
if position:
return tf.norm(db_cameras[..., :3] - camera[..., :3], axis=-1)
else:
x1 = geometry.quaternion_normalize(db_cameras[..., 3:])
x2 = geometry.quaternion_normalize(camera[..., 3:])
diff = geometry.quaternion_multiply(x1, geometry.quater... | ((x for x in self._localization_metrics if x.name == 'loc-angle')).result()))])
def result(self):
return OrderedDict((
(m.name, float(m.result()))
for m in self._localization_metrics))
def compute_camera_distances(db_cameras, camera, position):
| 64 | 64 | 122 | 13 | 51 | jkulhanek/viewformer | viewformer/evaluate/evaluate_sevenscenes_baseline.py | Python | compute_camera_distances | compute_camera_distances | 43 | 51 | 43 | 43 | 4e1ddd5594225677dd7a478c5b27a2b1b6ed8d74 | bigcode/the-stack | train |
33c615e7e8c5cfa04f1dbdd1 | train | function | def generate_batch_predictions_baseline(cameras, baseline):
ctx_cameras, gt_cameras = cameras[0, :-1], cameras[:, -1]
if baseline == 'mean':
xyz, quat = tf.split(ctx_cameras, (3, 4), -1)
xyz = tf.reduce_mean(xyz, 0)
quat = tf.convert_to_tensor(quaternion_average(quat.numpy()))
pr... | def generate_batch_predictions_baseline(cameras, baseline):
| ctx_cameras, gt_cameras = cameras[0, :-1], cameras[:, -1]
if baseline == 'mean':
xyz, quat = tf.split(ctx_cameras, (3, 4), -1)
xyz = tf.reduce_mean(xyz, 0)
quat = tf.convert_to_tensor(quaternion_average(quat.numpy()))
pred_cameras = tf.concat((xyz, quat), -1)
else:
as... | top_map = defaultdict(list)
with open(image_match_map_filepath, 'r') as f:
for line in f:
fr, to = line.strip('\n\r').split()
top_map[fr].append(to)
return top_map
def generate_batch_predictions_baseline(cameras, baseline):
| 64 | 64 | 185 | 11 | 52 | jkulhanek/viewformer | viewformer/evaluate/evaluate_sevenscenes_baseline.py | Python | generate_batch_predictions_baseline | generate_batch_predictions_baseline | 84 | 97 | 84 | 84 | 9f859577293ddfc356db7763295a4082560eb93b | bigcode/the-stack | train |
2431a02ac330b1e2d29cecf1 | train | function | @click.command('evaluate-sevenscenes-baseline')
def main(path: str,
job_dir: str,
image_match_map: Optional[str] = None,
scenes: List[str] = None,
sequence_size: Optional[int] = None,
num_eval_sequences: Optional[int] = 1000,
top_n_matched_images: int = 0,
... | @click.command('evaluate-sevenscenes-baseline')
def main(path: str,
job_dir: str,
image_match_map: Optional[str] = None,
scenes: List[str] = None,
sequence_size: Optional[int] = None,
num_eval_sequences: Optional[int] = 1000,
top_n_matched_images: int = 0,
... | if scenes is None:
scenes = ALL_SCENES
if top_n_matched_images > 0:
assert image_match_map is not None
all_results = dict()
for scene in scenes:
if image_match_map is not None:
top_match_map = load_image_match_map(image_match_map.format(scene=scene))
scene_lo... | ['position_oracle', 'orientation_oracle']
pred = tf.argmin(compute_camera_distances(ctx_cameras, gt_cameras, baseline == 'position_oracle'), 0)
pred_cameras = ctx_cameras[pred]
return dict(
ground_truth_cameras=gt_cameras,
generated_cameras=tf.expand_dims(pred_cameras, 0))
@click.co... | 178 | 178 | 595 | 100 | 78 | jkulhanek/viewformer | viewformer/evaluate/evaluate_sevenscenes_baseline.py | Python | main | main | 100 | 155 | 100 | 108 | 04a73b4b941f06ec9a3411d786902abfba9cc070 | bigcode/the-stack | train |
3714700502a846633fb4c9bf | train | class | class SceneLookup:
def __init__(self, path, scene, image_size=None):
self.path = path
self.scene = scene
loader = SevenScenesLoader(path=path, split='train', scenes=[scene], image_size=image_size, _load_file_paths=True)
cameras = []
self.files = []
for batch in loader... | class SceneLookup:
| def __init__(self, path, scene, image_size=None):
self.path = path
self.scene = scene
loader = SevenScenesLoader(path=path, split='train', scenes=[scene], image_size=image_size, _load_file_paths=True)
cameras = []
self.files = []
for batch in loader:
camer... | _cameras[..., 3:])
x2 = geometry.quaternion_normalize(camera[..., 3:])
diff = geometry.quaternion_multiply(x1, geometry.quaternion_conjugate(x2))
return 2 * tf.asin(tf.linalg.norm(diff[..., 1:], axis=-1))
class SceneLookup:
| 64 | 64 | 170 | 4 | 60 | jkulhanek/viewformer | viewformer/evaluate/evaluate_sevenscenes_baseline.py | Python | SceneLookup | SceneLookup | 54 | 72 | 54 | 54 | 1a915e5a2de15c8d877bca248952d139e328b07e | bigcode/the-stack | train |
d2bb552b3b9306322fc193ff | train | function | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Lutron Caseta fan platform.
Adds fan controllers from the Caseta bridge associated with the config_entry
as fan entities.
"""
entities = []
data = hass.data[CASETA_DOMAIN][config_entry.entry_id]
bridge = data... | async def async_setup_entry(hass, config_entry, async_add_entities):
| """Set up the Lutron Caseta fan platform.
Adds fan controllers from the Caseta bridge associated with the config_entry
as fan entities.
"""
entities = []
data = hass.data[CASETA_DOMAIN][config_entry.entry_id]
bridge = data[BRIDGE_LEAP]
bridge_device = data[BRIDGE_DEVICE]
fan_devices... | as CASETA_DOMAIN
_LOGGER = logging.getLogger(__name__)
DEFAULT_ON_PERCENTAGE = 50
ORDERED_NAMED_FAN_SPEEDS = [FAN_LOW, FAN_MEDIUM, FAN_MEDIUM_HIGH, FAN_HIGH]
async def async_setup_entry(hass, config_entry, async_add_entities):
| 64 | 64 | 140 | 15 | 49 | tbarbette/core | homeassistant/components/lutron_caseta/fan.py | Python | async_setup_entry | async_setup_entry | 22 | 38 | 22 | 22 | 6f8c304252660ab1a02790860e2de8955dd81e42 | bigcode/the-stack | train |
1627b497dc4537be4cb5acf5 | train | class | class LutronCasetaFan(LutronCasetaDevice, FanEntity):
"""Representation of a Lutron Caseta fan. Including Fan Speed."""
@property
def percentage(self) -> Optional[int]:
"""Return the current speed percentage."""
if self._device["fan_speed"] is None:
return None
if self._... | class LutronCasetaFan(LutronCasetaDevice, FanEntity):
| """Representation of a Lutron Caseta fan. Including Fan Speed."""
@property
def percentage(self) -> Optional[int]:
"""Return the current speed percentage."""
if self._device["fan_speed"] is None:
return None
if self._device["fan_speed"] == FAN_OFF:
return 0
... | Caseta fan platform.
Adds fan controllers from the Caseta bridge associated with the config_entry
as fan entities.
"""
entities = []
data = hass.data[CASETA_DOMAIN][config_entry.entry_id]
bridge = data[BRIDGE_LEAP]
bridge_device = data[BRIDGE_DEVICE]
fan_devices = bridge.get_devices_by... | 133 | 133 | 444 | 15 | 118 | tbarbette/core | homeassistant/components/lutron_caseta/fan.py | Python | LutronCasetaFan | LutronCasetaFan | 41 | 101 | 41 | 41 | a59685b3ec8e23a08918d8e34fc2d1f643291a45 | bigcode/the-stack | train |
79e0365792fd5f223face8a9 | train | class | class FiscalYear(Document):
pass
| class FiscalYear(Document):
| pass
| # -*- coding: utf-8 -*-
# Copyright (c) 2020, Shariq and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
# import frappe
from frappe.model.document import Document
class FiscalYear(Document):
| 57 | 64 | 7 | 5 | 51 | shariquerik/accounting | accounting/accounting/doctype/fiscal_year/fiscal_year.py | Python | FiscalYear | FiscalYear | 9 | 10 | 9 | 9 | 427c79f04cf1936f1eda659a82cb5780df31b251 | bigcode/the-stack | train |
103cc0f49a86f1674db64abb | train | class | class KernelModuleTest(OERuntimeTestCase):
@classmethod
def setUpClass(cls):
src = os.path.join(cls.tc.runtime_files_dir, 'hellomod.c')
dst = '/tmp/hellomod.c'
cls.tc.target.copyTo(src, dst)
src = os.path.join(cls.tc.runtime_files_dir, 'hellomod_makefile')
dst = '/tmp/M... | class KernelModuleTest(OERuntimeTestCase):
@classmethod
| def setUpClass(cls):
src = os.path.join(cls.tc.runtime_files_dir, 'hellomod.c')
dst = '/tmp/hellomod.c'
cls.tc.target.copyTo(src, dst)
src = os.path.join(cls.tc.runtime_files_dir, 'hellomod_makefile')
dst = '/tmp/Makefile'
cls.tc.target.copyTo(src, dst)
@classme... | import os
from oeqa.runtime.case import OERuntimeTestCase
from oeqa.core.decorator.depends import OETestDepends
from oeqa.core.decorator.oeid import OETestID
from oeqa.core.decorator.data import skipIfNotFeature
class KernelModuleTest(OERuntimeTestCase):
@classmethod
| 70 | 92 | 307 | 14 | 55 | vineethrp/luv-yocto | meta/lib/oeqa/runtime/cases/kernelmodule.py | Python | KernelModuleTest | KernelModuleTest | 8 | 40 | 8 | 10 | 07c25db63c3f2cb84c0210c00e127634a1024185 | bigcode/the-stack | train |
7878ff93e0a810cee51890ca | train | function | def get_personal_proxy_infos(location=None):
personal_proxy_infos = {}
for personal_proxy in rab_config.load_package_config(
"rab_config.ini", "common", "proxy"):
proxy_method = personal_proxy.split("://")[0]
if (proxy_method not in personal_proxy_infos.keys()):
personal_... | def get_personal_proxy_infos(location=None):
| personal_proxy_infos = {}
for personal_proxy in rab_config.load_package_config(
"rab_config.ini", "common", "proxy"):
proxy_method = personal_proxy.split("://")[0]
if (proxy_method not in personal_proxy_infos.keys()):
personal_proxy_infos[proxy_method] = {}
out_ip... | else True
from rab_python_packages import rab_config
from rab_python_packages import rab_logging
from rab_python_packages import rab_ip
from rab_python_packages import rab_postgresql
# 日志记录
r_logger = rab_logging.r_logger()
"""
@description: 获取自建代理
-------
@param:
-------
@return:
"""
def get_personal_proxy_infos(... | 74 | 74 | 249 | 9 | 65 | senjianlu/rab_python_packages | rab_proxy.py | Python | get_personal_proxy_infos | get_personal_proxy_infos | 35 | 58 | 35 | 35 | 39c1350c0fcff25223b11d02d2ba30ed2da5b486 | bigcode/the-stack | train |
6cc8863cd51a82a4e82d16c1 | train | function | def init_ip_usage_counts(proxy_infos):
ip_usage_counts = {}
for proxy_method in proxy_infos.keys():
for out_ip in proxy_infos[proxy_method]:
for web in proxy_infos[proxy_method][out_ip]["access"].keys():
# 如果还不存在这个网站对应的列表则进行新建
if (web not in ip_usage_counts.ke... | def init_ip_usage_counts(proxy_infos):
| ip_usage_counts = {}
for proxy_method in proxy_infos.keys():
for out_ip in proxy_infos[proxy_method]:
for web in proxy_infos[proxy_method][out_ip]["access"].keys():
# 如果还不存在这个网站对应的列表则进行新建
if (web not in ip_usage_counts.keys()):
ip_usage_cou... | "]
}
proxy_infos[proxy_method][out_ip] = proxy_info
# 端口无服务说明此代理不存在
else:
pass
return proxy_infos
"""
@description: 初始化代理使用次数
-------
@param:
-------
@return:
"""
def init_ip_usage_counts(proxy_infos):
| 64 | 64 | 135 | 8 | 56 | senjianlu/rab_python_packages | rab_proxy.py | Python | init_ip_usage_counts | init_ip_usage_counts | 162 | 173 | 162 | 162 | 353073029ea99786d61d6fde38c97684dbd31c0e | bigcode/the-stack | train |
e4dbcdb81395ce1ba7b918b2 | train | function | def parse_proxy_info(proxy_method, proxy_info):
# 反代
if (proxy_method == "reverse"):
return "http://{host}:{port}".format(**proxy_info)
# HTTP 代理
elif(proxy_method == "http"):
return {
"http": "http://{auth}@{host}:{port}".format(**proxy_info),
"https": "http://{a... | def parse_proxy_info(proxy_method, proxy_info):
# 反代
| if (proxy_method == "reverse"):
return "http://{host}:{port}".format(**proxy_info)
# HTTP 代理
elif(proxy_method == "http"):
return {
"http": "http://{auth}@{host}:{port}".format(**proxy_info),
"https": "http://{auth}@{host}:{port}".format(**proxy_info)
}
# ... | _ip]["access"][web]):
ip_usage_counts[web][out_ip] = 0
return ip_usage_counts
"""
@description: 根据代理信息和协议将代理可用化
-------
@param:
-------
@return:
"""
def parse_proxy_info(proxy_method, proxy_info):
# 反代
| 64 | 64 | 168 | 16 | 48 | senjianlu/rab_python_packages | rab_proxy.py | Python | parse_proxy_info | parse_proxy_info | 182 | 197 | 182 | 183 | 1563aa3f659e2dd5abc0677717745e3df7bc4f17 | bigcode/the-stack | train |
168d5ac6d330f83054642df5 | train | class | class r_proxy():
"""
@description: 初始化
-------
@param:
-------
@return:
"""
def __init__(self, r_pgsql_driver, location=None, level=None):
# 数据库连接
self.r_pgsql_driver = r_pgsql_driver
# 所有代理信息
self.proxy_infos = get_proxy_infos(r_pgsql_driver, location, l... | class r_proxy():
| """
@description: 初始化
-------
@param:
-------
@return:
"""
def __init__(self, r_pgsql_driver, location=None, level=None):
# 数据库连接
self.r_pgsql_driver = r_pgsql_driver
# 所有代理信息
self.proxy_infos = get_proxy_infos(r_pgsql_driver, location, level)
# 各个... | 如果可以访问,从 0 开始计数
if (proxy_infos[proxy_method][out_ip]["access"][web]):
ip_usage_counts[web][out_ip] = 0
return ip_usage_counts
"""
@description: 根据代理信息和协议将代理可用化
-------
@param:
-------
@return:
"""
def parse_proxy_info(proxy_method, proxy_info):
# 反代
if (proxy_method ==... | 256 | 256 | 1,228 | 4 | 252 | senjianlu/rab_python_packages | rab_proxy.py | Python | r_proxy | r_proxy | 207 | 337 | 207 | 208 | 6626c0138317862c08277f0afc61ec584fa8af63 | bigcode/the-stack | train |
a72b99df13227c009dbaf16e | train | function | @rab_postgresql.change_database(rab_config.load_package_config(
"rab_config.ini", "rab_proxy", "proxy_database"))
def get_proxy_infos(r_pgsql_driver, location=None, level=None):
# 代理信息存储
proxy_infos = {
"reverse": {},
"http": {},
"socks5":{}
}
# 如果对代理等级无要求,则从数据库中搜索出其他代理
i... | @rab_postgresql.change_database(rab_config.load_package_config(
"rab_config.ini", "rab_proxy", "proxy_database"))
def get_proxy_infos(r_pgsql_driver, location=None, level=None):
# 代理信息存储
| proxy_infos = {
"reverse": {},
"http": {},
"socks5":{}
}
# 如果对代理等级无要求,则从数据库中搜索出其他代理
if (not level or level < 10):
# 搜索所有代理
select_sql = """
SELECT
*
FROM
(SELECT
sp_ip AS host,
... | 1].split(":")[1],
"auth": personal_proxy.split("://")[1].split("@")[0],
"access": {},
"level": 10
}
if (location):
# 将代理转换并测试代理所在地区
ip_info = rab_ip.get_ip_info(
parse_proxy_info(proxy_method, personal_proxy_info))
i... | 197 | 197 | 657 | 50 | 147 | senjianlu/rab_python_packages | rab_proxy.py | Python | get_proxy_infos | get_proxy_infos | 67 | 153 | 67 | 70 | 82f5fb828987c946934f3daa2b676747917cdd39 | bigcode/the-stack | train |
f472fc84038a7cb97c6e6d90 | train | class | class ChatInviteLinkMembers(BaseObject):
"""
Contains a list of chat members joined a chat by an invite link
:param total_count: Approximate total count of chat members found
:type total_count: :class:`int`
:param members: List of chat members, joined a chat by an invite link
:type mem... | class ChatInviteLinkMembers(BaseObject):
| """
Contains a list of chat members joined a chat by an invite link
:param total_count: Approximate total count of chat members found
:type total_count: :class:`int`
:param members: List of chat members, joined a chat by an invite link
:type members: :class:`list[ChatInviteLinkMember]`... | has been generated automatically!! Do not change this manually! #
# #
# =============================================================================== #
from __future__ import annotations
from pydantic import Field
from .chat_invite_... | 64 | 64 | 148 | 8 | 55 | jraylan/aiotdlib | aiotdlib/api/types/chat_invite_link_members.py | Python | ChatInviteLinkMembers | ChatInviteLinkMembers | 14 | 32 | 14 | 14 | dd180124886d700fc7b420d48c80a9369912cfca | bigcode/the-stack | train |
1069f4054956d677cf11b989 | train | class | class DumpToFileHandler(BaseExceptionHandler):
"""
Write the stack trace to a stream-file.
Note that your file-like objects you throw into that must support only .write() and optionally
.flush()
:param human_readables: iterable of either a file-like objects, or paths where
human-readable f... | class DumpToFileHandler(BaseExceptionHandler):
| """
Write the stack trace to a stream-file.
Note that your file-like objects you throw into that must support only .write() and optionally
.flush()
:param human_readables: iterable of either a file-like objects, or paths where
human-readable files will be output. Also a logger can be put h... | .mode == StreamType.MODE_STREAM:
return self.o
elif self.mode == StreamType.MODE_DEVNULL:
self.o = DevNullFilelikeObject()
return self.o
def __exit__(self, exc_type, exc_val, exc_tp):
if self.mode == StreamType.MODE_FILE:
return self.file.__exit__(exc... | 126 | 126 | 420 | 9 | 116 | piotrmaslanka/satella | satella/exception_handling/dump_to_file.py | Python | DumpToFileHandler | DumpToFileHandler | 83 | 125 | 83 | 83 | 4a3f413af8512a422e371e7182ee0926d9256bc9 | bigcode/the-stack | train |
9cdb85474b25610108c0e046 | train | class | class StreamType(enum.IntEnum):
MODE_FILE = 0 # write to file
MODE_STREAM = 1 # a file-like object was provided
MODE_DEVNULL = 2 # just redirect to /dev/null
MODE_LOGGER = 3 # just a logger
| class StreamType(enum.IntEnum):
| MODE_FILE = 0 # write to file
MODE_STREAM = 1 # a file-like object was provided
MODE_DEVNULL = 2 # just redirect to /dev/null
MODE_LOGGER = 3 # just a logger
| .Union[str, tp.IO, None, Logger, tp.Tuple[Logger, int]]
AsStreamTypeAcceptHR = tp.Union[str, tp.TextIO, Logger, tp.Tuple[Logger, int]]
AsStreamTypeAcceptIN = tp.Union[str, tp.BinaryIO]
class StreamType(enum.IntEnum):
| 64 | 64 | 63 | 7 | 57 | piotrmaslanka/satella | satella/exception_handling/dump_to_file.py | Python | StreamType | StreamType | 20 | 24 | 20 | 20 | e0db05e9e7fbd3d47d6605f9d736ccd9cbdb0587 | bigcode/the-stack | train |
83850b579f4af13dbee70d76 | train | class | class AsStream:
__slots__ = ('o', 'human_readable', 'mode', 'file', 'level', 'logger')
def __init__(self, o: AsStreamTypeAccept, human_readable: bool):
"""
A stream to dump to
:param o: stream, or a file name to use, or None to use /dev/null
:param human_readable: whether the o... | class AsStream:
| __slots__ = ('o', 'human_readable', 'mode', 'file', 'level', 'logger')
def __init__(self, o: AsStreamTypeAccept, human_readable: bool):
"""
A stream to dump to
:param o: stream, or a file name to use, or None to use /dev/null
:param human_readable: whether the output should be ... | back
from .exception_handlers import BaseExceptionHandler
AsStreamTypeAccept = tp.Union[str, tp.IO, None, Logger, tp.Tuple[Logger, int]]
AsStreamTypeAcceptHR = tp.Union[str, tp.TextIO, Logger, tp.Tuple[Logger, int]]
AsStreamTypeAcceptIN = tp.Union[str, tp.BinaryIO]
class StreamType(enum.IntEnum):
MODE_FILE = 0 ... | 141 | 141 | 470 | 4 | 136 | piotrmaslanka/satella | satella/exception_handling/dump_to_file.py | Python | AsStream | AsStream | 27 | 80 | 27 | 27 | 112c02ab62c434e1d6b83b5beb0157a551b81564 | bigcode/the-stack | train |
e9a5a02770abe1044d6a798f | train | function | def gauss_kern(fwhm, side, pixsize):
''' Create a 2D Gaussian (size= side x side)'''
from scipy.ndimage.filters import gaussian_filter
from shift import shift_twod
import numpy as np
from numpy import zeros
from numpy import shape
sig = fwhm / 2.355 / pixsize
delt = zeros([side,side])
delt[0,0]=1.0
#delt =... | def gauss_kern(fwhm, side, pixsize):
| ''' Create a 2D Gaussian (size= side x side)'''
from scipy.ndimage.filters import gaussian_filter
from shift import shift_twod
import numpy as np
from numpy import zeros
from numpy import shape
sig = fwhm / 2.355 / pixsize
delt = zeros([side,side])
delt[0,0]=1.0
#delt = shift_twod(delt,int(side / 2),int(sid... | import pdb
def gauss_kern(fwhm, side, pixsize):
| 18 | 64 | 207 | 15 | 2 | deutschmarco/simstack | gauss_kern.py | Python | gauss_kern | gauss_kern | 2 | 21 | 2 | 2 | 6b8b66c5059d404df75040ac50ac339c7aff4ba7 | bigcode/the-stack | train |
5c3f38610ab3f4ff623e8a25 | train | function | def read_tag_info(fid):
"""Read Tag info (or header)."""
tag = _read_tag_header(fid)
if tag is None:
return None
if tag.next == 0:
fid.seek(tag.size, 1)
elif tag.next > 0:
fid.seek(tag.next, 0)
return tag
| def read_tag_info(fid):
| """Read Tag info (or header)."""
tag = _read_tag_header(fid)
if tag is None:
return None
if tag.next == 0:
fid.seek(tag.size, 1)
elif tag.next > 0:
fid.seek(tag.next, 0)
return tag
| tag): # noqa: D105
return int(self.kind == tag.kind and
self.type == tag.type and
self.size == tag.size and
self.next == tag.next and
self.pos == tag.pos and
self.data == tag.data)
def read_tag_info(fid):
| 64 | 64 | 73 | 6 | 58 | emilelemoine/mne-python | mne/io/tag.py | Python | read_tag_info | read_tag_info | 63 | 72 | 63 | 63 | 284ed75eb5840bdde2577ed87a590dd1cb33de39 | bigcode/the-stack | train |
bc03a69bbb088b8828991e64 | train | function | def _read_simple(fid, tag, shape, rlims, dtype):
"""Read simple datatypes from tag (typically used with partial)."""
return _frombuffer_rows(fid, tag.size, dtype=dtype, shape=shape,
rlims=rlims)
| def _read_simple(fid, tag, shape, rlims, dtype):
| """Read simple datatypes from tag (typically used with partial)."""
return _frombuffer_rows(fid, tag.size, dtype=dtype, shape=shape,
rlims=rlims)
| ='<i4')
data = sparse.csr_matrix((data, indices,
indptr), shape=shape)
else:
raise Exception('Cannot handle other than dense or sparse '
'matrices yet')
return data
def _read_simple(fid, tag, shape, rlims, dtype):
| 64 | 64 | 56 | 15 | 48 | emilelemoine/mne-python | mne/io/tag.py | Python | _read_simple | _read_simple | 263 | 266 | 263 | 263 | 09dd877c06e0360549e2302d0825514670ebbc94 | bigcode/the-stack | train |
093d8ebf5739fbf62fdd282f | train | function | def _read_string(fid, tag, shape, rlims):
"""Read a string tag."""
# Always decode to ISO 8859-1 / latin1 (FIFF standard).
d = _frombuffer_rows(fid, tag.size, dtype='>c', shape=shape, rlims=rlims)
return str(d.tobytes().decode('latin1', 'ignore'))
| def _read_string(fid, tag, shape, rlims):
| """Read a string tag."""
# Always decode to ISO 8859-1 / latin1 (FIFF standard).
d = _frombuffer_rows(fid, tag.size, dtype='>c', shape=shape, rlims=rlims)
return str(d.tobytes().decode('latin1', 'ignore'))
| , tag, shape, rlims, dtype):
"""Read simple datatypes from tag (typically used with partial)."""
return _frombuffer_rows(fid, tag.size, dtype=dtype, shape=shape,
rlims=rlims)
def _read_string(fid, tag, shape, rlims):
| 64 | 64 | 82 | 13 | 51 | emilelemoine/mne-python | mne/io/tag.py | Python | _read_string | _read_string | 269 | 273 | 269 | 269 | 291427056d9001122b1636e3b5f65745abe17747 | bigcode/the-stack | train |
bc03623a4922438196fc0ecc | train | function | def find_tag(fid, node, findkind):
"""Find Tag in an open FIF file descriptor.
Parameters
----------
fid : file-like
Open file.
node : dict
Node to search.
findkind : int
Tag kind to find.
Returns
-------
tag : instance of Tag
The first tag found.
... | def find_tag(fid, node, findkind):
| """Find Tag in an open FIF file descriptor.
Parameters
----------
fid : file-like
Open file.
node : dict
Node to search.
findkind : int
Tag kind to find.
Returns
-------
tag : instance of Tag
The first tag found.
"""
if node['directory'] is n... | shape, rlims)
if tag.next != FIFF.FIFFV_NEXT_SEQ:
# f.seek(tag.next,0)
fid.seek(tag.next, 1) # XXX : fix? pb when tag.next < 0
return tag
def find_tag(fid, node, findkind):
| 64 | 64 | 120 | 10 | 53 | emilelemoine/mne-python | mne/io/tag.py | Python | find_tag | find_tag | 474 | 495 | 474 | 474 | 4bbca9877b6c980ed4351f5e7eceff0e1370a07b | bigcode/the-stack | train |
c0a0b02bdb9a3f78ac6ad0ad | train | function | def _read_dig_point_struct(fid, tag, shape, rlims):
"""Read dig point struct tag."""
kind = int(np.frombuffer(fid.read(4), dtype=">i4"))
kind = _dig_kind_named.get(kind, kind)
ident = int(np.frombuffer(fid.read(4), dtype=">i4"))
if kind == FIFF.FIFFV_POINT_CARDINAL:
ident = _dig_cardinal_nam... | def _read_dig_point_struct(fid, tag, shape, rlims):
| """Read dig point struct tag."""
kind = int(np.frombuffer(fid.read(4), dtype=">i4"))
kind = _dig_kind_named.get(kind, kind)
ident = int(np.frombuffer(fid.read(4), dtype=">i4"))
if kind == FIFF.FIFFV_POINT_CARDINAL:
ident = _dig_cardinal_named.get(ident, ident)
return dict(
kind=k... | buffer(fid.read(8), dtype=">i4"),
secs=int(np.frombuffer(fid.read(4), dtype=">i4")),
usecs=int(np.frombuffer(fid.read(4), dtype=">i4")))
def _read_dig_point_struct(fid, tag, shape, rlims):
| 63 | 64 | 140 | 16 | 47 | emilelemoine/mne-python | mne/io/tag.py | Python | _read_dig_point_struct | _read_dig_point_struct | 305 | 315 | 305 | 305 | 7ad35b61ae7dce6be03d005b6d4756f3f4721f9c | bigcode/the-stack | train |
9828bf49c477b37a22f80133 | train | function | def _loc_to_coil_trans(loc):
"""Convert loc vector to coil_trans."""
assert loc.shape[-1] == 12
coil_trans = np.zeros(loc.shape[:-1] + (4, 4))
coil_trans[..., :3, 3] = loc[..., :3]
coil_trans[..., :3, :3] = np.reshape(
loc[..., 3:], loc.shape[:-1] + (3, 3)).swapaxes(-1, -2)
coil_trans[..... | def _loc_to_coil_trans(loc):
| """Convert loc vector to coil_trans."""
assert loc.shape[-1] == 12
coil_trans = np.zeros(loc.shape[:-1] + (4, 4))
coil_trans[..., :3, 3] = loc[..., :3]
coil_trans[..., :3, :3] = np.reshape(
loc[..., 3:], loc.shape[:-1] + (3, 3)).swapaxes(-1, -2)
coil_trans[..., -1, -1] = 1.
return co... | out = np.frombuffer(fid.read(read_size), dtype=dtype)
# Move the pointer ahead to the end of the tag
fid.seek(end_pos)
else:
out = np.frombuffer(fid.read(tag_size), dtype=dtype)
return out
def _loc_to_coil_trans(loc):
| 64 | 64 | 122 | 9 | 54 | emilelemoine/mne-python | mne/io/tag.py | Python | _loc_to_coil_trans | _loc_to_coil_trans | 107 | 115 | 107 | 107 | a6c634feb82687da4c073287565365697a14a0a9 | bigcode/the-stack | train |
45e976f94364f4a57310b489 | train | function | def _read_complex_double(fid, tag, shape, rlims):
"""Read complex double tag."""
# data gets stored twice as large
if shape is not None:
shape = (shape[0], shape[1] * 2)
d = _frombuffer_rows(fid, tag.size, dtype=">f8", shape=shape, rlims=rlims)
d = d.view(">c16")
return d
| def _read_complex_double(fid, tag, shape, rlims):
| """Read complex double tag."""
# data gets stored twice as large
if shape is not None:
shape = (shape[0], shape[1] * 2)
d = _frombuffer_rows(fid, tag.size, dtype=">f8", shape=shape, rlims=rlims)
d = d.view(">c16")
return d
| ], shape[1] * 2)
d = _frombuffer_rows(fid, tag.size, dtype=">f4", shape=shape, rlims=rlims)
d = d.view(">c8")
return d
def _read_complex_double(fid, tag, shape, rlims):
| 64 | 64 | 94 | 14 | 49 | emilelemoine/mne-python | mne/io/tag.py | Python | _read_complex_double | _read_complex_double | 286 | 293 | 286 | 286 | 6bf466c24cd9ef30174809b3e1f0868241c2997e | bigcode/the-stack | train |
1b678a62b50b94e4234f911f | train | function | def read_tag(fid, pos=None, shape=None, rlims=None):
"""Read a Tag from a file at a given position.
Parameters
----------
fid : file
The open FIF file descriptor.
pos : int
The position of the Tag in the file.
shape : tuple | None
If tuple, the shape of the stored matrix... | def read_tag(fid, pos=None, shape=None, rlims=None):
| """Read a Tag from a file at a given position.
Parameters
----------
fid : file
The open FIF file descriptor.
pos : int
The position of the Tag in the file.
shape : tuple | None
If tuple, the shape of the stored matrix. Only to be used with
data stored as a vecto... | u2',
FIFF.FIFFT_UINT: '>u4',
FIFF.FIFFT_FLOAT: '>f4',
FIFF.FIFFT_DOUBLE: '>f8',
FIFF.FIFFT_DAU_PACK16: '>i2',
}
for key, dtype in _simple_dict.items():
_call_dict[key] = partial(_read_simple, dtype=dtype)
_call_dict_names[key] = dtype
def read_tag(fid, pos=None, shape=None, rlims=None):
| 106 | 106 | 356 | 15 | 90 | emilelemoine/mne-python | mne/io/tag.py | Python | read_tag | read_tag | 430 | 471 | 430 | 430 | 51c98b22305ece3a37daab230de7703a4237f4d4 | bigcode/the-stack | train |
4111d101255ce36ced780b77 | train | function | def _read_coord_trans_struct(fid, tag, shape, rlims):
"""Read coord trans struct tag."""
from ..transforms import Transform
fro = int(np.frombuffer(fid.read(4), dtype=">i4"))
to = int(np.frombuffer(fid.read(4), dtype=">i4"))
rot = np.frombuffer(fid.read(36), dtype=">f4").reshape(3, 3)
move = np.... | def _read_coord_trans_struct(fid, tag, shape, rlims):
| """Read coord trans struct tag."""
from ..transforms import Transform
fro = int(np.frombuffer(fid.read(4), dtype=">i4"))
to = int(np.frombuffer(fid.read(4), dtype=">i4"))
rot = np.frombuffer(fid.read(36), dtype=">f4").reshape(3, 3)
move = np.frombuffer(fid.read(12), dtype=">f4")
trans = np.r... | inal_named.get(ident, ident)
return dict(
kind=kind, ident=ident,
r=np.frombuffer(fid.read(12), dtype=">f4"),
coord_frame=FIFF.FIFFV_COORD_UNKNOWN)
def _read_coord_trans_struct(fid, tag, shape, rlims):
| 64 | 64 | 171 | 15 | 49 | emilelemoine/mne-python | mne/io/tag.py | Python | _read_coord_trans_struct | _read_coord_trans_struct | 318 | 329 | 318 | 318 | f1af204929bab5becd765f0a128ad989cb80c829 | bigcode/the-stack | train |
5253ac4c50a3bf294886b509 | train | function | def _read_old_pack(fid, tag, shape, rlims):
"""Read old pack tag."""
offset = float(np.frombuffer(fid.read(4), dtype=">f4"))
scale = float(np.frombuffer(fid.read(4), dtype=">f4"))
data = np.frombuffer(fid.read(tag.size - 8), dtype=">i2")
data = data * scale # to float64
data += offset
retur... | def _read_old_pack(fid, tag, shape, rlims):
| """Read old pack tag."""
offset = float(np.frombuffer(fid.read(4), dtype=">f4"))
scale = float(np.frombuffer(fid.read(4), dtype=">f4"))
data = np.frombuffer(fid.read(tag.size - 8), dtype=">i2")
data = data * scale # to float64
data += offset
return data
| ['coil_type'])
d['unit'] = _ch_unit_named.get(d['unit'], d['unit'])
d['unit_mul'] = _ch_unit_mul_named.get(d['unit_mul'], d['unit_mul'])
return d
def _read_old_pack(fid, tag, shape, rlims):
| 64 | 64 | 98 | 14 | 49 | emilelemoine/mne-python | mne/io/tag.py | Python | _read_old_pack | _read_old_pack | 367 | 374 | 367 | 367 | c4f3734301cd0ea9f549a57d6c4aa760657cc2d6 | bigcode/the-stack | train |
355d40c465922c22bc4dcf0e | train | function | def _read_dir_entry_struct(fid, tag, shape, rlims):
"""Read dir entry struct tag."""
return [_read_tag_header(fid) for _ in range(tag.size // 16 - 1)]
| def _read_dir_entry_struct(fid, tag, shape, rlims):
| """Read dir entry struct tag."""
return [_read_tag_header(fid) for _ in range(tag.size // 16 - 1)]
| 4), dtype=">f4"))
data = np.frombuffer(fid.read(tag.size - 8), dtype=">i2")
data = data * scale # to float64
data += offset
return data
def _read_dir_entry_struct(fid, tag, shape, rlims):
| 64 | 64 | 44 | 15 | 48 | emilelemoine/mne-python | mne/io/tag.py | Python | _read_dir_entry_struct | _read_dir_entry_struct | 377 | 379 | 377 | 377 | c02043e1d5b801c00c32ab7f22b81e6ddc7b6e17 | bigcode/the-stack | train |
26e1b61c5f79e1c67969ae52 | train | function | def has_tag(node, kind):
"""Check if the node contains a Tag of a given kind."""
for d in node['directory']:
if d.kind == kind:
return True
return False
| def has_tag(node, kind):
| """Check if the node contains a Tag of a given kind."""
for d in node['directory']:
if d.kind == kind:
return True
return False
| tag : instance of Tag
The first tag found.
"""
if node['directory'] is not None:
for subnode in node['directory']:
if subnode.kind == findkind:
return read_tag(fid, subnode.pos)
return None
def has_tag(node, kind):
| 64 | 64 | 44 | 7 | 56 | emilelemoine/mne-python | mne/io/tag.py | Python | has_tag | has_tag | 498 | 503 | 498 | 498 | 6578370495b01bc9f2f994844684b31276854ce4 | bigcode/the-stack | train |
55e3dcf50d9c203081b0c4f2 | train | class | class Tag(object):
"""Tag in FIF tree structure.
Parameters
----------
kind : int
Kind of Tag.
type_ : int
Type of Tag.
size : int
Size in bytes.
int : next
Position of next Tag.
pos : int
Position of Tag is the original file.
"""
def __i... | class Tag(object):
| """Tag in FIF tree structure.
Parameters
----------
kind : int
Kind of Tag.
type_ : int
Type of Tag.
size : int
Size in bytes.
int : next
Position of next Tag.
pos : int
Position of Tag is the original file.
"""
def __init__(self, kind, t... | .edu>
#
# License: BSD (3-clause)
from functools import partial
import struct
import numpy as np
from .constants import (FIFF, _dig_kind_named, _dig_cardinal_named,
_ch_kind_named, _ch_coil_type_named, _ch_unit_named,
_ch_unit_mul_named)
from ..utils.numerics import _j... | 92 | 92 | 309 | 4 | 87 | emilelemoine/mne-python | mne/io/tag.py | Python | Tag | Tag | 20 | 60 | 20 | 20 | 7b6829b5043aebb4bb3f0a98e6c6a7ea35b1983f | bigcode/the-stack | train |
7f3a1cf899c55de0e5b14062 | train | function | def _read_tag_header(fid):
"""Read only the header of a Tag."""
s = fid.read(4 * 4)
if len(s) == 0:
return None
# struct.unpack faster than np.frombuffer, saves ~10% of time some places
return Tag(*struct.unpack('>iIii', s))
| def _read_tag_header(fid):
| """Read only the header of a Tag."""
s = fid.read(4 * 4)
if len(s) == 0:
return None
# struct.unpack faster than np.frombuffer, saves ~10% of time some places
return Tag(*struct.unpack('>iIii', s))
| 0
_matrix_coding_dense = 16384 # 4000
_matrix_coding_CCS = 16400 # 4010
_matrix_coding_RCS = 16416 # 4020
_data_type = 65535 # ffff
def _read_tag_header(fid):
| 64 | 64 | 74 | 7 | 56 | emilelemoine/mne-python | mne/io/tag.py | Python | _read_tag_header | _read_tag_header | 149 | 155 | 149 | 149 | 14b878514b78392b2f87c4d33c9691febdeeb822 | bigcode/the-stack | train |
9209b2cb7f24dcfdb9409786 | train | function | def _read_id_struct(fid, tag, shape, rlims):
"""Read ID struct tag."""
return dict(
version=int(np.frombuffer(fid.read(4), dtype=">i4")),
machid=np.frombuffer(fid.read(8), dtype=">i4"),
secs=int(np.frombuffer(fid.read(4), dtype=">i4")),
usecs=int(np.frombuffer(fid.read(4), dtype=... | def _read_id_struct(fid, tag, shape, rlims):
| """Read ID struct tag."""
return dict(
version=int(np.frombuffer(fid.read(4), dtype=">i4")),
machid=np.frombuffer(fid.read(8), dtype=">i4"),
secs=int(np.frombuffer(fid.read(4), dtype=">i4")),
usecs=int(np.frombuffer(fid.read(4), dtype=">i4")))
| ], shape[1] * 2)
d = _frombuffer_rows(fid, tag.size, dtype=">f8", shape=shape, rlims=rlims)
d = d.view(">c16")
return d
def _read_id_struct(fid, tag, shape, rlims):
| 64 | 64 | 94 | 14 | 49 | emilelemoine/mne-python | mne/io/tag.py | Python | _read_id_struct | _read_id_struct | 296 | 302 | 296 | 296 | 1c40041337fa07c34282b8a982f041f77f48bf1e | bigcode/the-stack | train |
fc6df14644e8daf8081d3f74 | train | function | def _read_complex_float(fid, tag, shape, rlims):
"""Read complex float tag."""
# data gets stored twice as large
if shape is not None:
shape = (shape[0], shape[1] * 2)
d = _frombuffer_rows(fid, tag.size, dtype=">f4", shape=shape, rlims=rlims)
d = d.view(">c8")
return d
| def _read_complex_float(fid, tag, shape, rlims):
| """Read complex float tag."""
# data gets stored twice as large
if shape is not None:
shape = (shape[0], shape[1] * 2)
d = _frombuffer_rows(fid, tag.size, dtype=">f4", shape=shape, rlims=rlims)
d = d.view(">c8")
return d
| 1 (FIFF standard).
d = _frombuffer_rows(fid, tag.size, dtype='>c', shape=shape, rlims=rlims)
return str(d.tobytes().decode('latin1', 'ignore'))
def _read_complex_float(fid, tag, shape, rlims):
| 63 | 64 | 94 | 14 | 49 | emilelemoine/mne-python | mne/io/tag.py | Python | _read_complex_float | _read_complex_float | 276 | 283 | 276 | 276 | 6ba65edf6a470e2be9ac0e2676c2a7f56b26b7ba | bigcode/the-stack | train |
d3bc7c26f39f74f0bb836624 | train | function | def _frombuffer_rows(fid, tag_size, dtype=None, shape=None, rlims=None):
"""Get a range of rows from a large tag."""
if shape is not None:
item_size = np.dtype(dtype).itemsize
if not len(shape) == 2:
raise ValueError('Only implemented for 2D matrices')
want_shape = np.prod(sh... | def _frombuffer_rows(fid, tag_size, dtype=None, shape=None, rlims=None):
| """Get a range of rows from a large tag."""
if shape is not None:
item_size = np.dtype(dtype).itemsize
if not len(shape) == 2:
raise ValueError('Only implemented for 2D matrices')
want_shape = np.prod(shape)
have_shape = tag_size // item_size
if want_shape != ... |
self.data == tag.data)
def read_tag_info(fid):
"""Read Tag info (or header)."""
tag = _read_tag_header(fid)
if tag is None:
return None
if tag.next == 0:
fid.seek(tag.size, 1)
elif tag.next > 0:
fid.seek(tag.next, 0)
return tag
def _frombuffer_rows(f... | 101 | 101 | 338 | 20 | 80 | emilelemoine/mne-python | mne/io/tag.py | Python | _frombuffer_rows | _frombuffer_rows | 75 | 104 | 75 | 75 | 28296b65fbe86c50290532ea42aed8508d9d46d5 | bigcode/the-stack | train |
e15bfe314659514f64662c9b | train | function | def _loc_to_eeg_loc(loc):
"""Convert a loc to an EEG loc."""
if not np.isfinite(loc[:3]).all():
raise RuntimeError('Missing EEG channel location')
if np.isfinite(loc[3:6]).all() and (loc[3:6]).any():
return np.array([loc[0:3], loc[3:6]]).T
else:
return loc[0:3][:, np.newaxis].cop... | def _loc_to_eeg_loc(loc):
| """Convert a loc to an EEG loc."""
if not np.isfinite(loc[:3]).all():
raise RuntimeError('Missing EEG channel location')
if np.isfinite(loc[3:6]).all() and (loc[3:6]).any():
return np.array([loc[0:3], loc[3:6]]).T
else:
return loc[0:3][:, np.newaxis].copy()
| .
return coil_trans
def _coil_trans_to_loc(coil_trans):
"""Convert coil_trans to loc."""
coil_trans = coil_trans.astype(np.float64)
return np.roll(coil_trans.T[:, :3], 1, 0).flatten()
def _loc_to_eeg_loc(loc):
| 64 | 64 | 102 | 9 | 55 | emilelemoine/mne-python | mne/io/tag.py | Python | _loc_to_eeg_loc | _loc_to_eeg_loc | 124 | 131 | 124 | 124 | c6315e5a1dc8c20be34082e54d417fa8ae6140e2 | bigcode/the-stack | train |
cc2cbacf0e2300eab390b6dc | train | function | def _read_julian(fid, tag, shape, rlims):
"""Read julian tag."""
return _julian_to_cal(int(np.frombuffer(fid.read(4), dtype=">i4")))
| def _read_julian(fid, tag, shape, rlims):
| """Read julian tag."""
return _julian_to_cal(int(np.frombuffer(fid.read(4), dtype=">i4")))
| return data
def _read_dir_entry_struct(fid, tag, shape, rlims):
"""Read dir entry struct tag."""
return [_read_tag_header(fid) for _ in range(tag.size // 16 - 1)]
def _read_julian(fid, tag, shape, rlims):
| 63 | 64 | 44 | 15 | 48 | emilelemoine/mne-python | mne/io/tag.py | Python | _read_julian | _read_julian | 382 | 384 | 382 | 382 | 08f5da49fac73c9f26af01f5919989d952b33f5a | bigcode/the-stack | train |
d7d9978dc7e19a2ae4a9de36 | train | function | def _read_matrix(fid, tag, shape, rlims, matrix_coding):
"""Read a matrix (dense or sparse) tag."""
from scipy import sparse
matrix_coding = matrix_coding >> 16
# This should be easy to implement (see _frombuffer_rows)
# if we need it, but for now, it's not...
if shape is not None:
rais... | def _read_matrix(fid, tag, shape, rlims, matrix_coding):
| """Read a matrix (dense or sparse) tag."""
from scipy import sparse
matrix_coding = matrix_coding >> 16
# This should be easy to implement (see _frombuffer_rows)
# if we need it, but for now, it's not...
if shape is not None:
raise ValueError('Row reading not implemented for matrices '
... | 0 # ffff0000
_matrix_coding_dense = 16384 # 4000
_matrix_coding_CCS = 16400 # 4010
_matrix_coding_RCS = 16416 # 4020
_data_type = 65535 # ffff
def _read_tag_header(fid):
"""Read only the header of a Tag."""
s = fid.read(4 * 4)
if len(s) == 0:
return None
# struct.unpack fa... | 256 | 256 | 1,038 | 17 | 239 | emilelemoine/mne-python | mne/io/tag.py | Python | _read_matrix | _read_matrix | 168 | 260 | 168 | 168 | 5c176a3658912c8de2419e7efefd9633e4aa1a2a | bigcode/the-stack | train |
da0bbeb6d6102f0bedce4ff5 | train | function | def _read_ch_info_struct(fid, tag, shape, rlims):
"""Read channel info struct tag."""
d = dict(
scanno=int(np.frombuffer(fid.read(4), dtype=">i4")),
logno=int(np.frombuffer(fid.read(4), dtype=">i4")),
kind=int(np.frombuffer(fid.read(4), dtype=">i4")),
range=float(np.frombuffer(fi... | def _read_ch_info_struct(fid, tag, shape, rlims):
| """Read channel info struct tag."""
d = dict(
scanno=int(np.frombuffer(fid.read(4), dtype=">i4")),
logno=int(np.frombuffer(fid.read(4), dtype=">i4")),
kind=int(np.frombuffer(fid.read(4), dtype=">i4")),
range=float(np.frombuffer(fid.read(4), dtype=">f4")),
cal=float(np.fro... | ], [1]]).T]
data = Transform(fro, to, trans)
fid.seek(48, 1) # Skip over the inverse transformation
return data
_ch_coord_dict = {
FIFF.FIFFV_MEG_CH: FIFF.FIFFV_COORD_DEVICE,
FIFF.FIFFV_REF_MEG_CH: FIFF.FIFFV_COORD_DEVICE,
FIFF.FIFFV_EEG_CH: FIFF.FIFFV_COORD_HEAD,
}
def _read_ch_info_struct(f... | 115 | 115 | 386 | 15 | 100 | emilelemoine/mne-python | mne/io/tag.py | Python | _read_ch_info_struct | _read_ch_info_struct | 339 | 364 | 339 | 339 | cdcebbf48e617b77a980b05e3b240aeecc9fd16a | bigcode/the-stack | train |
09d7a196cd24a4fab6ba247c | train | function | def _coil_trans_to_loc(coil_trans):
"""Convert coil_trans to loc."""
coil_trans = coil_trans.astype(np.float64)
return np.roll(coil_trans.T[:, :3], 1, 0).flatten()
| def _coil_trans_to_loc(coil_trans):
| """Convert coil_trans to loc."""
coil_trans = coil_trans.astype(np.float64)
return np.roll(coil_trans.T[:, :3], 1, 0).flatten()
| 3, :3] = np.reshape(
loc[..., 3:], loc.shape[:-1] + (3, 3)).swapaxes(-1, -2)
coil_trans[..., -1, -1] = 1.
return coil_trans
def _coil_trans_to_loc(coil_trans):
| 64 | 64 | 49 | 10 | 53 | emilelemoine/mne-python | mne/io/tag.py | Python | _coil_trans_to_loc | _coil_trans_to_loc | 118 | 121 | 118 | 118 | d4c59bba22ef137783c6ef7b80a5f7ee62178172 | bigcode/the-stack | train |
54dc81cdead12ca65d63ef76 | train | function | def sci_notation(num, decimal_digits=1, precision=0, exponent=None):
"""
Returns a string representation of the scientific
notation of the given number formatted for use with
LaTeX or Mathtext, with specified number of significant
decimal digits and precision (number of decimal digits
to show). ... | def sci_notation(num, decimal_digits=1, precision=0, exponent=None):
| """
Returns a string representation of the scientific
notation of the given number formatted for use with
LaTeX or Mathtext, with specified number of significant
decimal digits and precision (number of decimal digits
to show). The exponent to be used can also be specified
explicitly.
"""... | black']
soft_colors = ['salmon', 'plum', 'lightsteelblue', 'gainsboro']
markers = ['s', '^', 'o', 'x']
# Define function for string formatting of scientific notation
def sci_notation(num, decimal_digits=1, precision=0, exponent=None):
| 64 | 64 | 159 | 18 | 45 | tommbendall/peakondrake | plotting/plot_stochastic_histograms.py | Python | sci_notation | sci_notation | 26 | 41 | 26 | 26 | 9890e6ae6238681c37d3ca53ea00fc2d4dfd2c7b | bigcode/the-stack | train |
cb05969e5190698d71b84206 | train | class | class Trainer:
""" Performs model training. """
def __init__(self, checkpoint_dir: Path, loss_type='ctc') -> None:
"""
Initializes a Trainer object.
Args:
checkpoint_dir (Path): Directory to store the model checkpoints.
loss_type (str): Type of loss: 'ctc' for forw... | class Trainer:
| """ Performs model training. """
def __init__(self, checkpoint_dir: Path, loss_type='ctc') -> None:
"""
Initializes a Trainer object.
Args:
checkpoint_dir (Path): Directory to store the model checkpoints.
loss_type (str): Type of loss: 'ctc' for forward transformer ... | import math
from collections import Counter
from pathlib import Path
from typing import List, Dict, Any, Tuple
import torch
import tqdm
from torch.optim import Adam
from torch.optim.lr_scheduler import ReduceLROnPlateau
from torch.utils.tensorboard import SummaryWriter
from dp.model.model import Model
from dp.model.u... | 138 | 256 | 2,418 | 3 | 134 | LucSan10/DeepPhonemizer-main | dp/training/trainer.py | Python | Trainer | Trainer | 22 | 270 | 22 | 23 | e90e07fca9c2b6e2087cf17a7cc23a0e7f2abc9d | bigcode/the-stack | train |
4ffbd44a17358c249b5f71d7 | train | class | class JinjiaTemplateService(Service):
def __init__(self, env, pathes, global_vars):
super(JinjiaTemplateService, self).__init__(env)
self._templateCls = Jinja2Template
self._init_path(pathes)
self._globals = json.loads(global_vars or '{}')
self._templates = {} # template c... | class JinjiaTemplateService(Service):
| def __init__(self, env, pathes, global_vars):
super(JinjiaTemplateService, self).__init__(env)
self._templateCls = Jinja2Template
self._init_path(pathes)
self._globals = json.loads(global_vars or '{}')
self._templates = {} # template cache: key: (id(lookup), tpl), value(te... | # coding:utf-8
import json
import os
from bottle import TEMPLATE_PATH, Jinja2Template, request, abort
from service import Service
__all__ = [ "JinjiaTemplateService" ]
class JinjiaTemplateService(Service):
| 53 | 158 | 527 | 8 | 45 | armersong/bottle-web-seed | services/jinjia_template_service.py | Python | JinjiaTemplateService | JinjiaTemplateService | 10 | 58 | 10 | 10 | 67cf949fba823a22298c15e6d685aef06a3dbc65 | bigcode/the-stack | train |
3dfb69bed964de54e8ef8cc6 | train | function | def stock_board_concept_cons_ths(symbol: str = "阿里巴巴概念") -> pd.DataFrame:
"""
同花顺-板块-概念板块-成份股
http://q.10jqka.com.cn/gn/detail/code/301558/
:param symbol: 板块名称
:type symbol: str
:return: 成份股
:rtype: pandas.DataFrame
"""
stock_board_ths_map_df = stock_board_concept_name_ths()
symb... | def stock_board_concept_cons_ths(symbol: str = "阿里巴巴概念") -> pd.DataFrame:
| """
同花顺-板块-概念板块-成份股
http://q.10jqka.com.cn/gn/detail/code/301558/
:param symbol: 板块名称
:type symbol: str
:return: 成份股
:rtype: pandas.DataFrame
"""
stock_board_ths_map_df = stock_board_concept_name_ths()
symbol = stock_board_ths_map_df[stock_board_ths_map_df['name'] == symbol]['url... | Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36'
}
url = 'http://q.10jqka.com.cn/gn/detail/code/302045/'
r = requests.get(url, headers=headers)
soup = BeautifulSoup(r.text, "lxml")
html_list = soup.find('div', attrs={'class': 'cate_inner'}).find_... | 189 | 189 | 632 | 25 | 163 | wheatma38/akshare | akshare/stock_feature/stock_board_concept_ths.py | Python | stock_board_concept_cons_ths | stock_board_concept_cons_ths | 89 | 133 | 89 | 89 | c827b575d4915b69ee01b4890237c0df6f223271 | bigcode/the-stack | train |
7d366139fdd8b3d1685a4a96 | train | function | def _stock_board_concept_code_ths() -> pd.DataFrame:
"""
同花顺-板块-概念板块-概念
http://q.10jqka.com.cn/gn/detail/code/301558/
:return: 所有概念板块的名称和链接
:rtype: pandas.DataFrame
"""
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/... | def _stock_board_concept_code_ths() -> pd.DataFrame:
| """
同花顺-板块-概念板块-概念
http://q.10jqka.com.cn/gn/detail/code/301558/
:return: 所有概念板块的名称和链接
:rtype: pandas.DataFrame
"""
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36'
}
url = 'http://q... | target': '_blank'})
name_list = [item.text for item in html_list]
url_list = [item['href'] for item in html_list]
temp_df = pd.DataFrame([name_list, url_list], index=['name', 'url']).T
return temp_df
def _stock_board_concept_code_ths() -> pd.DataFrame:
| 76 | 76 | 256 | 15 | 60 | wheatma38/akshare | akshare/stock_feature/stock_board_concept_ths.py | Python | _stock_board_concept_code_ths | _stock_board_concept_code_ths | 69 | 86 | 69 | 69 | 5e18954f0e925f2cbdf0bf2c6750205fa0a0f872 | bigcode/the-stack | train |
e35eed97a625d9d1873f6ec1 | train | function | def stock_board_concept_info_ths(symbol: str = "阿里巴巴概念") -> pd.DataFrame:
"""
同花顺-板块-概念板块-板块简介
http://q.10jqka.com.cn/gn/detail/code/301558/
:param symbol: 板块简介
:type symbol: str
:return: 板块简介
:rtype: pandas.DataFrame
"""
stock_board_ths_map_df = stock_board_concept_name_ths()
sy... | def stock_board_concept_info_ths(symbol: str = "阿里巴巴概念") -> pd.DataFrame:
| """
同花顺-板块-概念板块-板块简介
http://q.10jqka.com.cn/gn/detail/code/301558/
:param symbol: 板块简介
:type symbol: str
:return: 板块简介
:rtype: pandas.DataFrame
"""
stock_board_ths_map_df = stock_board_concept_name_ths()
symbol_code = stock_board_ths_map_df[stock_board_ths_map_df['name'] == symbo... | 跌幅",
"涨速(%)": "涨速",
"换手(%)": "换手",
"振幅(%)": "振幅",
}, inplace=True, axis=1)
del big_df['加自选']
big_df['代码'] = big_df['代码'].astype(str).str.zfill(6)
return big_df
def stock_board_concept_info_ths(symbol: str = "阿里巴巴概念") -> pd.DataFrame... | 105 | 105 | 352 | 25 | 79 | wheatma38/akshare | akshare/stock_feature/stock_board_concept_ths.py | Python | stock_board_concept_info_ths | stock_board_concept_info_ths | 136 | 157 | 136 | 136 | e9014657b33359c2e45ad1b7fd56ce33495474f6 | bigcode/the-stack | train |
7d725a213da290e1bf61794d | train | function | def _get_js_path_ths(name: str = None, module_file: str = None) -> str:
"""
获取 JS 文件的路径(从模块所在目录查找)
:param name: 文件名
:type name: str
:param module_file: 模块路径
:type module_file: str
:return: 路径
:rtype: str
"""
module_folder = os.path.abspath(os.path.dirname(os.path.dirname(module_f... | def _get_js_path_ths(name: str = None, module_file: str = None) -> str:
| """
获取 JS 文件的路径(从模块所在目录查找)
:param name: 文件名
:type name: str
:param module_file: 模块路径
:type module_file: str
:return: 路径
:rtype: str
"""
module_folder = os.path.abspath(os.path.dirname(os.path.dirname(module_file)))
module_json_path = os.path.join(module_folder, "stock_feature... | from akshare.utils import demjson
import pandas as pd
import requests
from bs4 import BeautifulSoup
from py_mini_racer import py_mini_racer
from tqdm import tqdm
def _get_js_path_ths(name: str = None, module_file: str = None) -> str:
| 64 | 64 | 127 | 23 | 40 | wheatma38/akshare | akshare/stock_feature/stock_board_concept_ths.py | Python | _get_js_path_ths | _get_js_path_ths | 19 | 31 | 19 | 19 | 05a21500e93537dcfd4c5d7fc8da6d5c41bb282f | bigcode/the-stack | train |
56556917d25062a9144af7d1 | train | function | def _get_file_content_ths(file_name: str = "ase.min.js") -> str:
"""
获取 JS 文件的内容
:param file_name: JS 文件名
:type file_name: str
:return: 文件内容
:rtype: str
"""
setting_file_name = file_name
setting_file_path = _get_js_path_ths(setting_file_name, __file__)
with open(setting_file_pat... | def _get_file_content_ths(file_name: str = "ase.min.js") -> str:
| """
获取 JS 文件的内容
:param file_name: JS 文件名
:type file_name: str
:return: 文件内容
:rtype: str
"""
setting_file_name = file_name
setting_file_path = _get_js_path_ths(setting_file_name, __file__)
with open(setting_file_path) as f:
file_data = f.read()
return file_data
| : str
"""
module_folder = os.path.abspath(os.path.dirname(os.path.dirname(module_file)))
module_json_path = os.path.join(module_folder, "stock_feature", name)
return module_json_path
def _get_file_content_ths(file_name: str = "ase.min.js") -> str:
| 64 | 64 | 111 | 20 | 43 | wheatma38/akshare | akshare/stock_feature/stock_board_concept_ths.py | Python | _get_file_content_ths | _get_file_content_ths | 34 | 46 | 34 | 34 | 462ec42d488e884fb3c9b59b4104b51796a30410 | bigcode/the-stack | train |
f36975ac9637222858b00f1a | train | function | def stock_board_concept_hist_ths(start_year: str = '2000', symbol: str = "安防") -> pd.DataFrame:
"""
同花顺-板块-概念板块-指数数据
http://q.10jqka.com.cn/gn/detail/code/301558/
:param start_year: 开始年份; e.g., 2019
:type start_year: str
:param symbol: 板块简介
:type symbol: str
:return: 板块简介
:rtype: pan... | def stock_board_concept_hist_ths(start_year: str = '2000', symbol: str = "安防") -> pd.DataFrame:
| """
同花顺-板块-概念板块-指数数据
http://q.10jqka.com.cn/gn/detail/code/301558/
:param start_year: 开始年份; e.g., 2019
:type start_year: str
:param symbol: 板块简介
:type symbol: str
:return: 板块简介
:rtype: pandas.DataFrame
"""
code_map = _stock_board_concept_code_ths()
symbol_url = f'http://q... | ://q.10jqka.com.cn/gn/detail/code/{symbol_code}/'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36',
}
r = requests.get(url, headers=headers)
soup = BeautifulSoup(r.text, 'lxml')
name_list = [item.te... | 228 | 228 | 763 | 30 | 197 | wheatma38/akshare | akshare/stock_feature/stock_board_concept_ths.py | Python | stock_board_concept_hist_ths | stock_board_concept_hist_ths | 160 | 227 | 160 | 160 | 5eac8b528be2b7fae4dfce42f845762f4c06764a | bigcode/the-stack | train |
c680d072d37ef445eb92d536 | train | function | def stock_board_concept_name_ths() -> pd.DataFrame:
"""
同花顺-板块-概念板块-概念
http://q.10jqka.com.cn/gn/detail/code/301558/
:return: 所有概念板块的名称和链接
:rtype: pandas.DataFrame
"""
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/8... | def stock_board_concept_name_ths() -> pd.DataFrame:
| """
同花顺-板块-概念板块-概念
http://q.10jqka.com.cn/gn/detail/code/301558/
:return: 所有概念板块的名称和链接
:rtype: pandas.DataFrame
"""
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36'
}
url = 'http://q... | :return: 文件内容
:rtype: str
"""
setting_file_name = file_name
setting_file_path = _get_js_path_ths(setting_file_name, __file__)
with open(setting_file_path) as f:
file_data = f.read()
return file_data
def stock_board_concept_name_ths() -> pd.DataFrame:
| 77 | 77 | 259 | 14 | 62 | wheatma38/akshare | akshare/stock_feature/stock_board_concept_ths.py | Python | stock_board_concept_name_ths | stock_board_concept_name_ths | 49 | 66 | 49 | 49 | fe6a38ea33b47098d30c6002b057cc65aad84e20 | bigcode/the-stack | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.