output stringlengths 1 928k | instruction stringlengths 7 928k | system stringlengths 0 104k |
|---|---|---|
Yields all the instances in the cache. | Make a summary of the following Python 3 code
def __instances(self):
for instance in self.__instances_cache:
yield instance
for instance in self.__instances_original:
self.__instances_cache.append(instance)
yield instance | You are a Python code analyst, evaluating scripts for potential improvements. |
Resolves the value for the given name. | Explain what the following Python 3 code does
def _resolve_value(self, name):
for instance in self.__instances():
value = instance._resolve_value(name)
if value:
return value
# Otherwise, return an appropriate default value (populate_from)
# TODO: This is... | You are a Python code architect, reviewing and designing scalable and efficient code |
Return an object to conveniently access the appropriate values. | Here you have a function in Python 3, explain what it does
def _get_formatted_data(cls, path, context=None, site=None, language=None):
return FormattedMetadata(cls(), cls._get_instances(path, context, site, language), path, site, language) | You are a Python code architect, reviewing and designing scalable and efficient code |
A generator that yields all instances from each backend that are available for the given path. | Can you tell what is the following Python 3 function doing
def _get_instances(cls, path, context=None, site=None, language=None):
backend_context = {'view_context': context }
for model in cls._meta.models.values():
for instance in model.objects.get_instances(path, site, language, backend_co... | As a python code expert, you are capable of creating scripts from specifications. |
Resolves any template references in the given value. | Here you have a function in Python 3, explain what it does
def _resolve(value, model_instance=None, context=None):
if isinstance(value, basestring) and "{" in value:
if context is None:
context = Context()
if model_instance is not None:
context[model_instance._meta.module_na... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Validates the application of this backend to a given metadata
| Here you have a function in Python 3, explain what it does
def validate(options):
try:
if options.backends.index('modelinstance') > options.backends.index('model'):
raise Exception("Metadata backend 'modelinstance' must come before 'model' backend")
except ValueError:
... | You are a Python code generator, capable of creating scripts from specifications. |
def _register_elements(self, elements):
""" Takes elements from the metadata class and creates a base model for all backend models .
"""
self.elements = elements
for key, obj in elements.items():
obj.contribute_to_class(self.metadata, key)
# Create the common Django... | Write a Python 3 function that can
take elements from the metadata class and creates a base model for all backend models. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Adds a backend to the metadata base model | Make a summary of the following Python 3 code
def _add_backend(self, backend):
md_type = backend.verbose_name
base = backend().get_model(self)
# TODO: Rename this field
new_md_attrs = {'_metadata': self.metadata, '__module__': __name__ }
new_md_meta = {}
new_md_meta['ver... | As a python code expert, you are capable of creating scripts from specifications. |
def _set_seo_models(self, value):
""" Gets the actual models to be used. """
seo_models = []
for model_name in value:
if "." in model_name:
app_label, model_name = model_name.split(".", 1)
model = models.get_model(app_label, model_name)
... | Write a Python 3 function that can
set the list of models to be used. | You are a Python code analyst, evaluating scripts for potential improvements. |
Validate that the field is valid. | Here you have a function in Python 3, explain what it does
def validate(self):
if not self.editable:
assert self.populate_from is not NotSet, u"If field (%s) is not editable, you must set populate_from" % self.name | As a python code expert, you are capable of creating scripts from specifications. |
Populate all metadata instances for all models in seo_models. | Explain what the following Python 3 code does
def populate_all_metadata():
for Metadata in registry.values():
InstanceMetadata = Metadata._meta.get_model('modelinstance')
if InstanceMetadata is not None:
for model in Metadata._meta.seo_models:
populate_metadata(model, Ins... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def populate(self):
""" Populate this list with all views that take no arguments.
"""
from django.conf import settings
from django.core import urlresolvers
self.append(("", ""))
urlconf = settings.ROOT_URLCONF
resolver = urlresolvers.RegexURLResolver(r'^/', urlco... | Can you implement a function in Python 3 that
populates this list with all views that take no arguments. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def block_splitter(data, block_size):
"""
Creates a generator by slicing ``data`` into chunks of ``block_size``.
>>> data = range(10)
>>> list(block_splitter(data, 2))
[[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]
If ``data`` cannot be evenly divided by ``block_size``, the last block will
simpl... | Implement a Python 3 function for
generating a generator that yields a list of blocks of size block_size. | As a python code expert, you are capable of creating scripts from specifications. |
Round coordinates of a geometric object to given precision. | Can you tell what is the following Python 3 function doing
def round_geom(geom, precision=None):
if geom['type'] == 'Point':
x, y = geom['coordinates']
xp, yp = [x], [y]
if precision is not None:
xp = [round(v, precision) for v in xp]
yp = [round(v, precision) for v i... | As a Python code composer, you craft elegant and concise scripts. |
Flatten a multi - dimensional array - like to a single dimensional sequence - like. | Given the following Python 3 function, write the documentation
def flatten_multi_dim(sequence):
for x in sequence:
if (isinstance(x, collections.Iterable)
and not isinstance(x, six.string_types)):
for y in flatten_multi_dim(x):
yield y
else:
yi... | As a Python code composer, you craft elegant and concise scripts. |
def cli(input, verbose, quiet, output_format, precision, indent):
"""Convert text read from the first positional argument, stdin, or
a file to GeoJSON and write to stdout."""
verbosity = verbose - quiet
configure_logging(verbosity)
logger = logging.getLogger('geomet')
# Handle the case of file... | Can you write a function in Python 3 where it
converts text read from the first positional argument stdin or a file to GeoJSON and write to stdout. | As a Python code analyst, you investigate and solve complex coding mysteries |
Get the GeoJSON geometry type label from a WKB type byte string. | Here you have a function in Python 3, explain what it does
def _get_geom_type(type_bytes):
# slice off the high byte, which may contain the SRID flag
high_byte = type_bytes[0]
if six.PY3:
high_byte = bytes([high_byte])
has_srid = high_byte == b'\x20'
if has_srid:
# replace the high b... | You are a Python code generator, capable of creating scripts from specifications. |
def dumps(obj, big_endian=True):
"""
Dump a GeoJSON-like `dict` to a WKB string.
.. note::
The dimensions of the generated WKB will be inferred from the first
vertex in the GeoJSON `coordinates`. It will be assumed that all
vertices are uniform. There are 4 types:
- 2D (X, ... | Write a Python 3 script for
dumping a GeoJSON - like dict to a WKB string. | As a Python code composer, you craft elegant and concise scripts. |
def loads(string):
"""
Construct a GeoJSON `dict` from WKB (`string`).
The resulting GeoJSON `dict` will include the SRID as an integer in the
`meta` object. This was an arbitrary decision made by `geomet, the
discussion of which took place here:
https://github.com/geomet/geomet/issues/28.
... | Can you write a function in Python 3 where it
takes a WKB string and returns a GeoJSON dict. | You are a Python code generator, capable of creating scripts from specifications. |
Utility function to get the header byte format string and byte order string. | Given the following Python 3 function, write the documentation
def _header_bytefmt_byteorder(geom_type, num_dims, big_endian, meta=None):
dim = _INT_TO_DIM_LABEL.get(num_dims)
if dim is None:
pass # TODO: raise
type_byte_str = _WKB[dim][geom_type]
srid = meta.get('srid')
if srid is not Non... | As a Python code analyst, you investigate and solve complex coding mysteries |
Dump a GeoJSON - like dict to a point WKB string. | Can you generate a brief explanation for the following Python 3 code
def _dump_point(obj, big_endian, meta):
coords = obj['coordinates']
num_dims = len(coords)
wkb_string, byte_fmt, _ = _header_bytefmt_byteorder(
'Point', num_dims, big_endian, meta
)
wkb_string += struct.pack(byte_fmt, *co... | As a python code expert, you are capable of creating scripts from specifications. |
def _dump_linestring(obj, big_endian, meta):
"""
Dump a GeoJSON-like `dict` to a linestring WKB string.
Input parameters and output are similar to :func:`_dump_point`.
"""
coords = obj['coordinates']
vertex = coords[0]
# Infer the number of dimensions from the first vertex
num_dims = le... | Implement a Python 3 function for
dumping a GeoJSON - like dict to a linestring WKB string. | As a Python code composer, you craft elegant and concise scripts. |
def _dump_multipoint(obj, big_endian, meta):
"""
Dump a GeoJSON-like `dict` to a multipoint WKB string.
Input parameters and output are similar to :funct:`_dump_point`.
"""
coords = obj['coordinates']
vertex = coords[0]
num_dims = len(vertex)
wkb_string, byte_fmt, byte_order = _header_... | Can you implement a function in Python 3 that
dumps a GeoJSON - like dict to a multipoint WKB string. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def _dump_multilinestring(obj, big_endian, meta):
"""
Dump a GeoJSON-like `dict` to a multilinestring WKB string.
Input parameters and output are similar to :funct:`_dump_point`.
"""
coords = obj['coordinates']
vertex = coords[0][0]
num_dims = len(vertex)
wkb_string, byte_fmt, byte_ord... | Can you write a function in Python 3 where it
dumps a GeoJSON - like dict to a multilinestring WKB string. | As a Python code analyst, you investigate and solve complex coding mysteries |
def _dump_multipolygon(obj, big_endian, meta):
"""
Dump a GeoJSON-like `dict` to a multipolygon WKB string.
Input parameters and output are similar to :funct:`_dump_point`.
"""
coords = obj['coordinates']
vertex = coords[0][0][0]
num_dims = len(vertex)
wkb_string, byte_fmt, byte_order ... | Can you write a function in Python 3 where it
dumps a GeoJSON - like dict to a multipolygon WKB string. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Convert byte data for a Point into a GeoJSON dict. | Explain what the following Python 3 code does
def _load_point(big_endian, type_bytes, data_bytes):
endian_token = '>' if big_endian else '<'
if type_bytes == WKB_2D['Point']:
coords = struct.unpack('%sdd' % endian_token,
as_bin_str(take(16, data_bytes)))
elif type_byt... | As a Python code composer, you craft elegant and concise scripts. |
def dumps(obj, decimals=16):
"""
Dump a GeoJSON-like `dict` to a WKT string.
"""
try:
geom_type = obj['type']
exporter = _dumps_registry.get(geom_type)
if exporter is None:
_unsupported_geom_type(geom_type)
# Check for empty cases
if geom_type == 'Ge... | Can you create a Python 3 function that
dumps a GeoJSON - like dict to a WKT string. | As a python code expert, you are capable of creating scripts from specifications. |
Construct a GeoJSON dict from a WKT string. | Can you generate the documentation for the following Python 3 function
def loads(string):
sio = StringIO.StringIO(string)
# NOTE: This is not the intended purpose of `tokenize`, but it works.
tokens = (x[1] for x in tokenize.generate_tokens(sio.readline))
tokens = _tokenize_wkt(tokens)
geom_type_or_... | As a python code expert, you are capable of creating scripts from specifications. |
Yields a list of tokens from the WKT. | Can you tell what is the following Python 3 function doing
def _tokenize_wkt(tokens):
negative = False
for t in tokens:
if t == '-':
negative = True
continue
else:
if negative:
yield '-%s' % t
else:
yield t
... | As a python code expert, you are capable of creating scripts from specifications. |
def _round_and_pad(value, decimals):
"""
Round the input value to `decimals` places, and pad with 0's
if the resulting value is less than `decimals`.
:param value:
The value to round
:param decimals:
Number of decimals places which should be displayed after the rounding.
:return... | How would you code a function in Python 3 to
round the input value to decimals places and pad with 0 s | You are a Python code architect, reviewing and designing scalable and efficient code |
Dump a GeoJSON - like Point object to WKT. | Can you generate the documentation for the following Python 3 function
def _dump_point(obj, decimals):
coords = obj['coordinates']
pt = 'POINT (%s)' % ' '.join(_round_and_pad(c, decimals)
for c in coords)
return pt | As a python code expert, you are capable of creating scripts from specifications. |
Dump a GeoJSON - like LineString object to WKT. | Can you tell what is the following Python 3 function doing
def _dump_linestring(obj, decimals):
coords = obj['coordinates']
ls = 'LINESTRING (%s)'
ls %= ', '.join(' '.join(_round_and_pad(c, decimals)
for c in pt) for pt in coords)
return ls | As a python code expert, you are capable of creating scripts from specifications. |
def _dump_polygon(obj, decimals):
"""
Dump a GeoJSON-like Polygon object to WKT.
Input parameters and return value are the POLYGON equivalent to
:func:`_dump_point`.
"""
coords = obj['coordinates']
poly = 'POLYGON (%s)'
rings = (', '.join(' '.join(_round_and_pad(c, decimals)
... | Implement a Python 3 function for
dumping a GeoJSON - like Polygon object to WKT. | As a Python code analyst, you investigate and solve complex coding mysteries |
def _dump_multipoint(obj, decimals):
"""
Dump a GeoJSON-like MultiPoint object to WKT.
Input parameters and return value are the MULTIPOINT equivalent to
:func:`_dump_point`.
"""
coords = obj['coordinates']
mp = 'MULTIPOINT (%s)'
points = (' '.join(_round_and_pad(c, decimals)
... | Write a Python 3 function that can
dump a GeoJSON - like MultiPoint object to WKT. | You are a Python code architect, reviewing and designing scalable and efficient code |
Dump a GeoJSON - like MultiLineString object to WKT. | Can you generate the documentation for the following Python 3 function
def _dump_multilinestring(obj, decimals):
coords = obj['coordinates']
mlls = 'MULTILINESTRING (%s)'
linestrs = ('(%s)' % ', '.join(' '.join(_round_and_pad(c, decimals)
for c in pt) for pt in linestr) for linestr in coords... | You are a Python code architect, reviewing and designing scalable and efficient code |
def _dump_multipolygon(obj, decimals):
"""
Dump a GeoJSON-like MultiPolygon object to WKT.
Input parameters and return value are the MULTIPOLYGON equivalent to
:func:`_dump_point`.
"""
coords = obj['coordinates']
mp = 'MULTIPOLYGON (%s)'
polys = (
# join the polygons in the mul... | Can you create a Python 3 function that
dumps a GeoJSON - like MultiPolygon object to WKT. | You are a Python code architect, reviewing and designing scalable and efficient code |
def _dump_geometrycollection(obj, decimals):
"""
Dump a GeoJSON-like GeometryCollection object to WKT.
Input parameters and return value are the GEOMETRYCOLLECTION equivalent to
:func:`_dump_point`.
The WKT conversions for each geometry in the collection are delegated to
their respective funct... | Write a Python 3 function for
dumping a GeoJSON - like GeometryCollection object to WKT. | You are a Python code analyst, evaluating scripts for potential improvements. |
Load a point from a WKT string. | How would you explain what the following Python 3 function does
def _load_point(tokens, string):
if not next(tokens) == '(':
raise ValueError(INVALID_WKT_FMT % string)
coords = []
try:
for t in tokens:
if t == ')':
break
else:
coords.a... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Loads a WKT string into a GeoJSON dict. | Explain what the following Python 3 code does
def _load_linestring(tokens, string):
if not next(tokens) == '(':
raise ValueError(INVALID_WKT_FMT % string)
# a list of lists
# each member list represents a point
coords = []
try:
pt = []
for t in tokens:
if t == ')... | You are a Python code analyst, evaluating scripts for potential improvements. |
Parses a WKT string and returns a GeoJSON Polygon representation of the WKT string. | How would you explain what the following Python 3 function does
def _load_polygon(tokens, string):
open_parens = next(tokens), next(tokens)
if not open_parens == ('(', '('):
raise ValueError(INVALID_WKT_FMT % string)
# coords contains a list of rings
# each ring contains a list of points
# ... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def _load_multipoint(tokens, string):
"""
Has similar inputs and return value to to :func:`_load_point`, except is
for handling MULTIPOINT geometry.
:returns:
A GeoJSON `dict` MultiPoint representation of the WKT ``string``.
"""
open_paren = next(tokens)
if not open_paren == '(':
... | Can you write a function in Python 3 where it
parses a WKT string and returns a GeoJSON MultiPoint representation of the WKT string. | As a Python code analyst, you investigate and solve complex coding mysteries |
Loads a MULTIPOLYGON geometry from a WKT string. | Given the following Python 3 function, write the documentation
def _load_multipolygon(tokens, string):
open_paren = next(tokens)
if not open_paren == '(':
raise ValueError(INVALID_WKT_FMT % string)
polygons = []
while True:
try:
poly = _load_polygon(tokens, string)
... | You are a Python code analyst, evaluating scripts for potential improvements. |
def _load_multilinestring(tokens, string):
"""
Has similar inputs and return value to to :func:`_load_point`, except is
for handling MULTILINESTRING geometry.
:returns:
A GeoJSON `dict` MultiLineString representation of the WKT ``string``.
"""
open_paren = next(tokens)
if not open_p... | How would you implement a function in Python 3 that
loads a MULTILINESTRING geometry from a WKT string. | As a Python code composer, you craft elegant and concise scripts. |
def _load_geometrycollection(tokens, string):
"""
Has similar inputs and return value to to :func:`_load_point`, except is
for handling GEOMETRYCOLLECTIONs.
Delegates parsing to the parsers for the individual geometry types.
:returns:
A GeoJSON `dict` GeometryCollection representation of t... | Write a Python 3 script to
parse a WKT string and returns a GeoJSON GeometryCollection representation of the WKT. | As a python code expert, you are capable of creating scripts from specifications. |
Merge shared params and new params. | Here you have a function in Python 3, explain what it does
def _get_request_params(self, **kwargs):
request_params = copy.deepcopy(self._shared_request_params)
for key, value in iteritems(kwargs):
if isinstance(value, dict) and key in request_params:
# ensure we don't lose di... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def _sanitize_request_params(self, request_params):
"""Remove keyword arguments not used by `requests`"""
if 'verify_ssl' in request_params:
request_params['verify'] = request_params.pop('verify_ssl')
return dict((key, val) for key, val in request_params.items()
i... | Write a Python 3 script to
remove keyword arguments not used by requests | As a Python code translator, you convert algorithms and pseudocode into Python. |
Send a HTTP request and demand a
| Can you generate a brief explanation for the following Python 3 code
def request(self, method, path, **kwargs):
if path:
url = '%s/%s' % (self.url.rstrip('/'), path.lstrip('/'))
else:
url = self.url
request_params = self._get_request_params(method=method,
... | You are a Python code architect, reviewing and designing scalable and efficient code |
def pre_send(self, request_params):
"""Override this method to modify sent request parameters"""
for adapter in itervalues(self.adapters):
adapter.max_retries = request_params.get('max_retries', 0)
return request_params | How would you code a function in Python 3 to
override this method to modify sent request parameters | As a Python code analyst, you investigate and solve complex coding mysteries |
def is_acceptable(self, response, request_params):
"""
Override this method to create a different definition of
what kind of response is acceptable.
If `bool(the_return_value) is False` then an `HTTPServiceError`
will be raised.
For example, you might want to assert that... | Implement a Python 3 function for
returning True if the response is acceptable for the current request. | You are a Python code analyst, evaluating scripts for potential improvements. |
Rounds a signed list over the last element. | Can you tell what is the following Python 3 function doing
def _roundSlist(slist):
slist[-1] = 60 if slist[-1] >= 30 else 0
for i in range(len(slist)-1, 1, -1):
if slist[i] == 60:
slist[i] = 0
slist[i-1] += 1
return slist[:-1] | You are a Python code architect, reviewing and designing scalable and efficient code |
def strSlist(string):
""" Converts angle string to signed list. """
sign = '-' if string[0] == '-' else '+'
values = [abs(int(x)) for x in string.split(':')]
return _fixSlist(list(sign) + values) | Implement a Python 3 function for
converting angle string to signed list. | You are a Python code generator, capable of creating scripts from specifications. |
def slistStr(slist):
""" Converts signed list to angle string. """
slist = _fixSlist(slist)
string = ':'.join(['%02d' % x for x in slist[1:]])
return slist[0] + string | Create a Python 3 function for
converting signed list to angle string. | As a python code expert, you are capable of creating scripts from specifications. |
def slistFloat(slist):
""" Converts signed list to float. """
values = [v / 60**(i) for (i,v) in enumerate(slist[1:])]
value = sum(values)
return -value if slist[0] == '-' else value | How would you code a function in Python 3 to
convert signed list to float. | You are a Python code generator, capable of creating scripts from specifications. |
Converts float to signed list. | Can you tell what is the following Python 3 function doing
def floatSlist(value):
slist = ['+', 0, 0, 0, 0]
if value < 0:
slist[0] = '-'
value = abs(value)
for i in range(1,5):
slist[i] = math.floor(value)
value = (value - slist[i]) * 60
return _roundSlist(slist) | As a Python code analyst, you investigate and solve complex coding mysteries |
Converts string or signed list to float. | Make a summary of the following Python 3 code
def toFloat(value):
if isinstance(value, str):
return strFloat(value)
elif isinstance(value, list):
return slistFloat(value)
else:
return value | You are a Python code analyst, evaluating scripts for potential improvements. |
Returns the dignities of A which belong to B. | Can you tell what is the following Python 3 function doing
def inDignities(self, idA, idB):
objA = self.chart.get(idA)
info = essential.getInfo(objA.sign, objA.signlon)
# Should we ignore exile and fall?
return [dign for (dign, ID) in info.items() if ID == idB] | As a python code expert, you are capable of creating scripts from specifications. |
Returns all pairs of dignities in mutual reception. | Can you tell what is the following Python 3 function doing
def mutualReceptions(self, idA, idB):
AB = self.receives(idA, idB)
BA = self.receives(idB, idA)
# Returns a product of both lists
return [(a,b) for a in AB for b in BA] | You are a Python code architect, reviewing and designing scalable and efficient code |
def reMutualReceptions(self, idA, idB):
""" Returns ruler and exaltation mutual receptions. """
mr = self.mutualReceptions(idA, idB)
filter_ = ['ruler', 'exalt']
# Each pair of dignities must be 'ruler' or 'exalt'
return [(a,b) for (a,b) in mr if (a in filter_ and b in filter_)] | Can you write a function in Python 3 where it
returns ruler and exaltation mutual receptions. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Returns a list with the aspects an object
makes with the other six planets considering a
list of possible aspects. | Can you tell what is the following Python 3 function doing
def validAspects(self, ID, aspList):
obj = self.chart.getObject(ID)
res = []
for otherID in const.LIST_SEVEN_PLANETS:
if ID == otherID:
continue
otherObj = self.chart.getObjec... | You are a Python code architect, reviewing and designing scalable and efficient code |
Returns the aspects an object makes with the highest priority. | Here you have a function in Python 3, explain what it does
def aspectsByCat(self, ID, aspList):
res = {
const.APPLICATIVE: [],
const.SEPARATIVE: [],
const.EXACT: [],
const.NO_MOVEMENT: []
}
objA = self.chart.getObject(ID)
valid = s... | As a Python code composer, you craft elegant and concise scripts. |
def immediateAspects(self, ID, aspList):
""" Returns the last separation and next application
considering a list of possible aspects.
"""
asps = self.aspectsByCat(ID, aspList)
applications = asps[const.APPLICATIVE]
separations = asps[const.SEPARATIVE]
exact = as... | How would you code a function in Python 3 to
return the last separation and next application based on a list of possible aspects. | As a python code expert, you are capable of creating scripts from specifications. |
Returns if a planet is VOC of Course. | How would you explain what the following Python 3 function does
def isVOC(self, ID):
asps = self.aspectsByCat(ID, const.MAJOR_ASPECTS)
applications = asps[const.APPLICATIVE]
exacts = asps[const.EXACT]
return len(applications) == 0 and len(exacts) == 0 | As a Python code composer, you craft elegant and concise scripts. |
Single factor for the table. | Can you generate the documentation for the following Python 3 function
def singleFactor(factors, chart, factor, obj, aspect=None):
objID = obj if type(obj) == str else obj.id
res = {
'factor': factor,
'objID': objID,
'aspect': aspect
}
# For signs (obj as string) return... | As a Python code composer, you craft elegant and concise scripts. |
def modifierFactor(chart, factor, factorObj, otherObj, aspList):
""" Computes a factor for a modifier. """
asp = aspects.aspectType(factorObj, otherObj, aspList)
if asp != const.NO_ASPECT:
return {
'factor': factor,
'aspect': asp,
'objID': otherObj.id,
... | Write a Python 3 function that can
compute a factor for a modifier. | You are a Python code generator, capable of creating scripts from specifications. |
def getFactors(chart):
""" Returns the factors for the temperament. """
factors = []
# Asc sign
asc = chart.getAngle(const.ASC)
singleFactor(factors, chart, ASC_SIGN, asc.sign)
# Asc ruler
ascRulerID = essential.ruler(asc.sign)
ascRuler = chart.getObject(ascRulerID)
si... | Create a Python 3 function for
returning the list of factors for the temperament. | As a Python code analyst, you investigate and solve complex coding mysteries |
def getModifiers(chart):
""" Returns the factors of the temperament modifiers. """
modifiers = []
# Factors which can be affected
asc = chart.getAngle(const.ASC)
ascRulerID = essential.ruler(asc.sign)
ascRuler = chart.getObject(ascRulerID)
moon = chart.getObject(const.MOON)
fac... | Can you implement a function in Python 3 that
returns the factors of the temperament modifiers. | You are a Python code analyst, evaluating scripts for potential improvements. |
Computes the score of temperaments and qualities of the current resource. | How would you explain what the following Python 3 function does
def scores(factors):
temperaments = {
const.CHOLERIC: 0,
const.MELANCHOLIC: 0,
const.SANGUINE: 0,
const.PHLEGMATIC: 0
}
qualities = {
const.HOT: 0,
const.COLD: 0,
cons... | You are a Python code architect, reviewing and designing scalable and efficient code |
Returns an ephemeris object. | Explain what the following Python 3 code does
def getObject(ID, date, pos):
obj = eph.getObject(ID, date.jd, pos.lat, pos.lon)
return Object.fromDict(obj) | You are a Python code analyst, evaluating scripts for potential improvements. |
Returns a list of objects. | Given the following Python 3 function, write the documentation
def getObjectList(IDs, date, pos):
objList = [getObject(ID, date, pos) for ID in IDs]
return ObjectList(objList) | As a Python code translator, you convert algorithms and pseudocode into Python. |
def getHouses(date, pos, hsys):
""" Returns the lists of houses and angles.
Since houses and angles are computed at the
same time, this function should be fast.
"""
houses, angles = eph.getHouses(date.jd, pos.lat, pos.lon, hsys)
hList = [House.fromDict(house) for house in houses]
a... | Implement a function in Python 3 to
return the lists of houses and angles. | As a Python code composer, you craft elegant and concise scripts. |
def getFixedStar(ID, date):
""" Returns a fixed star from the ephemeris. """
star = eph.getFixedStar(ID, date.jd)
return FixedStar.fromDict(star) | Write a Python 3 function for
returning a fixed star from the ephemeris. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Returns a list of fixed stars. | Given the following Python 3 function, write the documentation
def getFixedStarList(IDs, date):
starList = [getFixedStar(ID, date) for ID in IDs]
return FixedStarList(starList) | As a Python code analyst, you investigate and solve complex coding mysteries |
def nextSolarReturn(date, lon):
""" Returns the next date when sun is at longitude 'lon'. """
jd = eph.nextSolarReturn(date.jd, lon)
return Datetime.fromJD(jd, date.utcoffset) | How would you implement a function in Python 3 that
returns the next date when sun is at longitude lon. | You are a Python code analyst, evaluating scripts for potential improvements. |
Returns the previous date when sun is at longitude lon. | Can you generate the documentation for the following Python 3 function
def prevSolarReturn(date, lon):
jd = eph.prevSolarReturn(date.jd, lon)
return Datetime.fromJD(jd, date.utcoffset) | As a Python code composer, you craft elegant and concise scripts. |
def nextSunrise(date, pos):
""" Returns the date of the next sunrise. """
jd = eph.nextSunrise(date.jd, pos.lat, pos.lon)
return Datetime.fromJD(jd, date.utcoffset) | Can you create a Python 3 function that
returns the date of the next sunrise. | As a Python code composer, you craft elegant and concise scripts. |
def nextStation(ID, date):
""" Returns the aproximate date of the next station. """
jd = eph.nextStation(ID, date.jd)
return Datetime.fromJD(jd, date.utcoffset) | Can you write a function in Python 3 where it
returns the aproximate date of the next station. | As a python code expert, you are capable of creating scripts from specifications. |
Returns the Datetime of the maximum phase of the previous global solar eclipse. | Given the following Python 3 function, write the documentation
def prevSolarEclipse(date):
eclipse = swe.solarEclipseGlobal(date.jd, backward=True)
return Datetime.fromJD(eclipse['maximum'], date.utcoffset) | You are a Python code architect, reviewing and designing scalable and efficient code |
Returns the Datetime of the maximum phase of the next global solar eclipse. | Given the following Python 3 function, write the documentation
def nextSolarEclipse(date):
eclipse = swe.solarEclipseGlobal(date.jd, backward=False)
return Datetime.fromJD(eclipse['maximum'], date.utcoffset) | As a python code expert, you are capable of creating scripts from specifications. |
Returns the Datetime of the maximum phase of the previous global lunar eclipse. | Given the following Python 3 function, write the documentation
def prevLunarEclipse(date):
eclipse = swe.lunarEclipseGlobal(date.jd, backward=True)
return Datetime.fromJD(eclipse['maximum'], date.utcoffset) | You are a Python code analyst, evaluating scripts for potential improvements. |
Returns the Datetime of the maximum phase of the next global lunar eclipse. | Make a summary of the following Python 3 code
def nextLunarEclipse(date):
eclipse = swe.lunarEclipseGlobal(date.jd, backward=False)
return Datetime.fromJD(eclipse['maximum'], date.utcoffset) | As a Python code translator, you convert algorithms and pseudocode into Python. |
def plot(hdiff, title):
""" Plots the tropical solar length
by year.
"""
import matplotlib.pyplot as plt
years = [elem[0] for elem in hdiff]
diffs = [elem[1] for elem in hdiff]
plt.plot(years, diffs)
plt.ylabel('Distance in minutes')
plt.xlabel('Year')
plt.title(title)
p... | How would you implement a function in Python 3 that
plots the tropical solar length by year. | You are a Python code generator, capable of creating scripts from specifications. |
Returns the Ascensional Difference of a point. | Make a summary of the following Python 3 code
def ascdiff(decl, lat):
delta = math.radians(decl)
phi = math.radians(lat)
ad = math.asin(math.tan(delta) * math.tan(phi))
return math.degrees(ad) | You are a Python code generator, capable of creating scripts from specifications. |
def dnarcs(decl, lat):
""" Returns the diurnal and nocturnal arcs of a point. """
dArc = 180 + 2 * ascdiff(decl, lat)
nArc = 360 - dArc
return (dArc, nArc) | How would you code a function in Python 3 to
return the diurnal and nocturnal arcs of a point. | As a Python code analyst, you investigate and solve complex coding mysteries |
def isAboveHorizon(ra, decl, mcRA, lat):
""" Returns if an object's 'ra' and 'decl'
is above the horizon at a specific latitude,
given the MC's right ascension.
"""
# This function checks if the equatorial distance from
# the object to the MC is within its diurnal semi-arc.
dArc... | Can you write a function in Python 3 where it
returns True if an object s ra and decl is above the horizon at a specific latitude. | You are a Python code generator, capable of creating scripts from specifications. |
Converts from ecliptical to equatorial coordinates. | Can you tell what is the following Python 3 function doing
def eqCoords(lon, lat):
# Convert to radians
_lambda = math.radians(lon)
_beta = math.radians(lat)
_epson = math.radians(23.44) # The earth's inclination
# Declination in radians
decl = math.asin(math.sin(_epson) * math.sin(_lambda... | As a Python code analyst, you investigate and solve complex coding mysteries |
def sunRelation(obj, sun):
""" Returns an object's relation with the sun. """
if obj.id == const.SUN:
return None
dist = abs(angle.closestdistance(sun.lon, obj.lon))
if dist < 0.2833: return CAZIMI
elif dist < 8.0: return COMBUST
elif dist < 16.0: return UNDER_SUN
else:
retur... | Can you write a function in Python 3 where it
returns an object s relation with the sun. | You are a Python code analyst, evaluating scripts for potential improvements. |
def light(obj, sun):
""" Returns if an object is augmenting or diminishing light. """
dist = angle.distance(sun.lon, obj.lon)
faster = sun if sun.lonspeed > obj.lonspeed else obj
if faster == sun:
return LIGHT_DIMINISHING if dist < 180 else LIGHT_AUGMENTING
else:
return LIGHT_AUGMENT... | Can you write a function in Python 3 where it
returns if an object is augmenting or diminishing light. | As a Python code composer, you craft elegant and concise scripts. |
Returns if an object is oriental or
occidental to the sun. | Explain what the following Python 3 code does
def orientality(obj, sun):
dist = angle.distance(sun.lon, obj.lon)
return OCCIDENTAL if dist < 180 else ORIENTAL | As a Python code composer, you craft elegant and concise scripts. |
def haiz(obj, chart):
""" Returns if an object is in Haiz. """
objGender = obj.gender()
objFaction = obj.faction()
if obj.id == const.MERCURY:
# Gender and faction of mercury depends on orientality
sun = chart.getObject(const.SUN)
orientalityM = orientality(obj, sun)
... | Write a Python 3 script for
returning if an object is in Haiz. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def house(self):
""" Returns the object's house. """
house = self.chart.houses.getObjectHouse(self.obj)
return house | Write a Python 3 function for
returning the object s house. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Returns the relation of the object with the sun. | How would you explain what the following Python 3 function does
def sunRelation(self):
sun = self.chart.getObject(const.SUN)
return sunRelation(self.obj, sun) | As a Python code translator, you convert algorithms and pseudocode into Python. |
def light(self):
""" Returns if object is augmenting or diminishing its
light.
"""
sun = self.chart.getObject(const.SUN)
return light(self.obj, sun) | How would you implement a function in Python 3 that
returns if object is augmenting or diminishing its | As a Python code translator, you convert algorithms and pseudocode into Python. |
def orientality(self):
""" Returns the orientality of the object. """
sun = self.chart.getObject(const.SUN)
return orientality(self.obj, sun) | How would you implement a function in Python 3 that
returns the orientality of the object. | You are a Python code generator, capable of creating scripts from specifications. |
def inHouseJoy(self):
""" Returns if the object is in its house of joy. """
house = self.house()
return props.object.houseJoy[self.obj.id] == house.id | Write a Python 3 function that can
return True if the object is in its house of joy. | You are a Python code architect, reviewing and designing scalable and efficient code |
def inSignJoy(self):
""" Returns if the object is in its sign of joy. """
return props.object.signJoy[self.obj.id] == self.obj.sign | Can you implement a function in Python 3 that
returns True if the object is in its sign of joy. | As a python code expert, you are capable of creating scripts from specifications. |
Returns all mutual receptions with the object
and other planets indexed by planet ID. | Can you generate a brief explanation for the following Python 3 code
def reMutualReceptions(self):
planets = copy(const.LIST_SEVEN_PLANETS)
planets.remove(self.obj.id)
mrs = {}
for ID in planets:
mr = self.dyn.reMutualReceptions(self.obj.id, ID)
if mr:
... | You are a Python code analyst, evaluating scripts for potential improvements. |
Returns a list with all mutual receptions with the
object and other planets when the reception is the
same for both ruler and both exaltation. | Here you have a function in Python 3, explain what it does
def eqMutualReceptions(self):
mrs = self.reMutualReceptions()
res = []
for ID, receptions in mrs.items():
for pair in receptions:
if pair[0] == pair[1]:
res.append(pair[0])
return r... | You are a Python code analyst, evaluating scripts for potential improvements. |
def __aspectLists(self, IDs, aspList):
""" Returns a list with the aspects that the object
makes to the objects in IDs. It considers only
conjunctions and other exact/applicative aspects
if in aspList.
"""
res = []
for otherID in IDs:
... | Implement a function in Python 3 to
return a list with the aspects that the object makes to the objects in IDs. It considers only conjunctions and other exact or applicative aspects are returned. | You are a Python code architect, reviewing and designing scalable and efficient code |
def aspectBenefics(self):
""" Returns a list with the good aspects the object
makes to the benefics.
"""
benefics = [const.VENUS, const.JUPITER]
return self.__aspectLists(benefics, aspList=[0, 60, 120]) | Implement a Python 3 function for
returning a list of good aspects the object makes to the benefics. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Returns a list with the bad aspects the object
makes to the malefics. | Can you tell what is the following Python 3 function doing
def aspectMalefics(self):
malefics = [const.MARS, const.SATURN]
return self.__aspectLists(malefics, aspList=[0, 90, 180]) | As a Python code translator, you convert algorithms and pseudocode into Python. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.