function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def __init__(self): vstruct.VStruct.__init__(self) self.DisableAffinity = v_uint32()
atlas0fd00m/CanCat
[ 169, 34, 169, 6, 1428517921 ]
def __init__(self): vstruct.VStruct.__init__(self) self.ListSize = v_uint32() self.InterfaceType = v_uint32() self.BusNumber = v_uint32() self.SlotNumber = v_uint32() self.Reserved = vstruct.VArray([ v_uint32() for i in xrange(3) ]) self.AlternativeLists = v_uint3...
atlas0fd00m/CanCat
[ 169, 34, 169, 6, 1428517921 ]
def bin2asc(data: bytes): """ Encode binary data as ascii. If it is a large data set, then use a list of hex characters. """ if len(data) > 30: res = [] for part in chunks(data): res.append(binascii.hexlify(part).decode("ascii")) return res else: retur...
windelbouwman/ppci-mirror
[ 280, 28, 280, 61, 1480248069 ]
def setUp(self): self.set_filename('chart_format23.xlsx')
jmcnamara/XlsxWriter
[ 3172, 594, 3172, 18, 1357261626 ]
def test_lipop1(self): if not self.params['lipop1_bin']: self.params['lipop1_bin'] = 'LipoP' lipop1.annotate(self.params, self.proteins) self.expected_output = { u'SPy_0252': True, u'SPy_2077': False, u'SPy_0317': True, u'tr|Q9HYX8': ...
boscoh/inmembrane
[ 9, 9, 9, 3, 1320018818 ]
def contact(self, sponsor): # comma-separated emails in mailto: should work: https://www.ietf.org/rfc/rfc2368.txt # but the commas need to be URL-quoted return format_html( u'<a href="mailto:{}">{}</a>', quote(u','.join(sponsor.contact_emails)), sponsor.contac...
PyCon/pycon
[ 156, 98, 156, 58, 1370354058 ]
def get_form(self, *args, **kwargs): # @@@ kinda ugly but using choices= on NullBooleanField is broken form = super(SponsorAdmin, self).get_form(*args, **kwargs) form.base_fields["active"].widget.choices = [ (u"1", _(u"unreviewed")), (u"2", _(u"approved")), (...
PyCon/pycon
[ 156, 98, 156, 58, 1370354058 ]
def func_generator(ben): def column_func(obj): return getattr(obj, ben['field_name']) column_func.short_description = ben['column_title'] column_func.boolean = True column_func.admin_order_field = ben['field_name'] return column_func
PyCon/pycon
[ 156, 98, 156, 58, 1370354058 ]
def save_related(self, request, form, formsets, change): super(SponsorAdmin, self).save_related(request, form, formsets, change) obj = form.instance obj.save()
PyCon/pycon
[ 156, 98, 156, 58, 1370354058 ]
def levels(self, benefit): return u", ".join(l.level.name for l in benefit.benefit_levels.all())
PyCon/pycon
[ 156, 98, 156, 58, 1370354058 ]
def benefits(self, obj): return ', '.join(obj.benefit_levels.values_list('benefit__name', flat=True))
PyCon/pycon
[ 156, 98, 156, 58, 1370354058 ]
def benefits(self, obj): return ', '.join(obj.benefit_packages.values_list('benefit__name', flat=True))
PyCon/pycon
[ 156, 98, 156, 58, 1370354058 ]
def test_list_several(monkeypatch): monkeypatch.setenv("foo", "bar,baz,barf") assert parsenvy.list("foo") == ["bar", "baz", "barf"]
nkantar/Parsenvy
[ 35, 9, 35, 11, 1487911029 ]
def test_list_one_comma(monkeypatch): monkeypatch.setenv("foo", ",") assert parsenvy.list("foo") == ["", ""]
nkantar/Parsenvy
[ 35, 9, 35, 11, 1487911029 ]
def __init__(self): self.reporters = []
drallensmith/neat-python
[ 32, 10, 32, 3, 1498176757 ]
def remove(self, reporter): self.reporters.remove(reporter)
drallensmith/neat-python
[ 32, 10, 32, 3, 1498176757 ]
def end_generation(self, config, population, species_set): for r in self.reporters: r.end_generation(config, population, species_set)
drallensmith/neat-python
[ 32, 10, 32, 3, 1498176757 ]
def post_reproduction(self, config, population, species): for r in self.reporters: r.post_reproduction(config, population, species)
drallensmith/neat-python
[ 32, 10, 32, 3, 1498176757 ]
def found_solution(self, config, generation, best): for r in self.reporters: r.found_solution(config, generation, best)
drallensmith/neat-python
[ 32, 10, 32, 3, 1498176757 ]
def info(self, msg): for r in self.reporters: r.info(msg)
drallensmith/neat-python
[ 32, 10, 32, 3, 1498176757 ]
def start_generation(self, generation): pass
drallensmith/neat-python
[ 32, 10, 32, 3, 1498176757 ]
def post_evaluate(self, config, population, species, best_genome): pass
drallensmith/neat-python
[ 32, 10, 32, 3, 1498176757 ]
def complete_extinction(self): pass
drallensmith/neat-python
[ 32, 10, 32, 3, 1498176757 ]
def species_stagnant(self, sid, species): pass
drallensmith/neat-python
[ 32, 10, 32, 3, 1498176757 ]
def __init__(self, show_species_detail): self.show_species_detail = show_species_detail self.generation = None self.generation_start_time = None self.generation_times = [] self.num_extinctions = 0
drallensmith/neat-python
[ 32, 10, 32, 3, 1498176757 ]
def end_generation(self, config, population, species_set): ng = len(population) ns = len(species_set.species) if self.show_species_detail: print('Population of {0:d} members in {1:d} species:'.format(ng, ns)) sids = list(iterkeys(species_set.species)) sids.sor...
drallensmith/neat-python
[ 32, 10, 32, 3, 1498176757 ]
def complete_extinction(self): self.num_extinctions += 1 print('All species extinct.')
drallensmith/neat-python
[ 32, 10, 32, 3, 1498176757 ]
def species_stagnant(self, sid, species): if self.show_species_detail: print("\nSpecies {0} with {1} members is stagnated: removing it".format(sid, len(species.members)))
drallensmith/neat-python
[ 32, 10, 32, 3, 1498176757 ]
def point_in_hull(point, hull, tolerance=1e-12): return all((np.dot(eq[:-1], point) + eq[-1] <= tolerance) for eq in hull.equations)
ethz-asl/segmatch
[ 972, 390, 972, 67, 1474386165 ]
def time_to_hms(delta): ''' Convert some time in seconds to a tuple of (hours, minutes, seconds). ''' m, s = divmod(delta, 60) h, m = divmod(m, 60) return (h, m, s)
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def check_foreground(): ''' function that returns True if the process executing this module is in foreground. If in background, this module won't print to stderr/stdout. ''' if(not platform.system().lower().startswith('linux')): return True try: if(os.getpgrp() ==...
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def not_zero(i): ''' function that returns True if i is not zero. the funciton is equivalent to lambda i: i!=0 ''' return i != 0
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def __init__( self, command, dependencies=[], targets=[], cpu=1, name='Anonymous_Task', stderr=None, stdout=None, error_check=not_zero, max_wall_time=float('inf')): ''' The __init__ for the Task object has nine parameters described below: command - a string represent...
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def checkDependencies(self): ''' Method will check all dependencies of this object. self.dependencies is a list containing Task objects, Supervisor objects, or unit functions. A call to self.checkDependencies will return True if and only if all Task objects in dependencie...
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def start(self): ''' Method used to start the execution of this Task. self.command will be executed using the subprocess.Popen constructor with shell=True. ''' if(self.stderr is not None): err = open(self.stderr, 'w', 1) err.write(str(self.command) + '\n...
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def finished(self): ''' A method that will check if this Task has finished executing, and check to ensure that execution was succesfull. If this Task hasn't been started and hasn't been skipped, it will return false. Otherwise, this method will query the subproccess creat...
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def run(self, delay=1): ''' A convenience method that alllows for the execution of a task serially. This task will be started by a call to self.start(), then every delay seconds, a call to self.finished() will check to see if the command has finished executing. self.run()...
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def killRun(self): ''' Calling this method will safely stop the execution of this task. ''' try: self.process.kill() except: pass self.close_files() self.rename_targets()
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def close_files(self): ''' This method is responsible for closing all log files opened by a call to self.start. ''' for f in self.opened_files: f.close() self.opened_files = []
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def rename_targets(self): ''' This method will check for each t in self.targets, if t exists. If it does, t will be renamed to be t+".partial". This method is called whenever this task halts unexpectedly or in error. ''' for f in self.targets: if(os.path...
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def skipable(self): ''' Method uses by Supervisor objects to determine if this task needs to be executed. This method will return True if this task is skippable and so does not need to be executed. A task is skippable if and only if all dependencies are satisfied, all dep...
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def __str__(self): return self.name
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def __repr__(self): return self.__str__()
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def __init__( self, tasks=[], dependencies=[], cpu=float('inf'), name='Supervisor', delay=1, force_run=False, email=None, email_interval=30, log=None): ''' the __init__ for the Superviosr object has nine paramters described below. tasks - A list of Task ...
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def run(self): ''' Use this funciton to get a Supervisor to run all tasks that it is managing. Execution occurs inside of a large loop with multiple steps. First, this supervisor checks all running tasks to see if they are finished. Those tasks that are finished are handl...
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def __removeTaskPath__(self, task): ''' Helper function that removes tasks that can no longer be executed from the sueprvisors list of tasks that need o be executed. Basically, anything down stream of task is removed. ''' flag = True removed = set([task]) ...
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def log(self, message): ''' Convienvince funciton that allows for the SUpervisor to write messages to stdout and the supervisors log file ''' self.log_str += message self.log_file.write(message) if(check_foreground()): print(message) if(tim...
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def finished(self): ''' A method called from within run. If a task is dependant on a this supervisor, then this supervisor will query all of its tasks to determine if the supervisor is finished executing. A Supervisor is finished if and only if all of the Supervisor's tas...
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def skipable(self): ''' A method called from within run. If a task is dependant on a this supervisor, then this supervisor will query all of its tasks to determine if the supervisor doesn't need to be executed. A Supervisor is skippable if and only if all of the Superviso...
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def send_email(self, message, subject=''): ''' A convienince function that allows for the sending of emails to the Supervisor's self.email adress. If self.email is none, the method does nothing. Otherwise, Supervisor will start a subprocess that sends the email with the s...
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def killRun(self): ''' safely stops all running tasks and halts the run. ''' for t in self.tasks_running: t.killRun() self.running = []
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def add_task(self, task): ''' Allows for a task or supervisor to be added to this supervisor. A supervisor is added to this supervisor by adding all tasks that the supervisor managed. ''' if(isinstance(task, Supervisor)): for t in task.tasks: ...
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def __str__(self): return self.name
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def __repr__(self): return self.__str__()
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def t2_dep(): t2.command = 'python ..\\..\\test.py 8' return True
bluegenes/MakeMyTranscriptome
[ 9, 5, 9, 10, 1425336439 ]
def extractChuunihimeWordpressCom(item): ''' Parser for 'chuunihime.wordpress.com' ''' vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title']) if not (chp or vol) or "preview" in item['title'].lower(): return None tagmap = [ ('PRC', 'PRC', 'translated'), ('Loit...
fake-name/ReadableWebProxy
[ 191, 16, 191, 3, 1437712243 ]
def _calculate_divisions( df, partition_col, repartition, npartitions, upsample=1.0, partition_size=128e6,
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def sort_values( df, by, npartitions=None, ascending=True, na_position="last", upsample=1.0, partition_size=128e6, sort_function=None, sort_function_kwargs=None, **kwargs,
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def set_index( df, index, npartitions=None, shuffle=None, compute=False, drop=True, upsample=1.0, divisions=None, partition_size=128e6, **kwargs,
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def remove_nans(divisions): """Remove nans from divisions These sometime pop up when we call min/max on an empty partition Examples -------- >>> remove_nans((np.nan, 1, 2)) [1, 1, 2] >>> remove_nans((1, np.nan, 2)) [1, 2, 2] >>> remove_nans((1, 2, np.nan)) [1, 2, 2] """ ...
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def shuffle( df, index, shuffle=None, npartitions=None, max_branch=32, ignore_index=False, compute=None,
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def rearrange_by_divisions( df, column, divisions, max_branch=None, shuffle=None, ascending=True, na_position="last", duplicates=True,
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def rearrange_by_column( df, col, npartitions=None, max_branch=None, shuffle=None, compute=None, ignore_index=False,
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def __init__(self, buffer=True, tempdir=None): self.tempdir = tempdir or config.get("temporary_directory", None) self.buffer = buffer self.compression = config.get("dataframe.shuffle-compression", None)
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def __call__(self, *args, **kwargs): import partd path = tempfile.mkdtemp(suffix=".partd", dir=self.tempdir) try: partd_compression = ( getattr(partd.compressed, self.compression) if self.compression else None ) ex...
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def _noop(x, cleanup_token): """ A task that does nothing. """ return x
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def partitioning_index(df, npartitions): """ Computes a deterministic index mapping each record to a partition. Identical rows are mapped to the same partition. Parameters ---------- df : DataFrame/Series/Index npartitions : int The number of partitions to group into. Returns ...
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def cleanup_partd_files(p, keys): """ Cleanup the files in a partd.File dataset. Parameters ---------- p : partd.Interface File or Encode wrapping a file should be OK. keys: List Just for scheduling purposes, not actually used. """ import partd if isinstance(p, part...
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def set_partitions_pre(s, divisions, ascending=True, na_position="last"): try: if ascending: partitions = divisions.searchsorted(s, side="right") - 1 else: partitions = len(divisions) - divisions.searchsorted(s, side="right") - 1 except TypeError: # `searchsorted`...
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def shuffle_group_get(g_head, i): g, head = g_head if i in g: return g[i] else: return head
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def ensure_cleanup_on_exception(p): """Ensure a partd.File is cleaned up. We have several tasks referring to a `partd.File` instance. We want to ensure that the file is cleaned up if and only if there's an exception in the tasks using the `partd.File`. """ try: yield except Exceptio...
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def set_index_post_scalar(df, index_name, drop, column_dtype): df2 = df.drop("_partitions", axis=1).set_index(index_name, drop=drop) df2.columns = df2.columns.astype(column_dtype) return df2
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def drop_overlap(df, index): return df.drop(index) if index in df.index else df
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def fix_overlap(ddf, overlap): """Ensures that the upper bound on each partition of ddf (except the last) is exclusive""" name = "fix-overlap-" + tokenize(ddf, overlap) n = len(ddf.divisions) - 1 dsk = {(name, i): (ddf._name, i) for i in range(n)} frames = [] for i in overlap: # `frame...
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def sync_user_profile(sender, instance, created, **kwargs): # pylint: disable=unused-argument """ Signal handler create/update a DiscussionUser every time a profile is created/updated """ if not settings.FEATURES.get('OPEN_DISCUSSIONS_USER_SYNC', False): return transaction.on_commit(lambda:...
mitodl/micromasters
[ 28, 16, 28, 318, 1456876397 ]
def add_staff_as_moderator(sender, instance, created, **kwargs): # pylint: disable=unused-argument """ Signal handler add user as moderator when his staff role on program is added """ if not settings.FEATURES.get('OPEN_DISCUSSIONS_USER_SYNC', False): return if instance.role not in Role.per...
mitodl/micromasters
[ 28, 16, 28, 318, 1456876397 ]
def is_done(self): from os.path import exists if self.options['files'].is_dependency(): return False for f in self.options["files"].raw(): if exists(f): return False return True
thasso/pyjip
[ 19, 8, 19, 18, 1375120760 ]
def get_command(self): return "bash", "for file in ${files}; do rm -f $file; done"
thasso/pyjip
[ 19, 8, 19, 18, 1375120760 ]
def print_demo_lengths(demos): num_frames_per_episode = [len(demo[2]) for demo in demos] logger.info('Demo length: {:.3f}+-{:.3f}'.format( np.mean(num_frames_per_episode), np.std(num_frames_per_episode)))
mila-iqia/babyai
[ 575, 129, 575, 9, 1538503104 ]
def generate_demos_cluster(): demos_per_job = args.episodes // args.jobs demos_path = utils.get_demos_path(args.demos, args.env, 'agent') job_demo_names = [os.path.realpath(demos_path + '.shard{}'.format(i)) for i in range(args.jobs)] for demo_name in job_demo_names: job_dem...
mila-iqia/babyai
[ 575, 129, 575, 9, 1538503104 ]
def test_simple(self): f = mod.get_function('simple') result = interp.run(f, args=[10.0]) assert result == 100.0, result
flypy/pykit
[ 26, 5, 26, 1, 1371216754 ]
def test_exceptions(self): f = mod.get_function('raise') try: result = interp.run(f) except interp.UncaughtException as e: exc, = e.args assert isinstance(exc, TypeError), exc else: assert False, result
flypy/pykit
[ 26, 5, 26, 1, 1371216754 ]
def _meta_from_array(x, columns=None, index=None, meta=None): """Create empty DataFrame or Series which has correct dtype""" if x.ndim > 2: raise ValueError( "from_array does not input more than 2D array, got" " array with shape %r" % (x.shape,) ) if index is not No...
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def from_pandas(data, npartitions=None, chunksize=None, sort=True, name=None): """ Construct a Dask DataFrame from a Pandas DataFrame This splits an in-memory Pandas dataframe into several parts and constructs a dask.dataframe from those parts on which Dask.dataframe can operate in parallel. By de...
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def dataframe_from_ctable(x, slc, columns=None, categories=None, lock=lock): """Get DataFrame from bcolz.ctable Parameters ---------- x: bcolz.ctable slc: slice columns: list of column names or None >>> import bcolz >>> x = bcolz.ctable([[1, 2, 3, 4], [10, 20, 30, 40]], names=['a', 'b'...
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def _link(token, result): """A dummy function to link results together in a graph We use this to enforce an artificial sequential ordering on tasks that don't explicitly pass around a shared resource """ return None
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def to_bag(df, index=False, format="tuple"): """Create Dask Bag from a Dask DataFrame Parameters ---------- index : bool, optional If True, the elements are tuples of ``(index, value)``, otherwise they're just the ``value``. Default is False. format : {"tuple", "dict"},optional ...
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def from_delayed( dfs, meta=None, divisions=None, prefix="from-delayed", verify_meta=True
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def sorted_division_locations(seq, npartitions=None, chunksize=None): """Find division locations and values in sorted list Examples -------- >>> L = ['A', 'B', 'C', 'D', 'E', 'F'] >>> sorted_division_locations(L, chunksize=2) (['A', 'C', 'E', 'F'], [0, 2, 4, 6]) >>> sorted_division_locati...
blaze/dask
[ 10792, 1599, 10792, 913, 1420397400 ]
def _render_plugin(plugin, context, renderer=None): if renderer: content = renderer.render_plugin( instance=plugin, context=context, editable=False, ) else: content = plugin.render_plugin(context) return content
aldryn/aldryn-search
[ 48, 71, 48, 25, 1373443182 ]
def get_plugin_index_data(base_plugin, request): text_bits = [] instance, plugin_type = base_plugin.get_plugin_instance() if instance is None or instance.plugin_type in EXCLUDED_PLUGINS: # this is an empty plugin or excluded from search return text_bits search_fields = getattr(instanc...
aldryn/aldryn-search
[ 48, 71, 48, 25, 1373443182 ]
def main(): for model_name, ( select_config, feature_filename, ) in config_feature_file_pairs.items(): print("running {} to create model files".format(select_config)) # have to put tmp_output_dir into yaml file select_config = TEST_CONFIGS / select_config feature_...
NickleDave/hybrid-vocal-classifier
[ 23, 8, 23, 44, 1483596187 ]
def data(N=100, period=1, theta=[10, 2, 3], dy=1, rseed=0): """Generate some data for testing""" rng = np.random.RandomState(rseed) t = 20 * period * rng.rand(N) omega = 2 * np.pi / period y = theta[0] + theta[1] * np.sin(omega * t) + theta[2] * np.cos(omega * t) dy = dy * (0.5 + rng.rand(N)) ...
jakevdp/lombscargle
[ 4, 2, 4, 2, 1458772994 ]
def test_output_shapes(method, shape, data): t, y, dy = data freq = np.asarray(np.random.rand(*shape)) freq.flat = np.arange(1, freq.size + 1) PLS = lombscargle(t, y, frequency=freq, fit_bias=False, method=method) assert_equal(PLS.shape, shape)
jakevdp/lombscargle
[ 4, 2, 4, 2, 1458772994 ]
def test_units_match(method, t_unit, frequency_unit, y_unit, data): t, y, dy = data dy = dy.mean() # scipy only supports constant errors t = t * t_unit y = y * y_unit dy = dy * y_unit frequency = np.linspace(0.5, 1.5, 10) * frequency_unit PLS = lombscargle(t, y, frequency=frequency, ...
jakevdp/lombscargle
[ 4, 2, 4, 2, 1458772994 ]
def test_units_mismatch(method, data): t, y, dy = data dy = dy.mean() # scipy only supports constant errors t = t * units.second y = y * units.mag frequency = np.linspace(0.5, 1.5, 10) # this should fail because frequency and 1/t unitsdo not match with pytest.raises(ValueError) as err: ...
jakevdp/lombscargle
[ 4, 2, 4, 2, 1458772994 ]
def test_common_interface(method, center_data, freq, data): t, y, dy = data if freq is None: freq_expected = LombScargle(t, y, dy).autofrequency(t) else: freq_expected = freq expected_PLS = lombscargle_slow(t, y, dy=None, frequency=freq_expected, fit...
jakevdp/lombscargle
[ 4, 2, 4, 2, 1458772994 ]
def test_object_interface_power(data, method, center_data, fit_bias, freq): t, y, dy = data if method == 'scipy' and fit_bias: return if method == 'scipy': dy = None expected_PLS = lombscargle(t, y, dy, frequency=freq, method=...
jakevdp/lombscargle
[ 4, 2, 4, 2, 1458772994 ]
def test_object_interface_autopower(data, method, center_data, fit_bias): t, y, dy = data if method == 'scipy' and fit_bias: return if method == 'scipy': dy = None ls = LombScargle(t, y, dy, fit_bias=fit_bias, center_data=center_data) freq, PLS = ls.autopower(method=method) exp...
jakevdp/lombscargle
[ 4, 2, 4, 2, 1458772994 ]
def test_object_interface_model(fit_bias, freq): rand = np.random.RandomState(0) t = 10 * rand.rand(40) params = 10 * rand.rand(3) y = np.zeros_like(t) if fit_bias: y += params[0] y += params[1] * np.sin(2 * np.pi * freq * (t - params[2])) ls = LombScargle(t, y, center_data=False, ...
jakevdp/lombscargle
[ 4, 2, 4, 2, 1458772994 ]