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
fa16d3e3ec553c90d0a48fd6
train
function
@pytest.fixture(autouse=True, scope='module') def startup_and_cleanup(): kml_drv = ogr.GetDriverByName('KML') # Unregister KML driver if present as it's behaviour is not identical # to new LIBKML driver if kml_drv is not None: print('Unregister KML driver') kml_drv.Deregister() ogr...
@pytest.fixture(autouse=True, scope='module') def startup_and_cleanup():
kml_drv = ogr.GetDriverByName('KML') # Unregister KML driver if present as it's behaviour is not identical # to new LIBKML driver if kml_drv is not None: print('Unregister KML driver') kml_drv.Deregister() ogrtest.have_read_libkml = ogr.Open('data/kml/samples.kml') is not None ...
sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRAN...
219
219
732
16
203
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
startup_and_cleanup
startup_and_cleanup
45
93
45
47
c28a41dcc4478e802720b15f77105a74fa3c7308
bigcode/the-stack
train
047908f3e9a28c5765ef63d5
train
function
def test_ogr_libkml_read_kml_with_space_content_in_coordinates(): if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/kml_with_space_content_in_coordinates.kml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() wkt = 'LINESTRING EMPTY' assert not ogrtest.check_feat...
def test_ogr_libkml_read_kml_with_space_content_in_coordinates():
if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/kml_with_space_content_in_coordinates.kml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() wkt = 'LINESTRING EMPTY' assert not ogrtest.check_feature_geometry(feat, wkt)
LINESTRING Z (1 2 3,4 5 6)' assert not ogrtest.check_feature_geometry(feat, wkt) ############################################################################### # Test reading KML with coordinate with space only content (#7232) def test_ogr_libkml_read_kml_with_space_content_in_coordinates():
64
64
90
16
48
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_read_kml_with_space_content_in_coordinates
test_ogr_libkml_read_kml_with_space_content_in_coordinates
1,843
1,854
1,843
1,844
373b889847aceba6d69a773b730e19f282d29b77
bigcode/the-stack
train
8d6b0436ec2e1938d7517c9a
train
function
def test_ogr_libkml_write_networklink(): if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.GetDriverByName('LIBKML').CreateDataSource("/vsimem/ogr_libkml_write_networklink.kml") lyr = ds.CreateLayer('test') lyr.CreateField(ogr.FieldDefn('name', ogr.OFTString)) lyr.CreateField(ogr.Fie...
def test_ogr_libkml_write_networklink():
if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.GetDriverByName('LIBKML').CreateDataSource("/vsimem/ogr_libkml_write_networklink.kml") lyr = ds.CreateLayer('test') lyr.CreateField(ogr.FieldDefn('name', ogr.OFTString)) lyr.CreateField(ogr.FieldDefn("networklink", ogr.OFTString)) ...
IFReadL(1, 2048, f) data = data.decode('ascii') gdal.VSIFCloseL(f) assert (not (data.find('<styleUrl>#root_doc_liststyle</styleUrl>') == -1 or \ data.find('<Style id="root_doc_liststyle">') == -1 or \ data.find('<href>http://www.gdal.org/gdalicon.png</href>') == -1 or \ data.find('<sty...
256
256
912
11
244
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_write_networklink
test_ogr_libkml_write_networklink
1,520
1,580
1,520
1,521
09d03578c192b4e6028e1e1ff7524b73f6f4c7df
bigcode/the-stack
train
99fd6cc277567790ffc904a0
train
function
def test_ogr_libkml_attributes_2(): if not ogrtest.have_read_libkml: pytest.skip() kml_ds = ogr.Open('data/kml/samples.kml') lyr = kml_ds.GetLayerByName('Highlighted Icon') feat = lyr.GetNextFeature() assert feat.GetField('Name') == 'Roll over this icon', 'Wrong name field value' if...
def test_ogr_libkml_attributes_2():
if not ogrtest.have_read_libkml: pytest.skip() kml_ds = ogr.Open('data/kml/samples.kml') lyr = kml_ds.GetLayerByName('Highlighted Icon') feat = lyr.GetNextFeature() assert feat.GetField('Name') == 'Roll over this icon', 'Wrong name field value' if feat.GetField('description') is not ...
!= 'Tethered to the ground by a customizable\n \"tail\"': print('got: ', feat.GetField('description')) pytest.fail('Wrong description field value') ############################################################################### # Test reading attributes for another layer (point). # def t...
63
64
138
11
52
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_attributes_2
test_ogr_libkml_attributes_2
140
157
140
141
cf646b6256efbeda8018a03600e8f5c8bcbde7e1
bigcode/the-stack
train
21fc0b16f216203b017c5a34
train
function
def test_ogr_libkml_point_read(): if not ogrtest.have_read_libkml: pytest.skip() kml_ds = ogr.Open('data/kml/samples.kml') lyr = kml_ds.GetLayerByName('Placemarks') lyr.ResetReading() feat = lyr.GetNextFeature() wkt = 'POINT(-122.0822035425683 37.42228990140251)' assert not ogrt...
def test_ogr_libkml_point_read():
if not ogrtest.have_read_libkml: pytest.skip() kml_ds = ogr.Open('data/kml/samples.kml') lyr = kml_ds.GetLayerByName('Placemarks') lyr.ResetReading() feat = lyr.GetNextFeature() wkt = 'POINT(-122.0822035425683 37.42228990140251)' assert not ogrtest.check_feature_geometry(feat, wk...
')) pytest.fail('Wrong name field value') assert feat.GetField('description') is None, 'Wrong description field value' i = i + 1 feat = lyr.GetNextFeature() ############################################################################### # Test reading of KML point geometry # ...
66
67
226
10
56
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_point_read
test_ogr_libkml_point_read
223
250
223
224
7f250dde38b93983ad39a0abb6932ee09ee4aeb0
bigcode/the-stack
train
cc33c9a4f5cf726e76707e7e
train
function
def test_ogr_libkml_linestring_read(): if not ogrtest.have_read_libkml: pytest.skip() kml_ds = ogr.Open('data/kml/samples.kml') lyr = kml_ds.GetLayerByName('Paths') lyr.ResetReading() feat = lyr.GetNextFeature() wkt = 'LINESTRING (-112.081423783034495 36.106778704771372 0, -112.08702...
def test_ogr_libkml_linestring_read():
if not ogrtest.have_read_libkml: pytest.skip() kml_ds = ogr.Open('data/kml/samples.kml') lyr = kml_ds.GetLayerByName('Paths') lyr.ResetReading() feat = lyr.GetNextFeature() wkt = 'LINESTRING (-112.081423783034495 36.106778704771372 0, -112.087026775269294 36.0905099328766 0)' asse...
() assert feat is not None, 'expected feature not found.' wkt = 'POINT(-122.084075 37.4220033612141 50)' assert not ogrtest.check_feature_geometry(feat, wkt) feat = lyr.GetNextFeature() assert feat is not None, 'expected feature not found.' wkt = 'POINT(-122.0857667006183 37.42156927867553 5...
136
137
458
11
125
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_linestring_read
test_ogr_libkml_linestring_read
257
281
257
258
efa36ad90aa02b982f01e428cc7171b2a6c69833
bigcode/the-stack
train
768678c693d62bf27a9a9aed
train
function
def test_ogr_libkml_extended_data_without_schema_data(): if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/extended_data_without_schema_data.kml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() if feat.GetField('field1') != '1_1': feat.DumpReadable() ...
def test_ogr_libkml_extended_data_without_schema_data():
if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/extended_data_without_schema_data.kml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() if feat.GetField('field1') != '1_1': feat.DumpReadable() pytest.fail() if feat.GetField('field2') != '1_2': ...
foo') == -1 ds = None ############################################################################### # Test reading KML with <Data> elements of <ExtendedData> in case # <ExtendedData> doesn't use a <SchemaData> (test changeset r22127) def test_ogr_libkml_extended_data_without_schema_data():
64
64
171
13
51
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_extended_data_without_schema_data
test_ogr_libkml_extended_data_without_schema_data
647
670
647
648
dd336aca66bc99537c9100d9b3c7a68a0e536b6d
bigcode/the-stack
train
f19b7c6ecca588ac1d25c253
train
function
def test_ogr_libkml_write_region(): if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.GetDriverByName('LIBKML').CreateDataSource("/vsimem/ogr_libkml_write_region.kml") lyr = ds.CreateLayer('auto', options=['ADD_REGION=YES']) feat = ogr.Feature(lyr.GetLayerDefn()) feat.SetGeometry(ogr...
def test_ogr_libkml_write_region():
if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.GetDriverByName('LIBKML').CreateDataSource("/vsimem/ogr_libkml_write_region.kml") lyr = ds.CreateLayer('auto', options=['ADD_REGION=YES']) feat = ogr.Feature(lyr.GetLayerDefn()) feat.SetGeometry(ogr.CreateGeometryFromWkt('POLYGON((2 48...
.have_read_libkml: pytest.skip() filepath = '/vsimem/ogr_libkml_write_phonenumber.kml' ds = ogr.GetDriverByName('LIBKML').CreateDataSource(filepath, options=['phonenumber=tel:911']) assert ds is not None, ('Unable to create %s.' % filepath) ...
167
167
557
10
156
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_write_region
test_ogr_libkml_write_region
988
1,023
988
989
9e6000250ee8f930e915a98a7fe6d0297ea77e14
bigcode/the-stack
train
9c64a854bac143b7003ab9f0
train
function
def test_ogr_libkml_gxtrack(): if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/gxtrack.kml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() if feat.GetField('begin') != '2013/05/28 12:00:00' or \ feat.GetField('end') != '2013/05/28 13:00:00' or \ fea...
def test_ogr_libkml_gxtrack():
if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/gxtrack.kml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() if feat.GetField('begin') != '2013/05/28 12:00:00' or \ feat.GetField('end') != '2013/05/28 13:00:00' or \ feat.GetGeometryRef().ExportToWkt()...
feat.DumpReadable() pytest.fail() if feat.IsFieldSet('field2'): feat.DumpReadable() pytest.fail() ds = None ############################################################################### # Test reading KML with <gx:Track> element (#5095) def test_ogr_libkml_gxtrack():
64
64
147
11
53
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_gxtrack
test_ogr_libkml_gxtrack
676
690
676
677
f57b3c3569500e92315a69d111429bfa31c7ffdf
bigcode/the-stack
train
31d0d7740c5ba9f6a52bb7b5
train
function
def test_ogr_libkml_write_dir(): return ogr_libkml_write('/vsimem/libkmldir')
def test_ogr_libkml_write_dir():
return ogr_libkml_write('/vsimem/libkmldir')
.SetConfigOption("LIBKML_USE_DOC.KML", None) return ret def test_ogr_libkml_check_write_kmz_use_doc_off(): return ogr_libkml_check_write('/vsimem/libkml_use_doc_off.kmz') def test_ogr_libkml_write_dir():
64
64
26
10
54
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_write_dir
test_ogr_libkml_write_dir
468
469
468
468
b587fa455f253b324799111b04c9e2f9734f36ba
bigcode/the-stack
train
a1af47fa6ec905fa6c7d6f03
train
function
def test_ogr_libkml_read_gx_timestamp(): if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/gxtimestamp.kml') lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f['timestamp'] != '2016/02/13 12:34:56+00': f.DumpReadable() pytest.fail() f = lyr.GetNextF...
def test_ogr_libkml_read_gx_timestamp():
if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/gxtimestamp.kml') lyr = ds.GetLayer(0) f = lyr.GetNextFeature() if f['timestamp'] != '2016/02/13 12:34:56+00': f.DumpReadable() pytest.fail() f = lyr.GetNextFeature() if f['begin'] != '2016/02/13 ...
\ data.find('<snippet>lyr_snippet</snippet>') == -1 or \ data.find('<description>lyr_description</description>') == -1)) ############################################################################### # Test reading gx:TimeStamp and gx:TimeSpan def test_ogr_libkml_read_gx_timestamp():
64
64
155
12
51
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_read_gx_timestamp
test_ogr_libkml_read_gx_timestamp
1,758
1,772
1,758
1,759
60871a02b5af8845d029d6f73f3d6aaba298c3c0
bigcode/the-stack
train
9f46c4d20a21db1a7fcd316e
train
function
def test_ogr_libkml_read_several_schema(): if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/several_schema_in_layer.kml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() if feat['fieldA'] != 'fieldAValue' or feat['common'] != 'commonAValue': feat.DumpReadable...
def test_ogr_libkml_read_several_schema():
if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/several_schema_in_layer.kml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() if feat['fieldA'] != 'fieldAValue' or feat['common'] != 'commonAValue': feat.DumpReadable() pytest.fail() feat = lyr.Get...
_space_content_in_coordinates.kml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() wkt = 'LINESTRING EMPTY' assert not ogrtest.check_feature_geometry(feat, wkt) ############################################################################### # Test reading a layer referring several schema (github #8...
74
74
248
12
62
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_read_several_schema
test_ogr_libkml_read_several_schema
1,860
1,887
1,860
1,861
0bcfbdd6f4d756a1fa3ecf3696fdfd8cf9252ae1
bigcode/the-stack
train
6b6161a2160ac7510b860c1d
train
function
def test_ogr_libkml_write_model(): if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.GetDriverByName('LIBKML').CreateDataSource("/vsimem/ogr_libkml_write_model.kml") lyr = ds.CreateLayer('test') lyr.CreateField(ogr.FieldDefn("model", ogr.OFTString)) lyr.CreateField(ogr.FieldDefn("hea...
def test_ogr_libkml_write_model():
if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.GetDriverByName('LIBKML').CreateDataSource("/vsimem/ogr_libkml_write_model.kml") lyr = ds.CreateLayer('test') lyr.CreateField(ogr.FieldDefn("model", ogr.OFTString)) lyr.CreateField(ogr.FieldDefn("heading", ogr.OFTReal)) lyr.CreateF...
em/ogr_libkml_write_screenoverlay.kml', 'rb') data = gdal.VSIFReadL(1, 2048, f) data = data.decode('ascii') gdal.VSIFCloseL(f) assert (not (data.find('<href>http://foo</href>') == -1 or \ data.find('<screenXY x="0.05" xunits="fraction" y="0.05" yunits="fraction"/>') == -1)) assert (not (dat...
256
256
886
10
245
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_write_model
test_ogr_libkml_write_model
1,071
1,133
1,071
1,072
02f58f6e57b44e65f01423cba2e0c3bb8e5b12de
bigcode/the-stack
train
0e7054e2af4d966c56765b0b
train
function
def test_ogr_libkml_write_atom_author(): if not ogrtest.have_read_libkml: pytest.skip() filepath = '/vsimem/ogr_libkml_write_atom_author.kml' ds = ogr.GetDriverByName('LIBKML').CreateDataSource(filepath, options=['author_name=name', 'author_u...
def test_ogr_libkml_write_atom_author():
if not ogrtest.have_read_libkml: pytest.skip() filepath = '/vsimem/ogr_libkml_write_atom_author.kml' ds = ogr.GetDriverByName('LIBKML').CreateDataSource(filepath, options=['author_name=name', 'author_uri=http://foo', 'author_email=foo@bar.com'...
.GetNextFeature() if feat.GetField('snippet') != 'test_snippet': feat.DumpReadable() pytest.fail() if feat.GetGeometryRef().ExportToWkt() != 'POINT (0 1 0)': feat.DumpReadable() pytest.fail() ############################################################################### # ...
83
83
278
11
72
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_write_atom_author
test_ogr_libkml_write_atom_author
917
937
917
918
bb0349dc0b3722f7cc70a3de27228329e76d1890
bigcode/the-stack
train
3e5b1dd320a38e95e754e3f7
train
function
def test_ogr_libkml_test_ogrsf(): if not ogrtest.have_read_libkml: pytest.skip() import test_cli_utilities if test_cli_utilities.get_test_ogrsf_path() is None: pytest.skip() ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' --config OGR_SKIP KML -ro data/kml/samp...
def test_ogr_libkml_test_ogrsf():
if not ogrtest.have_read_libkml: pytest.skip() import test_cli_utilities if test_cli_utilities.get_test_ogrsf_path() is None: pytest.skip() ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' --config OGR_SKIP KML -ro data/kml/samples.kml') assert not (ret.find...
ies.kml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() while feat is not None: feat = lyr.GetNextFeature() ds = None ############################################################################### # Run test_ogrsf def test_ogr_libkml_test_ogrsf():
64
64
132
13
50
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_test_ogrsf
test_ogr_libkml_test_ogrsf
527
538
527
528
9a88ca7cbf69214c76d1eda97ab81983702bb12d
bigcode/the-stack
train
33d59ada948e3795283a2dc3
train
function
def test_ogr_libkml_read_placemark(): if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/placemark.kml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() assert feat is not None ds = None
def test_ogr_libkml_read_placemark():
if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/placemark.kml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() assert feat is not None ds = None
.kml') assert not (ret.find("using driver `LIBKML'") == -1 or ret.find('INFO') == -1 or ret.find('ERROR') != -1) ############################################################################### # Test reading KML with only Placemark def test_ogr_libkml_read_placemark():
64
64
71
12
51
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_read_placemark
test_ogr_libkml_read_placemark
544
554
544
545
0114cd96d536da6f9c4ffac40929c8d3e2f7d001
bigcode/the-stack
train
c1e6830faa2fee3b09392f78
train
function
def test_ogr_libkml_write_snippet(): if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.GetDriverByName('LIBKML').CreateDataSource("/vsimem/ogr_libkml_write_snippet.kml") lyr = ds.CreateLayer('test') lyr.CreateField(ogr.FieldDefn("snippet", ogr.OFTString)) feat = ogr.Feature(lyr.GetLa...
def test_ogr_libkml_write_snippet():
if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.GetDriverByName('LIBKML').CreateDataSource("/vsimem/ogr_libkml_write_snippet.kml") lyr = ds.CreateLayer('test') lyr.CreateField(ogr.FieldDefn("snippet", ogr.OFTString)) feat = ogr.Feature(lyr.GetLayerDefn()) feat.SetField('snippet'...
Feature() if feat.GetGeometryRef().ExportToWkt() != 'POINT (0 1 0)': feat.DumpReadable() pytest.fail() feat = lyr.GetNextFeature() if feat.GetGeometryRef().ExportToWkt() != 'GEOMETRYCOLLECTION EMPTY': feat.DumpReadable() pytest.fail() ###################################...
94
94
316
11
83
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_write_snippet
test_ogr_libkml_write_snippet
881
910
881
882
b20dba18d42bf97ae19f781147e6b95dfd8c44ba
bigcode/the-stack
train
999cefacd85ff45c2a01d502
train
function
def test_ogr_libkml_read_placemark_with_kml_prefix(): if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/placemark_with_kml_prefix.kml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() assert feat is not None
def test_ogr_libkml_read_placemark_with_kml_prefix():
if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/placemark_with_kml_prefix.kml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() assert feat is not None
00' or f['end'] != '2016/02/14 00:00:00+00': f.DumpReadable() pytest.fail() ############################################################################### # Test reading KML with kml: prefix def test_ogr_libkml_read_placemark_with_kml_prefix():
64
64
74
16
47
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_read_placemark_with_kml_prefix
test_ogr_libkml_read_placemark_with_kml_prefix
1,779
1,787
1,779
1,780
744bcba35280642f649f85e7de23612d531f23a7
bigcode/the-stack
train
689cbb1373905a4fe37687de
train
function
def test_ogr_libkml_read_write_data(): if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.GetDriverByName('LIBKML').CreateDataSource("/vsimem/ogr_libkml_read_write_data.kml") gdal.SetConfigOption('LIBKML_USE_SIMPLEFIELD', 'NO') lyr = ds.CreateLayer('test') gdal.SetConfigOption('LIBKML...
def test_ogr_libkml_read_write_data():
if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.GetDriverByName('LIBKML').CreateDataSource("/vsimem/ogr_libkml_read_write_data.kml") gdal.SetConfigOption('LIBKML_USE_SIMPLEFIELD', 'NO') lyr = ds.CreateLayer('test') gdal.SetConfigOption('LIBKML_USE_SIMPLEFIELD', None) lyr.CreateF...
-1 or \ data.find('<tileSize>256</tileSize>') == -1 or \ data.find('<maxWidth>512</maxWidth>') == -1 or \ data.find('<maxHeight>512</maxHeight>') == -1 or \ data.find('<gridOrigin>upperLeft</gridOrigin>') == -1)) #############################################################################...
97
97
324
11
85
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_read_write_data
test_ogr_libkml_read_write_data
1,670
1,697
1,670
1,671
919b324b75ab40f1024a83dad710cae1086ea99d
bigcode/the-stack
train
545d9723eb03cfa414537aab
train
function
def test_ogr_libkml_read_write_style(): if not ogrtest.have_read_libkml: pytest.skip() f = gdal.VSIFOpenL('/vsimem/ogr_libkml_read_write_style_read.kml', 'wb') styles = """<Style id="style1"> <IconStyle> <color>01234567</color> <scale>1.1</scale> ...
def test_ogr_libkml_read_write_style():
if not ogrtest.have_read_libkml: pytest.skip() f = gdal.VSIFOpenL('/vsimem/ogr_libkml_read_write_style_read.kml', 'wb') styles = """<Style id="style1"> <IconStyle> <color>01234567</color> <scale>1.1</scale> <heading>50</heading> ...
.find('<x>1</x>') == -1 or \ data.find('<y>1</y>') == -1 or \ data.find('<z>1</z>') == -1 or \ data.find('<href>http://makc.googlecode.com/svn/trunk/flash/sandy_flar2/cube.dae</href>') == -1 or \ data.find('<href>http://foo</href>') == -1)) # This can only appear if HTTP resource is ava...
256
256
2,178
11
244
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_read_write_style
test_ogr_libkml_read_write_style
1,140
1,370
1,140
1,141
c23bb7c874ca608d5218bfd9e889a897d04940c1
bigcode/the-stack
train
d3e1fa0ac1aa34755216f095
train
function
def test_ogr_libkml_attributes_3(): if not ogrtest.have_read_libkml: pytest.skip() kml_ds = ogr.Open('data/kml/samples.kml') lyr = kml_ds.GetLayerByName('Paths') feat = lyr.GetNextFeature() assert feat.GetField('Name') == 'Tessellated', 'Wrong name field value' assert feat.GetField(...
def test_ogr_libkml_attributes_3():
if not ogrtest.have_read_libkml: pytest.skip() kml_ds = ogr.Open('data/kml/samples.kml') lyr = kml_ds.GetLayerByName('Paths') feat = lyr.GetNextFeature() assert feat.GetField('Name') == 'Tessellated', 'Wrong name field value' assert feat.GetField('description') == 'If the <tessellate...
is not None: print("'%s'" % feat.GetField('description')) pytest.fail('Wrong description field value') feat = lyr.GetNextFeature() assert feat is None, 'unexpected feature found.' ############################################################################### # Test reading attributes for ano...
70
71
237
11
59
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_attributes_3
test_ogr_libkml_attributes_3
164
188
164
165
97a5c18cdd28bc9fecf462c21b7d5267a8cc839c
bigcode/the-stack
train
f2d275ef2e695fabf63ef23d
train
function
def test_ogr_libkml_read_placemark_in_root_and_subfolder(): if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/placemark_in_root_and_subfolder.kml') lyr = ds.GetLayerByName('TopLevel') assert lyr is not None assert lyr.GetFeatureCount() == 1 lyr = ds.GetLayerByName...
def test_ogr_libkml_read_placemark_in_root_and_subfolder():
if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/placemark_in_root_and_subfolder.kml') lyr = ds.GetLayerByName('TopLevel') assert lyr is not None assert lyr.GetFeatureCount() == 1 lyr = ds.GetLayerByName('SubFolder1') assert lyr is not None assert lyr.GetF...
layer' lyr = ds.GetLayer(1) assert lyr.GetName() == 'layer (#2)' ############################################################################### # Test reading KML with a placemark in root document, and a subfolder (#7221) def test_ogr_libkml_read_placemark_in_root_and_subfolder():
64
64
113
17
47
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_read_placemark_in_root_and_subfolder
test_ogr_libkml_read_placemark_in_root_and_subfolder
1,808
1,820
1,808
1,809
dff39dce0861df745e0bb8169ecd002d2540329c
bigcode/the-stack
train
ffc36ef10da08f6c5190c56d
train
function
def test_ogr_libkml_check_write_kmz(): return ogr_libkml_check_write('/vsimem/libkml.kmz')
def test_ogr_libkml_check_write_kmz():
return ogr_libkml_check_write('/vsimem/libkml.kmz')
ml_check_write_kml(): return ogr_libkml_check_write('/vsimem/libkml.kml') def test_ogr_libkml_write_kmz(): return ogr_libkml_write('/vsimem/libkml.kmz') def test_ogr_libkml_check_write_kmz():
64
64
30
12
52
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_check_write_kmz
test_ogr_libkml_check_write_kmz
453
454
453
453
2b7b09d225d02707325f7abad7f920c7d6bc2454
bigcode/the-stack
train
efe2309ce8d20f9b625b4664
train
function
def test_ogr_libkml_read_schema(): if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/test_schema.kml') assert ds.GetLayerCount() == 4 lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() if feat.GetField('foo') != 'bar': feat.DumpReadable() pytest.fail...
def test_ogr_libkml_read_schema():
if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/test_schema.kml') assert ds.GetLayerCount() == 4 lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() if feat.GetField('foo') != 'bar': feat.DumpReadable() pytest.fail() lyr = ds.GetLayer(1) fea...
assert ds.GetLayer(0).GetName() == 'Test', \ ("Layer name must be '" + ds.GetLayer(0).GetName() + "'.") ds = None ############################################################################### # Test reading KML with empty layers without_folder def test_ogr_libkml_read_schema():
64
64
187
10
53
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_read_schema
test_ogr_libkml_read_schema
614
640
614
615
2a0aee5296693a7d2964532317524b0a45e295f5
bigcode/the-stack
train
0c62cba9d2e12f45a907b7bb
train
function
def test_ogr_libkml_write_networklinkcontrol(): if not ogrtest.have_read_libkml: pytest.skip() options = ['NLC_MINREFRESHPERIOD=3600', 'NLC_MAXSESSIONLENGTH=-1', 'NLC_COOKIE=cookie', 'NLC_MESSAGE=message', 'NLC_LINKNAME=linkname', ...
def test_ogr_libkml_write_networklinkcontrol():
if not ogrtest.have_read_libkml: pytest.skip() options = ['NLC_MINREFRESHPERIOD=3600', 'NLC_MAXSESSIONLENGTH=-1', 'NLC_COOKIE=cookie', 'NLC_MESSAGE=message', 'NLC_LINKNAME=linkname', 'NLC_LINKDESCRIPTION=linkdescription', ...
data.find('<targetHref>http://foo</targetHref>') == -1 or \ data.find('<Placemark/>') == -1 or \ data.find('<Placemark id="layer_to_edit.10"/>') == -1 or \ data.find('<Create>') == -1 or \ data.find('<Document targetId="layer_to_edit">') == -1 or \ ...
169
169
564
12
156
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_write_networklinkcontrol
test_ogr_libkml_write_networklinkcontrol
1,432
1,477
1,432
1,433
ceb6181775a38cc1cc0c1e6966cb69df1321a78c
bigcode/the-stack
train
85fb23078f8422d523b8be52
train
function
def test_ogr_libkml_read_duplicate_folder_name(): if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/duplicate_folder_name.kml') lyr = ds.GetLayer(0) assert lyr.GetName() == 'layer' lyr = ds.GetLayer(1) assert lyr.GetName() == 'layer (#2)'
def test_ogr_libkml_read_duplicate_folder_name():
if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/duplicate_folder_name.kml') lyr = ds.GetLayer(0) assert lyr.GetName() == 'layer' lyr = ds.GetLayer(1) assert lyr.GetName() == 'layer (#2)'
ogr.Open('data/kml/placemark_with_kml_prefix.kml') lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() assert feat is not None ############################################################################### # Test reading KML with duplicated folder name def test_ogr_libkml_read_duplicate_folder_name():
64
64
83
12
51
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_read_duplicate_folder_name
test_ogr_libkml_read_duplicate_folder_name
1,793
1,802
1,793
1,794
f97f90a95a740109355f173aad42bb4aa7dc27b9
bigcode/the-stack
train
137551dfede7063a038b6c65
train
function
def test_ogr_libkml_write_layer_camera(): if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.GetDriverByName('LIBKML').CreateDataSource("/vsimem/ogr_libkml_write_layer_camera.kml") options = ['CAMERA_LONGITUDE=3', 'CAMERA_LATITUDE=50', 'CAMERA_ALTITUDE=100', 'CAMERA_HEADING=70'...
def test_ogr_libkml_write_layer_camera():
if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.GetDriverByName('LIBKML').CreateDataSource("/vsimem/ogr_libkml_write_layer_camera.kml") options = ['CAMERA_LONGITUDE=3', 'CAMERA_LATITUDE=50', 'CAMERA_ALTITUDE=100', 'CAMERA_HEADING=70', 'CAMERA_TILT=50', 'CAMERA_ROLL=10', 'CAME...
>') == -1 or \ data.find('<heading>70</heading>') == -1 or \ data.find('<tilt>50</tilt>') == -1 or \ data.find('<range>150</range>') == -1 or \ data.find('<altitudeMode>relativeToGround</altitudeMode>') == -1)) ###############################################################################...
101
101
338
11
89
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_write_layer_camera
test_ogr_libkml_write_layer_camera
817
840
817
818
b1b5d7f63ab5cf65542017c2b70be12009076a55
bigcode/the-stack
train
7785cde94a5294111ed83c3d
train
function
def test_ogr_libkml_write_folder(): if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.GetDriverByName('LIBKML').CreateDataSource("/vsimem/ogr_libkml_write_folder.kml") ds.CreateLayer('test', options=['LISTSTYLE_ICON_HREF=http://foo', 'FOLDER=YES']) ds.CreateLayer('test2', options=['FOLDE...
def test_ogr_libkml_write_folder():
if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.GetDriverByName('LIBKML').CreateDataSource("/vsimem/ogr_libkml_write_folder.kml") ds.CreateLayer('test', options=['LISTSTYLE_ICON_HREF=http://foo', 'FOLDER=YES']) ds.CreateLayer('test2', options=['FOLDER=YES']) ds = None f = gdal....
value>') == -1)) ds = ogr.Open("/vsimem/ogr_libkml_read_write_data.kml") lyr = ds.GetLayer(0) feat = lyr.GetNextFeature() assert feat.GetField('foo') == 'bar' ############################################################################### # Test writing layer as Folder def test_ogr_libkml_write_folder...
75
75
252
10
64
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_write_folder
test_ogr_libkml_write_folder
1,703
1,722
1,703
1,704
56cd1162f4fba3cb578938e81042acb66e428261
bigcode/the-stack
train
733d03b245c4bdd9705c86ab
train
function
def test_ogr_libkml_read_emptylayers(): if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/emptylayers.kml') assert ds.GetLayerCount() == 2 # --> One difference with the old KML driver assert ds.GetLayer(0).GetFeatureCount() == 1 assert ds.GetLayer(1).GetFeatureCo...
def test_ogr_libkml_read_emptylayers():
if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/emptylayers.kml') assert ds.GetLayerCount() == 2 # --> One difference with the old KML driver assert ds.GetLayer(0).GetFeatureCount() == 1 assert ds.GetLayer(1).GetFeatureCount() == 0 ds = None
ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open('data/kml/empty.kml') assert ds.GetLayerCount() == 0 ds = None ############################################################################### # Test reading KML with empty layers def test_ogr_libkml_read_emptylayers():
64
64
101
11
52
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_read_emptylayers
test_ogr_libkml_read_emptylayers
574
587
574
575
632069ec487a9c3ae7a3508c07841c760c582f2c
bigcode/the-stack
train
104a3ec63553d9c249c9458e
train
function
def test_ogr_libkml_write_phonenumber(): if not ogrtest.have_read_libkml: pytest.skip() filepath = '/vsimem/ogr_libkml_write_phonenumber.kml' ds = ogr.GetDriverByName('LIBKML').CreateDataSource(filepath, options=['phonenumber=tel:911']) a...
def test_ogr_libkml_write_phonenumber():
if not ogrtest.have_read_libkml: pytest.skip() filepath = '/vsimem/ogr_libkml_write_phonenumber.kml' ds = ogr.GetDriverByName('LIBKML').CreateDataSource(filepath, options=['phonenumber=tel:911']) assert ds is not None, ('Unable to create %...
xmlns:atom="http://www.w3.org/2005/Atom">') == -1 or \ data.find('<atom:link href="http://foo" rel="related"/>') == -1)) ############################################################################### # Test writing <phoneNumber> def test_ogr_libkml_write_phonenumber():
64
64
166
11
53
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_write_phonenumber
test_ogr_libkml_write_phonenumber
966
982
966
967
6ca681ae2bd7e1fd96c4b2ab88b89cc3d5e80f12
bigcode/the-stack
train
24ca7aabdb3d4783cee2ff95
train
function
def test_ogr_libkml_update_existing_kml(): if not ogrtest.have_read_libkml: pytest.skip() filename = '/vsimem/ogr_libkml_update_existing_kml.kml' gdal.FileFromMemBuffer(filename, open('data/kml/several_schema_in_layer.kml', 'rb').read()) ds = ogr.Open(filename, update=1) lyr = ds.GetLayer(...
def test_ogr_libkml_update_existing_kml():
if not ogrtest.have_read_libkml: pytest.skip() filename = '/vsimem/ogr_libkml_update_existing_kml.kml' gdal.FileFromMemBuffer(filename, open('data/kml/several_schema_in_layer.kml', 'rb').read()) ds = ogr.Open(filename, update=1) lyr = ds.GetLayer(0) fc_before = lyr.GetFeatureCount() ...
Readable() pytest.fail() feat = lyr.GetNextFeature() if feat['fieldB'] != 'fieldBValue' or feat['common'] != 'commonBValue': feat.DumpReadable() pytest.fail() ############################################################################### def test_ogr_libkml_update_existing_kml():...
63
64
169
12
51
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_update_existing_kml
test_ogr_libkml_update_existing_kml
1,893
1,912
1,893
1,894
5761c511c5c321358beb7d4fced856e067002c8b
bigcode/the-stack
train
90bd492b6529b4b23953f4c6
train
function
def ogr_libkml_check_write(filename): if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open(filename) if filename != '/vsimem/libkml_use_doc_off.kmz': lyr = ds.GetLayerByName('test_wgs84') else: lyr = ds.GetLayer(0) assert lyr.GetFeatureCount() == 8, 'Bad feature cou...
def ogr_libkml_check_write(filename):
if not ogrtest.have_read_libkml: pytest.skip() ds = ogr.Open(filename) if filename != '/vsimem/libkml_use_doc_off.kmz': lyr = ds.GetLayerByName('test_wgs84') else: lyr = ds.GetLayer(0) assert lyr.GetFeatureCount() == 8, 'Bad feature count.' feat = lyr.GetNextFeature() ...
.25 0.25 0,0.25 0.75 0,0.75 0.75 0,0.75 0.25 0,0.25 0.25 0)),((-0.25 0.25 0,-0.25 0.75 0,-0.75 0.75 0,-0.75 0.25 0,-0.25 0.25 0)))')) assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.' dst_feat = ogr.Feature(lyr.GetLayerDefn()) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('GEOMETRYCOLLECTIO...
209
209
697
9
199
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
ogr_libkml_check_write
ogr_libkml_check_write
389
436
389
390
b64584a5296a1bbb8b0bd5e2726e684e3b81299e
bigcode/the-stack
train
c1b46fe4ae5f170012861e1d
train
function
def test_ogr_libkml_write_kml(): return ogr_libkml_write('/vsimem/libkml.kml')
def test_ogr_libkml_write_kml():
return ogr_libkml_write('/vsimem/libkml.kml')
Ref().ExportToWkt() == 'GEOMETRYCOLLECTION (POINT (2 49 1),LINESTRING (0 1 0,2 3 0))', \ 'Unexpected geometry.' ds = None ############################################################################### def test_ogr_libkml_write_kml():
63
64
28
11
52
VirtualTim/gdal
autotest/ogr/ogr_libkml.py
Python
test_ogr_libkml_write_kml
test_ogr_libkml_write_kml
441
442
441
441
c6c07106b37abba5d9774234a8467e85209d6319
bigcode/the-stack
train
791b017c43be1f8e5a7cc761
train
function
def work(t, root, output, freq): t.load() count = t.df.count().sum() lowpass(t.df, freq) t.df = t.df.ffill().bfill() logging.info('filled in frames: %s -> %s', count, t.df.count().sum()) t.save(t.root.replace(root, output))
def work(t, root, output, freq):
t.load() count = t.df.count().sum() lowpass(t.df, freq) t.df = t.df.ffill().bfill() logging.info('filled in frames: %s -> %s', count, t.df.count().sum()) t.save(t.root.replace(root, output))
quist) for c in df.columns: if c.startswith('marker') and c[-1] in 'xyz': df.loc[:, c] = scipy.signal.filtfilt(b, a, df[c].interpolate().ffill().bfill()) def work(t, root, output, freq):
64
64
75
10
54
lmjohns3/cube-experiment
analysis/04-lowpass.py
Python
work
work
36
42
36
36
eeaddf04b44f6e5ff459b1b3350abf963b3d45f3
bigcode/the-stack
train
8f2ae7e0551b76ea954589f8
train
function
@climate.annotate( root='load data files from this directory tree', output='save smoothed data files to this directory tree', pattern=('process only trials matching this pattern', 'option'), freq=('lowpass filter at N Hz', 'option', None, float), ) def main(root, output, pattern='*', freq=None): tri...
@climate.annotate( root='load data files from this directory tree', output='save smoothed data files to this directory tree', pattern=('process only trials matching this pattern', 'option'), freq=('lowpass filter at N Hz', 'option', None, float), ) def main(root, output, pattern='*', freq=None):
trials = lmj.cubes.Experiment(root).trials_matching(pattern) run = joblib.delayed(work) args = root, output, freq joblib.Parallel(-1)(run(t, *args) for t in trials)
@climate.annotate( root='load data files from this directory tree', output='save smoothed data files to this directory tree', pattern=('process only trials matching this pattern', 'option'), freq=('lowpass filter at N Hz', 'option', None, float), ) def main(root, output, pattern='*', freq=None):
74
64
127
74
0
lmjohns3/cube-experiment
analysis/04-lowpass.py
Python
main
main
45
55
45
51
ab04e5015c2d9f452c2132b2603b9e363340dd71
bigcode/the-stack
train
1ac7c597850cd7865e87c511
train
function
def lowpass(df, freq=10., order=4): '''Filter marker data using a butterworth low-pass filter. This method alters the data in `df` in-place. Parameters ---------- freq : float, optional Use a butterworth filter with this cutoff frequency. Defaults to 10Hz. order : int, optional...
def lowpass(df, freq=10., order=4):
'''Filter marker data using a butterworth low-pass filter. This method alters the data in `df` in-place. Parameters ---------- freq : float, optional Use a butterworth filter with this cutoff frequency. Defaults to 10Hz. order : int, optional Order of the butterworth fi...
#!/usr/bin/env python from __future__ import division import climate import joblib import lmj.cubes import pandas as pd import scipy.signal logging = climate.get_logger('lowpass') def lowpass(df, freq=10., order=4):
57
69
233
13
44
lmjohns3/cube-experiment
analysis/04-lowpass.py
Python
lowpass
lowpass
13
33
13
13
745e946ad0d516ef38e7dad7605c4e6408e44e0f
bigcode/the-stack
train
bb2746fed0b52f80ef3e7ea2
train
class
class FacialLandmarksDetectionModel: def __init__(self, model_name, device = "CPU", extensions = None): self.model_name = model_name self.device = device self.extensions = extensions self.model_structure = self.model_name self.model_weights = self.model_name.split(...
class FacialLandmarksDetectionModel:
def __init__(self, model_name, device = "CPU", extensions = None): self.model_name = model_name self.device = device self.extensions = extensions self.model_structure = self.model_name self.model_weights = self.model_name.split(".")[0] + ".bin" self.plugin ...
import cv2 import numpy as np from openvino.inference_engine import IECore class FacialLandmarksDetectionModel:
26
246
822
7
18
jonathanyeh0723/OpenVINO_Computer_Pointer_Controller
src/facial_landmarks_detection.py
Python
FacialLandmarksDetectionModel
FacialLandmarksDetectionModel
5
96
5
6
94898b5fab2d9d9c7f8d5ffb864c7c7cd2edc090
bigcode/the-stack
train
673979aca3054025f0b2e48d
train
function
def _remove(project, args): for (flag_name, flag_value) in zip(args[u'<flag_name>'], args[u'<flag_value>']): project.remove_flags(flag_name, flag_value, target_name=args[u'--target'], configuration_name=args[u'--configuration']) return u'Flags removed successfully.'
def _remove(project, args):
for (flag_name, flag_value) in zip(args[u'<flag_name>'], args[u'<flag_value>']): project.remove_flags(flag_name, flag_value, target_name=args[u'--target'], configuration_name=args[u'--configuration']) return u'Flags removed successfully.'
_name, flag_value) in zip(args[u'<flag_name>'], args[u'<flag_value>']): project.add_flags(flag_name, flag_value, target_name=args[u'--target'], configuration_name=args[u'--configuration']) return u'Flags added successfully.' def _remove(project, args):
63
64
67
7
56
yixiaoqingyuz/mod-pbxproj
pbxproj/pbxcli/pbxproj_flag.py
Python
_remove
_remove
48
52
48
48
e44c3233b9e6e571c2983bf1305b3e69cdb25bcd
bigcode/the-stack
train
d2a51aa7c55ba5a417e33310
train
function
def main(): command_parser(execute)(docopt(__doc__))
def main():
command_parser(execute)(docopt(__doc__))
for (flag_name, flag_value) in zip(args[u'<flag_name>'], args[u'<flag_value>']): project.remove_flags(flag_name, flag_value, target_name=args[u'--target'], configuration_name=args[u'--configuration']) return u'Flags removed successfully.' def main():
63
64
14
3
60
yixiaoqingyuz/mod-pbxproj
pbxproj/pbxcli/pbxproj_flag.py
Python
main
main
55
56
55
55
a566ebe37e208454c9124706143c064a2baf641f
bigcode/the-stack
train
f52e963adfed068546fc2917
train
function
def _add(project, args): for (flag_name, flag_value) in zip(args[u'<flag_name>'], args[u'<flag_value>']): project.add_flags(flag_name, flag_value, target_name=args[u'--target'], configuration_name=args[u'--configuration']) return u'Flags added successfully.'
def _add(project, args):
for (flag_name, flag_value) in zip(args[u'<flag_name>'], args[u'<flag_value>']): project.add_flags(flag_name, flag_value, target_name=args[u'--target'], configuration_name=args[u'--configuration']) return u'Flags added successfully.'
from docopt import docopt def execute(project, args): # make a decision of what function to call based on the -D flag if args[u'--delete']: return _remove(project, args) else: return _add(project, args) def _add(project, args):
64
64
67
7
57
yixiaoqingyuz/mod-pbxproj
pbxproj/pbxcli/pbxproj_flag.py
Python
_add
_add
41
45
41
41
bebfffddbc802413cd83e4132044e1b1f70469cb
bigcode/the-stack
train
51f0785d4ea8a2b0db663cce
train
function
def execute(project, args): # make a decision of what function to call based on the -D flag if args[u'--delete']: return _remove(project, args) else: return _add(project, args)
def execute(project, args): # make a decision of what function to call based on the -D flag
if args[u'--delete']: return _remove(project, args) else: return _add(project, args)
options] (--delete | -D) (--all | -A) <project> [--] <flag_name>... from pbxproj.pbxcli import * from docopt import docopt def execute(project, args): # make a decision of what function to call based on the -D flag
64
64
50
23
40
yixiaoqingyuz/mod-pbxproj
pbxproj/pbxcli/pbxproj_flag.py
Python
execute
execute
33
38
33
34
8452a6cf1f6e72565772b637910ed1c62cc70519
bigcode/the-stack
train
ede1cb9d77cb6cffafe10f52
train
class
@export class ResBlock(nn.Module): def __init__(self,in_channels,out_channels,ksize=3,drop_rate=0,stride=1,gn=False,**kwargs): super().__init__() norm_layer = (lambda c: nn.GroupNorm(c//16,c)) if gn else nn.BatchNorm2d self.net = nn.Sequential( norm_layer(in_channels), ...
@export class ResBlock(nn.Module):
def __init__(self,in_channels,out_channels,ksize=3,drop_rate=0,stride=1,gn=False,**kwargs): super().__init__() norm_layer = (lambda c: nn.GroupNorm(c//16,c)) if gn else nn.BatchNorm2d self.net = nn.Sequential( norm_layer(in_channels), nn.ReLU(), conv2d(in_...
_channels), nn.ReLU() ) #@export #def CircBNrelu(in_channels,out_channels): # return nn.Sequential( # iConv2d(in_channels,out_channels), # nn.BatchNorm2d(out_channels), # nn.ReLU() # ) @export class ResBlock(nn.Module):
68
68
229
9
59
tridungduong16/fairCE
src/counterfactual_explanation/flow_ssl/conv_parts/convenience.py
Python
ResBlock
ResBlock
40
62
40
41
20f4af4a457dc55a7e14204e5b893159e07d7c1c
bigcode/the-stack
train
8cc32e51814c1bf7bc56fd0e
train
function
@export def ConvBNrelu(in_channels,out_channels,stride=1): return nn.Sequential( nn.Conv2d(in_channels,out_channels,3,padding=1,stride=stride), nn.BatchNorm2d(out_channels), nn.ReLU() )
@export def ConvBNrelu(in_channels,out_channels,stride=1):
return nn.Sequential( nn.Conv2d(in_channels,out_channels,3,padding=1,stride=stride), nn.BatchNorm2d(out_channels), nn.ReLU() )
(in_channels,out_channels,kernel_size,padding=same,dilation=dilation,**kwargs) else: return nn.Conv2d(in_channels,out_channels,kernel_size,padding=same,dilation=dilation,**kwargs) @export def ConvBNrelu(in_channels,out_channels,stride=1):
64
64
57
16
48
tridungduong16/fairCE
src/counterfactual_explanation/flow_ssl/conv_parts/convenience.py
Python
ConvBNrelu
ConvBNrelu
24
30
24
25
49fb1ded4b3574b8981caf2573b9bfa0fab21821
bigcode/the-stack
train
e09c768de1df50508e1ad5f2
train
function
@export def conv2d(in_channels,out_channels,kernel_size=3,coords=False,dilation=1,**kwargs): """ Wraps nn.Conv2d and CoordConv, padding is set to same and coords=True can be specified to get additional coordinate in_channels""" assert 'padding' not in kwargs, "assumed to be padding = same " same = (...
@export def conv2d(in_channels,out_channels,kernel_size=3,coords=False,dilation=1,**kwargs):
""" Wraps nn.Conv2d and CoordConv, padding is set to same and coords=True can be specified to get additional coordinate in_channels""" assert 'padding' not in kwargs, "assumed to be padding = same " same = (kernel_size//2)*dilation if coords: return CoordConv(in_channels,out_channels,ke...
d try: from oil.architectures.parts.CoordConv import CoordConv except: def CoordConv(*args,**kwargs): raise NotImplementedError @export def conv2d(in_channels,out_channels,kernel_size=3,coords=False,dilation=1,**kwargs):
64
64
146
27
36
tridungduong16/fairCE
src/counterfactual_explanation/flow_ssl/conv_parts/convenience.py
Python
conv2d
conv2d
12
21
12
13
d4ea238861b5ebaebcc5df819f1e78fd7b84cae7
bigcode/the-stack
train
e32af0e4a5475a0989a75ee1
train
class
class UserInformation(object): """Implementation of the 'UserInformation' model. A message to encapsulate information about the user who made the request. Request should be filtered by these fields if specified so that only the objects that the user is permissioned for are returned. If both sid_vec & ...
class UserInformation(object):
"""Implementation of the 'UserInformation' model. A message to encapsulate information about the user who made the request. Request should be filtered by these fields if specified so that only the objects that the user is permissioned for are returned. If both sid_vec & tenant_id are specified then...
# -*- coding: utf-8 -*- # Copyright 2021 Cohesity Inc. import cohesity_management_sdk.models.key_value_pair import cohesity_management_sdk.models.cluster_config_proto_sid class UserInformation(object):
43
239
799
5
37
nick6655/management-sdk-python
cohesity_management_sdk/models/user_information.py
Python
UserInformation
UserInformation
7
98
7
8
b91b75ce7514db653f8b141fe3dc310a40026010
bigcode/the-stack
train
c770b1045de3346a0d16bf29
train
function
def search_news(news_name): search_news_url = 'https://newsapi.org/v2/top-headlines?country=us&category={}&apiKey={}'.format(api_key,news_name) with urllib.request.urlopen(search_news_url) as url: search_news_data = url.read() search_news_response = json.loads(search_news_data) search_n...
def search_news(news_name):
search_news_url = 'https://newsapi.org/v2/top-headlines?country=us&category={}&apiKey={}'.format(api_key,news_name) with urllib.request.urlopen(search_news_url) as url: search_news_data = url.read() search_news_response = json.loads(search_news_data) search_news_results = None ...
news_details_response.get('author') title = news_details_response.get('title') description = news_details_response.get('description') url = news_details_response.get('url') news_object =News(id,name,author,title,description,url) return news_object def search_news(n...
62
64
115
6
55
mwanginyambura/highlight
app/requests.py
Python
search_news
search_news
62
75
62
62
db8d9c4dc594b5a837bd311c0ee498f192172576
bigcode/the-stack
train
a6e08754d44dc370d8dbecb7
train
function
def configure_request(app): global api_key,base_url api_key = app.config['NEWS_API_KEY'] base_url = app.config['NEWS_API_BASE_URL']
def configure_request(app):
global api_key,base_url api_key = app.config['NEWS_API_KEY'] base_url = app.config['NEWS_API_BASE_URL']
import urllib.request,json from .models import Article #Getting api key api_key = None #Getting the news base url base_url = None def configure_request(app):
38
64
36
5
32
mwanginyambura/highlight
app/requests.py
Python
configure_request
configure_request
13
16
13
13
70fb0fc8c0a1243b8711a38403ef0a874d8cd1ba
bigcode/the-stack
train
413fea2a38498f37a1dfec13
train
function
def get_newss(category): '''Function that gets the json response to our url request''' get_newss_url = base_url.format(category,api_key) with urllib.request.urlopen(get_newss_url) as url: get_newss_data = url.read() get_newss_response = json.loads(get_newss_data) news_results...
def get_newss(category):
'''Function that gets the json response to our url request''' get_newss_url = base_url.format(category,api_key) with urllib.request.urlopen(get_newss_url) as url: get_newss_data = url.read() get_newss_response = json.loads(get_newss_data) news_results = None if get_ne...
#Getting api key api_key = None #Getting the news base url base_url = None def configure_request(app): global api_key,base_url api_key = app.config['NEWS_API_KEY'] base_url = app.config['NEWS_API_BASE_URL'] def get_newss(category):
64
64
112
6
58
mwanginyambura/highlight
app/requests.py
Python
get_newss
get_newss
18
34
18
19
506ae7de7279575e3a3d155f8081feb6a5e0e73c
bigcode/the-stack
train
41a56c81634fc979d2564441
train
function
def get_news(id): get_news_details_url = base_url.format(id,api_key) with urllib.request.urlopen(get_news_details_url) as url: news_details_data = url.read() news_details_response = json.loads(news_details_data) news_object = None if news_details_response: id = new...
def get_news(id):
get_news_details_url = base_url.format(id,api_key) with urllib.request.urlopen(get_news_details_url) as url: news_details_data = url.read() news_details_response = json.loads(news_details_data) news_object = None if news_details_response: id = news_details_response...
url.read() get_newss_response = json.loads(get_newss_data) news_results = None if get_newss_response['results']: news_results_list = get_newss_response['results'] news_results = process_results(news_results_list) return news_results def get_news(id):
64
64
142
5
58
mwanginyambura/highlight
app/requests.py
Python
get_news
get_news
39
58
39
39
e432e9307bcd6a448a59b79d68f04cacece1cf7c
bigcode/the-stack
train
2e28959b705da31f33b45f57
train
function
def process_results(news_list): '''Function that process news result and transfort them to a list of Objects Args: news_list: A list of dictionaries that contain news details Returns : news_results: A list of news objects ''' news_results = [] for news_item in news_list: ...
def process_results(news_list):
'''Function that process news result and transfort them to a list of Objects Args: news_list: A list of dictionaries that contain news details Returns : news_results: A list of news objects ''' news_results = [] for news_item in news_list: id = news_item.get('id') ...
.read() search_news_response = json.loads(search_news_data) search_news_results = None if search_news_response['results']: search_news_list = search_news_response['results'] search_news_results = process_results(search_news_list) return search_news_results def pro...
62
64
152
6
55
mwanginyambura/highlight
app/requests.py
Python
process_results
process_results
81
105
81
81
71903f7eb23038270c4491501f641e8464a4e398
bigcode/the-stack
train
7f375526e210d7a253cd6aea
train
class
class TestValidateTemplateAccess(TestCase): clients = NotificationClientFixtures() templates = NotificationTemplateFixtures() @classmethod def setUpClass(cls): cls.clients.setUp() cls.templates.setUp() @classmethod def tearDownClass(cls): cls.templates.tearDown() ...
class TestValidateTemplateAccess(TestCase):
clients = NotificationClientFixtures() templates = NotificationTemplateFixtures() @classmethod def setUpClass(cls): cls.clients.setUp() cls.templates.setUp() @classmethod def tearDownClass(cls): cls.templates.tearDown() cls.clients.tearDown() def setUp(self...
from unittest import TestCase from typing import Any, Iterable, Optional import frappe from frappe_notification import ( NotificationTemplate, NotificationClientFixtures, NotificationTemplateFixtures, NotificationClientNotFound, NotificationTemplateNotFound, PermissionDenied, set_active_no...
75
256
1,801
8
66
leam-tech/frappe_notification
frappe_notification/frappe_notification/controllers/templates/tests/test_validate_template_access.py
Python
TestValidateTemplateAccess
TestValidateTemplateAccess
18
248
18
18
9fde0fcca2e4f0f97f97c61a78a9c96d4a66e0a9
bigcode/the-stack
train
c4ef49bdfd8a80ef1f97ec60
train
class
class BatchApi(object): """NOTE: This class is auto generated by OpenAPI Generator Ref: https://openapi-generator.tech Do not edit the class manually. """ def __init__(self, api_client=None): if api_client is None: api_client = ApiClient() self.api_client = api_client ...
class BatchApi(object):
"""NOTE: This class is auto generated by OpenAPI Generator Ref: https://openapi-generator.tech Do not edit the class manually. """ def __init__(self, api_client=None): if api_client is None: api_client = ApiClient() self.api_client = api_client def read(self, batch...
# coding: utf-8 """ Quotes No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 The version of the OpenAPI document: v3 Generated by: https://openapi-generator.tech """ from __future__ import absolute_import import re # noqa: F40...
133
256
1,240
5
127
Ronfer/hubspot-api-python
hubspot/crm/quotes/api/batch_api.py
Python
BatchApi
BatchApi
24
143
24
24
2569a7cbe1c1efaeb031c4ab2103781d5e180822
bigcode/the-stack
train
300f00155349aa2386f0e88f
train
class
class HexBytes(bytes): """ HexBytes is a *very* thin wrapper around the python built-in :class:`bytes` class. It has these three changes: 1. Accepts more initializing values, like hex strings, non-negative integers, and booleans 2. Returns hex with prefix '0x' from :meth:`HexBytes.hex` ...
class HexBytes(bytes):
""" HexBytes is a *very* thin wrapper around the python built-in :class:`bytes` class. It has these three changes: 1. Accepts more initializing values, like hex strings, non-negative integers, and booleans 2. Returns hex with prefix '0x' from :meth:`HexBytes.hex` 3. The representati...
from typing import ( Type, Union, cast, overload, ) from ._utils import ( to_bytes, ) class HexBytes(bytes):
33
109
365
5
28
julio-cesar-leitao/PGP-PKI
MOnewUser/env/lib/python3.8/site-packages/hexbytes/main.py
Python
HexBytes
HexBytes
13
50
13
13
b13060c68478eee675070fae787ae1de196bc62c
bigcode/the-stack
train
828537352cc0b21d128c06ed
train
class
class TestDatabaseModel(SupersetTestCase): def test_is_time_druid_time_col(self): """Druid has a special __time column""" database = Database(database_name="druid_db", sqlalchemy_uri="druid://db") tbl = SqlaTable(table_name="druid_tbl", database=database) col = TableColumn(column_na...
class TestDatabaseModel(SupersetTestCase):
def test_is_time_druid_time_col(self): """Druid has a special __time column""" database = Database(database_name="druid_db", sqlalchemy_uri="druid://db") tbl = SqlaTable(table_name="druid_tbl", database=database) col = TableColumn(column_name="__time", type="INTEGER", table=tbl) ...
The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the 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, # soft...
256
256
1,774
10
245
Halo9Pan/dive_superset
tests/sqla_models_tests.py
Python
TestDatabaseModel
TestDatabaseModel
32
231
32
32
16ce628dd93704591dca05152d81b06c3265e407
bigcode/the-stack
train
3e4b30165fb84d6e1a3b3581
train
class
class actor(object): def __init__(self): pass def build_graph(self, img_state, n_action_space, is_training, var_scope, action_range=None): """build a deterministic policy net π(s) Args: img_state: generally, a tensor with the shape(bs, h, w, c) n_action_space: an...
class actor(object):
def __init__(self): pass def build_graph(self, img_state, n_action_space, is_training, var_scope, action_range=None): """build a deterministic policy net π(s) Args: img_state: generally, a tensor with the shape(bs, h, w, c) n_action_space: an int, represents the ...
v2(inputs=img_state, n_dims=20, is_training=is_training) ## combine the state and action state_action = tf.concat([slim.softmax(feat), action], axis=-1) ## action state value self.action_state_value = self.max_abs_q_val*tf.reshape(bp(state_action, out_size=1, a_f='tanh'...
130
130
434
4
125
YoungYoung619/driving-desicion-in-carla
keep_lane/basic_net/ddpg_utils.py
Python
actor
actor
51
94
51
51
3cd32e373d9f8464cb81d60f25ab929f0998d540
bigcode/the-stack
train
f595b6870e16de083e7a6713
train
class
class critic(object): def __init__(self, max_abs_q_val = 45): self.max_abs_q_val = max_abs_q_val pass def build_graph(self, img_state, action, is_training, var_scope): """build a action-value function approximation Q(s,a) Args: state: generally, a tensor with the sha...
class critic(object):
def __init__(self, max_abs_q_val = 45): self.max_abs_q_val = max_abs_q_val pass def build_graph(self, img_state, action, is_training, var_scope): """build a action-value function approximation Q(s,a) Args: state: generally, a tensor with the shape(bs, h, w, c) ...
""" Copyright (c) College of Mechatronics and Control Engineering, Shenzhen University. All rights reserved. Description : Author:Team Li """ import tensorflow as tf import numpy as np from RL.backbone.vgg16 import * from RL.backbone.mobilenet_v2 import mobilenetv2 from RL.backbone.bp_net import bp slim = tf.contr...
84
92
307
4
79
YoungYoung619/driving-desicion-in-carla
keep_lane/basic_net/ddpg_utils.py
Python
critic
critic
19
48
19
19
c55ac13c932575e7dccc7d60a2cfbfab7d77673f
bigcode/the-stack
train
3c071cc0395fabe030bd4299
train
class
class mi_enb_decoder: def __init__(self, packet): self.packet = str(packet,'utf-8') self.p_type_name = None self.p_type = None self.content = None def get_type_id(self): # print (type(self.packet)) try: l = self.packet.split(" ") # print (l) if (l[1] in PACKET_TYPE): ...
class mi_enb_decoder:
def __init__(self, packet): self.packet = str(packet,'utf-8') self.p_type_name = None self.p_type = None self.content = None def get_type_id(self): # print (type(self.packet)) try: l = self.packet.split(" ") # print (l) if (l[1] in PACKET_TYPE): self.p_type = l[1]...
B0A3": "LTE_PDCP_DL_Cipher_Data_PDU", "0xB0B3": "LTE_PDCP_UL_Cipher_Data_PDU", "0xB173": "LTE_PHY_PDSCH_Stat_Indication", "0xB063": "LTE_MAC_DL_Transport_Block", "0xB064": "LTE_MAC_UL_Transport_Block", "0xB092": "LTE_RLC_UL_AM_All_PDU", "0xB082": "LTE_RLC_DL_AM_All_PDU", "0xB13C": "LTE_PHY_PUCCH_SR", } F...
256
256
1,161
6
250
Project-Flora/Flora
enb-analysis/mobile_insight_enb/monitor/decoder.py
Python
mi_enb_decoder
mi_enb_decoder
26
180
26
26
4f138be1955afff32e5bb89d35be926ea9146237
bigcode/the-stack
train
f3dfd6f238c4880744eddf53
train
class
class AttachVServerGroupsRequest(RpcRequest): def __init__(self): RpcRequest.__init__(self, 'Ess', '2014-08-28', 'AttachVServerGroups','ess') self.set_method('POST') if hasattr(self, "endpoint_map"): setattr(self, "endpoint_map", endpoint_data.getEndpointMap()) if hasattr(self, "endpoint_regional"): se...
class AttachVServerGroupsRequest(RpcRequest):
def __init__(self): RpcRequest.__init__(self, 'Ess', '2014-08-28', 'AttachVServerGroups','ess') self.set_method('POST') if hasattr(self, "endpoint_map"): setattr(self, "endpoint_map", endpoint_data.getEndpointMap()) if hasattr(self, "endpoint_regional"): setattr(self, "endpoint_regional", endpoint_data....
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
206
216
721
10
195
yndu13/aliyun-openapi-python-sdk
aliyun-python-sdk-ess/aliyunsdkess/request/v20140828/AttachVServerGroupsRequest.py
Python
AttachVServerGroupsRequest
AttachVServerGroupsRequest
23
78
23
24
87ef95e9d2b08a66bd39b710c5c66db2102993ee
bigcode/the-stack
train
bd2109b0bce615f6285c6894
train
function
def run(f, repeats=1000, nthreads=10): threads = [threading.Thread(target=loop, args=(f, repeats)) for i in range(nthreads)] for t in threads: t.start() for t in threads: t.join()
def run(f, repeats=1000, nthreads=10):
threads = [threading.Thread(target=loop, args=(f, repeats)) for i in range(nthreads)] for t in threads: t.start() for t in threads: t.join()
= threading.Lock() def __iter__(self): return self def next(self): with self.lock: self.i += 1 return self.i def loop(func, n): for i in range(n): func() def run(f, repeats=1000, nthreads=10):
64
64
59
14
50
HarmlessHarm/scriptie_bsc
test_scripts/multithreading_tut.py
Python
run
run
46
54
46
46
d9974a8d069125fa78c748ce1c1f7a6aec723766
bigcode/the-stack
train
a3e32dbde2b4f6bab99446b9
train
class
class Counter: def __init__(self): self.i = 0 self.lock = threading.Lock() def __iter__(self): return self def next(self): with self.lock: self.i += 1 return self.i
class Counter:
def __init__(self): self.i = 0 self.lock = threading.Lock() def __iter__(self): return self def next(self): with self.lock: self.i += 1 return self.i
= it self.lock = threading.Lock() def __iter__(self): return self def next(self): with self.lock: return self.it.next() @threadsafe_generator def count(): i = 0 while True: i += 1 yield i class Counter:
64
64
54
3
60
HarmlessHarm/scriptie_bsc
test_scripts/multithreading_tut.py
Python
Counter
Counter
29
40
29
29
0ee026669c965d5c49ebc14ac51380350ecc414f
bigcode/the-stack
train
7d35b48a6016b560eb9ad424
train
function
@threadsafe_generator def count(): i = 0 while True: i += 1 yield i
@threadsafe_generator def count():
i = 0 while True: i += 1 yield i
kw)) return g class threadsafe_iter: def __init__(self, it): self.it = it self.lock = threading.Lock() def __iter__(self): return self def next(self): with self.lock: return self.it.next() @threadsafe_generator def count():
64
64
26
8
56
HarmlessHarm/scriptie_bsc
test_scripts/multithreading_tut.py
Python
count
count
21
26
21
22
7c3bd5d47e0159b795090a74ce3af8be94cb9903
bigcode/the-stack
train
2fc73307df91b21ea3f96f4f
train
function
def main(): c1 = count() c2 = Counter() run(c1.next, repeats=100000, nthreads=2) print("c1", c1.next()) run(c2.next, repeats=100000, nthreads=2) print("c2", c2.next())
def main():
c1 = count() c2 = Counter() run(c1.next, repeats=100000, nthreads=2) print("c1", c1.next()) run(c2.next, repeats=100000, nthreads=2) print("c2", c2.next())
func() def run(f, repeats=1000, nthreads=10): threads = [threading.Thread(target=loop, args=(f, repeats)) for i in range(nthreads)] for t in threads: t.start() for t in threads: t.join() def main():
64
64
62
3
61
HarmlessHarm/scriptie_bsc
test_scripts/multithreading_tut.py
Python
main
main
56
64
56
56
b29f2f22fd71c396f8e0eea173e1209028f66107
bigcode/the-stack
train
b7c2f500806d6e250c7566bc
train
class
class threadsafe_iter: def __init__(self, it): self.it = it self.lock = threading.Lock() def __iter__(self): return self def next(self): with self.lock: return self.it.next()
class threadsafe_iter:
def __init__(self, it): self.it = it self.lock = threading.Lock() def __iter__(self): return self def next(self): with self.lock: return self.it.next()
import threading def threadsafe_generator(f): def g(*a, **kw): return threadsafe_iter(f(*a, **kw)) return g class threadsafe_iter:
37
64
51
5
31
HarmlessHarm/scriptie_bsc
test_scripts/multithreading_tut.py
Python
threadsafe_iter
threadsafe_iter
9
19
9
9
015d1c4e69f96be2ddd24dd417e6aa5f70064539
bigcode/the-stack
train
1485b704caf40d2ff93efc65
train
function
def threadsafe_generator(f): def g(*a, **kw): return threadsafe_iter(f(*a, **kw)) return g
def threadsafe_generator(f):
def g(*a, **kw): return threadsafe_iter(f(*a, **kw)) return g
import threading def threadsafe_generator(f):
9
64
29
6
2
HarmlessHarm/scriptie_bsc
test_scripts/multithreading_tut.py
Python
threadsafe_generator
threadsafe_generator
4
7
4
4
786e0f6af65a1be692c07b87353a8ed5f9ec7790
bigcode/the-stack
train
64081c1f54b7d17cae92fde1
train
function
def loop(func, n): for i in range(n): func()
def loop(func, n):
for i in range(n): func()
yield i class Counter: def __init__(self): self.i = 0 self.lock = threading.Lock() def __iter__(self): return self def next(self): with self.lock: self.i += 1 return self.i def loop(func, n):
64
64
15
6
57
HarmlessHarm/scriptie_bsc
test_scripts/multithreading_tut.py
Python
loop
loop
42
44
42
42
ba86890a0a0df36b18cbb569b4e0290a9dd14208
bigcode/the-stack
train
36082dd1286baa825bc1158d
train
class
class DataBlockManager(object): def __init__(self, data_source, partition_id): self._lock = threading.Lock() self._data_source = data_source self._partition_id = partition_id self._data_block_meta_cache = {} self._dumped_index = None self._dumping_index = None ...
class DataBlockManager(object):
def __init__(self, data_source, partition_id): self._lock = threading.Lock() self._data_source = data_source self._partition_id = partition_id self._data_block_meta_cache = {} self._dumped_index = None self._dumping_index = None self._make_directory_if_nessary...
.leader_stats_index, meta.joiner_stats_info.follower_stats_index, leader_join_rate, follower_join_rate) def _get_data_block_dir(self): return os.path.join(self._dirname, partition_repr(self._partition_id)) def _get_tmp_fpath(self): ...
256
256
1,060
6
249
zhenv5/fedlearner
fedlearner/data_join/data_block_manager.py
Python
DataBlockManager
DataBlockManager
227
338
227
227
7b61d54f0bb3fb9d9ef5b1bfcae0cf30436b53b7
bigcode/the-stack
train
9c6309c978803ccf6d47f3c1
train
class
class DataBlockBuilder(object): def __init__(self, dirname, data_source_name, partition_id, data_block_index, write_options, max_example_num=None): self._data_source_name = data_source_name self._partition_id = partition_id self._max_example_num = max_example_num sel...
class DataBlockBuilder(object):
def __init__(self, dirname, data_source_name, partition_id, data_block_index, write_options, max_example_num=None): self._data_source_name = data_source_name self._partition_id = partition_id self._max_example_num = max_example_num self._dirname = dirname sel...
0 (the "License"); # you may not use this file except in compliance with the 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, #...
256
256
1,770
6
249
zhenv5/fedlearner
fedlearner/data_join/data_block_manager.py
Python
DataBlockBuilder
DataBlockBuilder
39
225
39
39
c36b0b96f189eb3e758befaf06a4b03ab5f39b62
bigcode/the-stack
train
e28b6d839fb4d82efd7c19fa
train
function
def iter_pagelinks_dump_data(**kwargs): dump_url = _get_wiki_dump_dl_url(_WIKI_DP_PAGELINKS, **kwargs) return _parse_wiki_sql_dump(dump_url, _parse_fx_pagelinks_dump, **kwargs)
def iter_pagelinks_dump_data(**kwargs):
dump_url = _get_wiki_dump_dl_url(_WIKI_DP_PAGELINKS, **kwargs) return _parse_wiki_sql_dump(dump_url, _parse_fx_pagelinks_dump, **kwargs)
_dump(el): if el[1] not in (WIKI_NS_KIND_CATEGORY, WIKI_NS_KIND_PAGE): return redirectid = int(el[0]) title = _unescape_title(el[2]) return redirectid, title def iter_pagelinks_dump_data(**kwargs):
64
64
57
10
53
hp0404/spikex
spikex/wikigraph/dumptools.py
Python
iter_pagelinks_dump_data
iter_pagelinks_dump_data
106
108
106
106
af6800c90ba12b19e49d0f1206c111e3568f9a4a
bigcode/the-stack
train
f1e13f8f1973550c7e82d10c
train
function
def _parsing_task(line, parse_fx): ret = [] for el in _parse_wiki_sql_dump_line(line): res = parse_fx(el) if res is None: continue ret.append(res) return zlib.compress(pickle_dumps(ret, protocol=-1))
def _parsing_task(line, parse_fx):
ret = [] for el in _parse_wiki_sql_dump_line(line): res = parse_fx(el) if res is None: continue ret.append(res) return zlib.compress(pickle_dumps(ret, protocol=-1))
=10): compress_bytes = compress_obj.tell() pbar.update(compress_bytes - compress_bytes_read) compress_bytes_read = compress_bytes yield from pickle_loads(zlib.decompress(res)) msg.good(dump_name, show=verbose) def _parsing_task(line, parse_fx):
64
64
63
10
54
hp0404/spikex
spikex/wikigraph/dumptools.py
Python
_parsing_task
_parsing_task
223
230
223
223
6886c82f8d8b0f929b20aa307bebccbc0e84e775
bigcode/the-stack
train
ef66df9bce82ea6a9759f609
train
function
def _get_wiki_dump_obj(wiki_sql_dump_url, verbose=None): if isinstance(wiki_sql_dump_url, Path): if not wiki_sql_dump_url.exists(): raise FileNotFoundError compress_obj = wiki_sql_dump_url.open("rb") content_len = wiki_sql_dump_url.stat().st_size if content_len == 0: ...
def _get_wiki_dump_obj(wiki_sql_dump_url, verbose=None):
if isinstance(wiki_sql_dump_url, Path): if not wiki_sql_dump_url.exists(): raise FileNotFoundError compress_obj = wiki_sql_dump_url.open("rb") content_len = wiki_sql_dump_url.stat().st_size if content_len == 0: raise FileNotFoundError elif isinstance(wiki_...
umps_path"] if dp is not None and dp.exists(): path = dp.joinpath(n) if path.exists(): return path return URL(_WIKI_DL_PATH.format(w=w, n=n, v=v)) def _get_wiki_dump_obj(wiki_sql_dump_url, verbose=None):
64
64
159
16
48
hp0404/spikex
spikex/wikigraph/dumptools.py
Python
_get_wiki_dump_obj
_get_wiki_dump_obj
152
166
152
152
07cd645fbd3eda4f10e6cd8480462a770302b02c
bigcode/the-stack
train
6b1174051206d406fa7ebade
train
function
def _get_wiki_dump_dl_url(t, **kwargs): _kwargs = {**config, **kwargs} w = _kwargs["wiki"] v = _kwargs["version"] n = _WIKI_DL_NAME.format(w=w, t=t, v=v) dp = _kwargs["dumps_path"] if dp is not None and dp.exists(): path = dp.joinpath(n) if path.exists(): return path ...
def _get_wiki_dump_dl_url(t, **kwargs):
_kwargs = {**config, **kwargs} w = _kwargs["wiki"] v = _kwargs["version"] n = _WIKI_DL_NAME.format(w=w, t=t, v=v) dp = _kwargs["dumps_path"] if dp is not None and dp.exists(): path = dp.joinpath(n) if path.exists(): return path return URL(_WIKI_DL_PATH.format(w=w,...
sourceid = int(el[0]) target = _unescape_title(el[1]) return cl_type, sourceid, target def _unescape_title(title): return title.replace("\\'", "'").replace('\\"', '"') def _get_wiki_dump_dl_url(t, **kwargs):
64
64
113
13
51
hp0404/spikex
spikex/wikigraph/dumptools.py
Python
_get_wiki_dump_dl_url
_get_wiki_dump_dl_url
139
149
139
139
c6d725f15b2dcb3875722eb101eb813b9d44ba21
bigcode/the-stack
train
520359d934cbd23a56b7f56d
train
function
def _parse_wiki_sql_dump_line(line): line = line.decode("latin1") if line.startswith("INSERT INTO"): el_end = 0 el_start = 0 curr_tuple = [] is_escaping = False is_string_open = False line_start = line.index("(") for i in range(line_start, len(line)): ...
def _parse_wiki_sql_dump_line(line):
line = line.decode("latin1") if line.startswith("INSERT INTO"): el_end = 0 el_start = 0 curr_tuple = [] is_escaping = False is_string_open = False line_start = line.index("(") for i in range(line_start, len(line)): c = line[i] if no...
compress_bytes_read = compress_bytes yield from pickle_loads(zlib.decompress(res)) msg.good(dump_name, show=verbose) def _parsing_task(line, parse_fx): ret = [] for el in _parse_wiki_sql_dump_line(line): res = parse_fx(el) if res is None: continu...
104
104
347
10
94
hp0404/spikex
spikex/wikigraph/dumptools.py
Python
_parse_wiki_sql_dump_line
_parse_wiki_sql_dump_line
233
280
233
233
2cd32dcdec8b1ccec042adcfe20102db633c0dfc
bigcode/the-stack
train
3150fc25455eff668fea1a43
train
function
def resolve_version(wiki, version): url = _WIKI_BASE_DL_PATH.format(w=wiki) response = requests.get(url) versions = re.findall(r"href=\"(\d+)/\"", response.text) if version in versions: return version if version == "latest": return max(versions) msg.fail( "Wikipedia dump ...
def resolve_version(wiki, version):
url = _WIKI_BASE_DL_PATH.format(w=wiki) response = requests.get(url) versions = re.findall(r"href=\"(\d+)/\"", response.text) if version in versions: return version if version == "latest": return max(versions) msg.fail( "Wikipedia dump version not found", f"Pick o...
links" _WIKI_DL_NAME = "{w}wiki-{v}-{t}.sql.gz" _WIKI_BASE_DL_PATH = "https://dumps.wikimedia.org/{w}wiki/" _WIKI_DL_PATH = _WIKI_BASE_DL_PATH + "{v}/{n}" def resolve_version(wiki, version):
63
64
103
8
55
hp0404/spikex
spikex/wikigraph/dumptools.py
Python
resolve_version
resolve_version
50
62
50
50
89497e900f5c61cbd544c5f392e2057f4c59cacb
bigcode/the-stack
train
ab0be91e710d36239e5c0ae3
train
function
def iter_page_props_dump_data(**kwargs): dump_url = _get_wiki_dump_dl_url(_WIKI_DP_PAGE_PROPS, **kwargs) return _parse_wiki_sql_dump(dump_url, _parse_fx_page_props_dump, **kwargs)
def iter_page_props_dump_data(**kwargs):
dump_url = _get_wiki_dump_dl_url(_WIKI_DP_PAGE_PROPS, **kwargs) return _parse_wiki_sql_dump(dump_url, _parse_fx_page_props_dump, **kwargs)
in versions: return version if version == "latest": return max(versions) msg.fail( "Wikipedia dump version not found", f"Pick one of these: {', '.join(versions)}.", exits=1, ) def iter_page_props_dump_data(**kwargs):
64
64
53
9
55
hp0404/spikex
spikex/wikigraph/dumptools.py
Python
iter_page_props_dump_data
iter_page_props_dump_data
65
67
65
65
77be9dc2b1fe41b1a9e960d483cc792430e524e8
bigcode/the-stack
train
7557939eae03f925a9c78b10
train
function
def _parse_fx_page_props_dump(el): pageid = int(el[0]) prop = el[1] value = el[2] return pageid, prop, value
def _parse_fx_page_props_dump(el):
pageid = int(el[0]) prop = el[1] value = el[2] return pageid, prop, value
) def iter_page_props_dump_data(**kwargs): dump_url = _get_wiki_dump_dl_url(_WIKI_DP_PAGE_PROPS, **kwargs) return _parse_wiki_sql_dump(dump_url, _parse_fx_page_props_dump, **kwargs) def _parse_fx_page_props_dump(el):
64
64
41
9
55
hp0404/spikex
spikex/wikigraph/dumptools.py
Python
_parse_fx_page_props_dump
_parse_fx_page_props_dump
70
74
70
70
a4264da952ddd71f9323cfcadeb4c1809c85afd8
bigcode/the-stack
train
71fe5b99b158b4e6fd7e5155
train
function
def iter_redirect_dump_data(**kwargs): dump_url = _get_wiki_dump_dl_url(_WIKI_DP_REDIRECT, **kwargs) yield from _parse_wiki_sql_dump( dump_url, _parse_fx_redirect_dump, **kwargs )
def iter_redirect_dump_data(**kwargs):
dump_url = _get_wiki_dump_dl_url(_WIKI_DP_REDIRECT, **kwargs) yield from _parse_wiki_sql_dump( dump_url, _parse_fx_redirect_dump, **kwargs )
el[1] if ns_kind not in (WIKI_NS_KIND_CATEGORY, WIKI_NS_KIND_PAGE): return pageid = int(el[0]) title = _unescape_title(el[2]) return ns_kind, pageid, title def iter_redirect_dump_data(**kwargs):
64
64
54
8
55
hp0404/spikex
spikex/wikigraph/dumptools.py
Python
iter_redirect_dump_data
iter_redirect_dump_data
91
95
91
91
fee3cee37af0b937902fa1c861a787cf6098853d
bigcode/the-stack
train
03bf1e46a75742642953ad0e
train
function
def _parse_fx_pagelinks_dump(el): if el[1] != WIKI_NS_KIND_PAGE or el[3] != WIKI_NS_KIND_PAGE: return sourceid = int(el[0]) target = _unescape_title(el[2]) return sourceid, target
def _parse_fx_pagelinks_dump(el):
if el[1] != WIKI_NS_KIND_PAGE or el[3] != WIKI_NS_KIND_PAGE: return sourceid = int(el[0]) target = _unescape_title(el[2]) return sourceid, target
elinks_dump_data(**kwargs): dump_url = _get_wiki_dump_dl_url(_WIKI_DP_PAGELINKS, **kwargs) return _parse_wiki_sql_dump(dump_url, _parse_fx_pagelinks_dump, **kwargs) def _parse_fx_pagelinks_dump(el):
64
64
64
10
54
hp0404/spikex
spikex/wikigraph/dumptools.py
Python
_parse_fx_pagelinks_dump
_parse_fx_pagelinks_dump
111
116
111
111
355e40fd530f404753c77bf37710b57869f3064f
bigcode/the-stack
train
55d7cd6c7ab0e36df0d72272
train
function
def _parse_fx_categorylinks_dump(el): cl_type = el[6] if cl_type not in (WIKI_CL_TYPE_CATEGORY, WIKI_CL_TYPE_PAGE): return sourceid = int(el[0]) target = _unescape_title(el[1]) return cl_type, sourceid, target
def _parse_fx_categorylinks_dump(el):
cl_type = el[6] if cl_type not in (WIKI_CL_TYPE_CATEGORY, WIKI_CL_TYPE_PAGE): return sourceid = int(el[0]) target = _unescape_title(el[1]) return cl_type, sourceid, target
iter_categorylinks_dump_data(**kwargs): dump_url = _get_wiki_dump_dl_url(_WIKI_DP_CATEGORYLINKS, **kwargs) return _parse_wiki_sql_dump( dump_url, _parse_fx_categorylinks_dump, **kwargs ) def _parse_fx_categorylinks_dump(el):
64
64
69
9
55
hp0404/spikex
spikex/wikigraph/dumptools.py
Python
_parse_fx_categorylinks_dump
_parse_fx_categorylinks_dump
126
132
126
126
8f152ab4877f1fa3941965de981288ab38a8e123
bigcode/the-stack
train
f2fb6d9ea8b9a8fc67c2e34f
train
function
def iter_categorylinks_dump_data(**kwargs): dump_url = _get_wiki_dump_dl_url(_WIKI_DP_CATEGORYLINKS, **kwargs) return _parse_wiki_sql_dump( dump_url, _parse_fx_categorylinks_dump, **kwargs )
def iter_categorylinks_dump_data(**kwargs):
dump_url = _get_wiki_dump_dl_url(_WIKI_DP_CATEGORYLINKS, **kwargs) return _parse_wiki_sql_dump( dump_url, _parse_fx_categorylinks_dump, **kwargs )
): if el[1] != WIKI_NS_KIND_PAGE or el[3] != WIKI_NS_KIND_PAGE: return sourceid = int(el[0]) target = _unescape_title(el[2]) return sourceid, target def iter_categorylinks_dump_data(**kwargs):
64
64
56
9
54
hp0404/spikex
spikex/wikigraph/dumptools.py
Python
iter_categorylinks_dump_data
iter_categorylinks_dump_data
119
123
119
119
05f80b2925cd1e36e33db3adb38e5870aad475df
bigcode/the-stack
train
0b007eb4dee4881b0894466b
train
function
def _parse_fx_page_dump(el): ns_kind = el[1] if ns_kind not in (WIKI_NS_KIND_CATEGORY, WIKI_NS_KIND_PAGE): return pageid = int(el[0]) title = _unescape_title(el[2]) return ns_kind, pageid, title
def _parse_fx_page_dump(el):
ns_kind = el[1] if ns_kind not in (WIKI_NS_KIND_CATEGORY, WIKI_NS_KIND_PAGE): return pageid = int(el[0]) title = _unescape_title(el[2]) return ns_kind, pageid, title
pageid, prop, value def iter_page_dump_data(**kwargs): dump_url = _get_wiki_dump_dl_url(_WIKI_DP_PAGE, **kwargs) return _parse_wiki_sql_dump(dump_url, _parse_fx_page_dump, **kwargs) def _parse_fx_page_dump(el):
64
64
68
8
56
hp0404/spikex
spikex/wikigraph/dumptools.py
Python
_parse_fx_page_dump
_parse_fx_page_dump
82
88
82
82
5ba56ba44ee09bc935138fab9540cef40c67f25f
bigcode/the-stack
train
1d5e6ddbf013b936cd22ef35
train
function
def _parse_wiki_sql_dump(wiki_sql_dump_url, parse_fx, **kwargs): _kwargs = {**config, **kwargs} dumps_path = _kwargs["dumps_path"] max_workers = _kwargs["max_workers"] verbose = _kwargs["verbose"] compress_bytes_read = 0 dump_name = wiki_sql_dump_url.name msg.text(f"-> {dump_name}", show=ver...
def _parse_wiki_sql_dump(wiki_sql_dump_url, parse_fx, **kwargs):
_kwargs = {**config, **kwargs} dumps_path = _kwargs["dumps_path"] max_workers = _kwargs["max_workers"] verbose = _kwargs["verbose"] compress_bytes_read = 0 dump_name = wiki_sql_dump_url.name msg.text(f"-> {dump_name}", show=verbose) tqdm_disable = not verbose tqdm_kwargs = { ...
not wiki_sql_dump_url.exists(): raise FileNotFoundError compress_obj = wiki_sql_dump_url.open("rb") content_len = wiki_sql_dump_url.stat().st_size if content_len == 0: raise FileNotFoundError elif isinstance(wiki_sql_dump_url, URL): compress_obj = http_open(s...
149
149
497
19
129
hp0404/spikex
spikex/wikigraph/dumptools.py
Python
_parse_wiki_sql_dump
_parse_wiki_sql_dump
169
220
169
169
f5e05268aed824a9eb3b6174a07df9d657a81e2e
bigcode/the-stack
train
b832c6607793b13db1645ba8
train
function
def _parse_fx_redirect_dump(el): if el[1] not in (WIKI_NS_KIND_CATEGORY, WIKI_NS_KIND_PAGE): return redirectid = int(el[0]) title = _unescape_title(el[2]) return redirectid, title
def _parse_fx_redirect_dump(el):
if el[1] not in (WIKI_NS_KIND_CATEGORY, WIKI_NS_KIND_PAGE): return redirectid = int(el[0]) title = _unescape_title(el[2]) return redirectid, title
title def iter_redirect_dump_data(**kwargs): dump_url = _get_wiki_dump_dl_url(_WIKI_DP_REDIRECT, **kwargs) yield from _parse_wiki_sql_dump( dump_url, _parse_fx_redirect_dump, **kwargs ) def _parse_fx_redirect_dump(el):
64
64
59
8
56
hp0404/spikex
spikex/wikigraph/dumptools.py
Python
_parse_fx_redirect_dump
_parse_fx_redirect_dump
98
103
98
98
f1ce97e8bfd7dfac9985ea911febb51f3baef6dc
bigcode/the-stack
train
2cfed1fe10756a07c551fd1d
train
function
def _unescape_title(title): return title.replace("\\'", "'").replace('\\"', '"')
def _unescape_title(title):
return title.replace("\\'", "'").replace('\\"', '"')
= el[6] if cl_type not in (WIKI_CL_TYPE_CATEGORY, WIKI_CL_TYPE_PAGE): return sourceid = int(el[0]) target = _unescape_title(el[1]) return cl_type, sourceid, target def _unescape_title(title):
64
64
21
7
56
hp0404/spikex
spikex/wikigraph/dumptools.py
Python
_unescape_title
_unescape_title
135
136
135
135
dbb59c2fabe354c0aa90a360664721f1c29aba3e
bigcode/the-stack
train
0c1fcce45ed91e464a80e64d
train
function
def iter_page_dump_data(**kwargs): dump_url = _get_wiki_dump_dl_url(_WIKI_DP_PAGE, **kwargs) return _parse_wiki_sql_dump(dump_url, _parse_fx_page_dump, **kwargs)
def iter_page_dump_data(**kwargs):
dump_url = _get_wiki_dump_dl_url(_WIKI_DP_PAGE, **kwargs) return _parse_wiki_sql_dump(dump_url, _parse_fx_page_dump, **kwargs)
_dump(dump_url, _parse_fx_page_props_dump, **kwargs) def _parse_fx_page_props_dump(el): pageid = int(el[0]) prop = el[1] value = el[2] return pageid, prop, value def iter_page_dump_data(**kwargs):
64
64
49
8
55
hp0404/spikex
spikex/wikigraph/dumptools.py
Python
iter_page_dump_data
iter_page_dump_data
77
79
77
77
fb454118240d18dd4d3b96f689d81aef9bb71985
bigcode/the-stack
train
7e155a5783284e1d5f5478e0
train
function
def _parse_input_args(arguments: List): input_args = {} for argument in arguments: argument_name, value = argument.split("=") argument_name = argument_name.lstrip("-").replace("-", "_") value = value.strip('"') input_args[argument_name] = value return Input(input_args)
def _parse_input_args(arguments: List):
input_args = {} for argument in arguments: argument_name, value = argument.split("=") argument_name = argument_name.lstrip("-").replace("-", "_") value = value.strip('"') input_args[argument_name] = value return Input(input_args)
#!/usr/bin/env python import sys import argparse from importlib import util from typing import List from shared.infrastructure.command import ConsoleCommand, Input from shared.application.bootstrap import Bootstrap boostrap = Bootstrap() def _parse_input_args(arguments: List):
54
64
67
9
45
fdelgados/python-ddd-skeleton
bin/console.py
Python
_parse_input_args
_parse_input_args
15
24
15
15
34b31c6f97c139a9ccee25126b570ec68c2e47a1
bigcode/the-stack
train
abebe5f205a5a53f4c090c77
train
class
class ModelTests(TestCase): def test_create_user_with_email_successful(self): """ Test creating a new user with an email successful """ email = 'test@test.com' password = '123456' user = get_user_model().objects.create_user( email=email, ...
class ModelTests(TestCase):
def test_create_user_with_email_successful(self): """ Test creating a new user with an email successful """ email = 'test@test.com' password = '123456' user = get_user_model().objects.create_user( email=email, password=password ) ...
from django.test import TestCase from django.contrib.auth import get_user_model class ModelTests(TestCase):
22
77
257
6
15
dangquangdon/RecipeAPI
app/core/tests/test_models.py
Python
ModelTests
ModelTests
5
52
5
6
e1772df11914f4b247025b8b131e50b72dbc6ade
bigcode/the-stack
train
773ae4c1a65328eb4c5e9704
train
function
def regen(version: str) -> Set[str]: base_path = Path(".cache", RELEASES[version].split("/")[-1].rsplit(".", 1)[0]) setup_path = base_path / "setup.py" if not base_path.exists(): Path(".cache").mkdir(exist_ok=True) subprocess.check_call(["wget", "-c", RELEASES[version]], cwd=".cache") ...
def regen(version: str) -> Set[str]:
base_path = Path(".cache", RELEASES[version].split("/")[-1].rsplit(".", 1)[0]) setup_path = base_path / "setup.py" if not base_path.exists(): Path(".cache").mkdir(exist_ok=True) subprocess.check_call(["wget", "-c", RELEASES[version]], cwd=".cache") subprocess.check_call( ...
.readline() if not _line.strip(): break MY_COPYRIGHT_HEADER += _line GENERATED_TMPL = ( MY_COPYRIGHT_HEADER + """\ # Generated by stdlibs/fetch.py module_names = frozenset( [ {lines} ] ) """ ) def write_tmpl(name: str, data: Set[str]) -> None: lines = "".join(f' ...
256
256
937
10
246
thatch/stdlibs
stdlibs/fetch.py
Python
regen
regen
94
199
94
94
3d78ecdea63b0b32249c267562a5c3503df521c2
bigcode/the-stack
train
0d19e24b2aae4b0bd87eb425
train
function
def regen_all() -> None: all2: Set[str] = set() all3: Set[str] = set() for v in RELEASES: names = regen(v) if v.startswith("2"): all2 |= names elif v.startswith("3"): all3 |= names else: raise ValueError("What is this brave new future you l...
def regen_all() -> None:
all2: Set[str] = set() all3: Set[str] = set() for v in RELEASES: names = regen(v) if v.startswith("2"): all2 |= names elif v.startswith("3"): all3 |= names else: raise ValueError("What is this brave new future you live in") write_tmpl(...
""" ) def write_tmpl(name: str, data: Set[str]) -> None: lines = "".join(f' "{s}",\n' for s in sorted(data)) (BASE_DIR / name).write_text(GENERATED_TMPL.format(lines=lines)) def regen_all() -> None:
64
64
127
7
57
thatch/stdlibs
stdlibs/fetch.py
Python
regen_all
regen_all
75
91
75
75
f32643d3b03f4e3398a6f36d6b9a23f237f53946
bigcode/the-stack
train
80f4a3bf30afabddad0b990f
train
function
def write_tmpl(name: str, data: Set[str]) -> None: lines = "".join(f' "{s}",\n' for s in sorted(data)) (BASE_DIR / name).write_text(GENERATED_TMPL.format(lines=lines))
def write_tmpl(name: str, data: Set[str]) -> None:
lines = "".join(f' "{s}",\n' for s in sorted(data)) (BASE_DIR / name).write_text(GENERATED_TMPL.format(lines=lines))
_HEADER += _line GENERATED_TMPL = ( MY_COPYRIGHT_HEADER + """\ # Generated by stdlibs/fetch.py module_names = frozenset( [ {lines} ] ) """ ) def write_tmpl(name: str, data: Set[str]) -> None:
64
64
55
16
48
thatch/stdlibs
stdlibs/fetch.py
Python
write_tmpl
write_tmpl
70
72
70
70
46bd89489be539e754b6fc9ae8e224343415e477
bigcode/the-stack
train
1ef1d496a642728ed4cc99f5
train
class
class ExtensionVisitor(cst.CSTVisitor): def __init__(self) -> None: self.extension_names: List[str] = [] def visit_Call(self, node: cst.Call) -> None: # print(node) d = m.extract( node, m.Call( func=m.OneOf(m.Name("Extension"), m.Name("addMacExten...
class ExtensionVisitor(cst.CSTVisitor):
def __init__(self) -> None: self.extension_names: List[str] = [] def visit_Call(self, node: cst.Call) -> None: # print(node) d = m.extract( node, m.Call( func=m.OneOf(m.Name("Extension"), m.Name("addMacExtension")), args=( ...
(3, 3): names.append("_frozen_importlib") if version_tuple >= (3, 5): names.append("_frozen_importlib_external") write_tmpl(f"py{version.replace('.', '')}.py", set(names)) print(f"{version} done.") return set(names) class ExtensionVisitor(cst.CSTVisitor):
76
76
255
9
67
thatch/stdlibs
stdlibs/fetch.py
Python
ExtensionVisitor
ExtensionVisitor
202
234
202
202
30ae827455f102f14b57401e73551408dd496d70
bigcode/the-stack
train
e0b319adaa571016ded343d6
train
function
def try_parse(path: Path, data: Optional[bytes] = None) -> cst.Module: """ Attempts to parse the file with all syntax versions known by LibCST. If parsing fails on all supported grammar versions, then raises the parser error from the first/newest version attempted. """ if data is None: ...
def try_parse(path: Path, data: Optional[bytes] = None) -> cst.Module:
""" Attempts to parse the file with all syntax versions known by LibCST. If parsing fails on all supported grammar versions, then raises the parser error from the first/newest version attempted. """ if data is None: data = path.read_bytes() parse_error: Optional[cst.ParserSyntaxErr...
["list"], cst.List) for item in d["list"].elements: if isinstance(item.value, cst.SimpleString): self.extension_names.append(item.value.evaluated_value) # This is from usort def try_parse(path: Path, data: Optional[bytes] = None) -> cst.Module:
68
68
227
21
46
thatch/stdlibs
stdlibs/fetch.py
Python
try_parse
try_parse
238
263
238
238
7a940bd3b87e303b40ab967763effab4588fcb08
bigcode/the-stack
train
742cca9f236746464da290e6
train
class
class installed_comps(): """Checks for installed components and keeps track of prior checks""" installed = [] not_installed = [] def __init__(self, reqs): """Class for checking installed components""" self.reqs = reqs def inst(self, name): """Return True if name is in list ...
class installed_comps():
"""Checks for installed components and keeps track of prior checks""" installed = [] not_installed = [] def __init__(self, reqs): """Class for checking installed components""" self.reqs = reqs def inst(self, name): """Return True if name is in list of possible installed pac...
abi", "aarch64", "arm64"] ARM_PLATFORM = False if PROCESSOR.lower() in [x.lower() for x in ARM_LIST]: ARM_PLATFORM = True NINJA_PROG = ProgramBinary('ninja', ["ninja-build", "ninja"]) class installed_comps():
64
64
195
5
59
Junkrat-boommm/daos
utils/sl/components/__init__.py
Python
installed_comps
installed_comps
41
67
41
41
69129c902b29716c38a0ced5e9a2bbdb8f6d893a
bigcode/the-stack
train
8ee8d997308545aabcab1eb8
train
function
def exclude(reqs, name, use_value, exclude_value): """Return True if in exclude list""" if set([name, 'all']).intersection(set(reqs.exclude)): print("Excluding %s from build" % name) return exclude_value return use_value
def exclude(reqs, name, use_value, exclude_value):
"""Return True if in exclude list""" if set([name, 'all']).intersection(set(reqs.exclude)): print("Excluding %s from build" % name) return exclude_value return use_value
(name): print("Using installed version of %s" % name) self.installed.append(name) return True print("Using build version of %s" % name) self.not_installed.append(name) return False def exclude(reqs, name, use_value, exclude_value):
64
64
60
13
50
Junkrat-boommm/daos
utils/sl/components/__init__.py
Python
exclude
exclude
69
74
69
69
fa5ff1480d41fcf7a8b2cbe40cb4e122937f46be
bigcode/the-stack
train
5165b9dec205a5e1172da400
train
function
def define_mercury(reqs): """mercury definitions""" libs = ['rt'] if reqs.get_env('PLATFORM') == 'darwin': libs = [] else: reqs.define('rt', libs=['rt']) reqs.define('stdatomic', headers=['stdatomic.h']) if reqs.check_component('stdatomic'): atomic = 'stdatomic' els...
def define_mercury(reqs):
"""mercury definitions""" libs = ['rt'] if reqs.get_env('PLATFORM') == 'darwin': libs = [] else: reqs.define('rt', libs=['rt']) reqs.define('stdatomic', headers=['stdatomic.h']) if reqs.check_component('stdatomic'): atomic = 'stdatomic' else: atomic = 'openp...
) return True print("Using build version of %s" % name) self.not_installed.append(name) return False def exclude(reqs, name, use_value, exclude_value): """Return True if in exclude list""" if set([name, 'all']).intersection(set(reqs.exclude)): print("Excluding %s fr...
256
256
1,004
8
248
Junkrat-boommm/daos
utils/sl/components/__init__.py
Python
define_mercury
define_mercury
96
195
96
96
639d59e97e3d67fcc10c2d91a9572458a957ffca
bigcode/the-stack
train
7ca174eabe2d14b656fa5bc7
train
function
def check(reqs, name, built_str, installed_str=""): """Return a different string based on whether a component is installed or not""" installed = installed_comps(reqs) if installed.check(name): return installed_str return built_str
def check(reqs, name, built_str, installed_str=""):
"""Return a different string based on whether a component is installed or not""" installed = installed_comps(reqs) if installed.check(name): return installed_str return built_str
build" % name) return exclude_value return use_value def inst(reqs, name): """Return True if name is in list of installed packages""" installed = installed_comps(reqs) return installed.check(name) def check(reqs, name, built_str, installed_str=""):
64
64
57
14
50
Junkrat-boommm/daos
utils/sl/components/__init__.py
Python
check
check
81
87
81
81
76b310d6900302bd4983ce0267ca14a2c7e951c9
bigcode/the-stack
train
0bc029c70d050614aa82d0ee
train
function
def define_common(reqs): """common system component definitions""" reqs.define('lz4', headers=['lz4.h'], package='lz4-devel') reqs.define('valgrind_devel', headers=['valgrind/valgrind.h'], package='valgrind-devel') reqs.define('cunit', libs=['cunit'], headers=['CUnit/Basic.h'], ...
def define_common(reqs):
"""common system component definitions""" reqs.define('lz4', headers=['lz4.h'], package='lz4-devel') reqs.define('valgrind_devel', headers=['valgrind/valgrind.h'], package='valgrind-devel') reqs.define('cunit', libs=['cunit'], headers=['CUnit/Basic.h'], package='CUnit-d...
'-DOFI_LIBRARY=$OFI_PREFIX/lib/libfabric.so'), 'make $JOBS_OPT', 'make install'], libs=['mercury', 'na', 'mercury_util'], requires=[atomic, 'boost', 'ofi'] + libs, extra_include_path=[os.path.join('include', 'na')], out_of_src_bu...
110
111
371
6
104
Junkrat-boommm/daos
utils/sl/components/__init__.py
Python
define_common
define_common
199
238
199
199
d78aef59cc230ec8d493e3849aa8ee17c81618fb
bigcode/the-stack
train
2102376731b2e8951adac3f2
train
function
def inst(reqs, name): """Return True if name is in list of installed packages""" installed = installed_comps(reqs) return installed.check(name)
def inst(reqs, name):
"""Return True if name is in list of installed packages""" installed = installed_comps(reqs) return installed.check(name)
s, name, use_value, exclude_value): """Return True if in exclude list""" if set([name, 'all']).intersection(set(reqs.exclude)): print("Excluding %s from build" % name) return exclude_value return use_value def inst(reqs, name):
64
64
35
7
56
Junkrat-boommm/daos
utils/sl/components/__init__.py
Python
inst
inst
76
79
76
76
47d1f6c6c17d855e0825ab23e7772511580603c5
bigcode/the-stack
train
ece20a602f6a689d7130bd41
train
function
def define_ompi(reqs): """OMPI and related components""" reqs.define('hwloc', headers=['hwloc.h'], libs=['hwloc'], package='hwloc-devel') reqs.define('ompi', pkgconfig='ompi', package='ompi-devel') reqs.define('mpich', pkgconfig='mpich', package='mpich-devel')
def define_ompi(reqs):
"""OMPI and related components""" reqs.define('hwloc', headers=['hwloc.h'], libs=['hwloc'], package='hwloc-devel') reqs.define('ompi', pkgconfig='ompi', package='ompi-devel') reqs.define('mpich', pkgconfig='mpich', package='mpich-devel')
if reqs.get_env('PLATFORM') == 'darwin': reqs.define('uuid', headers=['uuid/uuid.h']) else: reqs.define('uuid', libs=['uuid'], headers=['uuid/uuid.h'], package='libuuid-devel') def define_ompi(reqs):
64
64
82
8
56
Junkrat-boommm/daos
utils/sl/components/__init__.py
Python
define_ompi
define_ompi
240
245
240
240
fdc4ff18a0689346bd56300044c25d78e91cb607
bigcode/the-stack
train
3350fe7b1db67c329eb2ce06
train
function
def define_components(reqs): """Define all of the components""" define_common(reqs) define_mercury(reqs) define_ompi(reqs) isal_build = ['./autogen.sh ', './configure --prefix=$ISAL_PREFIX --libdir=$ISAL_PREFIX/lib', 'make $JOBS_OPT', 'make install'] reqs.def...
def define_components(reqs):
"""Define all of the components""" define_common(reqs) define_mercury(reqs) define_ompi(reqs) isal_build = ['./autogen.sh ', './configure --prefix=$ISAL_PREFIX --libdir=$ISAL_PREFIX/lib', 'make $JOBS_OPT', 'make install'] reqs.define('isal', r...
boost/preprocessor.hpp'], package='boost-devel') reqs.define('yaml', headers=['yaml.h'], package='libyaml-devel') reqs.define('event', libs=['event'], package='libevent-devel') reqs.define('crypto', libs=['crypto'], headers=['openssl/md5.h'], package='openssl-devel') ...
242
242
808
6
236
Junkrat-boommm/daos
utils/sl/components/__init__.py
Python
define_components
define_components
248
327
248
248
095ec91ec7e548290da707922a2d85bf59011c90
bigcode/the-stack
train
41f41d3b0ba98f4e96e4ebd0
train
function
def ofi_config(config): """Check ofi version""" code = """#include <rdma/fabric.h> _Static_assert(FI_MAJOR_VERSION == 1 && FI_MINOR_VERSION >= 11, "libfabric must be >= 1.11");""" return config.TryCompile(code, ".c")
def ofi_config(config):
"""Check ofi version""" code = """#include <rdma/fabric.h> _Static_assert(FI_MAJOR_VERSION == 1 && FI_MINOR_VERSION >= 11, "libfabric must be >= 1.11");""" return config.TryCompile(code, ".c")
) def check(reqs, name, built_str, installed_str=""): """Return a different string based on whether a component is installed or not""" installed = installed_comps(reqs) if installed.check(name): return installed_str return built_str def ofi_config(config):
64
64
66
6
57
Junkrat-boommm/daos
utils/sl/components/__init__.py
Python
ofi_config
ofi_config
89
94
89
89
6f26fbc858ac3faa0df7ae0cafb4086adc36af18
bigcode/the-stack
train