_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q250400 | Tle.orbit | train | def orbit(self):
"""Convert TLE to Orbit object, in order to make computations on it
Return:
~beyond.orbits.orbit.Orbit:
"""
data = {
'bstar': self.bstar,
| python | {
"resource": ""
} |
q250401 | Tle.from_string | train | def from_string(cls, text, comments="#", error="warn"):
"""Generator of TLEs from a string
Args:
text (str): A text containing many TLEs
comments (str): If a line starts with this character, it is ignored
error (str): How to handle errors while parsing the text. Coul... | python | {
"resource": ""
} |
q250402 | orbit2frame | train | def orbit2frame(name, ref_orbit, orientation=None, center=None, bypass=False):
"""Create a frame based on a Orbit or Ephem object.
Args:
name (str): Name to give the created frame
ref_orbit (Orbit or Ephem):
orientation (str): Orientation of the created frame
bypass (bool): By-p... | python | {
"resource": ""
} |
q250403 | Frame.transform | train | def transform(self, new_frame):
"""Change the frame of the orbit
Args:
new_frame (str)
Return:
numpy.ndarray
"""
steps = self.__class__.steps(new_frame)
orbit = self.orbit
for _from, _to in steps:
from_obj = _from(self.date... | python | {
"resource": ""
} |
q250404 | Timescale._scale_tdb_minus_tt | train | def _scale_tdb_minus_tt(self, mjd, eop):
"""Definition of the Barycentric Dynamic Time scale relatively to Terrestrial Time
"""
jd = mjd + Date.JD_MJD
jj = Date._julian_century(jd)
m = radians(357.5277233 + 35999.05034 * jj)
| python | {
"resource": ""
} |
q250405 | Timescale.offset | train | def offset(self, mjd, new_scale, eop):
"""Compute the offset necessary in order to convert from one time-scale to another
Args:
mjd (float):
new_scale (str): Name of the desired scale
Return:
float: offset to apply in seconds
"""
delta = 0
... | python | {
"resource": ""
} |
q250406 | Date.datetime | train | def datetime(self):
"""Conversion of the Date object into a ``datetime.datetime``
The resulting object is a timezone-naive instance with the same scale
as the originating Date object.
"""
if 'dt_scale' not in self._cache.keys(): | python | {
"resource": ""
} |
q250407 | Date.strptime | train | def strptime(cls, data, format, scale=DEFAULT_SCALE): # pragma: no cover
"""Convert a string representation of a date to a Date object
| python | {
"resource": ""
} |
q250408 | Date.range | train | def range(cls, start=None, stop=None, step=None, inclusive=False):
"""Generator of a date range
Args:
start (Date):
stop (Date or datetime.timedelta)!
step (timedelta):
Keyword Args:
inclusive (bool): If ``False``, the stopping date is not include... | python | {
"resource": ""
} |
q250409 | Kepler._newton | train | def _newton(self, orb, step):
"""Newton's Law of Universal Gravitation
"""
date = orb.date + step
new_body = zeros(6)
new_body[:3] = orb[3:]
for body in self.bodies:
# retrieve the position of the body at the given date
orb_body = body.propagate... | python | {
"resource": ""
} |
q250410 | Kepler._make_step | train | def _make_step(self, orb, step):
"""Compute the next step with the selected method
"""
method = self.BUTCHER[self.method]
a, b, c = method['a'], method['b'], method['c']
y_n = orb.copy()
ks = [self._newton(y_n, timedelta(0))]
for a, c in zip(a[1:], c[1:]):
... | python | {
"resource": ""
} |
q250411 | SOIPropagator._soi | train | def _soi(self, orb):
"""Evaluate the need for SOI transition, by comparing the radial distance
between the considered body and the spacecraft
If therer is no body in sight, default to central body.
"""
for body in self.alt:
soi | python | {
"resource": ""
} |
q250412 | SOIPropagator._change_soi | train | def _change_soi(self, body):
"""Modify the inner parameters of the Kepler propagator in order to place
the spacecraft in the right Sphere of Influence
"""
if body == self.central:
self.bodies = [self.central]
| python | {
"resource": ""
} |
q250413 | register | train | def register(name=EopDb.DEFAULT_DBNAME):
"""Decorator for registering an Eop Database
Example:
.. code-block:: python
@register
class SqliteEnvDatabase:
# sqlite implementation
# this database will be known as 'default'
@register('json')
class Json... | python | {
"resource": ""
} |
q250414 | TaiUtc.get_last_next | train | def get_last_next(self, date):
"""Provide the last and next leap-second events relative to a date
Args:
date (float): Date in MJD
Return:
tuple:
"""
past, future = (None, None), (None, None)
| python | {
"resource": ""
} |
q250415 | EopDb.db | train | def db(cls, dbname=None):
"""Retrieve the database
Args:
dbname: Specify the name of the database to retrieve. If set to `None`, take the name
from the configuration (see :ref:`configuration <eop-dbname>`)
Return:
object
"""
cls._load_ent... | python | {
"resource": ""
} |
q250416 | EopDb.get | train | def get(cls, mjd: float, dbname: str = None) -> Eop:
"""Retrieve Earth Orientation Parameters and timescales differences
for a given date
Args:
mjd: Date expressed as Mean Julian Date
dbname: Name of the database to use
Return:
Eop: Interpolated data ... | python | {
"resource": ""
} |
q250417 | EopDb.register | train | def register(cls, klass, name=DEFAULT_DBNAME):
"""Register an Eop Database
The only requirement of this database is that it should have ``__getitem__``
method accepting MJD as float.
"""
if name in cls._dbs:
| python | {
"resource": ""
} |
q250418 | _tab | train | def _tab(max_i=None):
"""Extraction and caching of IAU1980 nutation coefficients
"""
filepath = Path(__file__).parent / "data" / "tab5.1.txt"
result = []
with filepath.open() as fhd:
i = 0
for line in fhd.read().splitlines():
| python | {
"resource": ""
} |
q250419 | _precesion | train | def _precesion(date):
"""Precession in degrees
"""
t = date.change_scale('TT').julian_century
zeta = (2306.2181 * t + 0.30188 * t ** 2 + 0.017998 * t ** 3) / 3600.
theta = (2004.3109 * t - 0.42665 * t ** 2 - 0.041833 * t ** 3) / 3600.
z = (2306.2181 * t + | python | {
"resource": ""
} |
q250420 | precesion | train | def precesion(date): # pragma: no cover
"""Precession as a rotation matrix
"""
| python | {
"resource": ""
} |
q250421 | _nutation | train | def _nutation(date, eop_correction=True, terms=106):
"""Model 1980 of nutation as described in Vallado p. 224
Args:
date (beyond.utils.date.Date)
eop_correction (bool): set to ``True`` to include model correction
from 'finals' files.
terms (int)
Return:
tuple : 3... | python | {
"resource": ""
} |
q250422 | nutation | train | def nutation(date, eop_correction=True, terms=106): # pragma: no cover
"""Nutation as a rotation matrix
"""
epsilon_bar, delta_psi, delta_eps = np.deg2rad(_nutation(date, eop_correction, terms))
| python | {
"resource": ""
} |
q250423 | equinox | train | def equinox(date, eop_correction=True, terms=106, kinematic=True):
"""Equinox equation in degrees
"""
epsilon_bar, delta_psi, delta_eps = _nutation(date, eop_correction, terms)
equin = delta_psi * 3600. * np.cos(np.deg2rad(epsilon_bar))
if date.d >= 50506 and kinematic:
# Starting 1992-02-... | python | {
"resource": ""
} |
q250424 | _sideral | train | def _sideral(date, longitude=0., model='mean', eop_correction=True, terms=106):
"""Get the sideral time at a defined date
Args:
date (Date):
longitude (float): Longitude of the observer (in degrees)
East positive/West negative.
model (str): 'mean' or 'apparent' for GMST and ... | python | {
"resource": ""
} |
q250425 | sideral | train | def sideral(date, longitude=0., model='mean', eop_correction=True, terms=106): # pragma: no cover
"""Sideral time as a rotation matrix
"""
theta | python | {
"resource": ""
} |
q250426 | Maneuver.dv | train | def dv(self, orb):
"""Computation of the velocity increment in the reference frame of the orbit
Args:
orb (Orbit):
Return:
numpy.array: Velocity increment, length 3
""" | python | {
"resource": ""
} |
q250427 | Orbit.copy | train | def copy(self, *, frame=None, form=None):
"""Provide a new instance of the same point in space-time
Keyword Args:
frame (str or Frame): Frame to convert the new instance into
form (str or Form): Form to convert the new instance into
Return:
Orbit:
Ov... | python | {
"resource": ""
} |
q250428 | Orbit.propagate | train | def propagate(self, date):
"""Propagate the orbit to a new date
Args:
date (Date)
Return:
Orbit
"""
if self.propagator.orbit | python | {
"resource": ""
} |
q250429 | Orbit.ephemeris | train | def ephemeris(self, **kwargs):
"""Generator giving the propagation of the orbit at different dates
Args:
start (Date)
stop (Date or timedelta)
step (timedelta)
| python | {
"resource": ""
} |
q250430 | OrbitInfos.period | train | def period(self):
"""Period of the orbit as a timedelta
"""
return | python | {
"resource": ""
} |
q250431 | OrbitInfos.va | train | def va(self):
"""Velocity at apocenter
"""
| python | {
"resource": ""
} |
q250432 | OrbitInfos.vp | train | def vp(self):
"""Velocity at pericenter
| python | {
"resource": ""
} |
q250433 | Node.path | train | def path(self, goal):
"""Get the shortest way between two nodes of the graph
Args:
goal (str): Name of the targeted node
Return:
list of Node
"""
if goal == self.name:
| python | {
"resource": ""
} |
q250434 | Node.steps | train | def steps(self, goal):
"""Get the list of individual relations leading to the targeted node
Args:
goal (str): Name of the targeted node
Return:
list of tuple of Node
| python | {
"resource": ""
} |
q250435 | build_if_needed | train | def build_if_needed(db):
"""Little helper method for making tables in SQL-Alchemy with SQLite"""
if len(db.engine.table_names()) == 0:
# import all | python | {
"resource": ""
} |
q250436 | deunicode | train | def deunicode(item):
""" Convert unicode objects to str """
if item is None:
return None
if isinstance(item, str):
return item
if isinstance(item, six.text_type):
return item.encode('utf-8')
if isinstance(item, dict):
return {
deunicode(key): deunicode(val... | python | {
"resource": ""
} |
q250437 | assert_true | train | def assert_true(expr, msg_fmt="{msg}"):
"""Fail the test unless the expression is truthy.
>>> assert_true("Hello World!")
>>> assert_true("")
Traceback (most recent call last):
...
AssertionError: '' is not truthy
The following msg_fmt arguments are supported:
* msg - the | python | {
"resource": ""
} |
q250438 | assert_false | train | def assert_false(expr, msg_fmt="{msg}"):
"""Fail the test unless the expression is falsy.
>>> assert_false("")
>>> assert_false("Hello World!")
Traceback (most recent call last):
...
AssertionError: 'Hello World!' is not falsy
The following msg_fmt arguments are supported:
* msg - ... | python | {
"resource": ""
} |
q250439 | assert_boolean_true | train | def assert_boolean_true(expr, msg_fmt="{msg}"):
"""Fail the test unless the expression is the constant True.
>>> assert_boolean_true(True)
>>> assert_boolean_true("Hello World!")
Traceback (most recent call last):
...
AssertionError: 'Hello World!' is not True
The following msg_fmt arg... | python | {
"resource": ""
} |
q250440 | assert_boolean_false | train | def assert_boolean_false(expr, msg_fmt="{msg}"):
"""Fail the test unless the expression is the constant False.
>>> assert_boolean_false(False)
>>> assert_boolean_false(0)
Traceback (most recent call last):
...
AssertionError: 0 is not False
The following msg_fmt arguments are supported... | python | {
"resource": ""
} |
q250441 | assert_is_none | train | def assert_is_none(expr, msg_fmt="{msg}"):
"""Fail if the expression is not None.
>>> assert_is_none(None)
>>> assert_is_none(False)
Traceback (most recent call last):
...
AssertionError: False is not None
The following msg_fmt arguments are supported:
* msg - the default error mes... | python | {
"resource": ""
} |
q250442 | assert_is_not_none | train | def assert_is_not_none(expr, msg_fmt="{msg}"):
"""Fail if the expression is None.
>>> assert_is_not_none(0)
>>> assert_is_not_none(None)
Traceback (most recent call last):
...
AssertionError: expression is None
The following msg_fmt arguments are supported:
* msg - the default | python | {
"resource": ""
} |
q250443 | assert_equal | train | def assert_equal(first, second, msg_fmt="{msg}"):
"""Fail unless first equals second, as determined by the '==' operator.
>>> assert_equal(5, 5.0)
>>> assert_equal("Hello World!", "Goodbye!")
Traceback (most recent call last):
...
AssertionError: 'Hello World!' != 'Goodbye!'
The follow... | python | {
"resource": ""
} |
q250444 | assert_not_equal | train | def assert_not_equal(first, second, msg_fmt="{msg}"):
"""Fail if first equals second, as determined by the '==' operator.
>>> assert_not_equal(5, 8)
>>> assert_not_equal(-7, -7.0)
Traceback (most recent call last):
...
AssertionError: -7 == -7.0
The following msg_fmt arguments are supp... | python | {
"resource": ""
} |
q250445 | assert_almost_equal | train | def assert_almost_equal(
first, second, msg_fmt="{msg}", places=None, delta=None
):
"""Fail if first and second are not equal after rounding.
By default, the difference between first and second is rounded to
7 decimal places. This can be configured with the places argument.
Alternatively, delta can... | python | {
"resource": ""
} |
q250446 | assert_dict_equal | train | def assert_dict_equal(
first, second, key_msg_fmt="{msg}", value_msg_fmt="{msg}"
):
"""Fail unless first dictionary equals second.
The dictionaries are considered equal, if they both contain the same
keys, and their respective values are also equal.
>>> assert_dict_equal({"foo": 5}, {"foo": 5})
... | python | {
"resource": ""
} |
q250447 | assert_less | train | def assert_less(first, second, msg_fmt="{msg}"):
"""Fail if first is not less than second.
>>> assert_less('bar', 'foo')
>>> assert_less(5, 5)
Traceback (most recent call last):
...
AssertionError: 5 is not less than 5
The following msg_fmt arguments are supported:
* msg - the defa... | python | {
"resource": ""
} |
q250448 | assert_less_equal | train | def assert_less_equal(first, second, msg_fmt="{msg}"):
"""Fail if first is not less than or equal to second.
>>> assert_less_equal('bar', 'foo')
>>> assert_less_equal(5, 5)
>>> assert_less_equal(6, 5)
Traceback (most recent call last):
...
AssertionError: 6 is not less than or equal to ... | python | {
"resource": ""
} |
q250449 | assert_greater | train | def assert_greater(first, second, msg_fmt="{msg}"):
"""Fail if first is not greater than second.
>>> assert_greater('foo', 'bar')
>>> assert_greater(5, 5)
Traceback (most recent call last):
...
AssertionError: 5 is not greater than 5
The following msg_fmt arguments are supported:
*... | python | {
"resource": ""
} |
q250450 | assert_greater_equal | train | def assert_greater_equal(first, second, msg_fmt="{msg}"):
"""Fail if first is not greater than or equal to second.
>>> assert_greater_equal('foo', 'bar')
>>> assert_greater_equal(5, 5)
>>> assert_greater_equal(5, 6)
Traceback (most recent call last):
...
AssertionError: 5 is not greater... | python | {
"resource": ""
} |
q250451 | assert_regex | train | def assert_regex(text, regex, msg_fmt="{msg}"):
"""Fail if text does not match the regular expression.
regex can be either a regular expression string or a compiled regular
expression object.
>>> assert_regex("Hello World!", r"llo.*rld!$")
>>> assert_regex("Hello World!", r"\\d")
Traceback (mo... | python | {
"resource": ""
} |
q250452 | assert_is | train | def assert_is(first, second, msg_fmt="{msg}"):
"""Fail if first and second do not refer to the same object.
>>> list1 = [5, "foo"]
>>> list2 = [5, "foo"]
>>> assert_is(list1, list1)
>>> assert_is(list1, list2)
Traceback (most recent call last):
...
AssertionError: [5, 'foo'] is not ... | python | {
"resource": ""
} |
q250453 | assert_is_not | train | def assert_is_not(first, second, msg_fmt="{msg}"):
"""Fail if first and second refer to the same object.
>>> list1 = [5, "foo"]
>>> list2 = [5, "foo"]
>>> assert_is_not(list1, list2)
>>> assert_is_not(list1, list1)
Traceback (most recent call last):
...
AssertionError: both argument... | python | {
"resource": ""
} |
q250454 | assert_in | train | def assert_in(first, second, msg_fmt="{msg}"):
"""Fail if first is not in collection second.
>>> assert_in("foo", [4, "foo", {}])
>>> assert_in("bar", [4, "foo", {}])
Traceback (most recent call last):
...
AssertionError: 'bar' not in [4, 'foo', {}]
The following msg_fmt arguments are ... | python | {
"resource": ""
} |
q250455 | assert_not_in | train | def assert_not_in(first, second, msg_fmt="{msg}"):
"""Fail if first is in a collection second.
>>> assert_not_in("bar", [4, "foo", {}])
>>> assert_not_in("foo", [4, "foo", {}])
Traceback (most recent call last):
...
AssertionError: 'foo' is in [4, 'foo', {}]
The following msg_fmt argum... | python | {
"resource": ""
} |
q250456 | assert_count_equal | train | def assert_count_equal(sequence1, sequence2, msg_fmt="{msg}"):
"""Compare the items of two sequences, ignoring order.
>>> assert_count_equal([1, 2], {2, 1})
Items missing in either sequence will be listed:
>>> assert_count_equal(["a", "b", "c"], ["a", "d"])
Traceback (most recent call last):
... | python | {
"resource": ""
} |
q250457 | assert_is_instance | train | def assert_is_instance(obj, cls, msg_fmt="{msg}"):
"""Fail if an object is not an instance of a class or tuple of classes.
>>> assert_is_instance(5, int)
>>> assert_is_instance('foo', (str, bytes))
>>> assert_is_instance(5, str)
Traceback (most recent call last):
...
AssertionError: 5 i... | python | {
"resource": ""
} |
q250458 | assert_has_attr | train | def assert_has_attr(obj, attribute, msg_fmt="{msg}"):
"""Fail is an object does not have an attribute.
>>> assert_has_attr([], "index")
>>> assert_has_attr([], "i_do_not_have_this")
Traceback (most recent call last):
...
AssertionError: [] does not have attribute 'i_do_not_have_this'
T... | python | {
"resource": ""
} |
q250459 | assert_datetime_about_now | train | def assert_datetime_about_now(actual, msg_fmt="{msg}"):
"""Fail if a datetime object is not within 5 seconds of the local time.
>>> assert_datetime_about_now(datetime.now())
>>> assert_datetime_about_now(datetime(1900, 1, 1, 12, 0, 0))
Traceback (most recent call last):
...
AssertionError: ... | python | {
"resource": ""
} |
q250460 | assert_raises_regex | train | def assert_raises_regex(exception, regex, msg_fmt="{msg}"):
"""Fail unless an exception with a message that matches a regular
expression is raised within the context.
The regular expression can be a regular expression string or object.
>>> with assert_raises_regex(ValueError, r"\\d+"):
... ra... | python | {
"resource": ""
} |
q250461 | assert_raises_errno | train | def assert_raises_errno(exception, errno, msg_fmt="{msg}"):
"""Fail unless an exception with a specific errno is raised with the
context.
>>> with assert_raises_errno(OSError, 42):
... raise OSError(42, "OS Error")
...
>>> with assert_raises_errno(OSError, 44):
... raise OSError(17... | python | {
"resource": ""
} |
q250462 | assert_succeeds | train | def assert_succeeds(exception, msg_fmt="{msg}"):
"""Fail if a specific exception is raised within the context.
This assertion should be used for cases, where successfully running a
function signals a successful test, and raising the exception of a
certain type signals a test failure. All other raised e... | python | {
"resource": ""
} |
q250463 | assert_warns_regex | train | def assert_warns_regex(warning_type, regex, msg_fmt="{msg}"):
"""Fail unless a warning with a message is issued inside the context.
The message can be a regular expression string or object.
>>> from warnings import warn
>>> with assert_warns_regex(UserWarning, r"#\\d+"):
... warn("Error #42", ... | python | {
"resource": ""
} |
q250464 | assert_json_subset | train | def assert_json_subset(first, second):
"""Assert that a JSON object or array is a subset of another JSON object
or array.
The first JSON object or array must be supplied as a JSON-compatible
dict or list, the JSON object or array to check must be a string, an
UTF-8 bytes object, or a JSON-compatibl... | python | {
"resource": ""
} |
q250465 | BaseBackend.get_data | train | def get_data(self, data_key, key=''):
"""Get the data from the cache.
:param data_key: a key for accessing the data;
:param key: if provided (e.g. non-empty string), will be used to
decrypt the data as a password;
:returns: the data extracted from the cache, a pytho... | python | {
"resource": ""
} |
q250466 | Helpers.encode_safely | train | def encode_safely(self, data):
"""Encode the data.
"""
encoder = self.base_encoder
result = settings.null
try:
result = encoder(pickle.dumps(data))
except: | python | {
"resource": ""
} |
q250467 | Helpers.decode_safely | train | def decode_safely(self, encoded_data):
"""Inverse for the `encode_safely` function.
"""
decoder = self.base_decoder
result = settings.null
try:
result = pickle.loads(decoder(encoded_data))
| python | {
"resource": ""
} |
q250468 | Helpers.get_function_hash | train | def get_function_hash(self, func, args=None, kwargs=None, ttl=None, key=None, noc=None):
"""Compute the hash of the function to be evaluated.
"""
base_hash = settings.HASH_FUNCTION()
if PY3:
base_hash.update(func.__name__.encode(settings.DEFAULT_ENCODING))
else:
... | python | {
"resource": ""
} |
q250469 | to_bytes | train | def to_bytes(obj):
"""Ensures that the obj is of byte-type.
"""
if PY3:
if isinstance(obj, str):
return obj.encode(settings.DEFAULT_ENCODING)
else:
return obj if isinstance(obj, bytes) else b''
else:
| python | {
"resource": ""
} |
q250470 | padding | train | def padding(s, bs=AES.block_size):
"""Fills a bytes-like object with arbitrary symbols to make its length divisible by `bs`.
"""
s = to_bytes(s)
if len(s) % bs == 0:
res = s + b''.join(map(to_bytes, [random.SystemRandom().choice(string.ascii_lowercase + string.digits) for _ in range(bs - 1... | python | {
"resource": ""
} |
q250471 | Client.stop | train | def stop(self):
"""Called to stop the reveiver thread."""
self._stop_thread.set()
# f you want to close the connection in a timely fashion,
# call shutdown() before close(). | python | {
"resource": ""
} |
q250472 | Client.send_code | train | def send_code(self, data, acknowledge=True):
"""Send a RF code known to the pilight-daemon.
For protocols look at https://manual.pilight.org/en/api.
When acknowledge is set, it is checked if the code was issued.
:param data: Dictionary with the data
:param acknowledge: Raise IO ... | python | {
"resource": ""
} |
q250473 | FuseProcess.setup | train | def setup(self):
"""
Set up filesystem in user space for http and https
so that we can retrieve tiles from remote sources.
Parameters
----------
tmp_dir: string
The temporary directory where to create the
http and https directories
"""
... | python | {
"resource": ""
} |
q250474 | Server.start | train | def start(self, log_file="/tmp/hgserver.log", log_level=logging.INFO):
"""
Start a lightweight higlass server.
Parameters
----------
log_file: string
Where to place diagnostic log files
log_level: logging.*
What level to log at
"""
... | python | {
"resource": ""
} |
q250475 | Server.stop | train | def stop(self):
"""
Stop this server so that the calling process can exit
"""
# unsetup_fuse()
| python | {
"resource": ""
} |
q250476 | Server.tileset_info | train | def tileset_info(self, uid):
"""
Return the tileset info for the given tileset
"""
url = "http://{host}:{port}/api/v1/tileset_info/?d={uid}".format(
host=self.host, port=self.port, uid=uid
)
req = requests.get(url)
| python | {
"resource": ""
} |
q250477 | Server.chromsizes | train | def chromsizes(self, uid):
"""
Return the chromosome sizes from the given filename
"""
url = "http://{host}:{port}/api/v1/chrom-sizes/?id={uid}".format(
host=self.host, port=self.port, uid=uid
)
req = requests.get(url) | python | {
"resource": ""
} |
q250478 | display | train | def display(views, location_sync=[], zoom_sync=[], host='localhost', server_port=None):
'''
Instantiate a HiGlass display with the given views
'''
from .server import Server
from .client import ViewConf
tilesets = []
for view in views:
for track in view.tracks:
if track.... | python | {
"resource": ""
} |
q250479 | view | train | def view(tilesets):
'''
Create a higlass viewer that displays the specified tilesets
Parameters:
-----------
Returns
-------
Nothing
'''
from .server import Server
from .client import View
curr_view = View()
server = Server()
server.start(tilesets)
for ts ... | python | {
"resource": ""
} |
q250480 | Track.change_attributes | train | def change_attributes(self, **kwargs):
'''
Change an attribute of this track and return a new copy.
'''
new_track = Track(self.viewconf['type'])
| python | {
"resource": ""
} |
q250481 | Track.change_options | train | def change_options(self, **kwargs):
'''
Change one of the track's options in the viewconf
'''
new_options = json.loads(json.dumps(self.viewconf['options']))
| python | {
"resource": ""
} |
q250482 | View.add_track | train | def add_track(self, *args, **kwargs):
"""
Add a track to a position.
Parameters
----------
track_type: string
The type of track to add (e.g. "heatmap", "line")
position: string
One of 'top', 'bottom', 'center', 'left', 'right'
tileset: hgf... | python | {
"resource": ""
} |
q250483 | View.to_dict | train | def to_dict(self):
"""
Convert the existing track to a JSON representation.
"""
viewconf = json.loads(json.dumps(self.viewconf))
for track in self.tracks:
if track.position is None:
raise ValueError(
| python | {
"resource": ""
} |
q250484 | ViewConf.add_view | train | def add_view(self, *args, **kwargs):
"""
Add a new view
Parameters
----------
uid: string
The uid of new view
width: int
The width of this of view on a 12 unit grid
height: int
The height of the this view. The height is proport... | python | {
"resource": ""
} |
q250485 | _slugify | train | def _slugify(string):
"""
This is not as good as a proper slugification function, but the input space is limited
>>> _slugify("beets")
'beets'
>>> _slugify("Toaster Strudel")
'toaster-strudel'
Here's why: It handles very little. It doesn't handle esoteric whitespace or symbols:
| python | {
"resource": ""
} |
q250486 | slugify_argument | train | def slugify_argument(func):
"""
Wraps a function that returns a string, adding the 'slugify' argument.
>>> slugified_fn = slugify_argument(lambda *args, **kwargs: "YOU ARE A NICE LADY")
>>> slugified_fn()
'YOU ARE A NICE LADY'
>>> slugified_fn(slugify=True)
'you-are-a-nice-lady'
"""
... | python | {
"resource": ""
} |
q250487 | capitalize_argument | train | def capitalize_argument(func):
"""
Wraps a function that returns a string, adding the 'capitalize' argument.
>>> capsified_fn = capitalize_argument(lambda *args, **kwargs: "what in the beeswax is this?")
>>> capsified_fn()
'what in the beeswax is this?'
>>> capsified_fn(capitalize=True)
'Wh... | python | {
"resource": ""
} |
q250488 | datetime | train | def datetime(past=True, random=random):
"""
Returns a random datetime from the past... or the future!
>>> mock_random.seed(0)
>>> datetime(random=mock_random).isoformat()
'1950-02-03T03:04:05'
"""
def year():
if past:
return random.choice(range(1950,2005))
else... | python | {
"resource": ""
} |
q250489 | a_noun | train | def a_noun(random=random, *args, **kwargs):
"""
Return a noun, but with an 'a' in front of it. Or an 'an', depending!
>>> mock_random.seed(0)
>>> a_noun(random=mock_random)
'an onion'
>>> a_noun(random=mock_random, capitalize=True) | python | {
"resource": ""
} |
q250490 | plural | train | def plural(random=random, *args, **kwargs):
"""
Return a plural noun.
>>> mock_random.seed(0)
>>> plural(random=mock_random)
'onions'
>>> plural(random=mock_random, capitalize=True)
'Chimps'
| python | {
"resource": ""
} |
q250491 | lastname | train | def lastname(random=random, *args, **kwargs):
"""
Return a first name!
>>> mock_random.seed(0)
>>> lastname(random=mock_random)
'chimp'
>>> mock_random.seed(1)
>>> lastname(random=mock_random, capitalize=True)
'Wonderful'
>>> mock_random.seed(2)
>>> lastname(random=mock_random, ... | python | {
"resource": ""
} |
q250492 | numberwang | train | def numberwang(random=random, *args, **kwargs):
"""
Return a number that is spelled out.
>>> numberwang(random=mock_random)
'two'
| python | {
"resource": ""
} |
q250493 | things | train | def things(random=random, *args, **kwargs):
"""
Return a set of things.
>>> mock_random.seed(0)
>>> things(random=mock_random)
'two secrets, two secrets, and two secrets'
>>> mock_random.seed(1)
>>> things(random=mock_random, capitalize=True)
| python | {
"resource": ""
} |
q250494 | name | train | def name(random=random, *args, **kwargs):
"""
Return someone's name
>>> mock_random.seed(0)
>>> name(random=mock_random)
'carl poopbritches'
>>> mock_random.seed(7)
>>> name(random=mock_random, capitalize=True)
'Duke Testy Wonderful'
"""
if random.choice([True, True, True, Fals... | python | {
"resource": ""
} |
q250495 | domain | train | def domain(random=random, *args, **kwargs):
"""
Return a domain
>>> mock_random.seed(0)
>>> domain(random=mock_random)
'onion.net'
>>> domain(random=mock_random)
| python | {
"resource": ""
} |
q250496 | email | train | def email(random=random, *args, **kwargs):
"""
Return an e-mail address
>>> mock_random.seed(0)
>>> email(random=mock_random)
'onion@bag-of-heroic-chimps.sexy'
>>> email(random=mock_random)
'agatha-incrediblebritches-spam@amazingbritches.click'
>>> email(random=mock_random, name="charle... | python | {
"resource": ""
} |
q250497 | phone_number | train | def phone_number(random=random, *args, **kwargs):
"""
Return a phone number
>>> mock_random.seed(0)
>>> phone_number(random=mock_random)
'555-0000'
>>> phone_number(random=mock_random)
'1-604-555-0000'
>>> phone_number(random=mock_random)
| python | {
"resource": ""
} |
q250498 | sentence | train | def sentence(random=random, *args, **kwargs):
"""
Return a whole sentence
>>> mock_random.seed(0)
>>> sentence(random=mock_random)
"Agatha Incrediblebritches can't wait to smell two chimps in Boatbencheston."
>>> mock_random.seed(2)
>>> sentence(random=mock_random, slugify=True)
'blist... | python | {
"resource": ""
} |
q250499 | paragraph | train | def paragraph(random=random, length=10, *args, **kwargs):
"""
Produces a paragraph of text.
>>> mock_random.seed(0)
>>> paragraph(random=mock_random, length=2)
"Agatha Incrediblebritches can't wait to smell two chimps in Boatbencheston. Wonderfulsecretsound is in Gallifrey."
>>> mock_random.se... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.