function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def __init__(self, gan=None, config=None, trainer=None): super().__init__(config=config, gan=gan, trainer=trainer) self.d_grads = None self.g_grads = None
255BITS/HyperGAN
[ 1175, 170, 1175, 20, 1466808596 ]
def main(): # Contingency Table from Wilks (2011) Table 8.3 table = np.array([[50, 91, 71], [47, 2364, 170], [54, 205, 3288]]) mct = MulticlassContingencyTable(table, n_classes=table.shape[0], class_names=np.arange(table.shape[...
djgagne/hagelslag
[ 58, 25, 58, 5, 1434487723 ]
def __init__(self, table=None, n_classes=2, class_names=("1", "0")): self.table = table self.n_classes = n_classes self.class_names = class_names if table is None: self.table = np.zeros((self.n_classes, self.n_classes), dtype=int)
djgagne/hagelslag
[ 58, 25, 58, 5, 1434487723 ]
def peirce_skill_score(self): """ Multiclass Peirce Skill Score (also Hanssen and Kuipers score, True Skill Score) """ n = float(self.table.sum()) nf = self.table.sum(axis=1) no = self.table.sum(axis=0) correct = float(self.table.trace()) return (correct /...
djgagne/hagelslag
[ 58, 25, 58, 5, 1434487723 ]
def heidke_skill_score(self): n = float(self.table.sum()) nf = self.table.sum(axis=1) no = self.table.sum(axis=0) correct = float(self.table.trace()) return (correct / n - (nf * no).sum() / n ** 2) / (1 - (nf * no).sum() / n ** 2)
djgagne/hagelslag
[ 58, 25, 58, 5, 1434487723 ]
def __init__(self, band_names=['delta', 'theta', 'alpha', 'beta'], ch_names=['TP9', 'AF7', 'AF8', 'TP10']): """ """ self.band_names = band_names self.ch_names = ch_names self.n_bars = self.band_names * self.ch_names self.x = self.fig, self.ax = ...
bcimontreal/bci_workshop
[ 76, 43, 76, 11, 1431551360 ]
def test_multi_buffer(self): grid = Grid((3, 3)) f = TimeFunction(name="f", grid=grid) g = TimeFunction(name="g", grid=grid, save=Buffer(7)) op = Operator([Eq(f.forward, 1), Eq(g, f.forward)]) op(time_M=3) # f looped all time_order buffer and is 1 everywhere asse...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_interior(self, opt): """ Tests application of an Operator consisting of a single equation over the ``interior`` subdomain. """ grid = Grid(shape=(4, 4, 4)) x, y, z = grid.dimensions interior = grid.interior u = TimeFunction(name='u', grid=grid) ...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_subdim_middle(self, opt): """ Tests that instantiating SubDimensions using the classmethod constructors works correctly. """ grid = Grid(shape=(4, 4, 4)) x, y, z = grid.dimensions t = grid.stepping_dim # noqa u = TimeFunction(name='u', grid=grid...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_bcs(self, opt): """ Tests application of an Operator consisting of multiple equations defined over different sub-regions, explicitly created through the use of SubDimensions. """ grid = Grid(shape=(20, 20)) x, y = grid.dimensions t = grid.stepping...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_iteration_property_parallel(self, exprs, expected): """Tests detection of sequental and parallel Iterations when applying equations over different subdomains.""" grid = Grid(shape=(20, 20)) x, y = grid.dimensions # noqa t = grid.time_dim # noqa interior = grid...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_iteration_property_vector(self, exprs, expected): """Tests detection of vector Iterations when using subdimensions.""" grid = Grid(shape=(20, 20)) x, y = grid.dimensions # noqa time = grid.time_dim # noqa # The leftmost 10 elements yleft = SubDimension.left(na...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_subdimmiddle_parallel(self, opt): """ Tests application of an Operator consisting of a subdimension defined over different sub-regions, explicitly created through the use of SubDimensions. """ grid = Grid(shape=(20, 20)) x, y = grid.dimensions t =...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_subdimmiddle_notparallel(self): """ Tests application of an Operator consisting of a subdimension defined over different sub-regions, explicitly created through the use of SubDimensions. Different from ``test_subdimmiddle_parallel`` because an interior dimension...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_subdim_fd(self): """ Test that the FD shortcuts are handled correctly with SubDimensions """ grid = Grid(shape=(20, 20)) x, y = grid.dimensions u = TimeFunction(name='u', save=None, grid=grid, space_order=1, time_order=1) u.data[:] = 2. # Flows ...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_expandingbox_like(self, opt): """ Make sure SubDimensions aren't an obstacle to expanding boxes. """ grid = Grid(shape=(8, 8)) x, y = grid.dimensions u = TimeFunction(name='u', grid=grid) xi = SubDimension.middle(name='xi', parent=x, thickness_left=2, th...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_basic(self): nt = 19 grid = Grid(shape=(11, 11)) time = grid.time_dim u = TimeFunction(name='u', grid=grid) assert(grid.stepping_dim in u.indices) u2 = TimeFunction(name='u2', grid=grid, save=nt) assert(time in u2.indices) factor = 4 ti...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_spacial_subsampling(self, opt): """ Test conditional dimension for the spatial ones. This test saves u every two grid points : u2[x, y] = u[2*x, 2*y] """ nt = 19 grid = Grid(shape=(11, 11)) time = grid.time_dim u = TimeFunction(name='u', ...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_issue_1592(self): grid = Grid(shape=(11, 11)) time = grid.time_dim time_sub = ConditionalDimension('t_sub', parent=time, factor=2) v = TimeFunction(name="v", grid=grid, space_order=4, time_dim=time_sub, save=5) w = Function(name="w", grid=grid, space_order=4) Ope...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_nothing_in_negative(self): """Test the case where when the condition is false, there is nothing to do.""" nt = 4 grid = Grid(shape=(11, 11)) time = grid.time_dim u = TimeFunction(name='u', save=nt, grid=grid) assert(grid.time_dim in u.indices) factor = ...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_as_expr(self): nt = 19 grid = Grid(shape=(11, 11)) time = grid.time_dim u = TimeFunction(name='u', grid=grid) assert(grid.stepping_dim in u.indices) u2 = TimeFunction(name='u2', grid=grid, save=nt) assert(time in u2.indices) factor = 4 ...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_no_index(self): """Test behaviour when the ConditionalDimension is used as a symbol in an expression.""" nt = 19 grid = Grid(shape=(11, 11)) time = grid.time_dim u = TimeFunction(name='u', grid=grid) assert(grid.stepping_dim in u.indices) v = Fu...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_symbolic_factor(self): """ Test ConditionalDimension with symbolic factor (provided as a Constant). """ g = Grid(shape=(4, 4, 4)) u = TimeFunction(name='u', grid=g, time_order=0) fact = Constant(name='fact', dtype=np.int32, value=4) tsub = ConditionalDi...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_grouping(self): """ Test that Clusters over the same set of ConditionalDimensions fall within the same Conditional. This is a follow up to issue #1610. """ grid = Grid(shape=(10, 10)) time = grid.time_dim cond = ConditionalDimension(name='cond', parent=ti...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_expr_like_lowering(self): """ Test the lowering of an expr-like ConditionalDimension's condition. This test makes an Operator that should indexify and lower the condition passed in the Conditional Dimension """ grid = Grid(shape=(3, 3)) g1 = Function(nam...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_relational_classes(self, setup_rel, rhs, c1, c2, c3, c4): """ Test ConditionalDimension using conditions based on Relations over SubDomains. """ class InnerDomain(SubDomain): name = 'inner' def define(self, dimensions): return {d: ('midd...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_no_fusion_simple(self): """ If ConditionalDimensions are present, then Clusters must not be fused so that ultimately Eqs get scheduled to different loop nests. """ grid = Grid(shape=(4, 4, 4)) time = grid.time_dim f = TimeFunction(name='f', grid=grid) ...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_no_fusion_convoluted(self): """ Conceptually like `test_no_fusion_simple`, but with more expressions and non-trivial data flow. """ grid = Grid(shape=(4, 4, 4)) time = grid.time_dim f = TimeFunction(name='f', grid=grid) g = Function(name='g', gri...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def test_topofusion_w_subdims_conddims(self): """ Check that topological fusion works across guarded Clusters over different iteration spaces and in presence of anti-dependences. This test uses both SubDimensions (via SubDomains) and ConditionalDimensions. """ grid = Gri...
opesci/devito
[ 428, 198, 428, 105, 1458759589 ]
def __init__(self,domain='rds.aliyuncs.com',port=80): RestApi.__init__(self,domain, port) self.AccountName = None self.DBInstanceId = None self.resourceOwnerAccount = None
francisar/rds_manager
[ 11, 11, 11, 1, 1448422655 ]
def __init__(self, size): self._data = np.zeros((size,)) self._capacity = size self._size = 0
evenmarbles/mlpy
[ 7, 2, 7, 2, 1439328535 ]
def __getitem__(self, index): """Get the value at the given index. Parameters ---------- index : int The index into the array. """ return self._data[index]
evenmarbles/mlpy
[ 7, 2, 7, 2, 1439328535 ]
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
evenmarbles/mlpy
[ 7, 2, 7, 2, 1439328535 ]
def __init__(self, x=0.0, y=0.0, z=0.0): self.x = x self.y = y self.z = z
evenmarbles/mlpy
[ 7, 2, 7, 2, 1439328535 ]
def __init__(self, x=0.0, y=0.0, z=0.0): super(Vector3D, self).__init__(x, y, z)
evenmarbles/mlpy
[ 7, 2, 7, 2, 1439328535 ]
def __init__(self): self._queue = []
evenmarbles/mlpy
[ 7, 2, 7, 2, 1439328535 ]
def __contains__(self, item): try: self._queue.index(item) return True except Exception: return False
evenmarbles/mlpy
[ 7, 2, 7, 2, 1439328535 ]
def __str__(self): return '[' + ', '.join('{}'.format(el) for el in self._queue) + ']'
evenmarbles/mlpy
[ 7, 2, 7, 2, 1439328535 ]
def push(self, item): """Push a new element on the queue Parameters ---------- item : The element to push on the queue """ raise NotImplementedError
evenmarbles/mlpy
[ 7, 2, 7, 2, 1439328535 ]
def pop(self): """Pop an element from the queue.""" raise NotImplementedError
evenmarbles/mlpy
[ 7, 2, 7, 2, 1439328535 ]
def extend(self, items): """Extend the queue by a number of elements. Parameters ---------- items : list A list of items. """ for item in items: self.push(item)
evenmarbles/mlpy
[ 7, 2, 7, 2, 1439328535 ]
def remove(self, item): """Remove an element from the queue. Parameters ---------- item : The element to remove. """ self._queue.remove(item)
evenmarbles/mlpy
[ 7, 2, 7, 2, 1439328535 ]
def __init__(self): super(FIFOQueue, self).__init__()
evenmarbles/mlpy
[ 7, 2, 7, 2, 1439328535 ]
def pop(self): """Return the element at the front of the queue. Returns ------- The first element in the queue. """ return self._queue.pop(0)
evenmarbles/mlpy
[ 7, 2, 7, 2, 1439328535 ]
def __init__(self, func=lambda x: x): super(PriorityQueue, self).__init__() self.func = func
evenmarbles/mlpy
[ 7, 2, 7, 2, 1439328535 ]
def __str__(self): return '[' + ', '.join('({},{})'.format(*el) for el in self._queue) + ']'
evenmarbles/mlpy
[ 7, 2, 7, 2, 1439328535 ]
def pop(self): """Get the element with the highest priority. Get the element with the highest priority (i.e., smallest value). Returns ------- The element with the highest priority. """ return heapq.heappop(self._queue)[1]
evenmarbles/mlpy
[ 7, 2, 7, 2, 1439328535 ]
def __init__(self, plotly_name="textfont", parent_name="scattersmith", **kwargs): super(TextfontValidator, self).__init__( plotly_name=plotly_name, parent_name=parent_name, data_class_str=kwargs.pop("data_class_str", "Textfont"), data_docs=kwargs.pop( ...
plotly/plotly.py
[ 13052, 2308, 13052, 1319, 1385013188 ]
def __init__(self, json_dict=None): self.id = None # (Integer) self.company = None # *(CompanyReference) self.contact = None # (ContactReference) self.phone = None # (String) self.phoneExt = None # (String) self.email = None # (String) self.site = Non...
joshuamsmith/ConnectPyse
[ 23, 14, 23, 7, 1479865554 ]
def __init__( self,
JamesJeffryes/MINE-Database
[ 13, 7, 13, 4, 1479244917 ]
def load_mongo(self, mongo_uri: Union[str, None] = None): if mongo_uri: self.mongo_uri = mongo_uri self.client = MongoClient(mongo_uri) else: self.mongo_uri = "localhost:27017" self.client = MongoClient() self._core = self.client["core"]
JamesJeffryes/MINE-Database
[ 13, 7, 13, 4, 1479244917 ]
def _eq_loaded(self): if self.lc: return True else: print("Load eQulibrator local cache.") return False
JamesJeffryes/MINE-Database
[ 13, 7, 13, 4, 1479244917 ]
def load_thermo_from_postgres( self, postgres_uri: str = "postgresql:///eq_compounds"
JamesJeffryes/MINE-Database
[ 13, 7, 13, 4, 1479244917 ]
def load_thermo_from_sqlite( self, sqlite_filename: str = "compounds.sqlite"
JamesJeffryes/MINE-Database
[ 13, 7, 13, 4, 1479244917 ]
def get_eQ_compound_from_cid( self, c_id: str, pickaxe: Pickaxe = None, db_name: str = None
JamesJeffryes/MINE-Database
[ 13, 7, 13, 4, 1479244917 ]
def standard_dg_formation_from_cid( self, c_id: str, pickaxe: Pickaxe = None, db_name: str = None
JamesJeffryes/MINE-Database
[ 13, 7, 13, 4, 1479244917 ]
def get_eQ_reaction_from_rid( self, r_id: str, pickaxe: Pickaxe = None, db_name: str = None
JamesJeffryes/MINE-Database
[ 13, 7, 13, 4, 1479244917 ]
def physiological_dg_prime_from_rid( self, r_id: str, pickaxe: Pickaxe = None, db_name: str = None
JamesJeffryes/MINE-Database
[ 13, 7, 13, 4, 1479244917 ]
def standard_dg_prime_from_rid( self, r_id: str, pickaxe: Pickaxe = None, db_name: str = None
JamesJeffryes/MINE-Database
[ 13, 7, 13, 4, 1479244917 ]
def dg_prime_from_rid( self, r_id: str, pickaxe: Pickaxe = None, db_name: str = None, p_h: Q_ = default_physiological_p_h, p_mg: Q_ = default_physiological_p_mg, ionic_strength: Q_ = default_physiological_ionic_strength,
JamesJeffryes/MINE-Database
[ 13, 7, 13, 4, 1479244917 ]
def __init__( self, *, sampling_strategy="auto", random_state=None, shrinkage=None,
scikit-learn-contrib/imbalanced-learn
[ 6265, 1230, 6265, 56, 1408165706 ]
def _check_X_y(self, X, y): y, binarize_y = check_target_type(y, indicate_one_vs_all=True) X, y = self._validate_data( X, y, reset=True, accept_sparse=["csr", "csc"], dtype=None, force_all_finite=False, ) return X, y...
scikit-learn-contrib/imbalanced-learn
[ 6265, 1230, 6265, 56, 1408165706 ]
def setUp (self): utils.mktemp () for filename in self.filenames: with open (os.path.join (utils.TEST_ROOT, filename), "w"): pass
operepo/ope
[ 10, 8, 10, 78, 1499751734 ]
def test_glob (self): import glob pattern = os.path.join (utils.TEST_ROOT, "*") self.assertEquals (list (fs.glob (pattern)), glob.glob (pattern))
operepo/ope
[ 10, 8, 10, 78, 1499751734 ]
def canonicalMachineName(machine=''): aliases = {'nstxu': ['nstx', 'nstxu', 'nstx-u'], 'diiid': ['diiid', 'diii-d', 'd3d'], 'cmod': ['cmod', 'c-mod']} for key, value in aliases.items(): if machine.lower() in value: return key # invalid machine name raise...
Fusion-Data-Platform/fdp
[ 11, 5, 11, 6, 1449233589 ]
def __init__(self, manager, task_id, sub_ids=None, dry_run=False, resubmit=False): self.__manager = manager self.__task = self.__manager.load_task(task_id) self.__sub_ids = sub_ids self.__dry_run = dry_run self.__resubmit = resubmit self.__logger = logging.getLogger('JSUB') if self.__sub_ids==None: se...
jsubpy/jsub
[ 2, 2, 2, 1, 1416218010 ]
def handle(self): run_root = self.__backend_mgr.get_run_root(self.__task.data['backend'], self.__task.data['id']) main_root = os.path.join(run_root, 'main') safe_rmdir(main_root) safe_mkdir(main_root) self.__create_input(main_root) self.__create_context(main_root) self.__create_action(main_root) self...
jsubpy/jsub
[ 2, 2, 2, 1, 1416218010 ]
def __create_context(self, main_root): context_dir = os.path.join(main_root, 'context') safe_mkdir(context_dir) action_default = {} for unit, param in self.__task.data['workflow'].items(): action_default[unit] = self.__action_mgr.default_config(param['type']) navigators = self.__config_mgr.navigator() ...
jsubpy/jsub
[ 2, 2, 2, 1, 1416218010 ]
def __create_navigator(self, main_root): navigator_dir = os.path.join(main_root, 'navigator') safe_mkdir(navigator_dir) navigators = self.__config_mgr.navigator() self.__navigator_mgr.create_navigators(navigators, navigator_dir)
jsubpy/jsub
[ 2, 2, 2, 1, 1416218010 ]
def __create_launcher(self, run_root): launcher = self.__task.data['backend']['launcher'] return self.__launcher_mgr.create_launcher(launcher, run_root)
jsubpy/jsub
[ 2, 2, 2, 1, 1416218010 ]
def _no_ssl_required_on_debug(app, **kwargs): if app.debug or app.testing: os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '1'
indico/indico
[ 1446, 358, 1446, 649, 1311774990 ]
def normalized_cross(a, b): """ Returns the normalized cross product between vectors. Uses numpy.cross().
endarthur/autti
[ 1, 2, 1, 8, 1491768157 ]
def general_plane_intersection(n_a, da, n_b, db): """ Returns a point and direction vector for the line of intersection of two planes in space, or None if planes are parallel.
endarthur/autti
[ 1, 2, 1, 8, 1491768157 ]
def small_circle_intersection(axis_a, angle_a, axis_b, angle_b): """ Finds the intersection between two small-circles returning zero, one or two solutions as tuple.
endarthur/autti
[ 1, 2, 1, 8, 1491768157 ]
def build_rotation_matrix(azim, plng, rake): """ Returns the rotation matrix that rotates the North vector to the line given by Azimuth and Plunge and East and Up vectors are rotate clock-wise by Rake around the rotated North vector.
endarthur/autti
[ 1, 2, 1, 8, 1491768157 ]
def adjust_lines_to_planes(lines, planes): """ Project each given line to it's respective plane. Returns the projected lines as a new LineSet and the angle (in radians) between each line and plane prior to projection.
endarthur/autti
[ 1, 2, 1, 8, 1491768157 ]
def graphviz_setup(gviz_path): os.environ['PATH'] = gviz_path + ";" + os.environ['PATH']
geographika/mappyfile
[ 54, 19, 54, 16, 1484063271 ]
def add_children(graph, parent_id, d, level=0): blue = "#6b6bd1" white = "#fdfefd" green = "#33a333" colours = [blue, white, green] * 3 for class_, children in d.items(): colour = colours[level] child_label = class_ child_id = parent_id + "_" + class_ add_child(grap...
geographika/mappyfile
[ 54, 19, 54, 16, 1484063271 ]
def main(gviz_path, layer_only=False): graphviz_setup(gviz_path) graph = pydot.Dot(graph_type='digraph', rankdir="TB") layer_children = { 'CLASS': { 'LABEL': {'STYLE': {}}, 'CONNECTIONOPTIONS': {}, 'LEADER': {'STYLE': {}}, 'STYLE'...
geographika/mappyfile
[ 54, 19, 54, 16, 1484063271 ]
def playlist_handler(playlist_name, playlist_description, playlist_tracks): # skip empty and no-name playlists if not playlist_name: return if len(playlist_tracks) == 0: return # setup output files playlist_name = playlist_name.replace('/', '') open_log(os.path.join(output_dir,playlist_name+u'....
soulfx/gmusic-playlist
[ 159, 57, 159, 25, 1401254477 ]
def __init__( self, plotly_name="showexponent", parent_name="scatterpolar.marker.colorbar", **kwargs
plotly/plotly.py
[ 13052, 2308, 13052, 1319, 1385013188 ]
def __init__(self, query, explanation): if isinstance(query, list): query = " ".join(query) message = f"'{query}': {explanation}" super().__init__(message)
beetbox/beets
[ 11484, 1774, 11484, 509, 1281395840 ]
def __init__(self, what, expected, detail=None): message = f"'{what}' is not {expected}" if detail: message = f"{message}: {detail}" super().__init__(message)
beetbox/beets
[ 11484, 1774, 11484, 509, 1281395840 ]
def clause(self): """Generate an SQLite expression implementing the query. Return (clause, subvals) where clause is a valid sqlite WHERE clause implementing the query and subvals is a list of items to be substituted for ?s in the clause. """ return None, ()
beetbox/beets
[ 11484, 1774, 11484, 509, 1281395840 ]
def __repr__(self): return f"{self.__class__.__name__}()"
beetbox/beets
[ 11484, 1774, 11484, 509, 1281395840 ]
def __hash__(self): return 0
beetbox/beets
[ 11484, 1774, 11484, 509, 1281395840 ]
def __init__(self, field, pattern, fast=True): self.field = field self.pattern = pattern self.fast = fast
beetbox/beets
[ 11484, 1774, 11484, 509, 1281395840 ]
def clause(self): if self.fast: return self.col_clause() else: # Matching a flexattr. This is a slow query. return None, ()
beetbox/beets
[ 11484, 1774, 11484, 509, 1281395840 ]
def value_match(cls, pattern, value): """Determine whether the value matches the pattern. Both arguments are strings. """ raise NotImplementedError()
beetbox/beets
[ 11484, 1774, 11484, 509, 1281395840 ]
def __repr__(self): return ("{0.__class__.__name__}({0.field!r}, {0.pattern!r}, " "{0.fast})".format(self))
beetbox/beets
[ 11484, 1774, 11484, 509, 1281395840 ]
def __hash__(self): return hash((self.field, hash(self.pattern)))
beetbox/beets
[ 11484, 1774, 11484, 509, 1281395840 ]
def col_clause(self): return self.field + " = ?", [self.pattern]
beetbox/beets
[ 11484, 1774, 11484, 509, 1281395840 ]
def value_match(cls, pattern, value): return pattern == value
beetbox/beets
[ 11484, 1774, 11484, 509, 1281395840 ]
def __init__(self, field, fast=True): super().__init__(field, None, fast)
beetbox/beets
[ 11484, 1774, 11484, 509, 1281395840 ]
def match(self, item): return item.get(self.field) is None
beetbox/beets
[ 11484, 1774, 11484, 509, 1281395840 ]
def value_match(cls, pattern, value): """Determine whether the value matches the pattern. The value may have any type. """ return cls.string_match(pattern, util.as_string(value))
beetbox/beets
[ 11484, 1774, 11484, 509, 1281395840 ]
def string_match(cls, pattern, value): """Determine whether the value matches the pattern. Both arguments are strings. Subclasses implement this method. """ raise NotImplementedError()
beetbox/beets
[ 11484, 1774, 11484, 509, 1281395840 ]
def col_clause(self): search = (self.pattern .replace('\\', '\\\\') .replace('%', '\\%') .replace('_', '\\_')) clause = self.field + " like ? escape '\\'" subvals = [search] return clause, subvals
beetbox/beets
[ 11484, 1774, 11484, 509, 1281395840 ]
def string_match(cls, pattern, value): return pattern.lower() == value.lower()
beetbox/beets
[ 11484, 1774, 11484, 509, 1281395840 ]
def col_clause(self): pattern = (self.pattern .replace('\\', '\\\\') .replace('%', '\\%') .replace('_', '\\_')) search = '%' + pattern + '%' clause = self.field + " like ? escape '\\'" subvals = [search] return clause, subv...
beetbox/beets
[ 11484, 1774, 11484, 509, 1281395840 ]