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
8f3b4bd321e016e7ff1a014b
train
function
def _todb_dbapi_mkcurs(table, mkcurs, tablename, schema=None, commit=True, truncate=False): # sanitise table name tablename = _quote(tablename) if schema is not None: tablename = _quote(schema) + '.' + tablename debug('tablename: %r', tablename) # sanitise field name...
def _todb_dbapi_mkcurs(table, mkcurs, tablename, schema=None, commit=True, truncate=False): # sanitise table name
tablename = _quote(tablename) if schema is not None: tablename = _quote(schema) + '.' + tablename debug('tablename: %r', tablename) # sanitise field names it = iter(table) hdr = next(it) flds = list(map(text_type, hdr)) colnames = [_quote(n) for n in flds] debug('column name...
insertcolnames = ', '.join(colnames) insertquery = SQL_INSERT_QUERY % (tablename, insertcolnames, placeholders) debug('insert data via query %r' % insertquery) cursor.executemany(insertquery, it) # finish up debug('close the cursor') cursor.close() if commit: debug('commit tran...
117
117
392
35
82
thatneat/petl
petl/io/db.py
Python
_todb_dbapi_mkcurs
_todb_dbapi_mkcurs
444
489
444
447
ddc3b15591c00c09d1f7dd5ed00f174edf9be6bd
bigcode/the-stack
train
54772380a1e717636d7b8764
train
function
def todb(table, dbo, tablename, schema=None, commit=True, create=False, drop=False, constraints=True, metadata=None, dialect=None, sample=1000): """ Load data into an existing database table via a DB-API 2.0 connection or cursor. Note that the database table will be truncated, i.e., al...
def todb(table, dbo, tablename, schema=None, commit=True, create=False, drop=False, constraints=True, metadata=None, dialect=None, sample=1000):
""" Load data into an existing database table via a DB-API 2.0 connection or cursor. Note that the database table will be truncated, i.e., all existing rows will be deleted prior to inserting the new data. E.g.:: >>> import petl as etl >>> table = [['foo', 'bar'], ... ...
= None # fields should be available now hdr = [d[0] for d in cursor.description] yield tuple(hdr) if first_row is None: raise StopIteration yield first_row for row in it: yield row # don't wrap, return whatever the database engine returns def _iter_sqlalchemy_engine(engine, q...
256
256
1,275
38
217
thatneat/petl
petl/io/db.py
Python
todb
todb
203
341
203
205
d48fb93fa5495fc7aa626b05ce8d35ebb07f65b0
bigcode/the-stack
train
356f250d09b71cecb85bf858
train
function
def _todb(table, dbo, tablename, schema=None, commit=True, truncate=False): # need to deal with polymorphic dbo argument # what sort of duck is it? # does it quack like a standard DB-API 2.0 connection? if _is_dbapi_connection(dbo): debug('assuming %r is standard DB-API 2.0 connection', dbo) ...
def _todb(table, dbo, tablename, schema=None, commit=True, truncate=False): # need to deal with polymorphic dbo argument # what sort of duck is it? # does it quack like a standard DB-API 2.0 connection?
if _is_dbapi_connection(dbo): debug('assuming %r is standard DB-API 2.0 connection', dbo) _todb_dbapi_connection(table, dbo, tablename, schema=schema, commit=commit, truncate=truncate) # does it quack like a standard DB-API 2.0 cursor? elif _is_dbapi_cursor(db...
commit) create_table(table, dbo, tablename, schema=schema, commit=commit, constraints=constraints, metadata=metadata, dialect=dialect, sample=sample) _todb(table, dbo, tablename, schema=schema, commit=commit, truncate=True) finally...
139
139
466
58
80
thatneat/petl
petl/io/db.py
Python
_todb
_todb
347
390
347
352
6f70b7f7cffceef2a74a328af6dbf7635c392bb1
bigcode/the-stack
train
9d55dbb473e14785e31b4150
train
function
def _iter_dbapi_cursor(cursor, query, *args, **kwargs): cursor.execute(query, *args, **kwargs) # fetch one row before iterating, to force population of cursor.description # which may be postponed if using server-side cursors it = iter(cursor) try: first_row = next(it) except StopIteratio...
def _iter_dbapi_cursor(cursor, query, *args, **kwargs):
cursor.execute(query, *args, **kwargs) # fetch one row before iterating, to force population of cursor.description # which may be postponed if using server-side cursors it = iter(cursor) try: first_row = next(it) except StopIteration: first_row = None # fields should be avail...
, query, *args, **kwargs): cursor = connection.cursor() try: for row in _iter_dbapi_cursor(cursor, query, *args, **kwargs): yield row finally: cursor.close() def _iter_dbapi_cursor(cursor, query, *args, **kwargs):
64
64
149
16
48
thatneat/petl
petl/io/db.py
Python
_iter_dbapi_cursor
_iter_dbapi_cursor
162
178
162
162
f6e01c4a79be2e2aa95b649a650ac969cf8d9b49
bigcode/the-stack
train
6c2f04c4847c76d5957eafa3
train
function
def _todb_sqlalchemy_engine(table, engine, tablename, schema=None, commit=True, truncate=False): _todb_sqlalchemy_connection(table, engine.contextual_connect(), tablename, schema=schema, commit=commit, truncate=truncate)
def _todb_sqlalchemy_engine(table, engine, tablename, schema=None, commit=True, truncate=False):
_todb_sqlalchemy_connection(table, engine.contextual_connect(), tablename, schema=schema, commit=commit, truncate=truncate)
cursor.executemany(insertquery, it) # N.B., don't close the cursor, leave that to the application if commit: debug('commit transaction') connection.commit() def _todb_sqlalchemy_engine(table, engine, tablename, schema=None, commit=True, truncate=False):
64
64
54
24
40
thatneat/petl
petl/io/db.py
Python
_todb_sqlalchemy_engine
_todb_sqlalchemy_engine
537
541
537
539
6a197e2cc4e478ad3a08fb535a2c963d3776e4d1
bigcode/the-stack
train
6adb3b8c08fccaf2fb426826
train
function
def fromdb(dbo, query, *args, **kwargs): """Provides access to data from any DB-API 2.0 connection via a given query. E.g., using :mod:`sqlite3`:: >>> import petl as etl >>> import sqlite3 >>> connection = sqlite3.connect('example.db') >>> table = etl.fromdb(connection, 'SELECT ...
def fromdb(dbo, query, *args, **kwargs):
"""Provides access to data from any DB-API 2.0 connection via a given query. E.g., using :mod:`sqlite3`:: >>> import petl as etl >>> import sqlite3 >>> connection = sqlite3.connect('example.db') >>> table = etl.fromdb(connection, 'SELECT * FROM example') E.g., using :mod:`p...
# -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, division # standard library dependencies import logging from petl.compat import next, text_type, string_types # internal dependencies from petl.errors import ArgumentError from petl.util.base import Table from petl.io.db_utils import _i...
155
199
664
14
140
thatneat/petl
petl/io/db.py
Python
fromdb
fromdb
24
89
24
24
2ebec0aefabf051393ec71744ee0b46b3f8345fe
bigcode/the-stack
train
a3a1da2fb96db14da1847827
train
function
def _iter_sqlalchemy_session(session, query, *args, **kwargs): results = session.execute(query, *args, **kwargs) hdr = results.keys() yield tuple(hdr) for row in results: yield row
def _iter_sqlalchemy_session(session, query, *args, **kwargs):
results = session.execute(query, *args, **kwargs) hdr = results.keys() yield tuple(hdr) for row in results: yield row
**kwargs): debug('connection: %r', connection) results = connection.execute(query, *args, **kwargs) hdr = results.keys() yield tuple(hdr) for row in results: yield row def _iter_sqlalchemy_session(session, query, *args, **kwargs):
64
64
51
16
47
thatneat/petl
petl/io/db.py
Python
_iter_sqlalchemy_session
_iter_sqlalchemy_session
195
200
195
195
c3cf1574486eb5bb10b5239b77916b47646042f5
bigcode/the-stack
train
78443c14245e8863be66b68d
train
class
class DbView(Table): def __init__(self, dbo, query, *args, **kwargs): self.dbo = dbo self.query = query self.args = args self.kwargs = kwargs def __iter__(self): # does it quack like a standard DB-API 2.0 connection? if _is_dbapi_connection(self.dbo): ...
class DbView(Table):
def __init__(self, dbo, query, *args, **kwargs): self.dbo = dbo self.query = query self.args = args self.kwargs = kwargs def __iter__(self): # does it quack like a standard DB-API 2.0 connection? if _is_dbapi_connection(self.dbo): debug('assuming %r ...
>>> table = etl.fromdb(lambda: connection.cursor(name='arbitrary'), ... 'SELECT * FROM example') For more information on server-side cursors see the following links: * http://initd.org/psycopg/docs/usage.html#server-side-cursors * http://mysql-python.sourceforge.net/MyS...
133
133
446
5
128
thatneat/petl
petl/io/db.py
Python
DbView
DbView
92
141
92
93
48cc353c7ed2a65e35de905c66542dcf2f346a79
bigcode/the-stack
train
303b0b6a9ced56e576824659
train
function
@require_permission('perm_add') def linklist_manage(request, item_container): """ Pflegemodus des Ordners """ user_perms = UserEditPerms(request.user.username, request.path) add_ons = {} add_ons[0] = [ { 'url' : get_site_url(item_container, 'index.html/add/linkitem/'), 'info': _(u'Neuer Verw...
@require_permission('perm_add') def linklist_manage(request, item_container):
""" Pflegemodus des Ordners """ user_perms = UserEditPerms(request.user.username, request.path) add_ons = {} add_ons[0] = [ { 'url' : get_site_url(item_container, 'index.html/add/linkitem/'), 'info': _(u'Neuer Verweis')}, { 'url' : get_site_url(item_container, ...
auf do_manage """ from django.utils.translation import ugettext as _ from dms.queries import get_site_url from dms.roles import require_permission from dms.roles import UserEditPerms from dms.folder.views_manage import do_manage from dms_ext.extension import * # dms-Funktio...
95
95
318
16
79
shagun30/djambala-2
linklist/views_manage.py
Python
linklist_manage
linklist_manage
29
52
29
30
82e07017999dd1e7c793872e7f073ac6cd037801
bigcode/the-stack
train
ac982400f7b6bd7dc5b6e873
train
class
class SourceAdapter(ABC): @abstractmethod def get_picture(self): pass
class SourceAdapter(ABC): @abstractmethod
def get_picture(self): pass
__author__ = 'ipetrash' # SOURCE: Design Patterns: Adapter - Адаптер # SOURCE: https://ru.wikipedia.org/wiki/Адаптер_(шаблон_проектирования)#Python from abc import ABC, abstractmethod class SourceAdapter(ABC): @abstractmethod
64
64
20
11
52
DazEB2/SimplePyScripts
design_patterns__examples/Adapter/example__using_composition.py
Python
SourceAdapter
SourceAdapter
14
17
14
15
b7ccae174a2d3ad06069a148d870c6c621c154b6
bigcode/the-stack
train
55518127dd29ee35c47bba42
train
class
class TV: def __init__(self, source: SourceAdapter): self.source = source def show_picture(self): return self.source.get_picture()
class TV:
def __init__(self, source: SourceAdapter): self.source = source def show_picture(self): return self.source.get_picture()
def get_picture(self): return self.game_console.create_game_picture() class SourceAntennaAdapter(SourceAdapter): def __init__(self, antenna: Antenna): self.antenna = antenna def get_picture(self): return self.antenna.create_wave_picture() class TV:
64
64
34
3
61
DazEB2/SimplePyScripts
design_patterns__examples/Adapter/example__using_composition.py
Python
TV
TV
46
51
46
46
2bd733f7a06c82dfbbbd4987ebf627d65cee5233
bigcode/the-stack
train
4dd50461ee20af542d6829ec
train
class
class SourceGameConsoleAdapter(SourceAdapter): def __init__(self, game_console: GameConsole): self.game_console = game_console def get_picture(self): return self.game_console.create_game_picture()
class SourceGameConsoleAdapter(SourceAdapter):
def __init__(self, game_console: GameConsole): self.game_console = game_console def get_picture(self): return self.game_console.create_game_picture()
class SourceAdapter(ABC): @abstractmethod def get_picture(self): pass class GameConsole: def create_game_picture(self): return 'picture from console' class Antenna: def create_wave_picture(self): return 'picture from wave' class SourceGameConsoleAdapter(SourceAdapter):
64
64
44
8
56
DazEB2/SimplePyScripts
design_patterns__examples/Adapter/example__using_composition.py
Python
SourceGameConsoleAdapter
SourceGameConsoleAdapter
30
35
30
30
6e5d419c6731996076ebe07b2330bbb064c21898
bigcode/the-stack
train
aebb958cecb2d42558d699d6
train
class
class SourceAntennaAdapter(SourceAdapter): def __init__(self, antenna: Antenna): self.antenna = antenna def get_picture(self): return self.antenna.create_wave_picture()
class SourceAntennaAdapter(SourceAdapter):
def __init__(self, antenna: Antenna): self.antenna = antenna def get_picture(self): return self.antenna.create_wave_picture()
_wave_picture(self): return 'picture from wave' class SourceGameConsoleAdapter(SourceAdapter): def __init__(self, game_console: GameConsole): self.game_console = game_console def get_picture(self): return self.game_console.create_game_picture() class SourceAntennaAdapter(SourceAdapter...
64
64
45
9
55
DazEB2/SimplePyScripts
design_patterns__examples/Adapter/example__using_composition.py
Python
SourceAntennaAdapter
SourceAntennaAdapter
38
43
38
38
9409a969eb95261bd986f121cb40d4361bb95654
bigcode/the-stack
train
40abf416aa208fdf84b3a836
train
class
class GameConsole: def create_game_picture(self): return 'picture from console'
class GameConsole:
def create_game_picture(self): return 'picture from console'
Patterns: Adapter - Адаптер # SOURCE: https://ru.wikipedia.org/wiki/Адаптер_(шаблон_проектирования)#Python from abc import ABC, abstractmethod class SourceAdapter(ABC): @abstractmethod def get_picture(self): pass class GameConsole:
64
64
18
4
59
DazEB2/SimplePyScripts
design_patterns__examples/Adapter/example__using_composition.py
Python
GameConsole
GameConsole
20
22
20
20
cc81a83e8b5f6f161b50ffe771301b10bdd49b0a
bigcode/the-stack
train
f0350a0834f500b60bce616c
train
class
class Antenna: def create_wave_picture(self): return 'picture from wave'
class Antenna:
def create_wave_picture(self): return 'picture from wave'
Адаптер_(шаблон_проектирования)#Python from abc import ABC, abstractmethod class SourceAdapter(ABC): @abstractmethod def get_picture(self): pass class GameConsole: def create_game_picture(self): return 'picture from console' class Antenna:
64
64
18
4
60
DazEB2/SimplePyScripts
design_patterns__examples/Adapter/example__using_composition.py
Python
Antenna
Antenna
25
27
25
25
fab8ca647ac5705ec61aac1e6249ebcf9984e3ce
bigcode/the-stack
train
69432f89642c30b24284b0ba
train
function
def test_pybing(): #================================= # Detect Initialization #================================= # Create detector detector = BING_Detector() test_path = utool.grab_zipped_url(TEST_DATA_DETECT_URL, appname='utool') model_path = utool.grab_zipped_url(TEST_DATA_MODEL_URL, app...
def test_pybing(): #================================= # Detect Initialization #================================= # Create detector
detector = BING_Detector() test_path = utool.grab_zipped_url(TEST_DATA_DETECT_URL, appname='utool') model_path = utool.grab_zipped_url(TEST_DATA_MODEL_URL, appname='pybing') #================================= # Detect using Random Forest #================================= model_path = join...
import BING_Detector import utool TEST_DATA_DETECT_URL = 'https://lev.cs.rpi.edu/public/data/testdata_bing.zip' TEST_DATA_MODEL_URL = 'https://lev.cs.rpi.edu/public/models/bing.zip' def test_pybing(): #================================= # Detect Initialization #================================= # Cr...
77
77
259
24
53
bluemellophone/pybing
test_pybing.py
Python
test_pybing
test_pybing
12
42
12
17
20e5d10342d04a6c054c3252870affdde4dca912
bigcode/the-stack
train
c9f005de7df3207aa9cd3019
train
function
@click.command() @click.option('--url', default='http://localhost:7200/repositories/FIBO_RL', help='URL of SPARQL endpoint containing FIBO') def load_corpus(url): logging.info('SPARQL endpoint: %s' % url) rep = RemoteEndpoint(url) corpusdf = rep.select(''' select ?iri ?text where...
@click.command() @click.option('--url', default='http://localhost:7200/repositories/FIBO_RL', help='URL of SPARQL endpoint containing FIBO') def load_corpus(url):
logging.info('SPARQL endpoint: %s' % url) rep = RemoteEndpoint(url) corpusdf = rep.select(''' select ?iri ?text where { ?iri ?p ?o. filter(isiri(?iri)) filter(isliteral(?o)) bind(lcase(str(?o)) as ?text) } ''') logging.info('Query complete %d results' % len(corpusdf)) return corpusdf
=logging.INFO, datefmt='%Y-%m-%d %H:%M:%S') @click.command() @click.option('--url', default='http://localhost:7200/repositories/FIBO_RL', help='URL of SPARQL endpoint containing FIBO') def load_corpus(url):
64
64
138
45
19
kptyson/rdf_topic_modeling
create_fibo_topic_map.py
Python
load_corpus
load_corpus
10
26
10
14
294c07c0db1fe00482ace63f68529c236a106325
bigcode/the-stack
train
c5611d2f942fba68bf829241
train
function
def process_corpus(df): pass
def process_corpus(df):
pass
where { ?iri ?p ?o. filter(isiri(?iri)) filter(isliteral(?o)) bind(lcase(str(?o)) as ?text) } ''') logging.info('Query complete %d results' % len(corpusdf)) return corpusdf def process_corpus(df):
64
64
9
6
57
kptyson/rdf_topic_modeling
create_fibo_topic_map.py
Python
process_corpus
process_corpus
28
29
28
28
1330cc2723435028c3e912d0ae9c4f74e3127b1f
bigcode/the-stack
train
8bfcf5f3ac7dedb26438928f
train
class
class CommonTsetlinMachine(): def __init__(self, number_of_clauses, T, s, clause_drop_p=0.0, feature_drop_p=0.0, number_of_gpus=1, q=1.0, boost_true_positive_feedback=1, number_of_state_bits=8, append_negated=True, grid=(16*13,1,1), block=(128,1,1)): self.number_of_gpus = np.minimum(cuda.Device.count(), number_of_gp...
class CommonTsetlinMachine():
def __init__(self, number_of_clauses, T, s, clause_drop_p=0.0, feature_drop_p=0.0, number_of_gpus=1, q=1.0, boost_true_positive_feedback=1, number_of_state_bits=8, append_negated=True, grid=(16*13,1,1), block=(128,1,1)): self.number_of_gpus = np.minimum(cuda.Device.count(), number_of_gpus) self.number_of_clauses ...
import numpy as np import PyTsetlinMachineCUDA.kernels as kernels import pycuda.curandom as curandom import pycuda.driver as cuda from pycuda.compiler import SourceModule from time import time cuda.init() class GPU(): None class CommonTsetlinMachine():
62
256
4,846
7
54
Anonymous-2491/Drop-Clause-Interpretable-TM
PyTsetlinMachineCUDA/tm.py
Python
CommonTsetlinMachine
CommonTsetlinMachine
16
445
16
16
e5b6e2f4ff9fb59a85b98703a235222278cf98f6
bigcode/the-stack
train
448e63b54b3a348866172965
train
class
class MultiClassTsetlinMachine(CommonTsetlinMachine): def __init__(self, number_of_clauses, T, s, clause_drop_p=0.0, feature_drop_p=0.01, number_of_gpus=1, boost_true_positive_feedback=1, number_of_state_bits=8, append_negated=True, grid=(16*13,1,1), block=(128,1,1)): super().__init__(number_of_clauses, T, s, clause...
class MultiClassTsetlinMachine(CommonTsetlinMachine):
def __init__(self, number_of_clauses, T, s, clause_drop_p=0.0, feature_drop_p=0.01, number_of_gpus=1, boost_true_positive_feedback=1, number_of_state_bits=8, append_negated=True, grid=(16*13,1,1), block=(128,1,1)): super().__init__(number_of_clauses, T, s, clause_drop_p=clause_drop_p, feature_drop_p=feature_drop_p, ...
_Y = np.empty((Y.shape[0], self.number_of_classes), dtype = np.int32) for i in range(self.number_of_classes): encoded_Y[:,i] = np.where(Y == i, self.T, -self.T) self._fit(X, encoded_Y, epochs=epochs, incremental=incremental) def score(self, X): return self._score(X) def predict(self, X): return np.argma...
114
114
381
13
101
Anonymous-2491/Drop-Clause-Interpretable-TM
PyTsetlinMachineCUDA/tm.py
Python
MultiClassTsetlinMachine
MultiClassTsetlinMachine
475
502
475
475
f16472e466a4097a40231abbc68850fba42e6a79
bigcode/the-stack
train
4896ee0a7b97b67ed4e5be50
train
class
class RegressionTsetlinMachine(CommonTsetlinMachine): def __init__(self, number_of_clauses, T, s, number_of_gpus=1, boost_true_positive_feedback=1, number_of_state_bits=8, append_negated=True, grid=(16*13,1,1), block=(128,1,1)): super().__init__(number_of_clauses, T, s, clause_drop_p=clause_drop_p, feature_drop_p=fe...
class RegressionTsetlinMachine(CommonTsetlinMachine):
def __init__(self, number_of_clauses, T, s, number_of_gpus=1, boost_true_positive_feedback=1, number_of_state_bits=8, append_negated=True, grid=(16*13,1,1), block=(128,1,1)): super().__init__(number_of_clauses, T, s, clause_drop_p=clause_drop_p, feature_drop_p=feature_drop_p, number_of_gpus=number_of_gpus, boost_tru...
_Y = np.where(Y == 1, self.T, -self.T).astype(np.int32) self._fit(X, encoded_Y, epochs = epochs, incremental = incremental) return def score(self, X): X = X.reshape(X.shape[0], X.shape[1], 1) return self._score(X)[0,:] def predict(self, X): return self.score(X) >= 0 class RegressionTsetlinMachine(Common...
103
103
346
12
90
Anonymous-2491/Drop-Clause-Interpretable-TM
PyTsetlinMachineCUDA/tm.py
Python
RegressionTsetlinMachine
RegressionTsetlinMachine
531
554
531
531
8ddd3e76e4e26eadbd36c3bc9d780a068af9f041
bigcode/the-stack
train
8fe7facb7c70e9ffa09ccdb5
train
class
class GPU(): None
class GPU():
None
import numpy as np import PyTsetlinMachineCUDA.kernels as kernels import pycuda.curandom as curandom import pycuda.driver as cuda from pycuda.compiler import SourceModule from time import time cuda.init() class GPU():
52
64
6
3
49
Anonymous-2491/Drop-Clause-Interpretable-TM
PyTsetlinMachineCUDA/tm.py
Python
GPU
GPU
13
14
13
13
a88800db8f63d6f6cac851b40c71c99850545bad
bigcode/the-stack
train
62ec737297f9e4165af5089e
train
class
class TsetlinMachine(CommonTsetlinMachine): def __init__(self, number_of_clauses, T, s, clause_drop_p=0.0, feature_drop_p=0.0, number_of_gpus=1, boost_true_positive_feedback=1, number_of_state_bits=8, append_negated=True, grid=(16*13,1,1), block=(128,1,1)): super().__init__(number_of_clauses, T, s, clause_drop_p=cla...
class TsetlinMachine(CommonTsetlinMachine):
def __init__(self, number_of_clauses, T, s, clause_drop_p=0.0, feature_drop_p=0.0, number_of_gpus=1, boost_true_positive_feedback=1, number_of_state_bits=8, append_negated=True, grid=(16*13,1,1), block=(128,1,1)): super().__init__(number_of_clauses, T, s, clause_drop_p=clause_drop_p, feature_drop_p=feature_drop_p, n...
_classes): encoded_Y[:,i] = np.where(Y == i, self.T, -self.T) self._fit(X, encoded_Y, epochs = epochs, incremental = incremental) return def score(self, X): X = X.reshape(X.shape[0], X.shape[1], 1) return self._score(X) def predict(self, X): return np.argmax(self.score(X), axis=0) class TsetlinMachin...
103
103
344
11
92
Anonymous-2491/Drop-Clause-Interpretable-TM
PyTsetlinMachineCUDA/tm.py
Python
TsetlinMachine
TsetlinMachine
504
529
504
504
aeb21fb52fb5407b2d9f71a5fe23bbbd7bcabce3
bigcode/the-stack
train
5805927e89330862a2f7c709
train
class
class MultiClassConvolutionalTsetlinMachine2D(CommonTsetlinMachine): """ This class ... """ def __init__(self, number_of_clauses, T, s, patch_dim, clause_drop_p=0.0, feature_drop_p=0.0, number_of_gpus=1, q=1.0, boost_true_positive_feedback=1, number_of_state_bits=8, append_negated=True, grid=(16*13,1,1), block=(1...
class MultiClassConvolutionalTsetlinMachine2D(CommonTsetlinMachine):
""" This class ... """ def __init__(self, number_of_clauses, T, s, patch_dim, clause_drop_p=0.0, feature_drop_p=0.0, number_of_gpus=1, q=1.0, boost_true_positive_feedback=1, number_of_state_bits=8, append_negated=True, grid=(16*13,1,1), block=(128,1,1)): super().__init__(number_of_clauses, T, s, clause_drop_p=c...
gpu = self.gpus[i] gpu.context.push() gpu.context.synchronize() cuda.memcpy_dtoh(local_class_sum, self.class_sum_gpus[i]) global_class_sum += local_class_sum gpu.context.pop() class_sum_multi = np.clip(global_class_sum.reshape((self.number_of_classes, number_of_examples)), -self.T, self.T) retur...
108
108
360
18
89
Anonymous-2491/Drop-Clause-Interpretable-TM
PyTsetlinMachineCUDA/tm.py
Python
MultiClassConvolutionalTsetlinMachine2D
MultiClassConvolutionalTsetlinMachine2D
447
473
447
447
aa5d7143ad4081381a03d77ff9c3db14aa89dd52
bigcode/the-stack
train
238e0e35d16cd6f77f1c40f5
train
function
def evidence_macro_precision(instance, max_evidence=None): this_precision = 0.0 this_precision_hits = 0.0 if instance["label"].upper() != "NOT ENOUGH INFO": all_evi = [[e[0], e[1]] for eg in instance["evidence"] for e in eg if e[1] is not None] predicted_evidence = instance["predicted_ev...
def evidence_macro_precision(instance, max_evidence=None):
this_precision = 0.0 this_precision_hits = 0.0 if instance["label"].upper() != "NOT ENOUGH INFO": all_evi = [[e[0], e[1]] for eg in instance["evidence"] for e in eg if e[1] is not None] predicted_evidence = instance["predicted_evidence"] if max_evidence is None else \ ...
_sentences]): return True #If the class is NEI, we don't score the evidence retrieval component elif instance["label"].upper() == "NOT ENOUGH INFO" and is_correct_label(instance): return True return False def evidence_macro_precision(instance, max_evidence=None):
64
64
190
11
52
UKPLab/conll2019-snopes-experiments
src/retrieval/score/score.py
Python
evidence_macro_precision
evidence_macro_precision
54
71
54
54
927e4478aca0ac1c005dff90c3955cc6d65464af
bigcode/the-stack
train
a52a4288928956b2a3e6265b
train
function
def evidence_macro_recall(instance, max_evidence=None): # We only want to score F1/Precision/Recall of recalled evidence for NEI claims if instance["label"].upper() != "NOT ENOUGH INFO": # If there's no evidence to predict, return 1 if len(instance["evidence"]) == 0 or all([len(eg) == 0 for eg i...
def evidence_macro_recall(instance, max_evidence=None): # We only want to score F1/Precision/Recall of recalled evidence for NEI claims
if instance["label"].upper() != "NOT ENOUGH INFO": # If there's no evidence to predict, return 1 if len(instance["evidence"]) == 0 or all([len(eg) == 0 for eg in instance]): return 1.0, 1.0 predicted_evidence = instance["predicted_evidence"] if max_evidence is None else \ ...
_precision / len(all_evi_lst)) if this_precision_hits > 0 else 1.0, 1.0 return 0.0, 0.0 def evidence_macro_recall(instance, max_evidence=None): # We only want to score F1/Precision/Recall of recalled evidence for NEI claims
71
71
237
33
37
UKPLab/conll2019-snopes-experiments
src/retrieval/score/score.py
Python
evidence_macro_recall
evidence_macro_recall
98
114
98
99
cab37d63b80df320735d16dec344c7f6058c3ca7
bigcode/the-stack
train
089d74379e8d4eb46f9ff8d4
train
function
def fever_score(predictions,actual=None, max_pages=5, max_evidence=5): correct = 0 strict = 0 macro_precision = 0 macro_precision_hits = 0 macro_recall = 0 macro_recall_hits = 0 refutes_hits = 0 supports_hits = 0 doc_recall = 0 doc_recall_hits = 0 for idx,instance in enu...
def fever_score(predictions,actual=None, max_pages=5, max_evidence=5):
correct = 0 strict = 0 macro_precision = 0 macro_precision_hits = 0 macro_recall = 0 macro_recall_hits = 0 refutes_hits = 0 supports_hits = 0 doc_recall = 0 doc_recall_hits = 0 for idx,instance in enumerate(predictions): assert 'predicted_evidence' in instance.ke...
]): return 1.0,1.0 return 0.0,1.0 return 0.0,0.0 # Micro is not used. This code is just included to demostrate our model of macro/micro def evidence_micro_precision(instance): this_precision = 0 this_precision_hits = 0 # We only want to score Macro F1/Precision/Recall of rec...
216
216
720
20
195
UKPLab/conll2019-snopes-experiments
src/retrieval/score/score.py
Python
fever_score
fever_score
198
270
198
198
43455e4a230f8c0c5c0d7c0bbbbb788c5b209f88
bigcode/the-stack
train
19de79a7012ecf70e57cb925
train
function
def evidence_micro_precision(instance): this_precision = 0 this_precision_hits = 0 # We only want to score Macro F1/Precision/Recall of recalled evidence for NEI claims if instance["label"].upper() != "NOT ENOUGH INFO": all_evi = [[e[0], e[1]] for eg in instance["evidence"] for e in eg if e[1] ...
def evidence_micro_precision(instance):
this_precision = 0 this_precision_hits = 0 # We only want to score Macro F1/Precision/Recall of recalled evidence for NEI claims if instance["label"].upper() != "NOT ENOUGH INFO": all_evi = [[e[0], e[1]] for eg in instance["evidence"] for e in eg if e[1] is not None] for prediction in ...
in documents]): return 1.0,1.0 return 0.0,1.0 return 0.0,0.0 # Micro is not used. This code is just included to demostrate our model of macro/micro def evidence_micro_precision(instance):
64
64
140
6
57
UKPLab/conll2019-snopes-experiments
src/retrieval/score/score.py
Python
evidence_micro_precision
evidence_micro_precision
182
195
182
182
66a774731b82fca001a058e937ba7201e1c4792c
bigcode/the-stack
train
52f0b77fc5967823e71916d5
train
function
def is_correct_label(instance): return instance["label"].upper() == instance["predicted_label"].upper()
def is_correct_label(instance):
return instance["label"].upper() == instance["predicted_label"].upper()
evidence must be a list of (page<string>,line<int>) lists" assert all(isinstance(prediction[1], int) for prediction in instance["predicted_evidence"]), \ "Predicted evidence must be a list of (page<string>,line<int>) lists" def is_correct_label(instance):
64
64
23
6
58
UKPLab/conll2019-snopes-experiments
src/retrieval/score/score.py
Python
is_correct_label
is_correct_label
23
24
23
23
1fd8f4e7165222bc482a8019e50fb03a8b802a3c
bigcode/the-stack
train
5010a8cdefbccfee2c2426ca
train
function
def evidence_macro_precision_2(instance, max_evidence=None): this_precision = 0.0 this_precision_hits = 0.0 if instance["label"].upper() != "NOT ENOUGH INFO": all_evi = [[e[0], e[1]] for eg in instance["evidence"] for e in eg if e[1] is not None] all_evi_set = set(tuple(x) for x in all_evi...
def evidence_macro_precision_2(instance, max_evidence=None):
this_precision = 0.0 this_precision_hits = 0.0 if instance["label"].upper() != "NOT ENOUGH INFO": all_evi = [[e[0], e[1]] for eg in instance["evidence"] for e in eg if e[1] is not None] all_evi_set = set(tuple(x) for x in all_evi) all_evi_lst = [list(x) for x in all_evi_set] ...
_evidence: if prediction in all_evi: this_precision += 1.0 this_precision_hits += 1.0 return (this_precision / this_precision_hits) if this_precision_hits > 0 else 1.0, 1.0 return 0.0, 0.0 def evidence_macro_precision_2(instance, max_evidence=None):
83
83
277
13
69
UKPLab/conll2019-snopes-experiments
src/retrieval/score/score.py
Python
evidence_macro_precision_2
evidence_macro_precision_2
74
95
74
74
e8a855c5442d74ddab8f6ed924563dd7187a2fac
bigcode/the-stack
train
0db04d287141311c9e70604f
train
function
def check_predicted_evidence_format(instance): if 'predicted_evidence' in instance.keys() and len(instance['predicted_evidence']): assert all(isinstance(prediction, list) for prediction in instance["predicted_evidence"]), \ "Predicted evidence must be a list of (page,line) lis...
def check_predicted_evidence_format(instance):
if 'predicted_evidence' in instance.keys() and len(instance['predicted_evidence']): assert all(isinstance(prediction, list) for prediction in instance["predicted_evidence"]), \ "Predicted evidence must be a list of (page,line) lists" assert all(len(prediction) == 2 ...
import six from drqa.retriever.utils import normalize def check_predicted_evidence_format(instance):
23
64
195
9
13
UKPLab/conll2019-snopes-experiments
src/retrieval/score/score.py
Python
check_predicted_evidence_format
check_predicted_evidence_format
4
20
4
4
0abe3a267f0c681bc0bc2847b06d4e4f96ecc946
bigcode/the-stack
train
6d54fcdfb28c1b408fb4fcdf
train
function
def is_strictly_correct(instance, max_evidence=None): #Strict evidence matching is only for NEI class check_predicted_evidence_format(instance) if instance["label"].upper() != "NOT ENOUGH INFO" and is_correct_label(instance): assert 'predicted_evidence' in instance, "Predicted evidence must be prov...
def is_strictly_correct(instance, max_evidence=None): #Strict evidence matching is only for NEI class
check_predicted_evidence_format(instance) if instance["label"].upper() != "NOT ENOUGH INFO" and is_correct_label(instance): assert 'predicted_evidence' in instance, "Predicted evidence must be provided for strict scoring" if max_evidence is not None: instance["predicted_evidence"] ...
int) for prediction in instance["predicted_evidence"]), \ "Predicted evidence must be a list of (page<string>,line<int>) lists" def is_correct_label(instance): return instance["label"].upper() == instance["predicted_label"].upper() def is_strictly_correct(instance, max_evidence=Non...
81
81
270
25
56
UKPLab/conll2019-snopes-experiments
src/retrieval/score/score.py
Python
is_strictly_correct
is_strictly_correct
27
51
27
28
cb0b2f65d4f872a4ebb54b59114c3413c2552769
bigcode/the-stack
train
71f4fc299da33d6835b98d4f
train
function
def doc_macro_recall(instance,max_pages=None): if instance["label"].upper() != "NOT ENOUGH INFO": #If there's no evidence to predict,return 1 if len(instance["evidence"]) == 0 or all([len(eg) == 0 for eg in instance]): return 1.0, 1.0 # print(instance) predicted_pages ...
def doc_macro_recall(instance,max_pages=None):
if instance["label"].upper() != "NOT ENOUGH INFO": #If there's no evidence to predict,return 1 if len(instance["evidence"]) == 0 or all([len(eg) == 0 for eg in instance]): return 1.0, 1.0 # print(instance) predicted_pages = instance["predicted_pages"] if max_pages is No...
and len(evidences) < max_evidence: # len(evidences) # else: # max_evidence return 0.0, 1.0 return 0.0, 0.0 def doc_macro_recall(instance,max_pages=None):
64
64
195
10
53
UKPLab/conll2019-snopes-experiments
src/retrieval/score/score.py
Python
doc_macro_recall
doc_macro_recall
158
177
158
159
3822c3db0137e18cbf802bab47bc4a311af8c278
bigcode/the-stack
train
bc89da5a76cc03230f74b3b8
train
function
def evidence_macro_recall_2(instance, max_evidence=None): # We only want to score F1/Precision/Recall of recalled evidence for NEI claims if instance["label"].upper() != "NOT ENOUGH INFO": # If there's no evidence to predict, return 1 # if len(instance["evidence"]) == 0 or all([len(eg) == 0 for...
def evidence_macro_recall_2(instance, max_evidence=None): # We only want to score F1/Precision/Recall of recalled evidence for NEI claims
if instance["label"].upper() != "NOT ENOUGH INFO": # If there's no evidence to predict, return 1 # if len(instance["evidence"]) == 0 or all([len(eg) == 0 for eg in instance]): # return 1.0, 1.0 if len(instance["evidence"]) == 0 or instance["evidence"] == [[]]: ...
["predicted_evidence"][:max_evidence] for evidence_group in instance["evidence"]: evidence = [[normalize(e[0]), e[1]] for e in evidence_group] if all([[normalize(item[0]),item[1]] in predicted_evidence for item in evidence]): # We only want to score complete groups of ev...
151
151
506
35
115
UKPLab/conll2019-snopes-experiments
src/retrieval/score/score.py
Python
evidence_macro_recall_2
evidence_macro_recall_2
116
156
116
118
6692c94bb6b9e6abfc70d7815556b7f5e53f5ccf
bigcode/the-stack
train
fc3aac0c20a06dac5ea9b31f
train
class
class ExportDotTenTestCase(XmlReaderTestCase): """XML export version 0.10 tests.""" def test_pair(self): entries = self._get_entries('pair-0.10.xml', allrevisions=True) self.assertEqual(4, len(entries)) self.assertTrue(all(entry.username == 'Carlossuarez46' ...
class ExportDotTenTestCase(XmlReaderTestCase):
"""XML export version 0.10 tests.""" def test_pair(self): entries = self._get_entries('pair-0.10.xml', allrevisions=True) self.assertEqual(4, len(entries)) self.assertTrue(all(entry.username == 'Carlossuarez46' for entry in entries)) self.assertTrue(a...
None previous = self._compare(previous, '.xml', all_revisions) previous = self._compare(previous, '-utf16.xml', all_revisions) previous = self._compare(previous, '.xml.bz2', all_revisions) previous = self._compare(previous, '-utf16.xml.bz2', all_revisions) def test_XmlDump_compare_...
119
119
399
11
108
valhallasw/pywikibot-core
tests/xmlreader_tests.py
Python
ExportDotTenTestCase
ExportDotTenTestCase
87
123
87
88
9f61461fdc9f0b6a86bdd508040e3f43dc0c93d9
bigcode/the-stack
train
09d0bed9ddce425f1ed8ef85
train
class
class XmlReaderTestCase(TestCase): """XML Reader test cases.""" net = False def _get_entries(self, filename, **kwargs): entries = [r for r in xmlreader.XmlDump(os.path.join(_xml_data_dir, filename), **kwargs).parse()] return entries
class XmlReaderTestCase(TestCase):
"""XML Reader test cases.""" net = False def _get_entries(self, filename, **kwargs): entries = [r for r in xmlreader.XmlDump(os.path.join(_xml_data_dir, filename), **kwargs).parse()] return entries
40856d8c04353e3fee $' import os.path from pywikibot import xmlreader from tests import _data_dir from tests.aspects import unittest, TestCase _xml_data_dir = os.path.join(_data_dir, 'xml') class XmlReaderTestCase(TestCase):
64
64
66
8
56
valhallasw/pywikibot-core
tests/xmlreader_tests.py
Python
XmlReaderTestCase
XmlReaderTestCase
22
32
22
23
37f9ddf7a1d8457ddf10b807550f65139b7a7dcf
bigcode/the-stack
train
c8c09c0381b77b98d833f8da
train
class
class ExportDotThreeTestCase(XmlReaderTestCase): """XML export version 0.3 tests.""" def test_XmlDumpAllRevs(self): pages = self._get_entries('article-pear.xml', allrevisions=True) self.assertEqual(4, len(pages)) self.assertEqual(u"Automated conversion", pages[0].comment) self....
class ExportDotThreeTestCase(XmlReaderTestCase):
"""XML export version 0.3 tests.""" def test_XmlDumpAllRevs(self): pages = self._get_entries('article-pear.xml', allrevisions=True) self.assertEqual(4, len(pages)) self.assertEqual(u"Automated conversion", pages[0].comment) self.assertEqual(u"Pear", pages[0].title) self....
from __future__ import unicode_literals __version__ = '$Id: de2e86c12b99dbe77080cd40856d8c04353e3fee $' import os.path from pywikibot import xmlreader from tests import _data_dir from tests.aspects import unittest, TestCase _xml_data_dir = os.path.join(_data_dir, 'xml') class XmlReaderTestCase(TestCase): ""...
161
161
537
11
149
valhallasw/pywikibot-core
tests/xmlreader_tests.py
Python
ExportDotThreeTestCase
ExportDotThreeTestCase
35
84
35
36
27cad5e1c1fd2ac1c03ab2bcd35935f874a4bd20
bigcode/the-stack
train
cbfa35a93b65417c5aca56c5
train
class
class Migration(migrations.Migration): initial = True dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='Booking', fields=[ ('id', models.AutoField(auto_created=True, primar...
class Migration(migrations.Migration):
initial = True dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='Booking', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_nam...
# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-01-05 22:34 from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration):
65
110
369
7
57
alsanuz/room_booking_app
room_booking_project/room_booking/migrations/0001_initial.py
Python
Migration
Migration
10
49
10
11
c8cc7c57f863621c699bba4b6dc8662dc1c2debb
bigcode/the-stack
train
228f252755f3b51ce24deb91
train
function
def uint32_to_bytes(x: int) -> bytes: return x.to_bytes(4, byteorder='big', signed=False)
def uint32_to_bytes(x: int) -> bytes:
return x.to_bytes(4, byteorder='big', signed=False)
_bytes(x: int) -> bytes: return x.to_bytes(2, byteorder='big', signed=False) def uint24_to_bytes(x: int) -> bytes: return x.to_bytes(3, byteorder='big', signed=False) def uint32_to_bytes(x: int) -> bytes:
64
64
28
12
52
rtmigo/ksf_py
dmk/b_cryptoblobs/_10_byte_funcs.py
Python
uint32_to_bytes
uint32_to_bytes
68
69
68
68
40ff788c09f468edf160f01bdf7dae04a82dc66f
bigcode/the-stack
train
ffc7a3c0dc80a470de12d3de
train
function
def double_to_bytes(x: float) -> bytes: return struct.pack('>d', x)
def double_to_bytes(x: float) -> bytes:
return struct.pack('>d', x)
# SPDX-FileCopyrightText: (c) 2021 Artёm IG <github.com/rtmigo> # SPDX-License-Identifier: MIT import struct def double_to_bytes(x: float) -> bytes:
46
64
21
11
34
rtmigo/ksf_py
dmk/b_cryptoblobs/_10_byte_funcs.py
Python
double_to_bytes
double_to_bytes
8
9
8
8
a8f46c291ce40c39ee50383a129efaa0ea4dc97d
bigcode/the-stack
train
fb3434e1d0db7d3953bf0c1c
train
function
def uint24_to_bytes(x: int) -> bytes: return x.to_bytes(3, byteorder='big', signed=False)
def uint24_to_bytes(x: int) -> bytes:
return x.to_bytes(3, byteorder='big', signed=False)
) -> int: if len(data) != 1: raise ValueError return data[0] def uint16_to_bytes(x: int) -> bytes: return x.to_bytes(2, byteorder='big', signed=False) def uint24_to_bytes(x: int) -> bytes:
64
64
28
12
52
rtmigo/ksf_py
dmk/b_cryptoblobs/_10_byte_funcs.py
Python
uint24_to_bytes
uint24_to_bytes
64
65
64
64
fa980d4f8b74726df1dc2d3621184bd48bb8edbc
bigcode/the-stack
train
bca6f02ca1e9d4d186de1de5
train
function
def uint48_to_bytes(x: int) -> bytes: return x.to_bytes(6, byteorder='big', signed=False)
def uint48_to_bytes(x: int) -> bytes:
return x.to_bytes(6, byteorder='big', signed=False)
_bytes(x: int) -> bytes: return x.to_bytes(3, byteorder='big', signed=False) def uint32_to_bytes(x: int) -> bytes: return x.to_bytes(4, byteorder='big', signed=False) def uint48_to_bytes(x: int) -> bytes:
64
64
28
12
52
rtmigo/ksf_py
dmk/b_cryptoblobs/_10_byte_funcs.py
Python
uint48_to_bytes
uint48_to_bytes
72
73
72
72
765e58cc81b1e1427662ad8fdcbcf155bafd9dff
bigcode/the-stack
train
83332381fe952c02ba50a017
train
function
def bytes_to_uint8(data: bytes) -> int: if len(data) != 1: raise ValueError return data[0]
def bytes_to_uint8(data: bytes) -> int:
if len(data) != 1: raise ValueError return data[0]
return int.from_bytes(data, byteorder='big', signed=True) def uint8_to_bytes(x: int) -> bytes: if not 0 <= x <= 0xFF: raise OverflowError return bytes((x,)) def bytes_to_uint8(data: bytes) -> int:
63
64
32
12
52
rtmigo/ksf_py
dmk/b_cryptoblobs/_10_byte_funcs.py
Python
bytes_to_uint8
bytes_to_uint8
54
57
54
54
12292626f7aea0512eaa0008c8d85659bb323a09
bigcode/the-stack
train
56f60f8602afc96684082700
train
function
def bytes_to_double(b: bytes) -> float: result = struct.unpack('>d', b) # print(result) return result[0]
def bytes_to_double(b: bytes) -> float:
result = struct.unpack('>d', b) # print(result) return result[0]
FileCopyrightText: (c) 2021 Artёm IG <github.com/rtmigo> # SPDX-License-Identifier: MIT import struct def double_to_bytes(x: float) -> bytes: return struct.pack('>d', x) def bytes_to_double(b: bytes) -> float:
64
64
33
11
53
rtmigo/ksf_py
dmk/b_cryptoblobs/_10_byte_funcs.py
Python
bytes_to_double
bytes_to_double
12
15
12
12
087e2d414e65b2636dea58eebefe6a77fdf4dc86
bigcode/the-stack
train
a8b89c87f4eaede2a526242b
train
function
def bytes_to_int64(data: bytes) -> int: if len(data) != 8: raise ValueError return int.from_bytes(data, byteorder='big', signed=True)
def bytes_to_int64(data: bytes) -> int:
if len(data) != 8: raise ValueError return int.from_bytes(data, byteorder='big', signed=True)
_bytes(data, byteorder='big', signed=False) def bytes_to_uint48(data: bytes) -> int: if len(data) != 6: raise ValueError return int.from_bytes(data, byteorder='big', signed=False) def bytes_to_int64(data: bytes) -> int:
64
64
41
12
52
rtmigo/ksf_py
dmk/b_cryptoblobs/_10_byte_funcs.py
Python
bytes_to_int64
bytes_to_int64
42
45
42
42
a1edf6cb3f4b52eca93ca0924b92846056274f53
bigcode/the-stack
train
49e49a8fb3d7e29a14be3d8d
train
function
def bytes_to_uint16(data: bytes) -> int: if len(data) != 2: raise ValueError return int.from_bytes(data, byteorder='big', signed=False)
def bytes_to_uint16(data: bytes) -> int:
if len(data) != 2: raise ValueError return int.from_bytes(data, byteorder='big', signed=False)
# print(result) return result[0] def bytes_to_uint32(data: bytes) -> int: if len(data) != 4: raise ValueError return int.from_bytes(data, byteorder='big', signed=False) def bytes_to_uint16(data: bytes) -> int:
64
64
41
12
52
rtmigo/ksf_py
dmk/b_cryptoblobs/_10_byte_funcs.py
Python
bytes_to_uint16
bytes_to_uint16
24
27
24
24
57ab52f9304c5b8fb17383044488365c3d02bebf
bigcode/the-stack
train
56da72d510aba4528e88fae3
train
function
def bytes_to_uint48(data: bytes) -> int: if len(data) != 6: raise ValueError return int.from_bytes(data, byteorder='big', signed=False)
def bytes_to_uint48(data: bytes) -> int:
if len(data) != 6: raise ValueError return int.from_bytes(data, byteorder='big', signed=False)
_bytes(data, byteorder='big', signed=False) def bytes_to_uint24(data: bytes) -> int: if len(data) != 3: raise ValueError return int.from_bytes(data, byteorder='big', signed=False) def bytes_to_uint48(data: bytes) -> int:
64
64
41
12
52
rtmigo/ksf_py
dmk/b_cryptoblobs/_10_byte_funcs.py
Python
bytes_to_uint48
bytes_to_uint48
35
38
35
35
706b3fa7a2576108a7c120e07a7dce20bc767c71
bigcode/the-stack
train
27fc2ef218dcd73297c809ca
train
function
def bytes_to_uint24(data: bytes) -> int: if len(data) != 3: raise ValueError return int.from_bytes(data, byteorder='big', signed=False)
def bytes_to_uint24(data: bytes) -> int:
if len(data) != 3: raise ValueError return int.from_bytes(data, byteorder='big', signed=False)
_bytes(data, byteorder='big', signed=False) def bytes_to_uint16(data: bytes) -> int: if len(data) != 2: raise ValueError return int.from_bytes(data, byteorder='big', signed=False) def bytes_to_uint24(data: bytes) -> int:
64
64
41
12
52
rtmigo/ksf_py
dmk/b_cryptoblobs/_10_byte_funcs.py
Python
bytes_to_uint24
bytes_to_uint24
30
33
30
30
25f7afb0f671e7da9b55204d4fb0726ceab3b88a
bigcode/the-stack
train
508fe48e9c83929f726dbd76
train
function
def int64_to_bytes(x: int) -> bytes: return x.to_bytes(8, byteorder='big', signed=True)
def int64_to_bytes(x: int) -> bytes:
return x.to_bytes(8, byteorder='big', signed=True)
_bytes(x: int) -> bytes: return x.to_bytes(4, byteorder='big', signed=False) def uint48_to_bytes(x: int) -> bytes: return x.to_bytes(6, byteorder='big', signed=False) def int64_to_bytes(x: int) -> bytes:
64
64
28
12
52
rtmigo/ksf_py
dmk/b_cryptoblobs/_10_byte_funcs.py
Python
int64_to_bytes
int64_to_bytes
76
77
76
76
95654adb26d89b2585c1fbedd1b1f7ab0ee01ae5
bigcode/the-stack
train
2f875433a28e662f08da3a36
train
function
def uint16_to_bytes(x: int) -> bytes: return x.to_bytes(2, byteorder='big', signed=False)
def uint16_to_bytes(x: int) -> bytes:
return x.to_bytes(2, byteorder='big', signed=False)
<= x <= 0xFF: raise OverflowError return bytes((x,)) def bytes_to_uint8(data: bytes) -> int: if len(data) != 1: raise ValueError return data[0] def uint16_to_bytes(x: int) -> bytes:
64
64
28
12
52
rtmigo/ksf_py
dmk/b_cryptoblobs/_10_byte_funcs.py
Python
uint16_to_bytes
uint16_to_bytes
60
61
60
60
ceb05207d6730d3413fea9b4498a8735f41f5d68
bigcode/the-stack
train
a9210857fd0dc30a4972fe4f
train
function
def bytes_to_uint32(data: bytes) -> int: if len(data) != 4: raise ValueError return int.from_bytes(data, byteorder='big', signed=False)
def bytes_to_uint32(data: bytes) -> int:
if len(data) != 4: raise ValueError return int.from_bytes(data, byteorder='big', signed=False)
_to_bytes(x: float) -> bytes: return struct.pack('>d', x) def bytes_to_double(b: bytes) -> float: result = struct.unpack('>d', b) # print(result) return result[0] def bytes_to_uint32(data: bytes) -> int:
64
64
41
12
52
rtmigo/ksf_py
dmk/b_cryptoblobs/_10_byte_funcs.py
Python
bytes_to_uint32
bytes_to_uint32
18
21
18
18
0c5a6a27c62a6f7b52c36fbe253bdbd08de84d71
bigcode/the-stack
train
6cdf17dcc40528bae324b326
train
function
def uint8_to_bytes(x: int) -> bytes: if not 0 <= x <= 0xFF: raise OverflowError return bytes((x,))
def uint8_to_bytes(x: int) -> bytes:
if not 0 <= x <= 0xFF: raise OverflowError return bytes((x,))
_bytes(data, byteorder='big', signed=False) def bytes_to_int64(data: bytes) -> int: if len(data) != 8: raise ValueError return int.from_bytes(data, byteorder='big', signed=True) def uint8_to_bytes(x: int) -> bytes:
64
64
36
12
52
rtmigo/ksf_py
dmk/b_cryptoblobs/_10_byte_funcs.py
Python
uint8_to_bytes
uint8_to_bytes
48
51
48
48
c7c62c849d9e55ebd47c167b70dea02662322a08
bigcode/the-stack
train
6587f0e0887fa23a7e5e401c
train
class
class Drill( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector( "offset" ), ) ) self.size = None def tag_value( self, factory, value ): if self.size == None: self.size = value def write( self, writer ): if self.size or self.offset.is_set(): writer.begin( self...
class Drill( KicadFatObj ):
def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector( "offset" ), ) ) self.size = None def tag_value( self, factory, value ): if self.size == None: self.size = value def write( self, writer ): if self.size or self.offset.is_set(): writer.begin( self ) if self.size: write...
) writer.end() def copy( self, trans ): obj = Effects( self.obj_name ) obj.set( "font", self.font.copy( trans ) ) obj.set( "justify", self.justify.copy( trans ) ) return obj class Drill( KicadFatObj ):
64
64
206
10
53
BuysDB/splitflap
thirdparty/panelize.py
Python
Drill
Drill
1,187
1,215
1,187
1,188
dd7abdef79bc2e469adfc695ededdc6841ff37a9
bigcode/the-stack
train
2b76518db80632fe472271b0
train
class
class Layer( KicadObj ): def __init__( self, nr, name=None, kind=None, hide=None ): KicadObj.__init__( self, nr ) self.nr = int(nr) self.name = name self.kind = kind self.hide = hide def tag_value( self, factory, value ): if self.name == None: self.name = value elif self.kind == None: self.kind ...
class Layer( KicadObj ):
def __init__( self, nr, name=None, kind=None, hide=None ): KicadObj.__init__( self, nr ) self.nr = int(nr) self.name = name self.kind = kind self.hide = hide def tag_value( self, factory, value ): if self.name == None: self.name = value elif self.kind == None: self.kind = value elif self.hide =...
"pad_drill", "pad_to_mask_clearance", "pad_to_paste_clearance", "aux_axis_origin", "grid_origin", "visible_elements", "pcbplotparams" ) ) writer.newline() writer.end() class Layer( KicadObj ):
64
64
173
9
55
BuysDB/splitflap
thirdparty/panelize.py
Python
Layer
Layer
1,675
1,698
1,675
1,676
f7df2173aca31953a10285cb8841af9a455ffee0
bigcode/the-stack
train
2b8d0e2e8fd6476726ef21ca
train
class
class FpLine( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector( "start" ), Vector( "end" ), Text( "layer" ), Float( "width" ), ) ) def write( self, writer ): writer.begin( self ) self.write_objects( writer, ( "start", "end", "layer", "width", ), False...
class FpLine( KicadFatObj ):
def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector( "start" ), Vector( "end" ), Text( "layer" ), Float( "width" ), ) ) def write( self, writer ): writer.begin( self ) self.write_objects( writer, ( "start", "end", "layer", "width", ), False ) writer.end() def copy( ...
_rot( self.center ) ) obj.set( "end", trans.add_flip_rot( self.end ) ) obj.set( "layer", trans.layer( self.layer ) ) obj.set( "width", self.width.clone() ) return obj class FpLine( KicadFatObj ):
64
64
193
12
51
BuysDB/splitflap
thirdparty/panelize.py
Python
FpLine
FpLine
1,042
1,066
1,042
1,043
e82e573a85d407de40db47265a6378f9e8ac3b88
bigcode/the-stack
train
cddc192e1b17e822704762bb
train
function
def check_instance( inst, cls ): if isinstance( inst, cls ): return cname = cls.__name__ iname = type(inst).__name__ raise Exception( "Expected class '%s' but got an instance of '%s'." % ( cname, iname ) )
def check_instance( inst, cls ):
if isinstance( inst, cls ): return cname = cls.__name__ iname = type(inst).__name__ raise Exception( "Expected class '%s' but got an instance of '%s'." % ( cname, iname ) )
__ = "$Rev: 953 $ unkown".split()[1] kicad_versions = ( "4.0.5", "latest" ) compat_4_0_5 = kicad_versions.index( "4.0.5" ) def check_instance( inst, cls ):
64
64
61
8
56
BuysDB/splitflap
thirdparty/panelize.py
Python
check_instance
check_instance
39
45
39
39
6366463eb0ef89b6b9f885c56e29c615a93801b8
bigcode/the-stack
train
5364ad012865d2a799d4fec9
train
class
class GrText( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( VectorAngle( "at" ), Text( "layer" ), Text( "tstamp" ), Effects( "effects" ), ) ) self.text = None def tag_value( self, factory, value ): if self.text == None: self.text = value else: factory.par...
class GrText( KicadFatObj ):
def __init__( self, name ): KicadFatObj.__init__( self, name, ( VectorAngle( "at" ), Text( "layer" ), Text( "tstamp" ), Effects( "effects" ), ) ) self.text = None def tag_value( self, factory, value ): if self.text == None: self.text = value else: factory.parse_error( "too many values for...
trans.vector( self.start ) ) obj.set( "end", trans.vector( self.end ) ) obj.set( "angle", self.angle.clone() ) obj.set( "layer", trans.layer( self.layer ) ) obj.set( "width", self.width.clone() ) obj.set( "tstamp", self.tstamp.clone() ) return obj class GrText( KicadFatObj ):
88
88
294
11
76
BuysDB/splitflap
thirdparty/panelize.py
Python
GrText
GrText
944
983
944
945
670530a3643186805e0af4fa4d7b366d67cf6ee0
bigcode/the-stack
train
006b3ca122b59b916704b37a
train
class
class DimLinePoints( KicadFatObj ): def __init__( self, name ): self.lines = [] KicadFatObj.__init__( self, name, ( DimLinePoints( "arrow2b" ), ) ) self.size = None
class DimLinePoints( KicadFatObj ):
def __init__( self, name ): self.lines = [] KicadFatObj.__init__( self, name, ( DimLinePoints( "arrow2b" ), ) ) self.size = None
", trans.layer( self.layer ) ) obj.set( "net", trans.net( self.net ) ) obj.set( "tstamp", self.tstamp.clone() ) obj.set( "status", self.status.clone() ) return obj class DimLinePoints( KicadFatObj ):
64
64
61
12
51
BuysDB/splitflap
thirdparty/panelize.py
Python
DimLinePoints
DimLinePoints
758
765
758
759
1a7130b4aff33d058d0cb41555dbabd95c6c96c6
bigcode/the-stack
train
52165c477f4e2d8f097400ea
train
class
class Zone( KicadFatObj ): def __init__( self, name ): self.polygons = [] KicadFatObj.__init__( self, name, ( Int( "net" ), Text( "net_name" ), Text( "layer" ), Text( "tstamp" ), List( "hatch" ), ConnectPads( "connect_pads" ), Float( "min_thickness" ), Keepout( "keepout" ), Fill( "fill"...
class Zone( KicadFatObj ):
def __init__( self, name ): self.polygons = [] KicadFatObj.__init__( self, name, ( Int( "net" ), Text( "net_name" ), Text( "layer" ), Text( "tstamp" ), List( "hatch" ), ConnectPads( "connect_pads" ), Float( "min_thickness" ), Keepout( "keepout" ), Fill( "fill" ), ( "polygon", self.pol...
def __init__( self, name ): KicadFatObj.__init__( self, name, ( Float( "clearance" ), ) ) self.opt = None def tag_value( self, factory, value ): if self.opt == None: self.opt = value else: factory.parse_error( "too many values for '%s'" % self.obj_name ) def write_contents( self, writer ): if ...
138
138
462
10
128
BuysDB/splitflap
thirdparty/panelize.py
Python
Zone
Zone
644
699
644
645
1a466837011f60b0634b3b588287af0cae862f12
bigcode/the-stack
train
c04636c970a03eeabbd94203
train
class
class KicadFatObj( KicadObj ): def __init__( self, name, object_types ): KicadObj.__init__( self, name ) # self.object_types = object_types self.object_type_names = [] self.object_type_dict = {} for ot in object_types: if type(ot) is tuple: typename = ot[0] else: typename = ot.obj_name set...
class KicadFatObj( KicadObj ):
def __init__( self, name, object_types ): KicadObj.__init__( self, name ) # self.object_types = object_types self.object_type_names = [] self.object_type_dict = {} for ot in object_types: if type(ot) is tuple: typename = ot[0] else: typename = ot.obj_name setattr( self, typename, ot ) se...
.obj_name = name def clone( self ): raise Exception( "KicadObj.clone() has not been overridden by '%s'" % self.__class__.__name__ ) def tag_start( self, factory, name ): factory.parse_error( "unexpected tag '%s' in '%s'" % ( name, self.obj_name ) ) def tag_end( self, factory, obj ): factory.parse_error( "un...
198
198
663
13
184
BuysDB/splitflap
thirdparty/panelize.py
Python
KicadFatObj
KicadFatObj
77
166
77
78
ec02e0cc0ba5998f2817b0ff00dfba4f48d25f3a
bigcode/the-stack
train
f7d4e86864d1891d456a0c9e
train
class
class General( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( Int( "links" ), Int( "no_connects" ), Area( "area" ), Float( "thickness" ), Int( "drawings" ), Int( "tracks" ), Int( "zones" ), Int( "modules" ), Int( "nets" ), ) ) def init_defaults( self ):...
class General( KicadFatObj ):
def __init__( self, name ): KicadFatObj.__init__( self, name, ( Int( "links" ), Int( "no_connects" ), Area( "area" ), Float( "thickness" ), Int( "drawings" ), Int( "tracks" ), Int( "zones" ), Int( "modules" ), Int( "nets" ), ) ) def init_defaults( self ): self.links.value = 0 self....
.write_obj( writer, "rev" ) self.write_obj( writer, "company" ) for i in range( 0, 4 ): if self.comments[i] != None: writer.begin( "comment" ) writer.write_int( i+1 ) writer.write_text( self.comments[i] ) writer.end() writer.newline() writer.newline() writer.end() class General( KicadFatO...
96
96
321
10
86
BuysDB/splitflap
thirdparty/panelize.py
Python
General
General
1,809
1,845
1,809
1,810
6ad17df7265597282e013fb9390b2ed495ebb9de
bigcode/the-stack
train
5bc72aee79cffab9a7832397
train
class
class Font( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector( "size" ), Float( "thickness" ), # Flag( "italic" ), ) ) self.italic = False def tag_value( self, factory, value ): if value == "italic": self.italic = True else: raise Exception( "Font.tag_val...
class Font( KicadFatObj ):
def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector( "size" ), Float( "thickness" ), # Flag( "italic" ), ) ) self.italic = False def tag_value( self, factory, value ): if value == "italic": self.italic = True else: raise Exception( "Font.tag_value( '%s' )." % value ) def...
( "hide", self.hide ) obj.set( "at", trans.add_flip_rot( self.at ) ) obj.set( "layer", trans.layer( self.layer ) ) obj.set( "effects", self.effects.copy( trans ) ) return obj class Font( KicadFatObj ):
65
65
217
10
54
BuysDB/splitflap
thirdparty/panelize.py
Python
Font
Font
1,115
1,143
1,115
1,116
dabfe97323c468e2efa7d3a1cfdd4f8f1dc8591a
bigcode/the-stack
train
241ca4f0317280c4272d827e
train
class
class Via( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector( "at" ), Float( "size" ), Float( "drill" ), List( "layers" ), Int( "net" ), Text( "tstamp" ), Text( "status" ), ) ) def is_inside( self, area ): return area.is_inside( self.at ) def copy( se...
class Via( KicadFatObj ):
def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector( "at" ), Float( "size" ), Float( "drill" ), List( "layers" ), Int( "net" ), Text( "tstamp" ), Text( "status" ), ) ) def is_inside( self, area ): return area.is_inside( self.at ) def copy( self, trans ): obj = Via( s...
_thickness.clone() ) obj.set( "keepout", self.keepout.clone() ) obj.set( "fill", self.fill.clone() ) for p in self.polygons: obj.polygons.append( p.copy( trans ) ) return obj class Via( KicadFatObj ):
65
65
218
10
54
BuysDB/splitflap
thirdparty/panelize.py
Python
Via
Via
702
727
702
703
8d4962755eb9e023448f19b2483d5fa0737013d2
bigcode/the-stack
train
65364c7cb57a2cc8131b25b1
train
class
class Main: def __init__( self ): self.factory = KicadFactory() self.trans = Transformer() self.debugging = True self.var_layer_name = Variable( "Edge.Cuts" ) self.var_line_thickness = Variable( 0.15 ) self.var_text_height = Variable( 1.5 ) self.var_text_width = Variable( 1.2 ) self.var_text_thickness...
class Main:
def __init__( self ): self.factory = KicadFactory() self.trans = Transformer() self.debugging = True self.var_layer_name = Variable( "Edge.Cuts" ) self.var_line_thickness = Variable( 0.15 ) self.var_text_height = Variable( 1.5 ) self.var_text_width = Variable( 1.2 ) self.var_text_thickness = Variable( ...
= net.value elif isinstance( net, Net ): nr = net.nr elif isinstance( net, Text ): nr = self.src_pcb.nets.by_name[net.value].nr else: raise Exception( "unexpected class" ) if nr == None: return net.clone() name = self.src_pcb.nets.by_nr[nr].name newname = name if self.clone_nets: newname =...
256
256
5,055
3
253
BuysDB/splitflap
thirdparty/panelize.py
Python
Main
Main
2,488
3,177
2,488
2,489
81f2d3aa2a26a73e31d872bab7b1aa4cf80da1c8
bigcode/the-stack
train
11560885b89d1e80c893a8bf
train
class
class ConnectPads( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( Float( "clearance" ), ) ) self.opt = None def tag_value( self, factory, value ): if self.opt == None: self.opt = value else: factory.parse_error( "too many values for '%s'" % self.obj_name ) def wr...
class ConnectPads( KicadFatObj ):
def __init__( self, name ): KicadFatObj.__init__( self, name, ( Float( "clearance" ), ) ) self.opt = None def tag_value( self, factory, value ): if self.opt == None: self.opt = value else: factory.parse_error( "too many values for '%s'" % self.obj_name ) def write_contents( self, writer ): if ...
_contents( self, writer ): if self.opt != None: writer.write_text( self.opt ) self.write_objects( writer, ( "arc_segments", "thermal_gap", "thermal_bridge_width", ), False ) class ConnectPads( KicadFatObj ):
64
64
139
11
53
BuysDB/splitflap
thirdparty/panelize.py
Python
ConnectPads
ConnectPads
622
641
622
623
5a2fbab2f5329cc81a4a278610e2fa06ea1827b3
bigcode/the-stack
train
9099fff9f657e59d6d7c0ef0
train
class
class GrLine( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector( "start" ), Vector( "end" ), Int( "angle" ), Text( "layer" ), Float( "width" ), Text( "tstamp" ), ) ) def is_inside( self, area ): return area.is_inside( self.start ) and area.is_inside( self....
class GrLine( KicadFatObj ):
def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector( "start" ), Vector( "end" ), Int( "angle" ), Text( "layer" ), Float( "width" ), Text( "tstamp" ), ) ) def is_inside( self, area ): return area.is_inside( self.start ) and area.is_inside( self.end ) def copy( self, trans ...
", trans.arc_angle( self.angle ) ) obj.set( "layer", trans.layer( self.layer ) ) obj.set( "width", self.width.clone() ) obj.set( "tstamp", self.tstamp.clone() ) return obj class GrLine( KicadFatObj ):
64
64
207
11
52
BuysDB/splitflap
thirdparty/panelize.py
Python
GrLine
GrLine
918
941
918
919
6e32a998c8e2f92b0b2d5b1e01aa719c40a88829
bigcode/the-stack
train
eec108380f23e4b0f2944c44
train
class
class ListOfPoints( KicadObj ): def __init__( self, name ): self.points = [] KicadObj.__init__( self, name ) self.pts_started = False def tag_start( self, factory, name ): if not self.pts_started: self.pts_started = True return self elif name == "xy": obj = Vector( name ) self.points.append( o...
class ListOfPoints( KicadObj ):
def __init__( self, name ): self.points = [] KicadObj.__init__( self, name ) self.pts_started = False def tag_start( self, factory, name ): if not self.pts_started: self.pts_started = True return self elif name == "xy": obj = Vector( name ) self.points.append( obj ) return obj else: Kic...
self.net ) ) obj.set( "tstamp", self.tstamp.clone() ) obj.set( "status", self.status.clone() ) return obj class DimLinePoints( KicadFatObj ): def __init__( self, name ): self.lines = [] KicadFatObj.__init__( self, name, ( DimLinePoints( "arrow2b" ), ) ) self.size = None class ListOfPoints( KicadOb...
106
106
356
11
94
BuysDB/splitflap
thirdparty/panelize.py
Python
ListOfPoints
ListOfPoints
768
822
768
769
a5f98cd139a451a89b8871156e3b518ea5c9b4e9
bigcode/the-stack
train
b24455827723a6b76f3b9fca
train
class
class Vector( KicadObj ): def __init__( self, name, x=None, y=None ): KicadObj.__init__( self, name ) self.x = x self.y = y def tag_value( self, factory, value ): if self.x == None: self.x = float(value) elif self.y == None: self.y = float(value) else: factory.parse_error( "too many values for ...
class Vector( KicadObj ):
def __init__( self, name, x=None, y=None ): KicadObj.__init__( self, name ) self.x = x self.y = y def tag_value( self, factory, value ): if self.x == None: self.x = float(value) elif self.y == None: self.y = float(value) else: factory.parse_error( "too many values for '%s'" % self.obj_name ) d...
s'" % ( value, self.obj_name ) ) def clone( self ): obj = YesNo( self.obj_name ) obj.value = self.value return obj def is_set( self ): return self.value != None def write_contents( self, writer ): if self.value: writer.write_text( "yes" ) else: writer.write_text( "no" ) def __str__( self ): ...
131
131
438
9
122
BuysDB/splitflap
thirdparty/panelize.py
Python
Vector
Vector
315
375
315
316
597f6252776ddd88806ecb9fc873cb11d1d0a83c
bigcode/the-stack
train
13e3b20815289bfa283bd62a
train
class
class PcbPlotParams( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( Text( "layerselection" ), Bool( "usegerberextensions" ), Bool( "excludeedgelayer" ), Float( "linewidth" ), Bool( "plotframeref" ), Bool( "viasonmask" ), Int( "mode" ), Bool( "useauxorigin" ), ...
class PcbPlotParams( KicadFatObj ):
def __init__( self, name ): KicadFatObj.__init__( self, name, ( Text( "layerselection" ), Bool( "usegerberextensions" ), Bool( "excludeedgelayer" ), Float( "linewidth" ), Bool( "plotframeref" ), Bool( "viasonmask" ), Int( "mode" ), Bool( "useauxorigin" ), Int( "hpglpennumber" ), Int( "h...
writer.newline() writer.end() writer.newline() writer.newline( True ) class Net( KicadObj ): def __init__( self, name, nr=None, netname=None ): KicadObj.__init__( self, name ) self.nr = nr self.name = netname def tag_value( self, factory, value ): if self.nr == None: self.nr = int(value) elif...
208
208
695
13
194
BuysDB/splitflap
thirdparty/panelize.py
Python
PcbPlotParams
PcbPlotParams
1,506
1,576
1,506
1,507
5fd2a2b122b038fda65b446f19cf19ca0d403ccf
bigcode/the-stack
train
5436c378b783519bc34180bf
train
class
class Pad( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( VectorAngle( "at" ), Vector( "size" ), Vector( "rect_delta" ), Drill( "drill" ), List( "layers" ), Float( "solder_mask_margin" ), Float( "clearance" ), Net( "net" ), Int( "zone_connect" ), ) ) se...
class Pad( KicadFatObj ):
def __init__( self, name ): KicadFatObj.__init__( self, name, ( VectorAngle( "at" ), Vector( "size" ), Vector( "rect_delta" ), Drill( "drill" ), List( "layers" ), Float( "solder_mask_margin" ), Float( "clearance" ), Net( "net" ), Int( "zone_connect" ), ) ) self.nr = None self.kind = ...
), ) ) self.size = None def tag_value( self, factory, value ): if self.size == None: self.size = value def write( self, writer ): if self.size or self.offset.is_set(): writer.begin( self ) if self.size: writer.write_text( self.size ) if self.offset.is_set(): self.write_obj( writer, "off...
178
178
596
10
167
BuysDB/splitflap
thirdparty/panelize.py
Python
Pad
Pad
1,218
1,286
1,218
1,219
cc76f60d731819087586c6a6354d8a237c006152
bigcode/the-stack
train
c4c45beb54ee023f58652b00
train
class
class Area( KicadObj ): #def __init__( self, name, v1=Vector("area-v1"), v2=Vector("area-v2") ): # KicadObj.__init__( self, name ) # self.vector1 = v1 # self.vector2 = v2 def __init__( self, name, v1=None, v2=None ): KicadObj.__init__( self, name ) if v1 != None: self.vector1 = v1 else: self.vector1 ...
class Area( KicadObj ): #def __init__( self, name, v1=Vector("area-v1"), v2=Vector("area-v2") ): # KicadObj.__init__( self, name ) # self.vector1 = v1 # self.vector2 = v2
def __init__( self, name, v1=None, v2=None ): KicadObj.__init__( self, name ) if v1 != None: self.vector1 = v1 else: self.vector1 = Vector("area-v1") if v2 != None: self.vector2 = v2 else: self.vector2 = Vector("area-v2") def tag_value( self, factory, value ): # self.values.append( float(valu...
else: factory.parse_error( "too many values for '%s'" % self.obj_name ) def clone( self ): return Vector3D( self.obj_name, self.x, self.y, self.z ) def write_contents( self, writer ): writer.write_float( self.x ) writer.write_float( self.y ) if self.a != None: writer.write_float( self.a ) def __st...
194
194
648
69
125
BuysDB/splitflap
thirdparty/panelize.py
Python
Area
Area
472
544
472
478
1cdd586ec0b41cbf1a42e1926576c979cb8ca8ec
bigcode/the-stack
train
1b81bc8114081f7f831106bb
train
class
class Int( KicadObj ): def __init__( self, name, value=None ): KicadObj.__init__( self, name ) self.value = value def tag_value( self, factory, value ): self.value = int(value) def clone( self ): return Int( self.obj_name, self.value ) def is_set( self ): return self.value != None def write_contents...
class Int( KicadObj ):
def __init__( self, name, value=None ): KicadObj.__init__( self, name ) self.value = value def tag_value( self, factory, value ): self.value = int(value) def clone( self ): return Int( self.obj_name, self.value ) def is_set( self ): return self.value != None def write_contents( self, writer ): writ...
if newline: writer.newline() def write_objects( self, writer, keys, newline=True ): for key in keys: if type(key) is bool: newline = key else: self.write_obj( writer, key, newline ) class Int( KicadObj ):
64
64
129
9
55
BuysDB/splitflap
thirdparty/panelize.py
Python
Int
Int
169
190
169
170
d92dc330d9275800d65cba0ea96bb186a1f68320
bigcode/the-stack
train
e67dcdebe918f73704d58e29
train
class
class Net( KicadObj ): def __init__( self, name, nr=None, netname=None ): KicadObj.__init__( self, name ) self.nr = nr self.name = netname def tag_value( self, factory, value ): if self.nr == None: self.nr = int(value) elif self.name == None: self.name = value else: factory.parse_error( "too ma...
class Net( KicadObj ):
def __init__( self, name, nr=None, netname=None ): KicadObj.__init__( self, name ) self.nr = nr self.name = netname def tag_value( self, factory, value ): if self.nr == None: self.nr = int(value) elif self.name == None: self.name = value else: factory.parse_error( "too many values for '%s'" % se...
"uvia_dia", "uvia_drill", "diff_pair_gap", "diff_pair_width", "add_net", ) ) writer.newline() writer.end() writer.newline() writer.newline( True ) class Net( KicadObj ):
64
64
174
9
55
BuysDB/splitflap
thirdparty/panelize.py
Python
Net
Net
1,475
1,503
1,475
1,476
4e11d3bc169bcfc7568a1f188c11cdb0ca723961
bigcode/the-stack
train
c2a1467aa3575b46ee1d2ad1
train
class
class Text( KicadObj ): def __init__( self, name, value=None ): KicadObj.__init__( self, name ) self.value = value def tag_value( self, factory, value ): self.value = value def clone( self ): return Text( self.obj_name, self.value ) def is_set( self ): return self.value != None def write_contents( s...
class Text( KicadObj ):
def __init__( self, name, value=None ): KicadObj.__init__( self, name ) self.value = value def tag_value( self, factory, value ): self.value = value def clone( self ): return Text( self.obj_name, self.value ) def is_set( self ): return self.value != None def write_contents( self, writer ): writer.w...
( self ): return self.value != None def write_contents( self, writer ): writer.write_float( self.value ) def __str__( self ): if self.value == None: return "<<<NONE>>>" return "%f" % self.value class Text( KicadObj ):
64
64
124
9
54
BuysDB/splitflap
thirdparty/panelize.py
Python
Text
Text
217
238
217
218
c5b12c4384b1c93fde22be0e5e870d571efe6b95
bigcode/the-stack
train
7aa79af19fc80d60fae970c6
train
class
class TitleBlock( KicadFatObj ): def __init__( self, name ): self.comments = [ None, None, None, None ] KicadFatObj.__init__( self, name, ( Text( "title" ), Text( "date" ), Text( "rev" ), Text( "company" ), ( "comment", self.comments, List ), ) ) def append( self, obj ): i = int(obj.values[0]...
class TitleBlock( KicadFatObj ):
def __init__( self, name ): self.comments = [ None, None, None, None ] KicadFatObj.__init__( self, name, ( Text( "title" ), Text( "date" ), Text( "rev" ), Text( "company" ), ( "comment", self.comments, List ), ) ) def append( self, obj ): i = int(obj.values[0]) self.comments[i-1] = obj.value...
# nrs = self.layers.keys()[:] nrs = list( self.layers.keys() ) nrs.sort() for nr in nrs: self.layers[nr].write( writer ) writer.newline() writer.end() writer.newline() class TitleBlock( KicadFatObj ):
70
70
235
11
59
BuysDB/splitflap
thirdparty/panelize.py
Python
TitleBlock
TitleBlock
1,776
1,806
1,776
1,777
ebd8975fb80bab5606106c3b4b9aa8a1a0170ca8
bigcode/the-stack
train
816e7e4b3245c1a6f936d801
train
class
class Keepout( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( Text( "tracks" ), Text( "vias" ), Text( "copperpour" ), ) ) self.opt = None def tag_value( self, factory, value ): if self.opt == None: self.opt = value else: factory.parse_error( "too many values ...
class Keepout( KicadFatObj ):
def __init__( self, name ): KicadFatObj.__init__( self, name, ( Text( "tracks" ), Text( "vias" ), Text( "copperpour" ), ) ) self.opt = None def tag_value( self, factory, value ): if self.opt == None: self.opt = value else: factory.parse_error( "too many values for '%s'" % self.obj_name ) ...
v in self.values: obj.values.append( v ) return obj def is_set( self ): return len(self.values) > 0 def write_contents( self, writer ): for value in self.values: writer.write_text( value ) class Keepout( KicadFatObj ):
64
64
192
10
54
BuysDB/splitflap
thirdparty/panelize.py
Python
Keepout
Keepout
569
594
569
569
cc5bcfb0599dcd56dfd5546b8cbfb27adbe5036f
bigcode/the-stack
train
4497ee8e230471577d69604d
train
class
class NamedVector3D( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector3D( "xyz" ), ) )
class NamedVector3D( KicadFatObj ):
def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector3D( "xyz" ), ) )
.layer( layer ) ) obj.set( "clearance", self.clearance.clone() ) obj.set( "net", trans.net( self.net ) ) obj.set( "zone_connect", self.zone_connect.clone() ) return obj class NamedVector3D( KicadFatObj ):
64
64
48
13
50
BuysDB/splitflap
thirdparty/panelize.py
Python
NamedVector3D
NamedVector3D
1,289
1,294
1,289
1,290
99f51e711ccbb26f82cb239739abf6f5273b7f2f
bigcode/the-stack
train
f3c3cf47c05161a1a760536f
train
class
class ParseError( Exception ): def __init__( self, msg, factory ): self.msg = msg self.factory = factory self.args = ( factory.filename, factory.line, factory.column, msg ) def __repr__( self ): return "ParseError(%r, %r, %r, %r)" % self.args def __str__( self ): return "%s:%d.%d: %s" % self.args
class ParseError( Exception ):
def __init__( self, msg, factory ): self.msg = msg self.factory = factory self.args = ( factory.filename, factory.line, factory.column, msg ) def __repr__( self ): return "ParseError(%r, %r, %r, %r)" % self.args def __str__( self ): return "%s:%d.%d: %s" % self.args
# trailing single backslash break c = s[j] if c in quote_chars: c = quote_chars[c] s = s[:i] + c + s[j+1:] i = s.find( '\\', i ) return s class ParseError( Exception ):
64
64
94
7
56
BuysDB/splitflap
thirdparty/panelize.py
Python
ParseError
ParseError
2,065
2,076
2,065
2,066
a2d3bf44ef6b778590900573c257d74bcb1c47f3
bigcode/the-stack
train
2cc07e9781d173e145d582b4
train
class
class Justify( List ): def __init__( self, name ): List.__init__( self, name ) def clone( self ): obj = Justify( self.obj_name ) for v in self.values: obj.values.append( v ) return obj def copy( self, trans ): obj = self.clone() if trans.flip: if "mirror" in obj.values: obj.values.remove( "m...
class Justify( List ):
def __init__( self, name ): List.__init__( self, name ) def clone( self ): obj = Justify( self.obj_name ) for v in self.values: obj.values.append( v ) return obj def copy( self, trans ): obj = self.clone() if trans.flip: if "mirror" in obj.values: obj.values.remove( "mirror" ) else: ob...
.end() def copy( self, trans ): obj = Font( self.obj_name ) obj.set( "size", self.size.clone() ) obj.set( "thickness", self.thickness.clone() ) obj.italic = self.italic return obj class Justify( List ):
64
64
109
7
56
BuysDB/splitflap
thirdparty/panelize.py
Python
Justify
Justify
1,146
1,164
1,146
1,147
0dc37d14958147aa41506d4f2db5a6e705a0fd48
bigcode/the-stack
train
f0618edce7f99c394be3dd40
train
class
class KicadFactory( KicadObj ): def __init__( self ): KicadObj.__init__( self, "KicadFactory" ) self.filename = "" self.line = 0 self.column = 0 def parse_file( self, filename ): self.filename = filename print( "loading %s." % filename ) ifd = open( self.filename, "r" ) data = ifd.read( 16*1024*1024...
class KicadFactory( KicadObj ):
def __init__( self ): KicadObj.__init__( self, "KicadFactory" ) self.filename = "" self.line = 0 self.column = 0 def parse_file( self, filename ): self.filename = filename print( "loading %s." % filename ) ifd = open( self.filename, "r" ) data = ifd.read( 16*1024*1024 ) ifd.close() print( "parsin...
\t()": value = "\"%s\"" % value break self.ofd.write( " %s" % value ) quote_chars = { "n": "\n", "r": "\r", "t": "\t", } def unquote( s ): i = s.find( '\\' ) while i >= 0: j = i + 1 if j >= len(s): # trailing single backslash break c = s[j] if c in quote_chars: c = quote_chars[c] ...
256
256
928
12
243
BuysDB/splitflap
thirdparty/panelize.py
Python
KicadFactory
KicadFactory
2,079
2,193
2,079
2,080
af9990a7bf7b13598723c7a08bb7c08d679915c4
bigcode/the-stack
train
71d9368fe9f4caec983a315c
train
class
class Variable: def __init__( self, value ): self.value = value def __str__( self ): return str(self.value)
class Variable:
def __init__( self, value ): self.value = value def __str__( self ): return str(self.value)
newname ) if isinstance( net, Int ): return Int( net.obj_name, nr ) elif isinstance( net, Net ): return Net( net.obj_name, nr, newname ) elif isinstance( net, Text ): return Text( net.obj_name, newname ) class Variable:
64
64
29
3
61
BuysDB/splitflap
thirdparty/panelize.py
Python
Variable
Variable
2,479
2,485
2,479
2,480
62866781c266ad707974bacba6a7de865e3b8f7b
bigcode/the-stack
train
4b83cb36e324e932213c96dd
train
class
class NetsList: def __init__( self ): self.by_nr = {} self.by_name = {} self.max_nr = -1 def append( self, obj ): self.by_nr[obj.nr] = obj self.by_name[obj.name] = obj if obj.nr > self.max_nr: self.max_nr = obj.nr def create( self, name ): if self.max_nr < 0: self.append( Net( "net", 0, "" ) )...
class NetsList:
def __init__( self ): self.by_nr = {} self.by_name = {} self.max_nr = -1 def append( self, obj ): self.by_nr[obj.nr] = obj self.by_name[obj.name] = obj if obj.nr > self.max_nr: self.max_nr = obj.nr def create( self, name ): if self.max_nr < 0: self.append( Net( "net", 0, "" ) ) net = Net( "ne...
writer.newline() self.write_objects( writer, ( "links", "no_connects", "area", "thickness", "drawings", "tracks", "zones", "modules", "nets" ) ) writer.newline() writer.end() writer.newline() class NetsList:
64
64
176
4
60
BuysDB/splitflap
thirdparty/panelize.py
Python
NetsList
NetsList
1,848
1,874
1,848
1,849
f2112d94a797b24ed2d17bf1c0c400a8ae952354
bigcode/the-stack
train
456a6fe91a687928bf2225c1
train
class
class List( KicadObj ): def __init__( self, name ): KicadObj.__init__( self, name ) self.values = [] def tag_value( self, factory, value ): self.values.append( value ) def clone( self ): obj = List( self.obj_name ) for v in self.values: obj.values.append( v ) return obj def is_set( self ): retu...
class List( KicadObj ):
def __init__( self, name ): KicadObj.__init__( self, name ) self.values = [] def tag_value( self, factory, value ): self.values.append( value ) def clone( self ): obj = List( self.obj_name ) for v in self.values: obj.values.append( v ) return obj def is_set( self ): return len(self.values) > 0 ...
.obj_name, self.vector1 - v.vector1, self.vector2 - v.vector2 ) else: raise Exception( "invalid class" ) def __str__( self ): return "%s..%s" % ( self.vector1, self.vector2 ) class List( KicadObj ):
64
64
121
9
55
BuysDB/splitflap
thirdparty/panelize.py
Python
List
List
547
567
547
548
4f37fcf101d65547497da2ef36ec1d9118698af0
bigcode/the-stack
train
e1314b026eece6a5f40cdd75
train
class
class Bool( KicadObj ): def __init__( self, name ): KicadObj.__init__( self, name ) self.value = None def tag_value( self, factory, value ): if value == "true": self.value = True elif value == "false": self.value = False else: factory.parse_error( "invalid value '%s' for bool '%s'" % ( value, sel...
class Bool( KicadObj ):
def __init__( self, name ): KicadObj.__init__( self, name ) self.value = None def tag_value( self, factory, value ): if value == "true": self.value = True elif value == "false": self.value = False else: factory.parse_error( "invalid value '%s' for bool '%s'" % ( value, self.obj_name ) ) def clon...
) def is_set( self ): return self.value != None def write_contents( self, writer ): writer.write_text( self.value ) def __str__( self ): if self.value == None: return "<<<NONE>>>" return self.value class Bool( KicadObj ):
64
64
210
9
54
BuysDB/splitflap
thirdparty/panelize.py
Python
Bool
Bool
241
275
241
242
b2fc4ef61235443f0c7a4298bec08ce4dd5c7d39
bigcode/the-stack
train
37aebe7c10d72d53d2ba90d7
train
class
class FpArc( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector( "start" ), Vector( "end" ), Float( "angle" ), Text( "layer" ), Float( "width" ), ) ) def write( self, writer ): writer.begin( self ) self.write_objects( writer, ( "start", "end", "angle", ...
class FpArc( KicadFatObj ):
def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector( "start" ), Vector( "end" ), Float( "angle" ), Text( "layer" ), Float( "width" ), ) ) def write( self, writer ): writer.begin( self ) self.write_objects( writer, ( "start", "end", "angle", "layer", "width", ), False...
trans.vector( self.at ) ) obj.set( "layer", trans.layer( self.layer ) ) obj.set( "tstamp", self.tstamp.clone() ) obj.set( "effects", self.effects.copy( trans ) ) return obj class FpArc( KicadFatObj ):
65
65
219
12
52
BuysDB/splitflap
thirdparty/panelize.py
Python
FpArc
FpArc
986
1,012
986
987
91a55f91aee9d298e0dc8c54be21f7b49f62bb0c
bigcode/the-stack
train
f1b5e7b8292b2f17c5915acd
train
class
class GrCircle( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector( "center" ), Vector( "end" ), Text( "layer" ), Float( "width" ), ) ) def is_inside( self, area ): return area.is_inside( self.center ) def copy( self, trans ): obj = GrCircle( self.obj_name ) ...
class GrCircle( KicadFatObj ):
def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector( "center" ), Vector( "end" ), Text( "layer" ), Float( "width" ), ) ) def is_inside( self, area ): return area.is_inside( self.center ) def copy( self, trans ): obj = GrCircle( self.obj_name ) obj.set( "center", trans.vecto...
_text", "feature1", "feature2", "crossbar", "arrow1a", "arrow1b", "arrow2a", "arrow2b", ), False ) class GrCircle( KicadFatObj ):
64
64
158
11
53
BuysDB/splitflap
thirdparty/panelize.py
Python
GrCircle
GrCircle
870
889
870
871
8743afa3a0a23f345768bbf25bd2dd75152f0dec
bigcode/the-stack
train
fa5d71addf02b333510af6e1
train
class
class KicadObj: def __init__( self, name ): self.obj_name = name def clone( self ): raise Exception( "KicadObj.clone() has not been overridden by '%s'" % self.__class__.__name__ ) def tag_start( self, factory, name ): factory.parse_error( "unexpected tag '%s' in '%s'" % ( name, self.obj_name ) ) def tag_e...
class KicadObj:
def __init__( self, name ): self.obj_name = name def clone( self ): raise Exception( "KicadObj.clone() has not been overridden by '%s'" % self.__class__.__name__ ) def tag_start( self, factory, name ): factory.parse_error( "unexpected tag '%s' in '%s'" % ( name, self.obj_name ) ) def tag_end( self, factory...
( inst, cls ): if isinstance( inst, cls ): return cname = cls.__name__ iname = type(inst).__name__ raise Exception( "Expected class '%s' but got an instance of '%s'." % ( cname, iname ) ) class KicadObj:
64
64
201
6
58
BuysDB/splitflap
thirdparty/panelize.py
Python
KicadObj
KicadObj
48
74
48
49
b1de7186c6b1ce43927948903ed2895eeef54bbb
bigcode/the-stack
train
f38620960745719d5a517dcb
train
class
class FpText( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( VectorAngle( "at" ), Text( "layer" ), Effects( "effects" ), ) ) self.kind = None self.name = None self.hide = False def tag_value( self, factory, value ): if self.kind == None: self.kind = value el...
class FpText( KicadFatObj ):
def __init__( self, name ): KicadFatObj.__init__( self, name, ( VectorAngle( "at" ), Text( "layer" ), Effects( "effects" ), ) ) self.kind = None self.name = None self.hide = False def tag_value( self, factory, value ): if self.kind == None: self.kind = value elif self.name == None: self....
), False ) writer.end() def copy( self, trans ): obj = FpLine( self.obj_name ) obj.set( "start", trans.add_flip_rot( self.start ) ) obj.set( "end", trans.add_flip_rot( self.end ) ) obj.set( "layer", trans.layer( self.layer ) ) obj.set( "width", self.width.clone() ) return obj class FpText( KicadFatObj...
101
101
338
12
88
BuysDB/splitflap
thirdparty/panelize.py
Python
FpText
FpText
1,069
1,112
1,069
1,070
915224a697d29d43fd168c0ef6e098380a52f647
bigcode/the-stack
train
e989ffa1c2ca90bc0d117684
train
class
class VectorAngle( Vector ): def __init__( self, name, x=None, y=None, a=0 ): Vector.__init__( self, name, x, y ) self.a = a def tag_value( self, factory, value ): if self.x == None: self.x = float(value) elif self.y == None: self.y = float(value) #elif self.a == None: # self.a = float(value) #e...
class VectorAngle( Vector ):
def __init__( self, name, x=None, y=None, a=0 ): Vector.__init__( self, name, x, y ) self.a = a def tag_value( self, factory, value ): if self.x == None: self.x = float(value) elif self.y == None: self.y = float(value) #elif self.a == None: # self.a = float(value) #else: # factory.parse_error( ...
== 0: pass elif angle == 90: x, y = y, -x elif angle == 180: x, y = -x, -y elif angle == 270: x, y = -y, x else: # +++ sin/cos??? # raise Exception( "unsupported angle" ) ra = math.radians( angle ) sa = math.sin( ra ) ca = math.cos( ra ) x, y = x * ca + y * sa, x * sa - y * ca r...
150
150
503
7
143
BuysDB/splitflap
thirdparty/panelize.py
Python
VectorAngle
VectorAngle
378
438
378
379
4f1e26823b2c03d5028f6a0a16f30984fe266261
bigcode/the-stack
train
7aeba1345a6b3fbf5841e214
train
class
class Transformer: def __init__( self ): self.src_pcb = None self.src_area = None self.dst_pcb = None self.dst_vector = None self.rotate = None self.flip = None self.clone_nets = True self.swap_internal_layers = False self.layer_filter_list = None self.layer_filter_include = False # self.net_p...
class Transformer:
def __init__( self ): self.src_pcb = None self.src_area = None self.dst_pcb = None self.dst_vector = None self.rotate = None self.flip = None self.clone_nets = True self.swap_internal_layers = False self.layer_filter_list = None self.layer_filter_include = False # self.net_pfx_nr = 0 # self...
[-1].tag_value( self, value ) else: # skip whitespace while i < l and data[i].isspace(): if data[i] == '\n': self.line += 1 lineoff = i i += 1 return self.object def parse_error( self, text ): raise ParseError( text, self ) def tag_start( self, factory, name ): if name == "kic...
256
256
2,237
3
252
BuysDB/splitflap
thirdparty/panelize.py
Python
Transformer
Transformer
2,196
2,476
2,196
2,197
bff10e9bd236e7e7cacd9d55782953425c09da98
bigcode/the-stack
train
12f7dd0be1cb67accccca49e
train
function
def unquote( s ): i = s.find( '\\' ) while i >= 0: j = i + 1 if j >= len(s): # trailing single backslash break c = s[j] if c in quote_chars: c = quote_chars[c] s = s[:i] + c + s[j+1:] i = s.find( '\\', i ) return s
def unquote( s ):
i = s.find( '\\' ) while i >= 0: j = i + 1 if j >= len(s): # trailing single backslash break c = s[j] if c in quote_chars: c = quote_chars[c] s = s[:i] + c + s[j+1:] i = s.find( '\\', i ) return s
in " \t()": value = "\"%s\"" % value break self.ofd.write( " %s" % value ) quote_chars = { "n": "\n", "r": "\r", "t": "\t", } def unquote( s ):
64
64
94
6
58
BuysDB/splitflap
thirdparty/panelize.py
Python
unquote
unquote
2,050
2,062
2,050
2,050
45c098304f0fcc94830c7468587213b8966b89e0
bigcode/the-stack
train
42be223543a77f320936ae0b
train
class
class Segment( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector( "start" ), Vector( "end" ), Float( "width" ), Text( "layer" ), Int( "net" ), Text( "tstamp" ), Text( "status" ), ) ) def is_inside( self, area ): return area.is_inside( self.start ) and a...
class Segment( KicadFatObj ):
def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector( "start" ), Vector( "end" ), Float( "width" ), Text( "layer" ), Int( "net" ), Text( "tstamp" ), Text( "status" ), ) ) def is_inside( self, area ): return area.is_inside( self.start ) and area.is_inside( self.end ) def...
) obj.set( "layers", self.layers.clone() ) obj.set( "net", trans.net( self.net ) ) obj.set( "tstamp", self.tstamp.clone() ) obj.set( "status", self.status.clone() ) return obj class Segment( KicadFatObj ):
67
67
226
10
56
BuysDB/splitflap
thirdparty/panelize.py
Python
Segment
Segment
730
755
730
731
973914ea3fdc543407cce863ae2d864322597e36
bigcode/the-stack
train
d6445414a60b9be6f30b4c4d
train
class
class Writer: def __init__( self, filename, compat_index ): self.filename = filename self.compat_index = compat_index print( "writing %s..." % self.filename ) self.ofd = open( filename, "w" ) self.indent = "" self.need_indent = True def compat( self, compat_index ): return compat_index >= self.compat_...
class Writer:
def __init__( self, filename, compat_index ): self.filename = filename self.compat_index = compat_index print( "writing %s..." % self.filename ) self.ofd = open( filename, "w" ) self.indent = "" self.need_indent = True def compat( self, compat_index ): return compat_index >= self.compat_index def clo...
self.segments[:]: if isinstance( obj, Segment ): if trans.accepts_layer( obj.layer ): if obj.is_inside( trans.src_area ): dst_pcb.segments.append( obj.copy( trans ) ) else: if trans.accepts_layers( obj.layers ): if obj.is_inside( trans.src_area ): dst_pcb.segments.append( obj.copy( ...
130
130
435
3
127
BuysDB/splitflap
thirdparty/panelize.py
Python
Writer
Writer
1,980
2,041
1,980
1,981
d4d45b28e847fd6331830d63bb4a38d88a9d3b60
bigcode/the-stack
train
f41d25cbfa70aefd52b174e9
train
class
class Float( KicadObj ): def __init__( self, name, value=None ): KicadObj.__init__( self, name ) self.value = value def tag_value( self, factory, value ): self.value = float(value) def clone( self ): return Float( self.obj_name, self.value ) def is_set( self ): return self.value != None def write_co...
class Float( KicadObj ):
def __init__( self, name, value=None ): KicadObj.__init__( self, name ) self.value = value def tag_value( self, factory, value ): self.value = float(value) def clone( self ): return Float( self.obj_name, self.value ) def is_set( self ): return self.value != None def write_contents( self, writer ): ...
( self ): return self.value != None def write_contents( self, writer ): writer.write_int( self.value ) def __str__( self ): if self.value == None: return "<<<NONE>>>" return "%d" % self.value class Float( KicadObj ):
64
64
129
9
54
BuysDB/splitflap
thirdparty/panelize.py
Python
Float
Float
193
214
193
194
a1553404270d90307fc1b8e6267befad85202ee2
bigcode/the-stack
train
5433ce5940192aecaebb5f94
train
class
class Dimension( KicadFatObj ): def __init__( self, name ): self.lines = [] KicadFatObj.__init__( self, name, ( Float( "width" ), Text( "layer" ), GrText( "gr_text" ), Vector( "end" ), ListOfPoints( "feature1" ), ListOfPoints( "feature2" ), ListOfPoints( "crossbar" ), ListOfPoints( "arrow1...
class Dimension( KicadFatObj ):
def __init__( self, name ): self.lines = [] KicadFatObj.__init__( self, name, ( Float( "width" ), Text( "layer" ), GrText( "gr_text" ), Vector( "end" ), ListOfPoints( "feature1" ), ListOfPoints( "feature2" ), ListOfPoints( "crossbar" ), ListOfPoints( "arrow1a" ), ListOfPoints( "arrow1b" ...
line() def is_inside( self, area ): for p in self.points: if not area.is_inside( p ): return False return True def copy( self, trans ): obj = ListOfPoints( self.obj_name ) obj.pts_started = False for p in self.points: obj.points.append( trans.vector( p ) ) return obj class Dimension( KicadFatO...
92
92
307
10
81
BuysDB/splitflap
thirdparty/panelize.py
Python
Dimension
Dimension
825
867
825
826
5f6c28a6dcbef06920e93e8d5222fe19a849c34d
bigcode/the-stack
train
693d667082fcd11fa3b91bea
train
class
class GrArc( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector( "start" ), Vector( "end" ), Float( "angle" ), Text( "layer" ), Float( "width" ), Text( "tstamp" ), ) ) def is_inside( self, area ): return area.is_inside( self.start ) and area.is_inside( self...
class GrArc( KicadFatObj ):
def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector( "start" ), Vector( "end" ), Float( "angle" ), Text( "layer" ), Float( "width" ), Text( "tstamp" ), ) ) def is_inside( self, area ): return area.is_inside( self.start ) and area.is_inside( self.end ) def copy( self, tran...
center", trans.vector( self.center ) ) obj.set( "end", trans.vector( self.end ) ) obj.set( "layer", trans.layer( self.layer ) ) obj.set( "width", self.width.clone() ) return obj class GrArc( KicadFatObj ):
64
64
211
11
52
BuysDB/splitflap
thirdparty/panelize.py
Python
GrArc
GrArc
892
915
892
893
9ca3363a11f5b4ded639ef75cdfdaf2c1c474479
bigcode/the-stack
train
abdae1203bb5ee4a30292d06
train
class
class Effects( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( Font( "font" ), Justify( "justify" ), ) ) def write( self, writer ): writer.begin( self ) self.write_objects( writer, ( "font", "justify" ), False ) writer.end() def copy( self, trans ): obj = Effects( ...
class Effects( KicadFatObj ):
def __init__( self, name ): KicadFatObj.__init__( self, name, ( Font( "font" ), Justify( "justify" ), ) ) def write( self, writer ): writer.begin( self ) self.write_objects( writer, ( "font", "justify" ), False ) writer.end() def copy( self, trans ): obj = Effects( self.obj_name ) obj.set( "fon...
obj def copy( self, trans ): obj = self.clone() if trans.flip: if "mirror" in obj.values: obj.values.remove( "mirror" ) else: obj.values.append( "mirror" ) return obj class Effects( KicadFatObj ):
64
64
136
10
53
BuysDB/splitflap
thirdparty/panelize.py
Python
Effects
Effects
1,167
1,184
1,167
1,168
f4f6c7c0141912d10cdd45d6832a7c8d9226d769
bigcode/the-stack
train
394be9ce126ef4d0977ce542
train
class
class Fill( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( Int( "arc_segments" ), Float( "thermal_gap" ), Float( "thermal_bridge_width" ), ) ) self.opt = None def tag_value( self, factory, value ): if self.opt == None: self.opt = value else: factory.parse_err...
class Fill( KicadFatObj ):
def __init__( self, name ): KicadFatObj.__init__( self, name, ( Int( "arc_segments" ), Float( "thermal_gap" ), Float( "thermal_bridge_width" ), ) ) self.opt = None def tag_value( self, factory, value ): if self.opt == None: self.opt = value else: factory.parse_error( "too many values for '%s...
writer, ( "tracks", "vias", "copperpour", ), False ) def is_set( self ): return self.tracks.is_set() and self.vias.is_set() and self.copperpour.is_set() class Fill( KicadFatObj ):
64
64
169
10
54
BuysDB/splitflap
thirdparty/panelize.py
Python
Fill
Fill
596
619
596
597
b71c1a3dfa599974f1b6dc4f63f3694d628f3e1f
bigcode/the-stack
train
ef8413efefefdc8a343f5532
train
class
class FpCircle( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector( "center" ), Vector( "end" ), Text( "layer" ), Float( "width" ), ) ) def write( self, writer ): writer.begin( self ) self.write_objects( writer, ( "center", "end", "layer", "width", ), F...
class FpCircle( KicadFatObj ):
def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector( "center" ), Vector( "end" ), Text( "layer" ), Float( "width" ), ) ) def write( self, writer ): writer.begin( self ) self.write_objects( writer, ( "center", "end", "layer", "width", ), False ) writer.end() def copy...
_flip_rot( self.end ) ) obj.set( "angle", trans.arc_angle( self.angle ) ) obj.set( "layer", trans.layer( self.layer ) ) obj.set( "width", self.width.clone() ) return obj class FpCircle( KicadFatObj ):
64
64
193
12
51
BuysDB/splitflap
thirdparty/panelize.py
Python
FpCircle
FpCircle
1,015
1,039
1,015
1,016
1047c3bb32625acd675421a8c714ac4403459b92
bigcode/the-stack
train
56fd5001f969c7353f092a77
train
class
class Model( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( NamedVector3D( "at" ), NamedVector3D( "scale" ), NamedVector3D( "rotate" ), ) ) self.filename = None def tag_value( self, factory, value ): if self.filename == None: self.filename = value else: facto...
class Model( KicadFatObj ):
def __init__( self, name ): KicadFatObj.__init__( self, name, ( NamedVector3D( "at" ), NamedVector3D( "scale" ), NamedVector3D( "rotate" ), ) ) self.filename = None def tag_value( self, factory, value ): if self.filename == None: self.filename = value else: factory.parse_error( "too many val...
() ) return obj class NamedVector3D( KicadFatObj ): def __init__( self, name ): KicadFatObj.__init__( self, name, ( Vector3D( "xyz" ), ) ) class Model( KicadFatObj ):
64
64
203
10
54
BuysDB/splitflap
thirdparty/panelize.py
Python
Model
Model
1,297
1,322
1,297
1,298
f5c058a3e383cdd4f0dffcbf0bfca9d341279eaa
bigcode/the-stack
train