repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
guaix-ucm/numina | numina/array/wavecalib/check_wlcalib.py | fun_wv | def fun_wv(xchannel, crpix1, crval1, cdelt1):
"""Compute wavelengths from channels.
The wavelength calibration is provided through the usual parameters
CRPIX1, CRVAL1 and CDELT1.
Parameters
----------
xchannel : numpy array
Input channels where the wavelengths will be evaluated.
cr... | python | def fun_wv(xchannel, crpix1, crval1, cdelt1):
"""Compute wavelengths from channels.
The wavelength calibration is provided through the usual parameters
CRPIX1, CRVAL1 and CDELT1.
Parameters
----------
xchannel : numpy array
Input channels where the wavelengths will be evaluated.
cr... | [
"def",
"fun_wv",
"(",
"xchannel",
",",
"crpix1",
",",
"crval1",
",",
"cdelt1",
")",
":",
"wv",
"=",
"crval1",
"+",
"(",
"xchannel",
"-",
"crpix1",
")",
"*",
"cdelt1",
"return",
"wv"
] | Compute wavelengths from channels.
The wavelength calibration is provided through the usual parameters
CRPIX1, CRVAL1 and CDELT1.
Parameters
----------
xchannel : numpy array
Input channels where the wavelengths will be evaluated.
crpix1: float
CRPIX1 keyword.
crval1: float... | [
"Compute",
"wavelengths",
"from",
"channels",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/check_wlcalib.py#L109-L133 | train | Compute the wavelength calibration from channels. |
guaix-ucm/numina | numina/array/wavecalib/check_wlcalib.py | check_wlcalib_sp | def check_wlcalib_sp(sp, crpix1, crval1, cdelt1, wv_master,
coeff_ini=None, naxis1_ini=None,
min_nlines_to_refine=0,
interactive=False,
threshold=0,
nwinwidth_initial=7,
nwinwidth_refined=5,
... | python | def check_wlcalib_sp(sp, crpix1, crval1, cdelt1, wv_master,
coeff_ini=None, naxis1_ini=None,
min_nlines_to_refine=0,
interactive=False,
threshold=0,
nwinwidth_initial=7,
nwinwidth_refined=5,
... | [
"def",
"check_wlcalib_sp",
"(",
"sp",
",",
"crpix1",
",",
"crval1",
",",
"cdelt1",
",",
"wv_master",
",",
"coeff_ini",
"=",
"None",
",",
"naxis1_ini",
"=",
"None",
",",
"min_nlines_to_refine",
"=",
"0",
",",
"interactive",
"=",
"False",
",",
"threshold",
"... | Check wavelength calibration of the provided spectrum.
Parameters
----------
sp : numpy array
Wavelength calibrated spectrum.
crpix1: float
CRPIX1 keyword.
crval1: float
CRVAL1 keyword.
cdelt1: float
CDELT1 keyword.
wv_master: numpy array
Array with t... | [
"Check",
"wavelength",
"calibration",
"of",
"the",
"provided",
"spectrum",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/check_wlcalib.py#L136-L617 | train | This function checks the wavelength calibration of the provided spectrum. |
guaix-ucm/numina | numina/array/wavecalib/check_wlcalib.py | update_poly_wlcalib | def update_poly_wlcalib(coeff_ini, coeff_residuals, naxis1_ini, debugplot):
"""Update wavelength calibration polynomial using the residuals fit.
The idea is to repeat the original fit using the information
previously computed with the function check_wlcalib_sp() in this
module.
Parameters
----... | python | def update_poly_wlcalib(coeff_ini, coeff_residuals, naxis1_ini, debugplot):
"""Update wavelength calibration polynomial using the residuals fit.
The idea is to repeat the original fit using the information
previously computed with the function check_wlcalib_sp() in this
module.
Parameters
----... | [
"def",
"update_poly_wlcalib",
"(",
"coeff_ini",
",",
"coeff_residuals",
",",
"naxis1_ini",
",",
"debugplot",
")",
":",
"# define initial wavelength calibration polynomial (use generic",
"# code valid for lists of numpy.arrays)",
"coeff",
"=",
"[",
"]",
"for",
"fdum",
"in",
... | Update wavelength calibration polynomial using the residuals fit.
The idea is to repeat the original fit using the information
previously computed with the function check_wlcalib_sp() in this
module.
Parameters
----------
coeff_ini : array like (floats)
Coefficients corresponding to th... | [
"Update",
"wavelength",
"calibration",
"polynomial",
"using",
"the",
"residuals",
"fit",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/check_wlcalib.py#L620-L693 | train | Update the wavelength calibration polynomial for a single entry in the original spectrum. |
guaix-ucm/numina | numina/core/metarecipes.py | generate_docs | def generate_docs(klass):
"""Add documentation to generated classes"""
import numina.types.datatype
attrh = ('Attributes\n'
'----------\n')
doc = getattr(klass, '__doc__', None)
if doc is None or doc == '':
doc = "%s documentation." % klass.__name__
if len(klass.stored()... | python | def generate_docs(klass):
"""Add documentation to generated classes"""
import numina.types.datatype
attrh = ('Attributes\n'
'----------\n')
doc = getattr(klass, '__doc__', None)
if doc is None or doc == '':
doc = "%s documentation." % klass.__name__
if len(klass.stored()... | [
"def",
"generate_docs",
"(",
"klass",
")",
":",
"import",
"numina",
".",
"types",
".",
"datatype",
"attrh",
"=",
"(",
"'Attributes\\n'",
"'----------\\n'",
")",
"doc",
"=",
"getattr",
"(",
"klass",
",",
"'__doc__'",
",",
"None",
")",
"if",
"doc",
"is",
"... | Add documentation to generated classes | [
"Add",
"documentation",
"to",
"generated",
"classes"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/metarecipes.py#L83-L129 | train | Add documentation to generated classes |
guaix-ucm/numina | numina/types/product.py | DataProductMixin.extract_db_info | def extract_db_info(self, obj, keys):
"""Extract metadata from serialized file"""
result = {}
if isinstance(obj, dict):
try:
qc = obj['quality_control']
except KeyError:
qc = QC.UNKNOWN
elif isinstance(obj, DataFrame):
w... | python | def extract_db_info(self, obj, keys):
"""Extract metadata from serialized file"""
result = {}
if isinstance(obj, dict):
try:
qc = obj['quality_control']
except KeyError:
qc = QC.UNKNOWN
elif isinstance(obj, DataFrame):
w... | [
"def",
"extract_db_info",
"(",
"self",
",",
"obj",
",",
"keys",
")",
":",
"result",
"=",
"{",
"}",
"if",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"try",
":",
"qc",
"=",
"obj",
"[",
"'quality_control'",
"]",
"except",
"KeyError",
":",
"qc",
... | Extract metadata from serialized file | [
"Extract",
"metadata",
"from",
"serialized",
"file"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/types/product.py#L43-L60 | train | Extract metadata from serialized file |
xflr6/bitsets | bitsets/integers.py | reinverted | def reinverted(n, r):
"""Integer with reversed and inverted bits of n assuming bit length r.
>>> reinverted(1, 6)
31
>>> [reinverted(x, 6) for x in [7, 11, 13, 14, 19, 21, 22, 25, 26, 28]]
[7, 11, 19, 35, 13, 21, 37, 25, 41, 49]
"""
result = 0
r = 1 << (r - 1)
while n:
if n... | python | def reinverted(n, r):
"""Integer with reversed and inverted bits of n assuming bit length r.
>>> reinverted(1, 6)
31
>>> [reinverted(x, 6) for x in [7, 11, 13, 14, 19, 21, 22, 25, 26, 28]]
[7, 11, 19, 35, 13, 21, 37, 25, 41, 49]
"""
result = 0
r = 1 << (r - 1)
while n:
if n... | [
"def",
"reinverted",
"(",
"n",
",",
"r",
")",
":",
"result",
"=",
"0",
"r",
"=",
"1",
"<<",
"(",
"r",
"-",
"1",
")",
"while",
"n",
":",
"if",
"not",
"n",
"&",
"1",
":",
"result",
"|=",
"r",
"r",
">>=",
"1",
"n",
">>=",
"1",
"if",
"r",
"... | Integer with reversed and inverted bits of n assuming bit length r.
>>> reinverted(1, 6)
31
>>> [reinverted(x, 6) for x in [7, 11, 13, 14, 19, 21, 22, 25, 26, 28]]
[7, 11, 19, 35, 13, 21, 37, 25, 41, 49] | [
"Integer",
"with",
"reversed",
"and",
"inverted",
"bits",
"of",
"n",
"assuming",
"bit",
"length",
"r",
"."
] | ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf | https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/integers.py#L35-L53 | train | Integer with reversed and inverted bits of n assuming bit length r. |
xflr6/bitsets | bitsets/integers.py | rank | def rank(items, sequence=string.ascii_lowercase):
"""Rank items from sequence in colexicographical order.
>>> [rank(i) for i in ('', 'a', 'b', 'ab', 'c')]
[0, 1, 2, 3, 4]
>>> rank('spam')
299009
"""
items = set(items)
return sum(1 << i for i, s in enumerate(sequence) if s in items) | python | def rank(items, sequence=string.ascii_lowercase):
"""Rank items from sequence in colexicographical order.
>>> [rank(i) for i in ('', 'a', 'b', 'ab', 'c')]
[0, 1, 2, 3, 4]
>>> rank('spam')
299009
"""
items = set(items)
return sum(1 << i for i, s in enumerate(sequence) if s in items) | [
"def",
"rank",
"(",
"items",
",",
"sequence",
"=",
"string",
".",
"ascii_lowercase",
")",
":",
"items",
"=",
"set",
"(",
"items",
")",
"return",
"sum",
"(",
"1",
"<<",
"i",
"for",
"i",
",",
"s",
"in",
"enumerate",
"(",
"sequence",
")",
"if",
"s",
... | Rank items from sequence in colexicographical order.
>>> [rank(i) for i in ('', 'a', 'b', 'ab', 'c')]
[0, 1, 2, 3, 4]
>>> rank('spam')
299009 | [
"Rank",
"items",
"from",
"sequence",
"in",
"colexicographical",
"order",
"."
] | ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf | https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/integers.py#L56-L66 | train | Rank items from sequence in colexicographical order. |
xflr6/bitsets | bitsets/integers.py | unrank | def unrank(n, sequence=string.ascii_lowercase):
"""Unrank n from sequence in colexicographical order.
>>> [''.join(unrank(i)) for i in range(8)]
['', 'a', 'b', 'ab', 'c', 'ac', 'bc', 'abc']
>>> unrank(299009)
['a', 'm', 'p', 's']
"""
return list(map(sequence.__getitem__, indexes(n))) | python | def unrank(n, sequence=string.ascii_lowercase):
"""Unrank n from sequence in colexicographical order.
>>> [''.join(unrank(i)) for i in range(8)]
['', 'a', 'b', 'ab', 'c', 'ac', 'bc', 'abc']
>>> unrank(299009)
['a', 'm', 'p', 's']
"""
return list(map(sequence.__getitem__, indexes(n))) | [
"def",
"unrank",
"(",
"n",
",",
"sequence",
"=",
"string",
".",
"ascii_lowercase",
")",
":",
"return",
"list",
"(",
"map",
"(",
"sequence",
".",
"__getitem__",
",",
"indexes",
"(",
"n",
")",
")",
")"
] | Unrank n from sequence in colexicographical order.
>>> [''.join(unrank(i)) for i in range(8)]
['', 'a', 'b', 'ab', 'c', 'ac', 'bc', 'abc']
>>> unrank(299009)
['a', 'm', 'p', 's'] | [
"Unrank",
"n",
"from",
"sequence",
"in",
"colexicographical",
"order",
"."
] | ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf | https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/integers.py#L69-L78 | train | Unrank n from sequence in colexicographical order. |
guaix-ucm/numina | numina/array/background.py | background_estimator | def background_estimator(bdata):
"""Estimate the background in a 2D array"""
crowded = False
std = numpy.std(bdata)
std0 = std
mean = bdata.mean()
while True:
prep = len(bdata)
numpy.clip(bdata, mean - 3 * std, mean + 3 * std, out=bdata)
if prep == len(bdata):
... | python | def background_estimator(bdata):
"""Estimate the background in a 2D array"""
crowded = False
std = numpy.std(bdata)
std0 = std
mean = bdata.mean()
while True:
prep = len(bdata)
numpy.clip(bdata, mean - 3 * std, mean + 3 * std, out=bdata)
if prep == len(bdata):
... | [
"def",
"background_estimator",
"(",
"bdata",
")",
":",
"crowded",
"=",
"False",
"std",
"=",
"numpy",
".",
"std",
"(",
"bdata",
")",
"std0",
"=",
"std",
"mean",
"=",
"bdata",
".",
"mean",
"(",
")",
"while",
"True",
":",
"prep",
"=",
"len",
"(",
"bda... | Estimate the background in a 2D array | [
"Estimate",
"the",
"background",
"in",
"a",
"2D",
"array"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/background.py#L37-L61 | train | Estimate the background in a 2D array |
guaix-ucm/numina | numina/array/background.py | create_background_map | def create_background_map(data, bsx, bsy):
"""Create a background map with a given mesh size"""
sx, sy = data.shape
mx = sx // bsx
my = sy // bsy
comp = []
rms = []
# Rows
sp = numpy.split(data, numpy.arange(bsx, sx, bsx), axis=0)
for s in sp:
# Columns
rp = numpy.spl... | python | def create_background_map(data, bsx, bsy):
"""Create a background map with a given mesh size"""
sx, sy = data.shape
mx = sx // bsx
my = sy // bsy
comp = []
rms = []
# Rows
sp = numpy.split(data, numpy.arange(bsx, sx, bsx), axis=0)
for s in sp:
# Columns
rp = numpy.spl... | [
"def",
"create_background_map",
"(",
"data",
",",
"bsx",
",",
"bsy",
")",
":",
"sx",
",",
"sy",
"=",
"data",
".",
"shape",
"mx",
"=",
"sx",
"//",
"bsx",
"my",
"=",
"sy",
"//",
"bsy",
"comp",
"=",
"[",
"]",
"rms",
"=",
"[",
"]",
"# Rows",
"sp",
... | Create a background map with a given mesh size | [
"Create",
"a",
"background",
"map",
"with",
"a",
"given",
"mesh",
"size"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/background.py#L64-L95 | train | Create a background map with a given mesh size |
ckan/losser | losser/losser.py | _read_columns_file | def _read_columns_file(f):
"""Return the list of column queries read from the given JSON file.
:param f: path to the file to read
:type f: string
:rtype: list of dicts
"""
try:
columns = json.loads(open(f, 'r').read(),
object_pairs_hook=collections.Ordered... | python | def _read_columns_file(f):
"""Return the list of column queries read from the given JSON file.
:param f: path to the file to read
:type f: string
:rtype: list of dicts
"""
try:
columns = json.loads(open(f, 'r').read(),
object_pairs_hook=collections.Ordered... | [
"def",
"_read_columns_file",
"(",
"f",
")",
":",
"try",
":",
"columns",
"=",
"json",
".",
"loads",
"(",
"open",
"(",
"f",
",",
"'r'",
")",
".",
"read",
"(",
")",
",",
"object_pairs_hook",
"=",
"collections",
".",
"OrderedDict",
")",
"except",
"Exceptio... | Return the list of column queries read from the given JSON file.
:param f: path to the file to read
:type f: string
:rtype: list of dicts | [
"Return",
"the",
"list",
"of",
"column",
"queries",
"read",
"from",
"the",
"given",
"JSON",
"file",
"."
] | fd0832d9fa93cabe9ce9a9153dc923f2cf39cb5f | https://github.com/ckan/losser/blob/fd0832d9fa93cabe9ce9a9153dc923f2cf39cb5f/losser/losser.py#L23-L43 | train | Read the JSON file and return the list of dicts |
ckan/losser | losser/losser.py | _write_csv | def _write_csv(f, table_):
"""Write the given table (list of dicts) to the given file as CSV.
Writes UTF8-encoded, CSV-formatted text.
``f`` could be an opened file, sys.stdout, or a StringIO.
"""
fieldnames = table_[0].keys()
set_fieldname = set(table_[0].keys())
# go through all the fie... | python | def _write_csv(f, table_):
"""Write the given table (list of dicts) to the given file as CSV.
Writes UTF8-encoded, CSV-formatted text.
``f`` could be an opened file, sys.stdout, or a StringIO.
"""
fieldnames = table_[0].keys()
set_fieldname = set(table_[0].keys())
# go through all the fie... | [
"def",
"_write_csv",
"(",
"f",
",",
"table_",
")",
":",
"fieldnames",
"=",
"table_",
"[",
"0",
"]",
".",
"keys",
"(",
")",
"set_fieldname",
"=",
"set",
"(",
"table_",
"[",
"0",
"]",
".",
"keys",
"(",
")",
")",
"# go through all the fields and find all th... | Write the given table (list of dicts) to the given file as CSV.
Writes UTF8-encoded, CSV-formatted text.
``f`` could be an opened file, sys.stdout, or a StringIO. | [
"Write",
"the",
"given",
"table",
"(",
"list",
"of",
"dicts",
")",
"to",
"the",
"given",
"file",
"as",
"CSV",
"."
] | fd0832d9fa93cabe9ce9a9153dc923f2cf39cb5f | https://github.com/ckan/losser/blob/fd0832d9fa93cabe9ce9a9153dc923f2cf39cb5f/losser/losser.py#L46-L73 | train | Write the given table as CSV. |
ckan/losser | losser/losser.py | _table_to_csv | def _table_to_csv(table_):
"""Return the given table converted to a CSV string.
:param table: the table to convert
:type table: list of OrderedDicts each with the same keys in the same
order
:rtype: UTF8-encoded, CSV-formatted string
"""
f = cStringIO.StringIO()
try:
_writ... | python | def _table_to_csv(table_):
"""Return the given table converted to a CSV string.
:param table: the table to convert
:type table: list of OrderedDicts each with the same keys in the same
order
:rtype: UTF8-encoded, CSV-formatted string
"""
f = cStringIO.StringIO()
try:
_writ... | [
"def",
"_table_to_csv",
"(",
"table_",
")",
":",
"f",
"=",
"cStringIO",
".",
"StringIO",
"(",
")",
"try",
":",
"_write_csv",
"(",
"f",
",",
"table_",
")",
"return",
"f",
".",
"getvalue",
"(",
")",
"finally",
":",
"f",
".",
"close",
"(",
")"
] | Return the given table converted to a CSV string.
:param table: the table to convert
:type table: list of OrderedDicts each with the same keys in the same
order
:rtype: UTF8-encoded, CSV-formatted string | [
"Return",
"the",
"given",
"table",
"converted",
"to",
"a",
"CSV",
"string",
"."
] | fd0832d9fa93cabe9ce9a9153dc923f2cf39cb5f | https://github.com/ckan/losser/blob/fd0832d9fa93cabe9ce9a9153dc923f2cf39cb5f/losser/losser.py#L76-L91 | train | Convert a list of OrderedDicts to a CSV string. |
ckan/losser | losser/losser.py | table | def table(dicts, columns, csv=False, pretty=False):
"""Query a list of dicts with a list of queries and return a table.
A "table" is a list of OrderedDicts each having the same keys in the same
order.
:param dicts: the list of input dicts
:type dicts: list of dicts
:param columns: the list of... | python | def table(dicts, columns, csv=False, pretty=False):
"""Query a list of dicts with a list of queries and return a table.
A "table" is a list of OrderedDicts each having the same keys in the same
order.
:param dicts: the list of input dicts
:type dicts: list of dicts
:param columns: the list of... | [
"def",
"table",
"(",
"dicts",
",",
"columns",
",",
"csv",
"=",
"False",
",",
"pretty",
"=",
"False",
")",
":",
"# Optionally read columns from file.",
"if",
"isinstance",
"(",
"columns",
",",
"basestring",
")",
":",
"columns",
"=",
"_read_columns_file",
"(",
... | Query a list of dicts with a list of queries and return a table.
A "table" is a list of OrderedDicts each having the same keys in the same
order.
:param dicts: the list of input dicts
:type dicts: list of dicts
:param columns: the list of column query dicts, or the path to a JSON file
con... | [
"Query",
"a",
"list",
"of",
"dicts",
"with",
"a",
"list",
"of",
"queries",
"and",
"return",
"a",
"table",
"."
] | fd0832d9fa93cabe9ce9a9153dc923f2cf39cb5f | https://github.com/ckan/losser/blob/fd0832d9fa93cabe9ce9a9153dc923f2cf39cb5f/losser/losser.py#L94-L151 | train | Query a list of dicts with a list of queries and return a table. |
ckan/losser | losser/losser.py | query | def query(pattern_path, dict_, max_length=None, strip=False,
case_sensitive=False, unique=False, deduplicate=False,
string_transformations=None, hyperlink=False,
return_multiple_columns=False):
"""Query the given dict with the given pattern path and return the result.
The ``patter... | python | def query(pattern_path, dict_, max_length=None, strip=False,
case_sensitive=False, unique=False, deduplicate=False,
string_transformations=None, hyperlink=False,
return_multiple_columns=False):
"""Query the given dict with the given pattern path and return the result.
The ``patter... | [
"def",
"query",
"(",
"pattern_path",
",",
"dict_",
",",
"max_length",
"=",
"None",
",",
"strip",
"=",
"False",
",",
"case_sensitive",
"=",
"False",
",",
"unique",
"=",
"False",
",",
"deduplicate",
"=",
"False",
",",
"string_transformations",
"=",
"None",
"... | Query the given dict with the given pattern path and return the result.
The ``pattern_path`` is a either a single regular expression string or a
list of regex strings that will be matched against the keys of the dict and
its subdicts to find the value(s) in the dict to return.
The returned result is e... | [
"Query",
"the",
"given",
"dict",
"with",
"the",
"given",
"pattern",
"path",
"and",
"return",
"the",
"result",
"."
] | fd0832d9fa93cabe9ce9a9153dc923f2cf39cb5f | https://github.com/ckan/losser/blob/fd0832d9fa93cabe9ce9a9153dc923f2cf39cb5f/losser/losser.py#L154-L218 | train | Query the given dict with the given pattern path and return the result. |
SUNCAT-Center/CatHub | cathub/query.py | get_reactions | def get_reactions(columns='all', n_results=20, write_db=False, **kwargs):
"""
Get reactions from server
Give key value strings as arguments
"""
if write_db or columns == 'all':
columns = all_columns['reactions']
queries = {}
for key, value in kwargs.items():
key = map_column... | python | def get_reactions(columns='all', n_results=20, write_db=False, **kwargs):
"""
Get reactions from server
Give key value strings as arguments
"""
if write_db or columns == 'all':
columns = all_columns['reactions']
queries = {}
for key, value in kwargs.items():
key = map_column... | [
"def",
"get_reactions",
"(",
"columns",
"=",
"'all'",
",",
"n_results",
"=",
"20",
",",
"write_db",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"write_db",
"or",
"columns",
"==",
"'all'",
":",
"columns",
"=",
"all_columns",
"[",
"'reactions'",... | Get reactions from server
Give key value strings as arguments | [
"Get",
"reactions",
"from",
"server"
] | 324625d1d8e740673f139658b2de4c9e1059739e | https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/query.py#L136-L231 | train | Get reactions from server |
guaix-ucm/numina | numina/user/baserun.py | run_reduce | def run_reduce(datastore, obsid, copy_files=True):
"""Observing mode processing mode of numina."""
request = 'reduce'
request_params = {}
rb = ReductionBlock()
rb.id = obsid
request_params['oblock_id'] = rb.id
request_params["pipeline"] = rb.pipeline
request_params["instrument_configu... | python | def run_reduce(datastore, obsid, copy_files=True):
"""Observing mode processing mode of numina."""
request = 'reduce'
request_params = {}
rb = ReductionBlock()
rb.id = obsid
request_params['oblock_id'] = rb.id
request_params["pipeline"] = rb.pipeline
request_params["instrument_configu... | [
"def",
"run_reduce",
"(",
"datastore",
",",
"obsid",
",",
"copy_files",
"=",
"True",
")",
":",
"request",
"=",
"'reduce'",
"request_params",
"=",
"{",
"}",
"rb",
"=",
"ReductionBlock",
"(",
")",
"rb",
".",
"id",
"=",
"obsid",
"request_params",
"[",
"'obl... | Observing mode processing mode of numina. | [
"Observing",
"mode",
"processing",
"mode",
"of",
"numina",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/user/baserun.py#L46-L142 | train | This function runs the reduce task. |
guaix-ucm/numina | numina/user/baserun.py | create_recipe_file_logger | def create_recipe_file_logger(logger, logfile, logformat):
"""Redirect Recipe log messages to a file."""
recipe_formatter = logging.Formatter(logformat)
fh = logging.FileHandler(logfile, mode='w')
fh.setLevel(logging.DEBUG)
fh.setFormatter(recipe_formatter)
return fh | python | def create_recipe_file_logger(logger, logfile, logformat):
"""Redirect Recipe log messages to a file."""
recipe_formatter = logging.Formatter(logformat)
fh = logging.FileHandler(logfile, mode='w')
fh.setLevel(logging.DEBUG)
fh.setFormatter(recipe_formatter)
return fh | [
"def",
"create_recipe_file_logger",
"(",
"logger",
",",
"logfile",
",",
"logformat",
")",
":",
"recipe_formatter",
"=",
"logging",
".",
"Formatter",
"(",
"logformat",
")",
"fh",
"=",
"logging",
".",
"FileHandler",
"(",
"logfile",
",",
"mode",
"=",
"'w'",
")"... | Redirect Recipe log messages to a file. | [
"Redirect",
"Recipe",
"log",
"messages",
"to",
"a",
"file",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/user/baserun.py#L145-L151 | train | Redirect Recipe log messages to a file. |
guaix-ucm/numina | numina/user/baserun.py | run_recipe | def run_recipe(recipe, task, rinput, workenv, logger_control):
"""Recipe execution mode of numina."""
# Creating custom logger file
recipe_logger = logging.getLogger(logger_control['default'])
if logger_control['enabled']:
logfile = os.path.join(workenv.resultsdir, logger_control['logfile'])
... | python | def run_recipe(recipe, task, rinput, workenv, logger_control):
"""Recipe execution mode of numina."""
# Creating custom logger file
recipe_logger = logging.getLogger(logger_control['default'])
if logger_control['enabled']:
logfile = os.path.join(workenv.resultsdir, logger_control['logfile'])
... | [
"def",
"run_recipe",
"(",
"recipe",
",",
"task",
",",
"rinput",
",",
"workenv",
",",
"logger_control",
")",
":",
"# Creating custom logger file",
"recipe_logger",
"=",
"logging",
".",
"getLogger",
"(",
"logger_control",
"[",
"'default'",
"]",
")",
"if",
"logger_... | Recipe execution mode of numina. | [
"Recipe",
"execution",
"mode",
"of",
"numina",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/user/baserun.py#L154-L175 | train | This function runs a recipe in numina mode. |
guaix-ucm/numina | numina/user/baserun.py | run_recipe_timed | def run_recipe_timed(task, recipe, rinput):
"""Run the recipe and count the time it takes."""
_logger.info('running recipe')
now1 = datetime.datetime.now()
task.state = 1
task.time_start = now1
#
result = recipe(rinput)
_logger.info('result: %r', result)
task.result = result
#
... | python | def run_recipe_timed(task, recipe, rinput):
"""Run the recipe and count the time it takes."""
_logger.info('running recipe')
now1 = datetime.datetime.now()
task.state = 1
task.time_start = now1
#
result = recipe(rinput)
_logger.info('result: %r', result)
task.result = result
#
... | [
"def",
"run_recipe_timed",
"(",
"task",
",",
"recipe",
",",
"rinput",
")",
":",
"_logger",
".",
"info",
"(",
"'running recipe'",
")",
"now1",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"task",
".",
"state",
"=",
"1",
"task",
".",
"time_sta... | Run the recipe and count the time it takes. | [
"Run",
"the",
"recipe",
"and",
"count",
"the",
"time",
"it",
"takes",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/user/baserun.py#L178-L192 | train | Run the recipe and count the time it takes. |
PaulMcMillan/tasa | tasa/utils.py | iterit | def iterit(*args, **kwargs):
"""
This takes some input (int, string, list, iterable, whatever) and
makes sure it is an iterable, making it a single item list if not.
Importantly, it does rational things with strings.
You can pass it more than one item. Cast is optional.
def foo(offsets=10):
... | python | def iterit(*args, **kwargs):
"""
This takes some input (int, string, list, iterable, whatever) and
makes sure it is an iterable, making it a single item list if not.
Importantly, it does rational things with strings.
You can pass it more than one item. Cast is optional.
def foo(offsets=10):
... | [
"def",
"iterit",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
">",
"1",
":",
"return",
"[",
"iterit",
"(",
"arg",
",",
"*",
"*",
"kwargs",
")",
"for",
"arg",
"in",
"args",
"]",
"return",
"map",
"(",
"kwa... | This takes some input (int, string, list, iterable, whatever) and
makes sure it is an iterable, making it a single item list if not.
Importantly, it does rational things with strings.
You can pass it more than one item. Cast is optional.
def foo(offsets=10):
offsets = iterit(offsets, cast=int)... | [
"This",
"takes",
"some",
"input",
"(",
"int",
"string",
"list",
"iterable",
"whatever",
")",
"and",
"makes",
"sure",
"it",
"is",
"an",
"iterable",
"making",
"it",
"a",
"single",
"item",
"list",
"if",
"not",
".",
"Importantly",
"it",
"does",
"rational",
"... | fd548d97fd08e61c0e71296b08ffedb7d949e06a | https://github.com/PaulMcMillan/tasa/blob/fd548d97fd08e61c0e71296b08ffedb7d949e06a/tasa/utils.py#L1-L33 | train | This function takes some input and returns a list of items. |
kyzima-spb/flask-pony | flask_pony/__init__.py | stop_db_session | def stop_db_session(exc=None):
"""Stops the last db_session"""
# print('==> Stop session', type(exc))
if has_db_session():
exc_type = None
tb = None
if exc:
exc_type, exc, tb = get_exc_info(exc)
db_session.__exit__(exc_type, exc, tb) | python | def stop_db_session(exc=None):
"""Stops the last db_session"""
# print('==> Stop session', type(exc))
if has_db_session():
exc_type = None
tb = None
if exc:
exc_type, exc, tb = get_exc_info(exc)
db_session.__exit__(exc_type, exc, tb) | [
"def",
"stop_db_session",
"(",
"exc",
"=",
"None",
")",
":",
"# print('==> Stop session', type(exc))",
"if",
"has_db_session",
"(",
")",
":",
"exc_type",
"=",
"None",
"tb",
"=",
"None",
"if",
"exc",
":",
"exc_type",
",",
"exc",
",",
"tb",
"=",
"get_exc_info"... | Stops the last db_session | [
"Stops",
"the",
"last",
"db_session"
] | 6cf28d70b7ebf415d58fa138fcc70b8dd57432c7 | https://github.com/kyzima-spb/flask-pony/blob/6cf28d70b7ebf415d58fa138fcc70b8dd57432c7/flask_pony/__init__.py#L47-L58 | train | Stops the last db_session |
pylp/pylp | pylp/lib/dest.py | get_path | def get_path(dest, file, cwd = None):
"""Get the writing path of a file."""
if callable(dest):
return dest(file)
if not cwd:
cwd = file.cwd
if not os.path.isabs(dest):
dest = os.path.join(cwd, dest)
relative = os.path.relpath(file.path, file.base)
return os.path.join(dest, relative) | python | def get_path(dest, file, cwd = None):
"""Get the writing path of a file."""
if callable(dest):
return dest(file)
if not cwd:
cwd = file.cwd
if not os.path.isabs(dest):
dest = os.path.join(cwd, dest)
relative = os.path.relpath(file.path, file.base)
return os.path.join(dest, relative) | [
"def",
"get_path",
"(",
"dest",
",",
"file",
",",
"cwd",
"=",
"None",
")",
":",
"if",
"callable",
"(",
"dest",
")",
":",
"return",
"dest",
"(",
"file",
")",
"if",
"not",
"cwd",
":",
"cwd",
"=",
"file",
".",
"cwd",
"if",
"not",
"os",
".",
"path"... | Get the writing path of a file. | [
"Get",
"the",
"writing",
"path",
"of",
"a",
"file",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/dest.py#L23-L34 | train | Get the writing path of a file. |
pylp/pylp | pylp/lib/dest.py | write_file | def write_file(path, contents):
"""Write contents to a local file."""
os.makedirs(os.path.dirname(path), exist_ok=True)
with open(path, "w") as file:
file.write(contents) | python | def write_file(path, contents):
"""Write contents to a local file."""
os.makedirs(os.path.dirname(path), exist_ok=True)
with open(path, "w") as file:
file.write(contents) | [
"def",
"write_file",
"(",
"path",
",",
"contents",
")",
":",
"os",
".",
"makedirs",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"path",
")",
",",
"exist_ok",
"=",
"True",
")",
"with",
"open",
"(",
"path",
",",
"\"w\"",
")",
"as",
"file",
":",
"f... | Write contents to a local file. | [
"Write",
"contents",
"to",
"a",
"local",
"file",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/dest.py#L37-L41 | train | Write contents to a local file. |
pylp/pylp | pylp/lib/dest.py | FileWriter.transform | async def transform(self, file):
"""Function called when a file need to be transformed."""
path = get_path(self.dest, file)
await self.loop.run_in_executor(self.exe, write_file, path, file.contents)
return file | python | async def transform(self, file):
"""Function called when a file need to be transformed."""
path = get_path(self.dest, file)
await self.loop.run_in_executor(self.exe, write_file, path, file.contents)
return file | [
"async",
"def",
"transform",
"(",
"self",
",",
"file",
")",
":",
"path",
"=",
"get_path",
"(",
"self",
".",
"dest",
",",
"file",
")",
"await",
"self",
".",
"loop",
".",
"run_in_executor",
"(",
"self",
".",
"exe",
",",
"write_file",
",",
"path",
",",
... | Function called when a file need to be transformed. | [
"Function",
"called",
"when",
"a",
"file",
"need",
"to",
"be",
"transformed",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/dest.py#L58-L62 | train | Function called when a file need to be transformed. |
SUNCAT-Center/CatHub | cathub/tools.py | get_pub_id | def get_pub_id(title, authors, year):
"construct publication id"
if len(title.split(' ')) > 1 \
and title.split(' ')[0].lower() in ['the', 'a']:
_first_word = title.split(' ')[1].split('_')[0]
else:
_first_word = title.split(' ')[0].split('_')[0]
pub_id = authors[0].split(',')[0]... | python | def get_pub_id(title, authors, year):
"construct publication id"
if len(title.split(' ')) > 1 \
and title.split(' ')[0].lower() in ['the', 'a']:
_first_word = title.split(' ')[1].split('_')[0]
else:
_first_word = title.split(' ')[0].split('_')[0]
pub_id = authors[0].split(',')[0]... | [
"def",
"get_pub_id",
"(",
"title",
",",
"authors",
",",
"year",
")",
":",
"if",
"len",
"(",
"title",
".",
"split",
"(",
"' '",
")",
")",
">",
"1",
"and",
"title",
".",
"split",
"(",
"' '",
")",
"[",
"0",
"]",
".",
"lower",
"(",
")",
"in",
"["... | construct publication id | [
"construct",
"publication",
"id"
] | 324625d1d8e740673f139658b2de4c9e1059739e | https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/tools.py#L4-L15 | train | construct publication id |
SUNCAT-Center/CatHub | cathub/tools.py | extract_atoms | def extract_atoms(molecule):
"""Return a string with all atoms in molecule"""
if molecule == '':
return molecule
try:
return float(molecule)
except BaseException:
pass
atoms = ''
if not molecule[0].isalpha():
i = 0
while not molecule[i].isalpha():
... | python | def extract_atoms(molecule):
"""Return a string with all atoms in molecule"""
if molecule == '':
return molecule
try:
return float(molecule)
except BaseException:
pass
atoms = ''
if not molecule[0].isalpha():
i = 0
while not molecule[i].isalpha():
... | [
"def",
"extract_atoms",
"(",
"molecule",
")",
":",
"if",
"molecule",
"==",
"''",
":",
"return",
"molecule",
"try",
":",
"return",
"float",
"(",
"molecule",
")",
"except",
"BaseException",
":",
"pass",
"atoms",
"=",
"''",
"if",
"not",
"molecule",
"[",
"0"... | Return a string with all atoms in molecule | [
"Return",
"a",
"string",
"with",
"all",
"atoms",
"in",
"molecule"
] | 324625d1d8e740673f139658b2de4c9e1059739e | https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/tools.py#L18-L59 | train | Return a string with all atoms in molecule |
SUNCAT-Center/CatHub | cathub/tools.py | check_reaction | def check_reaction(reactants, products):
"""Check the stoichiometry and format of chemical reaction used for
folder structure.
list of reactants -> list of products
"""
reactant_list = [reactant.split('@')[0].strip(
'star').strip('gas') for reactant in reactants]
product_list = [product.... | python | def check_reaction(reactants, products):
"""Check the stoichiometry and format of chemical reaction used for
folder structure.
list of reactants -> list of products
"""
reactant_list = [reactant.split('@')[0].strip(
'star').strip('gas') for reactant in reactants]
product_list = [product.... | [
"def",
"check_reaction",
"(",
"reactants",
",",
"products",
")",
":",
"reactant_list",
"=",
"[",
"reactant",
".",
"split",
"(",
"'@'",
")",
"[",
"0",
"]",
".",
"strip",
"(",
"'star'",
")",
".",
"strip",
"(",
"'gas'",
")",
"for",
"reactant",
"in",
"re... | Check the stoichiometry and format of chemical reaction used for
folder structure.
list of reactants -> list of products | [
"Check",
"the",
"stoichiometry",
"and",
"format",
"of",
"chemical",
"reaction",
"used",
"for",
"folder",
"structure",
".",
"list",
"of",
"reactants",
"-",
">",
"list",
"of",
"products"
] | 324625d1d8e740673f139658b2de4c9e1059739e | https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/tools.py#L75-L104 | train | Check the stoichiometry and format of chemical reaction used for
folder structure. |
guaix-ucm/numina | numina/core/pipelineload.py | check_section | def check_section(node, section, keys=None):
"""Validate keys in a section"""
if keys:
for key in keys:
if key not in node:
raise ValueError('Missing key %r inside %r node' % (key, section)) | python | def check_section(node, section, keys=None):
"""Validate keys in a section"""
if keys:
for key in keys:
if key not in node:
raise ValueError('Missing key %r inside %r node' % (key, section)) | [
"def",
"check_section",
"(",
"node",
",",
"section",
",",
"keys",
"=",
"None",
")",
":",
"if",
"keys",
":",
"for",
"key",
"in",
"keys",
":",
"if",
"key",
"not",
"in",
"node",
":",
"raise",
"ValueError",
"(",
"'Missing key %r inside %r node'",
"%",
"(",
... | Validate keys in a section | [
"Validate",
"keys",
"in",
"a",
"section"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/pipelineload.py#L29-L34 | train | Validate keys in a section |
guaix-ucm/numina | numina/core/pipelineload.py | drp_load | def drp_load(package, resource, confclass=None):
"""Load the DRPS from a resource file."""
data = pkgutil.get_data(package, resource)
return drp_load_data(package, data, confclass=confclass) | python | def drp_load(package, resource, confclass=None):
"""Load the DRPS from a resource file."""
data = pkgutil.get_data(package, resource)
return drp_load_data(package, data, confclass=confclass) | [
"def",
"drp_load",
"(",
"package",
",",
"resource",
",",
"confclass",
"=",
"None",
")",
":",
"data",
"=",
"pkgutil",
".",
"get_data",
"(",
"package",
",",
"resource",
")",
"return",
"drp_load_data",
"(",
"package",
",",
"data",
",",
"confclass",
"=",
"co... | Load the DRPS from a resource file. | [
"Load",
"the",
"DRPS",
"from",
"a",
"resource",
"file",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/pipelineload.py#L37-L40 | train | Load the DRPS from a resource file. |
guaix-ucm/numina | numina/core/pipelineload.py | drp_load_data | def drp_load_data(package, data, confclass=None):
"""Load the DRPS from data."""
drpdict = yaml.safe_load(data)
ins = load_instrument(package, drpdict, confclass=confclass)
if ins.version == 'undefined':
pkg = importlib.import_module(package)
ins.version = getattr(pkg, '__version__', 'un... | python | def drp_load_data(package, data, confclass=None):
"""Load the DRPS from data."""
drpdict = yaml.safe_load(data)
ins = load_instrument(package, drpdict, confclass=confclass)
if ins.version == 'undefined':
pkg = importlib.import_module(package)
ins.version = getattr(pkg, '__version__', 'un... | [
"def",
"drp_load_data",
"(",
"package",
",",
"data",
",",
"confclass",
"=",
"None",
")",
":",
"drpdict",
"=",
"yaml",
".",
"safe_load",
"(",
"data",
")",
"ins",
"=",
"load_instrument",
"(",
"package",
",",
"drpdict",
",",
"confclass",
"=",
"confclass",
"... | Load the DRPS from data. | [
"Load",
"the",
"DRPS",
"from",
"data",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/pipelineload.py#L43-L50 | train | Load the DRPS from data. |
guaix-ucm/numina | numina/core/pipelineload.py | load_modes | def load_modes(node):
"""Load all observing modes"""
if isinstance(node, list):
values = [load_mode(child) for child in node]
keys = [mode.key for mode in values]
return dict(zip(keys,values))
elif isinstance(node, dict):
values = {key: load_mode(child) for key, child in node... | python | def load_modes(node):
"""Load all observing modes"""
if isinstance(node, list):
values = [load_mode(child) for child in node]
keys = [mode.key for mode in values]
return dict(zip(keys,values))
elif isinstance(node, dict):
values = {key: load_mode(child) for key, child in node... | [
"def",
"load_modes",
"(",
"node",
")",
":",
"if",
"isinstance",
"(",
"node",
",",
"list",
")",
":",
"values",
"=",
"[",
"load_mode",
"(",
"child",
")",
"for",
"child",
"in",
"node",
"]",
"keys",
"=",
"[",
"mode",
".",
"key",
"for",
"mode",
"in",
... | Load all observing modes | [
"Load",
"all",
"observing",
"modes"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/pipelineload.py#L53-L63 | train | Load all observing modes from a node |
guaix-ucm/numina | numina/core/pipelineload.py | load_mode | def load_mode(node):
"""Load one observing mdode"""
obs_mode = ObservingMode()
obs_mode.__dict__.update(node)
# handle validator
load_mode_validator(obs_mode, node)
# handle builder
load_mode_builder(obs_mode, node)
# handle tagger:
load_mode_tagger(obs_mode, node)
return obs... | python | def load_mode(node):
"""Load one observing mdode"""
obs_mode = ObservingMode()
obs_mode.__dict__.update(node)
# handle validator
load_mode_validator(obs_mode, node)
# handle builder
load_mode_builder(obs_mode, node)
# handle tagger:
load_mode_tagger(obs_mode, node)
return obs... | [
"def",
"load_mode",
"(",
"node",
")",
":",
"obs_mode",
"=",
"ObservingMode",
"(",
")",
"obs_mode",
".",
"__dict__",
".",
"update",
"(",
"node",
")",
"# handle validator",
"load_mode_validator",
"(",
"obs_mode",
",",
"node",
")",
"# handle builder",
"load_mode_bu... | Load one observing mdode | [
"Load",
"one",
"observing",
"mdode"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/pipelineload.py#L65-L79 | train | Load one observing mdode |
guaix-ucm/numina | numina/core/pipelineload.py | load_mode_tagger | def load_mode_tagger(obs_mode, node):
"""Load observing mode OB tagger"""
# handle tagger:
ntagger = node.get('tagger')
if ntagger is None:
pass
elif isinstance(ntagger, list):
def full_tagger(obsres):
return get_tags_from_full_ob(obsres, reqtags=ntagger)
obs_... | python | def load_mode_tagger(obs_mode, node):
"""Load observing mode OB tagger"""
# handle tagger:
ntagger = node.get('tagger')
if ntagger is None:
pass
elif isinstance(ntagger, list):
def full_tagger(obsres):
return get_tags_from_full_ob(obsres, reqtags=ntagger)
obs_... | [
"def",
"load_mode_tagger",
"(",
"obs_mode",
",",
"node",
")",
":",
"# handle tagger:",
"ntagger",
"=",
"node",
".",
"get",
"(",
"'tagger'",
")",
"if",
"ntagger",
"is",
"None",
":",
"pass",
"elif",
"isinstance",
"(",
"ntagger",
",",
"list",
")",
":",
"def... | Load observing mode OB tagger | [
"Load",
"observing",
"mode",
"OB",
"tagger"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/pipelineload.py#L82-L102 | train | Load observing mode OB tagger |
guaix-ucm/numina | numina/core/pipelineload.py | load_mode_builder | def load_mode_builder(obs_mode, node):
"""Load observing mode OB builder"""
# Check 'builder' and 'builder_options'
nval1 = node.get('builder')
if nval1 is not None:
if isinstance(nval1, str):
# override method
newmethod = import_object(nval1)
obs_mode.build... | python | def load_mode_builder(obs_mode, node):
"""Load observing mode OB builder"""
# Check 'builder' and 'builder_options'
nval1 = node.get('builder')
if nval1 is not None:
if isinstance(nval1, str):
# override method
newmethod = import_object(nval1)
obs_mode.build... | [
"def",
"load_mode_builder",
"(",
"obs_mode",
",",
"node",
")",
":",
"# Check 'builder' and 'builder_options'",
"nval1",
"=",
"node",
".",
"get",
"(",
"'builder'",
")",
"if",
"nval1",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"nval1",
",",
"str",
")"... | Load observing mode OB builder | [
"Load",
"observing",
"mode",
"OB",
"builder"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/pipelineload.py#L105-L132 | train | Load observing mode OB builder |
guaix-ucm/numina | numina/core/pipelineload.py | load_mode_validator | def load_mode_validator(obs_mode, node):
"""Load observing mode validator"""
nval = node.get('validator')
if nval is None:
pass
elif isinstance(nval, str):
# load function
obs_mode.validator = import_object(nval)
else:
raise TypeError('validator must be None or a st... | python | def load_mode_validator(obs_mode, node):
"""Load observing mode validator"""
nval = node.get('validator')
if nval is None:
pass
elif isinstance(nval, str):
# load function
obs_mode.validator = import_object(nval)
else:
raise TypeError('validator must be None or a st... | [
"def",
"load_mode_validator",
"(",
"obs_mode",
",",
"node",
")",
":",
"nval",
"=",
"node",
".",
"get",
"(",
"'validator'",
")",
"if",
"nval",
"is",
"None",
":",
"pass",
"elif",
"isinstance",
"(",
"nval",
",",
"str",
")",
":",
"# load function",
"obs_mode... | Load observing mode validator | [
"Load",
"observing",
"mode",
"validator"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/pipelineload.py#L135-L148 | train | Load observing mode validator |
JoseAntFer/pyny3d | pyny3d/utils.py | sort_numpy | def sort_numpy(array, col=0, order_back=False):
"""
Sorts the columns for an entire ``ndarrray`` according to sorting
one of them.
:param array: Array to sort.
:type array: ndarray
:param col: Master column to sort.
:type col: int
:param order_back: If True, also returns th... | python | def sort_numpy(array, col=0, order_back=False):
"""
Sorts the columns for an entire ``ndarrray`` according to sorting
one of them.
:param array: Array to sort.
:type array: ndarray
:param col: Master column to sort.
:type col: int
:param order_back: If True, also returns th... | [
"def",
"sort_numpy",
"(",
"array",
",",
"col",
"=",
"0",
",",
"order_back",
"=",
"False",
")",
":",
"x",
"=",
"array",
"[",
":",
",",
"col",
"]",
"sorted_index",
"=",
"np",
".",
"argsort",
"(",
"x",
",",
"kind",
"=",
"'quicksort'",
")",
"sorted_arr... | Sorts the columns for an entire ``ndarrray`` according to sorting
one of them.
:param array: Array to sort.
:type array: ndarray
:param col: Master column to sort.
:type col: int
:param order_back: If True, also returns the index to undo the
new order.
:type order_back:... | [
"Sorts",
"the",
"columns",
"for",
"an",
"entire",
"ndarrray",
"according",
"to",
"sorting",
"one",
"of",
"them",
".",
":",
"param",
"array",
":",
"Array",
"to",
"sort",
".",
":",
"type",
"array",
":",
"ndarray",
":",
"param",
"col",
":",
"Master",
"col... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/utils.py#L8-L33 | train | Sort the columns for an entire nparray according to sorting one of them. |
JoseAntFer/pyny3d | pyny3d/utils.py | arange_col | def arange_col(n, dtype=int):
"""
Returns ``np.arange`` in a column form.
:param n: Length of the array.
:type n: int
:param dtype: Type of the array.
:type dtype: type
:returns: ``np.arange`` in a column form.
:rtype: ndarray
"""
return np.reshape(np.arange(n, dt... | python | def arange_col(n, dtype=int):
"""
Returns ``np.arange`` in a column form.
:param n: Length of the array.
:type n: int
:param dtype: Type of the array.
:type dtype: type
:returns: ``np.arange`` in a column form.
:rtype: ndarray
"""
return np.reshape(np.arange(n, dt... | [
"def",
"arange_col",
"(",
"n",
",",
"dtype",
"=",
"int",
")",
":",
"return",
"np",
".",
"reshape",
"(",
"np",
".",
"arange",
"(",
"n",
",",
"dtype",
"=",
"dtype",
")",
",",
"(",
"n",
",",
"1",
")",
")"
] | Returns ``np.arange`` in a column form.
:param n: Length of the array.
:type n: int
:param dtype: Type of the array.
:type dtype: type
:returns: ``np.arange`` in a column form.
:rtype: ndarray | [
"Returns",
"np",
".",
"arange",
"in",
"a",
"column",
"form",
".",
":",
"param",
"n",
":",
"Length",
"of",
"the",
"array",
".",
":",
"type",
"n",
":",
"int",
":",
"param",
"dtype",
":",
"Type",
"of",
"the",
"array",
".",
":",
"type",
"dtype",
":",... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/utils.py#L35-L46 | train | Returns an array of n elements in a column form. |
JoseAntFer/pyny3d | pyny3d/utils.py | index2bool | def index2bool(index, length=None):
"""
Returns a numpy boolean array with Trues in the input index
positions.
:param index: index array with the Trues positions.
:type index: ndarray (type=int)
:param length: Length of the returned array.
:type length: int or None
:return... | python | def index2bool(index, length=None):
"""
Returns a numpy boolean array with Trues in the input index
positions.
:param index: index array with the Trues positions.
:type index: ndarray (type=int)
:param length: Length of the returned array.
:type length: int or None
:return... | [
"def",
"index2bool",
"(",
"index",
",",
"length",
"=",
"None",
")",
":",
"if",
"index",
".",
"shape",
"[",
"0",
"]",
"==",
"0",
"and",
"length",
"is",
"None",
":",
"return",
"np",
".",
"arange",
"(",
"0",
",",
"dtype",
"=",
"bool",
")",
"if",
"... | Returns a numpy boolean array with Trues in the input index
positions.
:param index: index array with the Trues positions.
:type index: ndarray (type=int)
:param length: Length of the returned array.
:type length: int or None
:returns: array with Trues in the input index positions.
... | [
"Returns",
"a",
"numpy",
"boolean",
"array",
"with",
"Trues",
"in",
"the",
"input",
"index",
"positions",
".",
":",
"param",
"index",
":",
"index",
"array",
"with",
"the",
"Trues",
"positions",
".",
":",
"type",
"index",
":",
"ndarray",
"(",
"type",
"=",... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/utils.py#L61-L81 | train | Returns a numpy boolean array with Trues in the input index. |
JoseAntFer/pyny3d | pyny3d/geoms.py | root.plot | def plot(self, color='default', ret=False, ax=None):
"""
Generates a basic 3D visualization.
:param color: Polygons color.
:type color: matplotlib color, 'default' or 't' (transparent)
:param ret: If True, returns the figure. It can be used to add
more elem... | python | def plot(self, color='default', ret=False, ax=None):
"""
Generates a basic 3D visualization.
:param color: Polygons color.
:type color: matplotlib color, 'default' or 't' (transparent)
:param ret: If True, returns the figure. It can be used to add
more elem... | [
"def",
"plot",
"(",
"self",
",",
"color",
"=",
"'default'",
",",
"ret",
"=",
"False",
",",
"ax",
"=",
"None",
")",
":",
"import",
"matplotlib",
".",
"pylab",
"as",
"plt",
"import",
"mpl_toolkits",
".",
"mplot3d",
"as",
"mplot3d",
"# Bypass a plot\r",
"if... | Generates a basic 3D visualization.
:param color: Polygons color.
:type color: matplotlib color, 'default' or 't' (transparent)
:param ret: If True, returns the figure. It can be used to add
more elements to the plot or to modify it.
:type ret: bool
:param ... | [
"Generates",
"a",
"basic",
"3D",
"visualization",
".",
":",
"param",
"color",
":",
"Polygons",
"color",
".",
":",
"type",
"color",
":",
"matplotlib",
"color",
"default",
"or",
"t",
"(",
"transparent",
")",
":",
"param",
"ret",
":",
"If",
"True",
"returns... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L25-L85 | train | Returns a 3D visualization of the object. |
JoseAntFer/pyny3d | pyny3d/geoms.py | root.center_plot | def center_plot(self, ax):
"""
Centers and keep the aspect ratio in a 3D representation.
Created to help higher classes to manage cascade representation
of multiple lower objects.
:param ax: Axes to apply the method.
:type ax: mplot3d.Axes3D
... | python | def center_plot(self, ax):
"""
Centers and keep the aspect ratio in a 3D representation.
Created to help higher classes to manage cascade representation
of multiple lower objects.
:param ax: Axes to apply the method.
:type ax: mplot3d.Axes3D
... | [
"def",
"center_plot",
"(",
"self",
",",
"ax",
")",
":",
"# Domain\r",
"domain",
"=",
"self",
".",
"get_domain",
"(",
")",
"bound",
"=",
"np",
".",
"max",
"(",
"domain",
"[",
"1",
"]",
"-",
"domain",
"[",
"0",
"]",
")",
"centroid",
"=",
"self",
".... | Centers and keep the aspect ratio in a 3D representation.
Created to help higher classes to manage cascade representation
of multiple lower objects.
:param ax: Axes to apply the method.
:type ax: mplot3d.Axes3D
:returns: None | [
"Centers",
"and",
"keep",
"the",
"aspect",
"ratio",
"in",
"a",
"3D",
"representation",
".",
"Created",
"to",
"help",
"higher",
"classes",
"to",
"manage",
"cascade",
"representation",
"of",
"multiple",
"lower",
"objects",
".",
":",
"param",
"ax",
":",
"Axes",... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L87-L108 | train | Center the plot of the object in a 3D representation. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Polygon.lock | def lock(self):
"""
Precomputes some parameters to run faster specific methods like
Surface.classify.
Stores ``self.domain`` and ``self.path``, both very used in
the shadows simulation, in order to avoid later unnecessary
calculations and verifications.
... | python | def lock(self):
"""
Precomputes some parameters to run faster specific methods like
Surface.classify.
Stores ``self.domain`` and ``self.path``, both very used in
the shadows simulation, in order to avoid later unnecessary
calculations and verifications.
... | [
"def",
"lock",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"locked",
":",
"self",
".",
"path",
"=",
"self",
".",
"get_path",
"(",
")",
"self",
".",
"domain",
"=",
"self",
".",
"get_domain",
"(",
")",
"self",
".",
"locked",
"=",
"True"
] | Precomputes some parameters to run faster specific methods like
Surface.classify.
Stores ``self.domain`` and ``self.path``, both very used in
the shadows simulation, in order to avoid later unnecessary
calculations and verifications.
:returns: None
... | [
"Precomputes",
"some",
"parameters",
"to",
"run",
"faster",
"specific",
"methods",
"like",
"Surface",
".",
"classify",
".",
"Stores",
"self",
".",
"domain",
"and",
"self",
".",
"path",
"both",
"very",
"used",
"in",
"the",
"shadows",
"simulation",
"in",
"orde... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L210-L226 | train | Locks the object. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Polygon.is_convex | def is_convex(points):
"""
Static method. Returns True if the polygon is convex regardless
of whether its vertices follow a clockwise or a
counter-clockwise order. This is a requirement for the rest of
the program.
:param points: Points intented to form... | python | def is_convex(points):
"""
Static method. Returns True if the polygon is convex regardless
of whether its vertices follow a clockwise or a
counter-clockwise order. This is a requirement for the rest of
the program.
:param points: Points intented to form... | [
"def",
"is_convex",
"(",
"points",
")",
":",
"# Verification based on the cross product\r",
"n_points",
"=",
"points",
".",
"shape",
"[",
"0",
"]",
"i",
"=",
"-",
"1",
"u",
"=",
"points",
"[",
"i",
"]",
"-",
"points",
"[",
"i",
"-",
"1",
"]",
"v",
"=... | Static method. Returns True if the polygon is convex regardless
of whether its vertices follow a clockwise or a
counter-clockwise order. This is a requirement for the rest of
the program.
:param points: Points intented to form a polygon.
:type points: ndarray wi... | [
"Static",
"method",
".",
"Returns",
"True",
"if",
"the",
"polygon",
"is",
"convex",
"regardless",
"of",
"whether",
"its",
"vertices",
"follow",
"a",
"clockwise",
"or",
"a",
"counter",
"-",
"clockwise",
"order",
".",
"This",
"is",
"a",
"requirement",
"for",
... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L239-L271 | train | Static method that returns True if the polygon is convex regardless of its vertices follow clockwise or counter - clockwise order. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Polygon.make_ccw | def make_ccw(points):
"""
Static method. Returns a counterclock wise ordered sequence of
points. If there are any repeated point, the method will raise
an error.
Due to the 3D character of the package, the order or the points
will be tried following this... | python | def make_ccw(points):
"""
Static method. Returns a counterclock wise ordered sequence of
points. If there are any repeated point, the method will raise
an error.
Due to the 3D character of the package, the order or the points
will be tried following this... | [
"def",
"make_ccw",
"(",
"points",
")",
":",
"from",
"scipy",
".",
"spatial",
"import",
"ConvexHull",
"from",
"pyny3d",
".",
"utils",
"import",
"sort_numpy",
"# Repeated points\r",
"points_aux",
"=",
"sort_numpy",
"(",
"points",
")",
"check",
"=",
"np",
".",
... | Static method. Returns a counterclock wise ordered sequence of
points. If there are any repeated point, the method will raise
an error.
Due to the 3D character of the package, the order or the points
will be tried following this order:
1. z=0 pprojection
... | [
"Static",
"method",
".",
"Returns",
"a",
"counterclock",
"wise",
"ordered",
"sequence",
"of",
"points",
".",
"If",
"there",
"are",
"any",
"repeated",
"point",
"the",
"method",
"will",
"raise",
"an",
"error",
".",
"Due",
"to",
"the",
"3D",
"character",
"of"... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L274-L308 | train | Static method that returns a counterclock wise ordered sequence of tuples of size N where N is the number of points in the original sequence. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Polygon.to_2d | def to_2d(self):
"""
Generates the real 2D polygon of the 3D polygon. This method
performs a change of reference system obtaining the same polygon
but with the new z=0 plane containing the polygon.
This library mostly uses the z=0 projection to perform
operations wit... | python | def to_2d(self):
"""
Generates the real 2D polygon of the 3D polygon. This method
performs a change of reference system obtaining the same polygon
but with the new z=0 plane containing the polygon.
This library mostly uses the z=0 projection to perform
operations wit... | [
"def",
"to_2d",
"(",
"self",
")",
":",
"# New reference system\r",
"a",
"=",
"self",
"[",
"1",
"]",
"-",
"self",
"[",
"0",
"]",
"a",
"=",
"a",
"/",
"np",
".",
"linalg",
".",
"norm",
"(",
"a",
")",
"# arbitrary first axis\r",
"n",
"=",
"np",
".",
... | Generates the real 2D polygon of the 3D polygon. This method
performs a change of reference system obtaining the same polygon
but with the new z=0 plane containing the polygon.
This library mostly uses the z=0 projection to perform
operations with the polygons. For this reason, if rea... | [
"Generates",
"the",
"real",
"2D",
"polygon",
"of",
"the",
"3D",
"polygon",
".",
"This",
"method",
"performs",
"a",
"change",
"of",
"reference",
"system",
"obtaining",
"the",
"same",
"polygon",
"but",
"with",
"the",
"new",
"z",
"=",
"0",
"plane",
"containin... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L310-L336 | train | Returns a new 2D polygon with the same coordinates. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Polygon.contains | def contains(self, points, edge=True):
"""
Point-in-Polygon algorithm for multiple points for the z=0
projection of the ``pyny.Polygon``.
:param points: Set of points to evaluate.
:type points: ndarray with points (xyz or xy) in rows
:param edge: If True,... | python | def contains(self, points, edge=True):
"""
Point-in-Polygon algorithm for multiple points for the z=0
projection of the ``pyny.Polygon``.
:param points: Set of points to evaluate.
:type points: ndarray with points (xyz or xy) in rows
:param edge: If True,... | [
"def",
"contains",
"(",
"self",
",",
"points",
",",
"edge",
"=",
"True",
")",
":",
"radius",
"=",
"1e-10",
"if",
"edge",
"else",
"-",
"1e-10",
"return",
"self",
".",
"get_path",
"(",
")",
".",
"contains_points",
"(",
"points",
"[",
":",
",",
":",
"... | Point-in-Polygon algorithm for multiple points for the z=0
projection of the ``pyny.Polygon``.
:param points: Set of points to evaluate.
:type points: ndarray with points (xyz or xy) in rows
:param edge: If True, consider the points in the Polygon's edge
as in... | [
"Point",
"-",
"in",
"-",
"Polygon",
"algorithm",
"for",
"multiple",
"points",
"for",
"the",
"z",
"=",
"0",
"projection",
"of",
"the",
"pyny",
".",
"Polygon",
".",
":",
"param",
"points",
":",
"Set",
"of",
"points",
"to",
"evaluate",
".",
":",
"type",
... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L338-L354 | train | Point - in - Polygon algorithm for multiple points for the z = 0 - 1 z = 0 projection of the pyny. Polygon. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Polygon.get_parametric | def get_parametric(self, check=True, tolerance=0.001):
"""
Calculates the parametric equation of the plane that contains
the polygon. The output has the form np.array([a, b, c, d])
for:
.. math::
a*x + b*y + c*z + d = 0
:param check: Check... | python | def get_parametric(self, check=True, tolerance=0.001):
"""
Calculates the parametric equation of the plane that contains
the polygon. The output has the form np.array([a, b, c, d])
for:
.. math::
a*x + b*y + c*z + d = 0
:param check: Check... | [
"def",
"get_parametric",
"(",
"self",
",",
"check",
"=",
"True",
",",
"tolerance",
"=",
"0.001",
")",
":",
"if",
"self",
".",
"parametric",
"is",
"None",
":",
"# Plane calculation\r",
"a",
",",
"b",
",",
"c",
"=",
"np",
".",
"cross",
"(",
"self",
"."... | Calculates the parametric equation of the plane that contains
the polygon. The output has the form np.array([a, b, c, d])
for:
.. math::
a*x + b*y + c*z + d = 0
:param check: Checks whether the points are actually
in the same plane with certain... | [
"Calculates",
"the",
"parametric",
"equation",
"of",
"the",
"plane",
"that",
"contains",
"the",
"polygon",
".",
"The",
"output",
"has",
"the",
"form",
"np",
".",
"array",
"(",
"[",
"a",
"b",
"c",
"d",
"]",
")",
"for",
":",
"..",
"math",
"::",
"a",
... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L356-L393 | train | Calculates the parametric equation of the plane that contains
the polygon. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Polygon.get_path | def get_path(self):
"""
:returns: matplotlib.path.Path object for the z=0 projection of
this polygon.
"""
if self.path == None:
from matplotlib import path
return path.Path(self.points[:, :2]) # z=0 projection!
return self.path | python | def get_path(self):
"""
:returns: matplotlib.path.Path object for the z=0 projection of
this polygon.
"""
if self.path == None:
from matplotlib import path
return path.Path(self.points[:, :2]) # z=0 projection!
return self.path | [
"def",
"get_path",
"(",
"self",
")",
":",
"if",
"self",
".",
"path",
"==",
"None",
":",
"from",
"matplotlib",
"import",
"path",
"return",
"path",
".",
"Path",
"(",
"self",
".",
"points",
"[",
":",
",",
":",
"2",
"]",
")",
"# z=0 projection!\r",
"retu... | :returns: matplotlib.path.Path object for the z=0 projection of
this polygon. | [
":",
"returns",
":",
"matplotlib",
".",
"path",
".",
"Path",
"object",
"for",
"the",
"z",
"=",
"0",
"projection",
"of",
"this",
"polygon",
"."
] | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L395-L403 | train | Returns a matplotlib. path. Path object for the z = 0 projection of
this polygon. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Polygon.get_shapely | def get_shapely(self):
"""
:returns: shapely.Polygon object of the z=0 projection of
this polygon.
"""
if self.shapely == None:
from shapely.geometry import Polygon as shPolygon
self.shapely = shPolygon(self.points[:, :2]) # z=0 projection!
... | python | def get_shapely(self):
"""
:returns: shapely.Polygon object of the z=0 projection of
this polygon.
"""
if self.shapely == None:
from shapely.geometry import Polygon as shPolygon
self.shapely = shPolygon(self.points[:, :2]) # z=0 projection!
... | [
"def",
"get_shapely",
"(",
"self",
")",
":",
"if",
"self",
".",
"shapely",
"==",
"None",
":",
"from",
"shapely",
".",
"geometry",
"import",
"Polygon",
"as",
"shPolygon",
"self",
".",
"shapely",
"=",
"shPolygon",
"(",
"self",
".",
"points",
"[",
":",
",... | :returns: shapely.Polygon object of the z=0 projection of
this polygon. | [
":",
"returns",
":",
"shapely",
".",
"Polygon",
"object",
"of",
"the",
"z",
"=",
"0",
"projection",
"of",
"this",
"polygon",
"."
] | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L405-L413 | train | Returns shapely. Polygon object of the z = 0 projection of
this polygon. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Polygon.get_domain | def get_domain(self):
"""
:returns: opposite vertices of the bounding prism for this
object.
:rtype: ndarray([min], [max])
"""
if self.domain is None:
return np.array([self.points.min(axis=0),
self.points.max(axis=0)]... | python | def get_domain(self):
"""
:returns: opposite vertices of the bounding prism for this
object.
:rtype: ndarray([min], [max])
"""
if self.domain is None:
return np.array([self.points.min(axis=0),
self.points.max(axis=0)]... | [
"def",
"get_domain",
"(",
"self",
")",
":",
"if",
"self",
".",
"domain",
"is",
"None",
":",
"return",
"np",
".",
"array",
"(",
"[",
"self",
".",
"points",
".",
"min",
"(",
"axis",
"=",
"0",
")",
",",
"self",
".",
"points",
".",
"max",
"(",
"axi... | :returns: opposite vertices of the bounding prism for this
object.
:rtype: ndarray([min], [max]) | [
":",
"returns",
":",
"opposite",
"vertices",
"of",
"the",
"bounding",
"prism",
"for",
"this",
"object",
".",
":",
"rtype",
":",
"ndarray",
"(",
"[",
"min",
"]",
"[",
"max",
"]",
")"
] | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L415-L424 | train | returns the opposite vertices of the bounding prism for this Arc. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Polygon.get_area | def get_area(self):
"""
:returns: The area of the polygon.
"""
if self.area is None:
self.area = self.to_2d().get_shapely().area
return self.area | python | def get_area(self):
"""
:returns: The area of the polygon.
"""
if self.area is None:
self.area = self.to_2d().get_shapely().area
return self.area | [
"def",
"get_area",
"(",
"self",
")",
":",
"if",
"self",
".",
"area",
"is",
"None",
":",
"self",
".",
"area",
"=",
"self",
".",
"to_2d",
"(",
")",
".",
"get_shapely",
"(",
")",
".",
"area",
"return",
"self",
".",
"area"
] | :returns: The area of the polygon. | [
":",
"returns",
":",
"The",
"area",
"of",
"the",
"polygon",
"."
] | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L426-L432 | train | Returns the area of the polygon. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Polygon.get_height | def get_height(self, points, only_in = True, edge=True, full=False):
"""
Given a set of points, it computes the z value for the
parametric equation of the plane where the polygon belongs.
Only the two first columns of the points will be taken into
account as x and y.
... | python | def get_height(self, points, only_in = True, edge=True, full=False):
"""
Given a set of points, it computes the z value for the
parametric equation of the plane where the polygon belongs.
Only the two first columns of the points will be taken into
account as x and y.
... | [
"def",
"get_height",
"(",
"self",
",",
"points",
",",
"only_in",
"=",
"True",
",",
"edge",
"=",
"True",
",",
"full",
"=",
"False",
")",
":",
"p",
"=",
"self",
".",
"get_parametric",
"(",
")",
"z",
"=",
"(",
"-",
"p",
"[",
"0",
"]",
"*",
"points... | Given a set of points, it computes the z value for the
parametric equation of the plane where the polygon belongs.
Only the two first columns of the points will be taken into
account as x and y.
By default, the points outside the object will have a NaN value
... | [
"Given",
"a",
"set",
"of",
"points",
"it",
"computes",
"the",
"z",
"value",
"for",
"the",
"parametric",
"equation",
"of",
"the",
"plane",
"where",
"the",
"polygon",
"belongs",
".",
"Only",
"the",
"two",
"first",
"columns",
"of",
"the",
"points",
"will",
... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L434-L474 | train | This method computes the z value of the edge of the object. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Polygon.get_plotable3d | def get_plotable3d(self):
"""
:returns: matplotlib Poly3DCollection
:rtype: mpl_toolkits.mplot3d
"""
import mpl_toolkits.mplot3d as mplot3d
return [mplot3d.art3d.Poly3DCollection([self.points])] | python | def get_plotable3d(self):
"""
:returns: matplotlib Poly3DCollection
:rtype: mpl_toolkits.mplot3d
"""
import mpl_toolkits.mplot3d as mplot3d
return [mplot3d.art3d.Poly3DCollection([self.points])] | [
"def",
"get_plotable3d",
"(",
"self",
")",
":",
"import",
"mpl_toolkits",
".",
"mplot3d",
"as",
"mplot3d",
"return",
"[",
"mplot3d",
".",
"art3d",
".",
"Poly3DCollection",
"(",
"[",
"self",
".",
"points",
"]",
")",
"]"
] | :returns: matplotlib Poly3DCollection
:rtype: mpl_toolkits.mplot3d | [
":",
"returns",
":",
"matplotlib",
"Poly3DCollection",
":",
"rtype",
":",
"mpl_toolkits",
".",
"mplot3d"
] | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L487-L493 | train | Returns a list of matplotlib Poly3DCollection objects for the given set of time - items. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Polygon.pip | def pip(self, points, sorted_col=0, radius=0):
"""
Point-in-Polygon for the z=0 projection. This function enhances
the performance of ``Polygon.contains()`` by verifying only the
points which are inside the bounding box of the polygon. To do
it fast, it needs the points ar... | python | def pip(self, points, sorted_col=0, radius=0):
"""
Point-in-Polygon for the z=0 projection. This function enhances
the performance of ``Polygon.contains()`` by verifying only the
points which are inside the bounding box of the polygon. To do
it fast, it needs the points ar... | [
"def",
"pip",
"(",
"self",
",",
"points",
",",
"sorted_col",
"=",
"0",
",",
"radius",
"=",
"0",
")",
":",
"xy",
"=",
"points",
"[",
":",
",",
":",
"2",
"]",
"n_points",
"=",
"xy",
".",
"shape",
"[",
"0",
"]",
"index",
"=",
"np",
".",
"arange"... | Point-in-Polygon for the z=0 projection. This function enhances
the performance of ``Polygon.contains()`` by verifying only the
points which are inside the bounding box of the polygon. To do
it fast, it needs the points array to be already sorted by one
column.
:... | [
"Point",
"-",
"in",
"-",
"Polygon",
"for",
"the",
"z",
"=",
"0",
"projection",
".",
"This",
"function",
"enhances",
"the",
"performance",
"of",
"Polygon",
".",
"contains",
"()",
"by",
"verifying",
"only",
"the",
"points",
"which",
"are",
"inside",
"the",
... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L495-L537 | train | This method enhances the polygon contains method by using the z = 0 projection. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Polygon.plot2d | def plot2d(self, color='default', alpha=1, ret=True):
"""
Generates a 2D plot for the z=0 Polygon projection.
:param color: Polygon color.
:type color: matplotlib color
:param alpha: Opacity.
:type alpha: float
:param ret: If True, returns the fig... | python | def plot2d(self, color='default', alpha=1, ret=True):
"""
Generates a 2D plot for the z=0 Polygon projection.
:param color: Polygon color.
:type color: matplotlib color
:param alpha: Opacity.
:type alpha: float
:param ret: If True, returns the fig... | [
"def",
"plot2d",
"(",
"self",
",",
"color",
"=",
"'default'",
",",
"alpha",
"=",
"1",
",",
"ret",
"=",
"True",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"import",
"matplotlib",
".",
"patches",
"as",
"patches",
"path",
"=",
"self",
... | Generates a 2D plot for the z=0 Polygon projection.
:param color: Polygon color.
:type color: matplotlib color
:param alpha: Opacity.
:type alpha: float
:param ret: If True, returns the figure. It can be used to add
more elements to the plot or to mod... | [
"Generates",
"a",
"2D",
"plot",
"for",
"the",
"z",
"=",
"0",
"Polygon",
"projection",
".",
":",
"param",
"color",
":",
"Polygon",
"color",
".",
":",
"type",
"color",
":",
"matplotlib",
"color",
":",
"param",
"alpha",
":",
"Opacity",
".",
":",
"type",
... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L539-L568 | train | Generates a 2D plot for the z = 0 polygon projection. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Polygon.matrix | def matrix(self, x=(0, 0), y=(0, 0) , z=(0, 0)):
"""
Copy the ``pyny.Polygon`` along a 3D matrix given by the
three tuples x, y, z:
:param x: Number of copies and distance between them in this
direction.
:type x: tuple (len=2)
:returns: list ... | python | def matrix(self, x=(0, 0), y=(0, 0) , z=(0, 0)):
"""
Copy the ``pyny.Polygon`` along a 3D matrix given by the
three tuples x, y, z:
:param x: Number of copies and distance between them in this
direction.
:type x: tuple (len=2)
:returns: list ... | [
"def",
"matrix",
"(",
"self",
",",
"x",
"=",
"(",
"0",
",",
"0",
")",
",",
"y",
"=",
"(",
"0",
",",
"0",
")",
",",
"z",
"=",
"(",
"0",
",",
"0",
")",
")",
":",
"space",
"=",
"Space",
"(",
"Place",
"(",
"Surface",
"(",
"self",
")",
")",
... | Copy the ``pyny.Polygon`` along a 3D matrix given by the
three tuples x, y, z:
:param x: Number of copies and distance between them in this
direction.
:type x: tuple (len=2)
:returns: list of ``pyny.Polygons`` | [
"Copy",
"the",
"pyny",
".",
"Polygon",
"along",
"a",
"3D",
"matrix",
"given",
"by",
"the",
"three",
"tuples",
"x",
"y",
"z",
":",
":",
"param",
"x",
":",
"Number",
"of",
"copies",
"and",
"distance",
"between",
"them",
"in",
"this",
"direction",
".",
... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L611-L623 | train | Returns a list of pyny. Polygons along a 3D matrix given by the
direction. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Surface.classify | def classify(self, points, edge=True, col=1, already_sorted=False):
"""
Calculates the belonging relationship between the polygons
in the Surface and a set of points.
This function enhances the performance of ``Polygon.contains()``
when used with multiple non-overlapping... | python | def classify(self, points, edge=True, col=1, already_sorted=False):
"""
Calculates the belonging relationship between the polygons
in the Surface and a set of points.
This function enhances the performance of ``Polygon.contains()``
when used with multiple non-overlapping... | [
"def",
"classify",
"(",
"self",
",",
"points",
",",
"edge",
"=",
"True",
",",
"col",
"=",
"1",
",",
"already_sorted",
"=",
"False",
")",
":",
"xy",
"=",
"points",
"[",
":",
",",
":",
"2",
"]",
".",
"copy",
"(",
")",
"radius",
"=",
"1e-10",
"if"... | Calculates the belonging relationship between the polygons
in the Surface and a set of points.
This function enhances the performance of ``Polygon.contains()``
when used with multiple non-overlapping polygons (stored in a
Surface) by verifying only the points which are inside the z=0 ... | [
"Calculates",
"the",
"belonging",
"relationship",
"between",
"the",
"polygons",
"in",
"the",
"Surface",
"and",
"a",
"set",
"of",
"points",
".",
"This",
"function",
"enhances",
"the",
"performance",
"of",
"Polygon",
".",
"contains",
"()",
"when",
"used",
"with"... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L722-L771 | train | This method calculates the belonging relationship between the polygons and a set of points. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Surface.intersect_with | def intersect_with(self, polygon):
"""
Calculates the intersection between the polygons in this surface
and other polygon, in the z=0 projection.
This method rely on the ``shapely.Polygon.intersects()`` method.
The way this method is used is intersecting this polyg... | python | def intersect_with(self, polygon):
"""
Calculates the intersection between the polygons in this surface
and other polygon, in the z=0 projection.
This method rely on the ``shapely.Polygon.intersects()`` method.
The way this method is used is intersecting this polyg... | [
"def",
"intersect_with",
"(",
"self",
",",
"polygon",
")",
":",
"intersections",
"=",
"{",
"}",
"for",
"i",
",",
"poly",
"in",
"enumerate",
"(",
"self",
")",
":",
"if",
"polygon",
".",
"get_shapely",
"(",
")",
".",
"intersects",
"(",
"poly",
".",
"ge... | Calculates the intersection between the polygons in this surface
and other polygon, in the z=0 projection.
This method rely on the ``shapely.Polygon.intersects()`` method.
The way this method is used is intersecting this polygon
recursively with all identified polygons whi... | [
"Calculates",
"the",
"intersection",
"between",
"the",
"polygons",
"in",
"this",
"surface",
"and",
"other",
"polygon",
"in",
"the",
"z",
"=",
"0",
"projection",
".",
"This",
"method",
"rely",
"on",
"the",
"shapely",
".",
"Polygon",
".",
"intersects",
"()",
... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L773-L795 | train | Returns a dictionary of all intersections between this polygon and the other polygon. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Surface.get_domain | def get_domain(self):
"""
:returns: opposite vertices of the bounding prism for this
object in the form of ndarray([min], [max])
.. note:: This method automatically stores the solution in order
to do not repeat calculations if the user needs to call it
... | python | def get_domain(self):
"""
:returns: opposite vertices of the bounding prism for this
object in the form of ndarray([min], [max])
.. note:: This method automatically stores the solution in order
to do not repeat calculations if the user needs to call it
... | [
"def",
"get_domain",
"(",
"self",
")",
":",
"points",
"=",
"(",
"[",
"poly",
".",
"points",
"for",
"poly",
"in",
"self",
"]",
"+",
"[",
"holes",
".",
"points",
"for",
"holes",
"in",
"self",
".",
"holes",
"]",
")",
"points",
"=",
"np",
".",
"conca... | :returns: opposite vertices of the bounding prism for this
object in the form of ndarray([min], [max])
.. note:: This method automatically stores the solution in order
to do not repeat calculations if the user needs to call it
more than once. | [
":",
"returns",
":",
"opposite",
"vertices",
"of",
"the",
"bounding",
"prism",
"for",
"this",
"object",
"in",
"the",
"form",
"of",
"ndarray",
"(",
"[",
"min",
"]",
"[",
"max",
"]",
")",
"..",
"note",
"::",
"This",
"method",
"automatically",
"stores",
"... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L804-L816 | train | Returns the opposite vertices of the bounding prism for this Arc Arc. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Surface.get_seed | def get_seed(self):
"""
Collects the required information to generate a data estructure
that can be used to recreate exactly the same geometry object
via *\*\*kwargs*.
:returns: Object's sufficient info to initialize it.
:rtype: dict
"""
... | python | def get_seed(self):
"""
Collects the required information to generate a data estructure
that can be used to recreate exactly the same geometry object
via *\*\*kwargs*.
:returns: Object's sufficient info to initialize it.
:rtype: dict
"""
... | [
"def",
"get_seed",
"(",
"self",
")",
":",
"return",
"{",
"'polygons'",
":",
"[",
"poly",
".",
"points",
"for",
"poly",
"in",
"self",
"]",
",",
"'holes'",
":",
"[",
"hole",
".",
"points",
"for",
"hole",
"in",
"self",
".",
"holes",
"]",
"}"
] | Collects the required information to generate a data estructure
that can be used to recreate exactly the same geometry object
via *\*\*kwargs*.
:returns: Object's sufficient info to initialize it.
:rtype: dict | [
"Collects",
"the",
"required",
"information",
"to",
"generate",
"a",
"data",
"estructure",
"that",
"can",
"be",
"used",
"to",
"recreate",
"exactly",
"the",
"same",
"geometry",
"object",
"via",
"*",
"\\",
"*",
"\\",
"*",
"kwargs",
"*",
".",
":",
"returns",
... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L818-L828 | train | Returns a dictionary of the required information to initialize the object with the same attributes. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Surface.get_height | def get_height(self, points, edge=True):
"""
Given a set of points, computes the z value for the parametric
equation of the Polygons in the Surface.
This method computes recursively the ``Polygon.get_height()``
method for all the Polygons in the Surface, obtaining ... | python | def get_height(self, points, edge=True):
"""
Given a set of points, computes the z value for the parametric
equation of the Polygons in the Surface.
This method computes recursively the ``Polygon.get_height()``
method for all the Polygons in the Surface, obtaining ... | [
"def",
"get_height",
"(",
"self",
",",
"points",
",",
"edge",
"=",
"True",
")",
":",
"for",
"poly",
"in",
"self",
":",
"points",
"=",
"poly",
".",
"get_height",
"(",
"points",
",",
"edge",
"=",
"edge",
",",
"full",
"=",
"True",
")",
"for",
"hole",
... | Given a set of points, computes the z value for the parametric
equation of the Polygons in the Surface.
This method computes recursively the ``Polygon.get_height()``
method for all the Polygons in the Surface, obtaining the z
value for the points according to the local Pol... | [
"Given",
"a",
"set",
"of",
"points",
"computes",
"the",
"z",
"value",
"for",
"the",
"parametric",
"equation",
"of",
"the",
"Polygons",
"in",
"the",
"Surface",
".",
"This",
"method",
"computes",
"recursively",
"the",
"Polygon",
".",
"get_height",
"()",
"metho... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L831-L858 | train | This method computes the z value for the given set of points. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Surface.add_holes | def add_holes(self, holes_list, make_ccw=True):
"""
Add holes to the holes list.
:param holes_list: Polygons that will be treated as holes.
:type holes_list: list or pyny.Polygon
:param make_ccw: If True, points will be sorted ccw.
:type make_ccw: bool
... | python | def add_holes(self, holes_list, make_ccw=True):
"""
Add holes to the holes list.
:param holes_list: Polygons that will be treated as holes.
:type holes_list: list or pyny.Polygon
:param make_ccw: If True, points will be sorted ccw.
:type make_ccw: bool
... | [
"def",
"add_holes",
"(",
"self",
",",
"holes_list",
",",
"make_ccw",
"=",
"True",
")",
":",
"if",
"type",
"(",
"holes_list",
")",
"!=",
"list",
":",
"holes_list",
"=",
"[",
"holes_list",
"]",
"self",
".",
"holes",
"+=",
"[",
"Polygon",
"(",
"hole",
"... | Add holes to the holes list.
:param holes_list: Polygons that will be treated as holes.
:type holes_list: list or pyny.Polygon
:param make_ccw: If True, points will be sorted ccw.
:type make_ccw: bool
:returns: None
.. note:: The holes can be any... | [
"Add",
"holes",
"to",
"the",
"holes",
"list",
".",
":",
"param",
"holes_list",
":",
"Polygons",
"that",
"will",
"be",
"treated",
"as",
"holes",
".",
":",
"type",
"holes_list",
":",
"list",
"or",
"pyny",
".",
"Polygon",
":",
"param",
"make_ccw",
":",
"I... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L860-L874 | train | Adds holes to the list of holes. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Surface.melt | def melt(self, plot=False):
"""
Find and merge groups of polygons in the surface that meet the
following criteria:
* Are coplanars.
* Are contiguous.
* The result is convex.
This method is very useful at reducing the num... | python | def melt(self, plot=False):
"""
Find and merge groups of polygons in the surface that meet the
following criteria:
* Are coplanars.
* Are contiguous.
* The result is convex.
This method is very useful at reducing the num... | [
"def",
"melt",
"(",
"self",
",",
"plot",
"=",
"False",
")",
":",
"from",
"pyny3d",
".",
"utils",
"import",
"bool2index",
"from",
"scipy",
".",
"spatial",
"import",
"ConvexHull",
"# First, coplanarity\r",
"## Normalize parametric equations\r",
"para",
"=",
"[",
"... | Find and merge groups of polygons in the surface that meet the
following criteria:
* Are coplanars.
* Are contiguous.
* The result is convex.
This method is very useful at reducing the number the items and,
therefore, the shadowi... | [
"Find",
"and",
"merge",
"groups",
"of",
"polygons",
"in",
"the",
"surface",
"that",
"meet",
"the",
"following",
"criteria",
":",
"*",
"Are",
"coplanars",
".",
"*",
"Are",
"contiguous",
".",
"*",
"The",
"result",
"is",
"convex",
".",
"This",
"method",
"is... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L876-L947 | train | Returns a new instance of the same class with the same attributes as the other ones. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Surface.get_area | def get_area(self):
"""
:returns: The area of the surface.
.. warning:: The area is computed as the sum of the areas of all
the polygons minus the sum of the areas of all the holes.
"""
polys = sum([polygon.get_area() for polygon in self])
hol... | python | def get_area(self):
"""
:returns: The area of the surface.
.. warning:: The area is computed as the sum of the areas of all
the polygons minus the sum of the areas of all the holes.
"""
polys = sum([polygon.get_area() for polygon in self])
hol... | [
"def",
"get_area",
"(",
"self",
")",
":",
"polys",
"=",
"sum",
"(",
"[",
"polygon",
".",
"get_area",
"(",
")",
"for",
"polygon",
"in",
"self",
"]",
")",
"holes",
"=",
"sum",
"(",
"[",
"hole",
".",
"get_area",
"(",
")",
"for",
"hole",
"in",
"self"... | :returns: The area of the surface.
.. warning:: The area is computed as the sum of the areas of all
the polygons minus the sum of the areas of all the holes. | [
":",
"returns",
":",
"The",
"area",
"of",
"the",
"surface",
".",
"..",
"warning",
"::",
"The",
"area",
"is",
"computed",
"as",
"the",
"sum",
"of",
"the",
"areas",
"of",
"all",
"the",
"polygons",
"minus",
"the",
"sum",
"of",
"the",
"areas",
"of",
"all... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L949-L958 | train | Returns the area of the polygon and all the holes. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Surface.contiguous | def contiguous(polygons):
"""
Static method. Check whether a set of convex polygons are all
contiguous. Two polygons are considered contiguous if they
share, at least, one side (two vertices).
This is not a complete verification, it is a very simplified
one. For a g... | python | def contiguous(polygons):
"""
Static method. Check whether a set of convex polygons are all
contiguous. Two polygons are considered contiguous if they
share, at least, one side (two vertices).
This is not a complete verification, it is a very simplified
one. For a g... | [
"def",
"contiguous",
"(",
"polygons",
")",
":",
"from",
"pyny3d",
".",
"utils",
"import",
"sort_numpy",
"n",
"=",
"len",
"(",
"polygons",
")",
"points",
"=",
"sort_numpy",
"(",
"np",
".",
"concatenate",
"(",
"[",
"polygon",
".",
"points",
"for",
"polygon... | Static method. Check whether a set of convex polygons are all
contiguous. Two polygons are considered contiguous if they
share, at least, one side (two vertices).
This is not a complete verification, it is a very simplified
one. For a given set of polygons this method will verify tha... | [
"Static",
"method",
".",
"Check",
"whether",
"a",
"set",
"of",
"convex",
"polygons",
"are",
"all",
"contiguous",
".",
"Two",
"polygons",
"are",
"considered",
"contiguous",
"if",
"they",
"share",
"at",
"least",
"one",
"side",
"(",
"two",
"vertices",
")",
".... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L961-L991 | train | Static method that checks whether a set of convex polygons are allded in a single common vertex. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Surface.plot2d | def plot2d(self, c_poly='default', alpha=1, cmap='default', ret=False,
title=' ', colorbar=False, cbar_label=''):
"""
Generates a 2D plot for the z=0 Surface projection.
:param c_poly: Polygons color.
:type c_poly: matplotlib color
:param alpha: Op... | python | def plot2d(self, c_poly='default', alpha=1, cmap='default', ret=False,
title=' ', colorbar=False, cbar_label=''):
"""
Generates a 2D plot for the z=0 Surface projection.
:param c_poly: Polygons color.
:type c_poly: matplotlib color
:param alpha: Op... | [
"def",
"plot2d",
"(",
"self",
",",
"c_poly",
"=",
"'default'",
",",
"alpha",
"=",
"1",
",",
"cmap",
"=",
"'default'",
",",
"ret",
"=",
"False",
",",
"title",
"=",
"' '",
",",
"colorbar",
"=",
"False",
",",
"cbar_label",
"=",
"''",
")",
":",
"import... | Generates a 2D plot for the z=0 Surface projection.
:param c_poly: Polygons color.
:type c_poly: matplotlib color
:param alpha: Opacity.
:type alpha: float
:param cmap: colormap
:type cmap: matplotlib.cm
:param ret: If True, returns the figure. It... | [
"Generates",
"a",
"2D",
"plot",
"for",
"the",
"z",
"=",
"0",
"Surface",
"projection",
".",
":",
"param",
"c_poly",
":",
"Polygons",
"color",
".",
":",
"type",
"c_poly",
":",
"matplotlib",
"color",
":",
"param",
"alpha",
":",
"Opacity",
".",
":",
"type"... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L993-L1051 | train | Generates a 2D plot for the most recent possible color of the polygon. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Surface.iplot | def iplot(self, c_poly='default', c_holes='c', ret=False, ax=None):
"""
Improved plot that allows to plot polygons and holes in
different colors.
:param c_poly: Polygons color.
:type c_poly: matplotlib color, 'default' or 't' (transparent)
:param c_holes: ... | python | def iplot(self, c_poly='default', c_holes='c', ret=False, ax=None):
"""
Improved plot that allows to plot polygons and holes in
different colors.
:param c_poly: Polygons color.
:type c_poly: matplotlib color, 'default' or 't' (transparent)
:param c_holes: ... | [
"def",
"iplot",
"(",
"self",
",",
"c_poly",
"=",
"'default'",
",",
"c_holes",
"=",
"'c'",
",",
"ret",
"=",
"False",
",",
"ax",
"=",
"None",
")",
":",
"# Default parameter\r",
"if",
"c_holes",
"==",
"'default'",
":",
"c_holes",
"=",
"'c'",
"# cyan for the... | Improved plot that allows to plot polygons and holes in
different colors.
:param c_poly: Polygons color.
:type c_poly: matplotlib color, 'default' or 't' (transparent)
:param c_holes: Holes color.
:type c_holes: matplotlib color, 'default' or 't' (transparent)
... | [
"Improved",
"plot",
"that",
"allows",
"to",
"plot",
"polygons",
"and",
"holes",
"in",
"different",
"colors",
".",
":",
"param",
"c_poly",
":",
"Polygons",
"color",
".",
":",
"type",
"c_poly",
":",
"matplotlib",
"color",
"default",
"or",
"t",
"(",
"transpar... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1053-L1083 | train | Returns a matplotlib figure that allows to plot polygons and holes in
different colors. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Surface.move | def move(self, d_xyz):
"""
Translate the Surface in x, y and z coordinates.
:param d_xyz: displacement in x, y(, and z).
:type d_xyz: tuple (len=2 or 3)
:returns: ``pyny.Surface``
"""
return Space(Place(self)).move(d_xyz, inplace=False)[0].surface | python | def move(self, d_xyz):
"""
Translate the Surface in x, y and z coordinates.
:param d_xyz: displacement in x, y(, and z).
:type d_xyz: tuple (len=2 or 3)
:returns: ``pyny.Surface``
"""
return Space(Place(self)).move(d_xyz, inplace=False)[0].surface | [
"def",
"move",
"(",
"self",
",",
"d_xyz",
")",
":",
"return",
"Space",
"(",
"Place",
"(",
"self",
")",
")",
".",
"move",
"(",
"d_xyz",
",",
"inplace",
"=",
"False",
")",
"[",
"0",
"]",
".",
"surface"
] | Translate the Surface in x, y and z coordinates.
:param d_xyz: displacement in x, y(, and z).
:type d_xyz: tuple (len=2 or 3)
:returns: ``pyny.Surface`` | [
"Translate",
"the",
"Surface",
"in",
"x",
"y",
"and",
"z",
"coordinates",
".",
":",
"param",
"d_xyz",
":",
"displacement",
"in",
"x",
"y",
"(",
"and",
"z",
")",
".",
":",
"type",
"d_xyz",
":",
"tuple",
"(",
"len",
"=",
"2",
"or",
"3",
")",
":",
... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1085-L1093 | train | Translate the Surface in x y and z coordinates. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Surface.rotate | def rotate(self, angle, direction='z', axis=None):
"""
Returns a new Surface which is the same but rotated about a
given axis.
If the axis given is ``None``, the rotation will be computed
about the Surface's centroid.
:param angle: Rotation angl... | python | def rotate(self, angle, direction='z', axis=None):
"""
Returns a new Surface which is the same but rotated about a
given axis.
If the axis given is ``None``, the rotation will be computed
about the Surface's centroid.
:param angle: Rotation angl... | [
"def",
"rotate",
"(",
"self",
",",
"angle",
",",
"direction",
"=",
"'z'",
",",
"axis",
"=",
"None",
")",
":",
"return",
"Space",
"(",
"Place",
"(",
"self",
")",
")",
".",
"rotate",
"(",
"angle",
",",
"direction",
",",
"axis",
")",
"[",
"0",
"]",
... | Returns a new Surface which is the same but rotated about a
given axis.
If the axis given is ``None``, the rotation will be computed
about the Surface's centroid.
:param angle: Rotation angle (in radians)
:type angle: float
:param direction: Axi... | [
"Returns",
"a",
"new",
"Surface",
"which",
"is",
"the",
"same",
"but",
"rotated",
"about",
"a",
"given",
"axis",
".",
"If",
"the",
"axis",
"given",
"is",
"None",
"the",
"rotation",
"will",
"be",
"computed",
"about",
"the",
"Surface",
"s",
"centroid",
"."... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1095-L1111 | train | Returns a new instance of the same but rotated about a specific axis. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Surface.mirror | def mirror(self, axes='x'):
"""
Generates a symmetry of the Surface respect global axes.
:param axes: 'x', 'y', 'z', 'xy', 'xz', 'yz'...
:type axes: str
:returns: ``pyny.Surface``
"""
return Space(Place(self)).mirror(axes, inplace=False)[0].surfac... | python | def mirror(self, axes='x'):
"""
Generates a symmetry of the Surface respect global axes.
:param axes: 'x', 'y', 'z', 'xy', 'xz', 'yz'...
:type axes: str
:returns: ``pyny.Surface``
"""
return Space(Place(self)).mirror(axes, inplace=False)[0].surfac... | [
"def",
"mirror",
"(",
"self",
",",
"axes",
"=",
"'x'",
")",
":",
"return",
"Space",
"(",
"Place",
"(",
"self",
")",
")",
".",
"mirror",
"(",
"axes",
",",
"inplace",
"=",
"False",
")",
"[",
"0",
"]",
".",
"surface"
] | Generates a symmetry of the Surface respect global axes.
:param axes: 'x', 'y', 'z', 'xy', 'xz', 'yz'...
:type axes: str
:returns: ``pyny.Surface`` | [
"Generates",
"a",
"symmetry",
"of",
"the",
"Surface",
"respect",
"global",
"axes",
".",
":",
"param",
"axes",
":",
"x",
"y",
"z",
"xy",
"xz",
"yz",
"...",
":",
"type",
"axes",
":",
"str",
":",
"returns",
":",
"pyny",
".",
"Surface"
] | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1113-L1121 | train | Returns a new copy of the current object with respect to the given axes. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Polyhedron.by_two_polygons | def by_two_polygons(poly1, poly2, make_ccw=True):
"""
Static method. Creates a closed ``pyny.Polyhedron`` connecting
two polygons. Both polygons must have the same number of
vertices. The faces of the Polyhedron created have to be planar,
otherwise, an error will be raise... | python | def by_two_polygons(poly1, poly2, make_ccw=True):
"""
Static method. Creates a closed ``pyny.Polyhedron`` connecting
two polygons. Both polygons must have the same number of
vertices. The faces of the Polyhedron created have to be planar,
otherwise, an error will be raise... | [
"def",
"by_two_polygons",
"(",
"poly1",
",",
"poly2",
",",
"make_ccw",
"=",
"True",
")",
":",
"if",
"type",
"(",
"poly1",
")",
"==",
"Polygon",
":",
"poly1",
"=",
"poly1",
".",
"points",
"poly2",
"=",
"poly2",
".",
"points",
"vertices",
"=",
"np",
".... | Static method. Creates a closed ``pyny.Polyhedron`` connecting
two polygons. Both polygons must have the same number of
vertices. The faces of the Polyhedron created have to be planar,
otherwise, an error will be raised.
The Polyhedron will have the *poly1* and *poly2* a... | [
"Static",
"method",
".",
"Creates",
"a",
"closed",
"pyny",
".",
"Polyhedron",
"connecting",
"two",
"polygons",
".",
"Both",
"polygons",
"must",
"have",
"the",
"same",
"number",
"of",
"vertices",
".",
"The",
"faces",
"of",
"the",
"Polyhedron",
"created",
"hav... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1182-L1223 | train | Static method that creates a closed pyny. Polyhedron connecting two polygons. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Polyhedron.move | def move(self, d_xyz):
"""
Translate the Polyhedron in x, y and z coordinates.
:param d_xyz: displacement in x, y(, and z).
:type d_xyz: tuple (len=2 or 3)
:returns: ``pyny.Polyhedron``
"""
polygon = np.array([[0,0], [0,1], [1,1], [0,1]])
... | python | def move(self, d_xyz):
"""
Translate the Polyhedron in x, y and z coordinates.
:param d_xyz: displacement in x, y(, and z).
:type d_xyz: tuple (len=2 or 3)
:returns: ``pyny.Polyhedron``
"""
polygon = np.array([[0,0], [0,1], [1,1], [0,1]])
... | [
"def",
"move",
"(",
"self",
",",
"d_xyz",
")",
":",
"polygon",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"0",
",",
"0",
"]",
",",
"[",
"0",
",",
"1",
"]",
",",
"[",
"1",
",",
"1",
"]",
",",
"[",
"0",
",",
"1",
"]",
"]",
")",
"space",
"=... | Translate the Polyhedron in x, y and z coordinates.
:param d_xyz: displacement in x, y(, and z).
:type d_xyz: tuple (len=2 or 3)
:returns: ``pyny.Polyhedron`` | [
"Translate",
"the",
"Polyhedron",
"in",
"x",
"y",
"and",
"z",
"coordinates",
".",
":",
"param",
"d_xyz",
":",
"displacement",
"in",
"x",
"y",
"(",
"and",
"z",
")",
".",
":",
"type",
"d_xyz",
":",
"tuple",
"(",
"len",
"=",
"2",
"or",
"3",
")",
":"... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1261-L1271 | train | Returns a new copy of the Polyhedron with the same coordinates. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Polyhedron.rotate | def rotate(self, angle, direction='z', axis=None):
"""
Returns a new Polyhedron which is the same but rotated about a
given axis.
If the axis given is ``None``, the rotation will be computed
about the Polyhedron's centroid.
:param angle: Rotatio... | python | def rotate(self, angle, direction='z', axis=None):
"""
Returns a new Polyhedron which is the same but rotated about a
given axis.
If the axis given is ``None``, the rotation will be computed
about the Polyhedron's centroid.
:param angle: Rotatio... | [
"def",
"rotate",
"(",
"self",
",",
"angle",
",",
"direction",
"=",
"'z'",
",",
"axis",
"=",
"None",
")",
":",
"polygon",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"0",
",",
"0",
"]",
",",
"[",
"0",
",",
"1",
"]",
",",
"[",
"1",
",",
"1",
"]... | Returns a new Polyhedron which is the same but rotated about a
given axis.
If the axis given is ``None``, the rotation will be computed
about the Polyhedron's centroid.
:param angle: Rotation angle (in radians)
:type angle: float
:param directio... | [
"Returns",
"a",
"new",
"Polyhedron",
"which",
"is",
"the",
"same",
"but",
"rotated",
"about",
"a",
"given",
"axis",
".",
"If",
"the",
"axis",
"given",
"is",
"None",
"the",
"rotation",
"will",
"be",
"computed",
"about",
"the",
"Polyhedron",
"s",
"centroid",... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1273-L1291 | train | Returns a new instance of the same but rotated about a specific axis. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Polyhedron.mirror | def mirror(self, axes='x'):
"""
Generates a symmetry of the Polyhedron respect global axes.
:param axes: 'x', 'y', 'z', 'xy', 'xz', 'yz'...
:type axes: str
:returns: ``pyny.Polyhedron``
"""
polygon = np.array([[0,0], [0,1], [1,1]])
space ... | python | def mirror(self, axes='x'):
"""
Generates a symmetry of the Polyhedron respect global axes.
:param axes: 'x', 'y', 'z', 'xy', 'xz', 'yz'...
:type axes: str
:returns: ``pyny.Polyhedron``
"""
polygon = np.array([[0,0], [0,1], [1,1]])
space ... | [
"def",
"mirror",
"(",
"self",
",",
"axes",
"=",
"'x'",
")",
":",
"polygon",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"0",
",",
"0",
"]",
",",
"[",
"0",
",",
"1",
"]",
",",
"[",
"1",
",",
"1",
"]",
"]",
")",
"space",
"=",
"Space",
"(",
"P... | Generates a symmetry of the Polyhedron respect global axes.
:param axes: 'x', 'y', 'z', 'xy', 'xz', 'yz'...
:type axes: str
:returns: ``pyny.Polyhedron`` | [
"Generates",
"a",
"symmetry",
"of",
"the",
"Polyhedron",
"respect",
"global",
"axes",
".",
":",
"param",
"axes",
":",
"x",
"y",
"z",
"xy",
"xz",
"yz",
"...",
":",
"type",
"axes",
":",
"str",
":",
"returns",
":",
"pyny",
".",
"Polyhedron"
] | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1293-L1303 | train | Returns a new copy of the current polygon with respect to the given axes. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Polyhedron.matrix | def matrix(self, x=(0, 0), y=(0, 0) , z=(0, 0)):
"""
Copy the ``pyny.Polyhedron`` along a 3D matrix given by the
three tuples x, y, z:
:param x: Number of copies and distance between them in this
direction.
:type x: tuple (len=2)
:returns: li... | python | def matrix(self, x=(0, 0), y=(0, 0) , z=(0, 0)):
"""
Copy the ``pyny.Polyhedron`` along a 3D matrix given by the
three tuples x, y, z:
:param x: Number of copies and distance between them in this
direction.
:type x: tuple (len=2)
:returns: li... | [
"def",
"matrix",
"(",
"self",
",",
"x",
"=",
"(",
"0",
",",
"0",
")",
",",
"y",
"=",
"(",
"0",
",",
"0",
")",
",",
"z",
"=",
"(",
"0",
",",
"0",
")",
")",
":",
"polygon",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"0",
",",
"0",
"]",
"... | Copy the ``pyny.Polyhedron`` along a 3D matrix given by the
three tuples x, y, z:
:param x: Number of copies and distance between them in this
direction.
:type x: tuple (len=2)
:returns: list of ``pyny.Polyhedron`` | [
"Copy",
"the",
"pyny",
".",
"Polyhedron",
"along",
"a",
"3D",
"matrix",
"given",
"by",
"the",
"three",
"tuples",
"x",
"y",
"z",
":",
":",
"param",
"x",
":",
"Number",
"of",
"copies",
"and",
"distance",
"between",
"them",
"in",
"this",
"direction",
".",... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1305-L1318 | train | Returns a list of pyny. Polyhedron objects along a 3D matrix given by the
direction. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Place.add_set_of_points | def add_set_of_points(self, points):
"""
Add a new set of points to the existing one without removing it.
:param points: Points to be added.
:type points: ndarray (shape=(N, 3))
:returns: None
"""
self.set_of_points = np.concatenate((self.set_of_p... | python | def add_set_of_points(self, points):
"""
Add a new set of points to the existing one without removing it.
:param points: Points to be added.
:type points: ndarray (shape=(N, 3))
:returns: None
"""
self.set_of_points = np.concatenate((self.set_of_p... | [
"def",
"add_set_of_points",
"(",
"self",
",",
"points",
")",
":",
"self",
".",
"set_of_points",
"=",
"np",
".",
"concatenate",
"(",
"(",
"self",
".",
"set_of_points",
",",
"points",
")",
")"
] | Add a new set of points to the existing one without removing it.
:param points: Points to be added.
:type points: ndarray (shape=(N, 3))
:returns: None | [
"Add",
"a",
"new",
"set",
"of",
"points",
"to",
"the",
"existing",
"one",
"without",
"removing",
"it",
".",
":",
"param",
"points",
":",
"Points",
"to",
"be",
"added",
".",
":",
"type",
"points",
":",
"ndarray",
"(",
"shape",
"=",
"(",
"N",
"3",
")... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1402-L1410 | train | Adds a new set of points to the existing set of points. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Place.get_domain | def get_domain(self):
"""
:returns: opposite vertices of the bounding prism for this
object.
:rtype: ndarray([min], [max])
"""
if self.polyhedra != []:
polyhedras_domain = np.vstack([poly.get_domain()
for... | python | def get_domain(self):
"""
:returns: opposite vertices of the bounding prism for this
object.
:rtype: ndarray([min], [max])
"""
if self.polyhedra != []:
polyhedras_domain = np.vstack([poly.get_domain()
for... | [
"def",
"get_domain",
"(",
"self",
")",
":",
"if",
"self",
".",
"polyhedra",
"!=",
"[",
"]",
":",
"polyhedras_domain",
"=",
"np",
".",
"vstack",
"(",
"[",
"poly",
".",
"get_domain",
"(",
")",
"for",
"poly",
"in",
"self",
".",
"polyhedra",
"]",
")",
... | :returns: opposite vertices of the bounding prism for this
object.
:rtype: ndarray([min], [max]) | [
":",
"returns",
":",
"opposite",
"vertices",
"of",
"the",
"bounding",
"prism",
"for",
"this",
"object",
".",
":",
"rtype",
":",
"ndarray",
"(",
"[",
"min",
"]",
"[",
"max",
"]",
")"
] | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1412-L1426 | train | returns the opposite vertices of the bounding prism for this Arc. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Place.get_height | def get_height(self, points, edge=True, attach=False,
extra_height=0):
"""
Launch ``pyny.Surface.get_height(points)`` for the Place's
Surface.
This method gives the possibility to store the computed points
along with the Place's set of points.... | python | def get_height(self, points, edge=True, attach=False,
extra_height=0):
"""
Launch ``pyny.Surface.get_height(points)`` for the Place's
Surface.
This method gives the possibility to store the computed points
along with the Place's set of points.... | [
"def",
"get_height",
"(",
"self",
",",
"points",
",",
"edge",
"=",
"True",
",",
"attach",
"=",
"False",
",",
"extra_height",
"=",
"0",
")",
":",
"points",
"=",
"self",
".",
"surface",
".",
"get_height",
"(",
"points",
",",
"edge",
"=",
"edge",
")",
... | Launch ``pyny.Surface.get_height(points)`` for the Place's
Surface.
This method gives the possibility to store the computed points
along with the Place's set of points. It also makes possible to
add an extra height (z value) to these points.
The points o... | [
"Launch",
"pyny",
".",
"Surface",
".",
"get_height",
"(",
"points",
")",
"for",
"the",
"Place",
"s",
"Surface",
".",
"This",
"method",
"gives",
"the",
"possibility",
"to",
"store",
"the",
"computed",
"points",
"along",
"with",
"the",
"Place",
"s",
"set",
... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1428-L1462 | train | Returns the height of the computed points along with the Place s set of points. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Place.mesh | def mesh(self, mesh_size=1, extra_height=0.1, edge=True, attach=True):
"""
Generates a set of points distributed in a mesh that covers the
whole Place and computes their height.
Generates a xy mesh with a given mesh_size in the
Place.surface's domain and computes the S... | python | def mesh(self, mesh_size=1, extra_height=0.1, edge=True, attach=True):
"""
Generates a set of points distributed in a mesh that covers the
whole Place and computes their height.
Generates a xy mesh with a given mesh_size in the
Place.surface's domain and computes the S... | [
"def",
"mesh",
"(",
"self",
",",
"mesh_size",
"=",
"1",
",",
"extra_height",
"=",
"0.1",
",",
"edge",
"=",
"True",
",",
"attach",
"=",
"True",
")",
":",
"# Mesh\r",
"a",
",",
"b",
"=",
"self",
".",
"get_domain",
"(",
")",
"a",
"-=",
"2",
"*",
"... | Generates a set of points distributed in a mesh that covers the
whole Place and computes their height.
Generates a xy mesh with a given mesh_size in the
Place.surface's domain and computes the Surface's height for the
nodes. This mesh is alligned with the main directions `x` an... | [
"Generates",
"a",
"set",
"of",
"points",
"distributed",
"in",
"a",
"mesh",
"that",
"covers",
"the",
"whole",
"Place",
"and",
"computes",
"their",
"height",
".",
"Generates",
"a",
"xy",
"mesh",
"with",
"a",
"given",
"mesh_size",
"in",
"the",
"Place",
".",
... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1464-L1500 | train | Returns a set of points distributed in a mesh that covers the same Place and computes their height. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Place.add_holes | def add_holes(self, holes_list, make_ccw=True):
"""
Add holes to the Place's ``pyny.Surface``.
:param holes_list: Polygons that will be treated as holes.
:type holes_list: list or ``pyny.Polygon``
:param make_ccw: If True, points will be sorted ccw.
:type ... | python | def add_holes(self, holes_list, make_ccw=True):
"""
Add holes to the Place's ``pyny.Surface``.
:param holes_list: Polygons that will be treated as holes.
:type holes_list: list or ``pyny.Polygon``
:param make_ccw: If True, points will be sorted ccw.
:type ... | [
"def",
"add_holes",
"(",
"self",
",",
"holes_list",
",",
"make_ccw",
"=",
"True",
")",
":",
"self",
".",
"surface",
".",
"add_holes",
"(",
"holes_list",
",",
"make_ccw",
"=",
"make_ccw",
")"
] | Add holes to the Place's ``pyny.Surface``.
:param holes_list: Polygons that will be treated as holes.
:type holes_list: list or ``pyny.Polygon``
:param make_ccw: If True, points will be sorted ccw.
:type make_ccw: bool
:returns: None
.. note:: Th... | [
"Add",
"holes",
"to",
"the",
"Place",
"s",
"pyny",
".",
"Surface",
".",
":",
"param",
"holes_list",
":",
"Polygons",
"that",
"will",
"be",
"treated",
"as",
"holes",
".",
":",
"type",
"holes_list",
":",
"list",
"or",
"pyny",
".",
"Polygon",
":",
"param"... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1508-L1521 | train | Adds holes to the Place s surface. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Place.add_extruded_obstacles | def add_extruded_obstacles(self, top_polys, make_ccw=True):
"""
Add polyhedras to the Place by giving their top polygon and
applying extrusion along the z axis. The resulting polygon
from the intersection will be declared as a hole in the Surface.
:param top_polys:... | python | def add_extruded_obstacles(self, top_polys, make_ccw=True):
"""
Add polyhedras to the Place by giving their top polygon and
applying extrusion along the z axis. The resulting polygon
from the intersection will be declared as a hole in the Surface.
:param top_polys:... | [
"def",
"add_extruded_obstacles",
"(",
"self",
",",
"top_polys",
",",
"make_ccw",
"=",
"True",
")",
":",
"if",
"type",
"(",
"top_polys",
")",
"!=",
"list",
":",
"top_polys",
"=",
"[",
"top_polys",
"]",
"for",
"poly1",
"in",
"top_polys",
":",
"if",
"type",... | Add polyhedras to the Place by giving their top polygon and
applying extrusion along the z axis. The resulting polygon
from the intersection will be declared as a hole in the Surface.
:param top_polys: Polygons to be extruded to the Surface.
:type top_polys: list of ``pyny.... | [
"Add",
"polyhedras",
"to",
"the",
"Place",
"by",
"giving",
"their",
"top",
"polygon",
"and",
"applying",
"extrusion",
"along",
"the",
"z",
"axis",
".",
"The",
"resulting",
"polygon",
"from",
"the",
"intersection",
"will",
"be",
"declared",
"as",
"a",
"hole",... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1523-L1565 | train | Adds extruded polyhedra to the Place by giving their top polygon and extrusion along the z axis. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Place.get_seed | def get_seed(self):
"""
Collects the required information to generate a data estructure
that can be used to recreate exactly the same geometry object
via *\*\*kwargs*.
:returns: Object's sufficient info to initialize it.
:rtype: dict
"""
... | python | def get_seed(self):
"""
Collects the required information to generate a data estructure
that can be used to recreate exactly the same geometry object
via *\*\*kwargs*.
:returns: Object's sufficient info to initialize it.
:rtype: dict
"""
... | [
"def",
"get_seed",
"(",
"self",
")",
":",
"seed",
"=",
"{",
"}",
"seed",
"[",
"'surface'",
"]",
"=",
"self",
".",
"surface",
".",
"get_seed",
"(",
")",
"polyhedra",
"=",
"[",
"polyhedron",
".",
"get_seed",
"(",
")",
"[",
"'polygons'",
"]",
"for",
"... | Collects the required information to generate a data estructure
that can be used to recreate exactly the same geometry object
via *\*\*kwargs*.
:returns: Object's sufficient info to initialize it.
:rtype: dict | [
"Collects",
"the",
"required",
"information",
"to",
"generate",
"a",
"data",
"estructure",
"that",
"can",
"be",
"used",
"to",
"recreate",
"exactly",
"the",
"same",
"geometry",
"object",
"via",
"*",
"\\",
"*",
"\\",
"*",
"kwargs",
"*",
".",
":",
"returns",
... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1567-L1587 | train | Returns a dictionary with the required information to initialize the object. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Place.get_plotable3d | def get_plotable3d(self):
"""
:returns: matplotlib Poly3DCollection
:rtype: list of mpl_toolkits.mplot3d
"""
polyhedra = sum([polyhedron.get_plotable3d()
for polyhedron in self.polyhedra], [])
return polyhedra + self.surface.get_plotable3d... | python | def get_plotable3d(self):
"""
:returns: matplotlib Poly3DCollection
:rtype: list of mpl_toolkits.mplot3d
"""
polyhedra = sum([polyhedron.get_plotable3d()
for polyhedron in self.polyhedra], [])
return polyhedra + self.surface.get_plotable3d... | [
"def",
"get_plotable3d",
"(",
"self",
")",
":",
"polyhedra",
"=",
"sum",
"(",
"[",
"polyhedron",
".",
"get_plotable3d",
"(",
")",
"for",
"polyhedron",
"in",
"self",
".",
"polyhedra",
"]",
",",
"[",
"]",
")",
"return",
"polyhedra",
"+",
"self",
".",
"su... | :returns: matplotlib Poly3DCollection
:rtype: list of mpl_toolkits.mplot3d | [
":",
"returns",
":",
"matplotlib",
"Poly3DCollection",
":",
"rtype",
":",
"list",
"of",
"mpl_toolkits",
".",
"mplot3d"
] | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1589-L1596 | train | returns list of matplotlib Poly3DCollection objects with all the plotable3d elements |
JoseAntFer/pyny3d | pyny3d/geoms.py | Place.iplot | def iplot(self, c_poly='default', c_holes='default', c_sop='r',
s_sop=25, extra_height=0, ret=False, ax=None):
"""
Improved plot that allows to plot polygons and holes in
different colors and to change the size and the color of the
set of points.
The... | python | def iplot(self, c_poly='default', c_holes='default', c_sop='r',
s_sop=25, extra_height=0, ret=False, ax=None):
"""
Improved plot that allows to plot polygons and holes in
different colors and to change the size and the color of the
set of points.
The... | [
"def",
"iplot",
"(",
"self",
",",
"c_poly",
"=",
"'default'",
",",
"c_holes",
"=",
"'default'",
",",
"c_sop",
"=",
"'r'",
",",
"s_sop",
"=",
"25",
",",
"extra_height",
"=",
"0",
",",
"ret",
"=",
"False",
",",
"ax",
"=",
"None",
")",
":",
"ax",
"=... | Improved plot that allows to plot polygons and holes in
different colors and to change the size and the color of the
set of points.
The points can be plotted accordingly to a ndarray colormap.
:param c_poly: Polygons color.
:type c_poly: matplotlib color,... | [
"Improved",
"plot",
"that",
"allows",
"to",
"plot",
"polygons",
"and",
"holes",
"in",
"different",
"colors",
"and",
"to",
"change",
"the",
"size",
"and",
"the",
"color",
"of",
"the",
"set",
"of",
"points",
".",
"The",
"points",
"can",
"be",
"plotted",
"a... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1598-L1637 | train | Returns a matplotlib figure that can be used to plot polygons and holes in the same set of points. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Place.rotate | def rotate(self, angle, direction='z', axis=None):
"""
Returns a new Place which is the same but rotated about a
given axis.
If the axis given is ``None``, the rotation will be computed
about the Place's centroid.
:param angle: Rotation angle (i... | python | def rotate(self, angle, direction='z', axis=None):
"""
Returns a new Place which is the same but rotated about a
given axis.
If the axis given is ``None``, the rotation will be computed
about the Place's centroid.
:param angle: Rotation angle (i... | [
"def",
"rotate",
"(",
"self",
",",
"angle",
",",
"direction",
"=",
"'z'",
",",
"axis",
"=",
"None",
")",
":",
"return",
"Space",
"(",
"self",
")",
".",
"rotate",
"(",
"angle",
",",
"direction",
",",
"axis",
")",
"[",
"0",
"]"
] | Returns a new Place which is the same but rotated about a
given axis.
If the axis given is ``None``, the rotation will be computed
about the Place's centroid.
:param angle: Rotation angle (in radians)
:type angle: float
:param direction: Axis di... | [
"Returns",
"a",
"new",
"Place",
"which",
"is",
"the",
"same",
"but",
"rotated",
"about",
"a",
"given",
"axis",
".",
"If",
"the",
"axis",
"given",
"is",
"None",
"the",
"rotation",
"will",
"be",
"computed",
"about",
"the",
"Place",
"s",
"centroid",
".",
... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1649-L1665 | train | Returns a new Place which is the same but rotated about a specific axis. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Space.lock | def lock(self):
"""
Precomputes some parameters to run faster specific methods like
Surface.classify. This method is automatically launched before shadows
computation.
:returns: None
"""
if self.locked: return
from pyny3d.utils import bool2inde... | python | def lock(self):
"""
Precomputes some parameters to run faster specific methods like
Surface.classify. This method is automatically launched before shadows
computation.
:returns: None
"""
if self.locked: return
from pyny3d.utils import bool2inde... | [
"def",
"lock",
"(",
"self",
")",
":",
"if",
"self",
".",
"locked",
":",
"return",
"from",
"pyny3d",
".",
"utils",
"import",
"bool2index",
"# seed\r",
"self",
".",
"seed",
"=",
"self",
".",
"get_seed",
"(",
")",
"# map\r",
"self",
".",
"map",
"=",
"se... | Precomputes some parameters to run faster specific methods like
Surface.classify. This method is automatically launched before shadows
computation.
:returns: None | [
"Precomputes",
"some",
"parameters",
"to",
"run",
"faster",
"specific",
"methods",
"like",
"Surface",
".",
"classify",
".",
"This",
"method",
"is",
"automatically",
"launched",
"before",
"shadows",
"computation",
".",
":",
"returns",
":",
"None"
] | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1739-L1789 | train | Returns None if the map is already locked. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Space.add_places | def add_places(self, places, ret=False):
"""
Add ``pyny.Places`` to the current space.
:param places: Places to add.
:type places: list of pyny.Place
:param ret: If True, returns the whole updated Space.
:type ret: bool
:returns: None, ``pyny.Spa... | python | def add_places(self, places, ret=False):
"""
Add ``pyny.Places`` to the current space.
:param places: Places to add.
:type places: list of pyny.Place
:param ret: If True, returns the whole updated Space.
:type ret: bool
:returns: None, ``pyny.Spa... | [
"def",
"add_places",
"(",
"self",
",",
"places",
",",
"ret",
"=",
"False",
")",
":",
"if",
"type",
"(",
"places",
")",
"!=",
"list",
":",
"places",
"=",
"[",
"places",
"]",
"self",
".",
"places",
"+=",
"places",
"if",
"ret",
":",
"return",
"self"
] | Add ``pyny.Places`` to the current space.
:param places: Places to add.
:type places: list of pyny.Place
:param ret: If True, returns the whole updated Space.
:type ret: bool
:returns: None, ``pyny.Space``
.. warning:: This method acts inplace. | [
"Add",
"pyny",
".",
"Places",
"to",
"the",
"current",
"space",
".",
":",
"param",
"places",
":",
"Places",
"to",
"add",
".",
":",
"type",
"places",
":",
"list",
"of",
"pyny",
".",
"Place",
":",
"param",
"ret",
":",
"If",
"True",
"returns",
"the",
"... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1808-L1822 | train | Adds one or more places to the current space. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Space.add_spaces | def add_spaces(self, spaces, ret=False):
"""
Add ``pyny.Spaces`` to the current space. In other words, it
merges multiple ``pyny.Spaces`` in this instance.
:param places: ``pyny.Spaces`` to add.
:type places: list of pyny.Spaces
:param ret: If True, returns the... | python | def add_spaces(self, spaces, ret=False):
"""
Add ``pyny.Spaces`` to the current space. In other words, it
merges multiple ``pyny.Spaces`` in this instance.
:param places: ``pyny.Spaces`` to add.
:type places: list of pyny.Spaces
:param ret: If True, returns the... | [
"def",
"add_spaces",
"(",
"self",
",",
"spaces",
",",
"ret",
"=",
"False",
")",
":",
"if",
"type",
"(",
"spaces",
")",
"!=",
"list",
":",
"spaces",
"=",
"[",
"spaces",
"]",
"Space",
".",
"add_places",
"(",
"self",
",",
"sum",
"(",
"[",
"space",
"... | Add ``pyny.Spaces`` to the current space. In other words, it
merges multiple ``pyny.Spaces`` in this instance.
:param places: ``pyny.Spaces`` to add.
:type places: list of pyny.Spaces
:param ret: If True, returns the whole updated Space.
:type ret: bool
:retur... | [
"Add",
"pyny",
".",
"Spaces",
"to",
"the",
"current",
"space",
".",
"In",
"other",
"words",
"it",
"merges",
"multiple",
"pyny",
".",
"Spaces",
"in",
"this",
"instance",
".",
":",
"param",
"places",
":",
"pyny",
".",
"Spaces",
"to",
"add",
".",
":",
"... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1824-L1839 | train | Add spaces to the current space. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Space.get_domain | def get_domain(self):
"""
:returns: opposite vertices of the bounding prism for this
object.
:rtype: ndarray([min], [max])
"""
points = np.vstack([place.get_domain() for place in self])
return np.array([points.min(axis=0), points.max(axis=0)]) | python | def get_domain(self):
"""
:returns: opposite vertices of the bounding prism for this
object.
:rtype: ndarray([min], [max])
"""
points = np.vstack([place.get_domain() for place in self])
return np.array([points.min(axis=0), points.max(axis=0)]) | [
"def",
"get_domain",
"(",
"self",
")",
":",
"points",
"=",
"np",
".",
"vstack",
"(",
"[",
"place",
".",
"get_domain",
"(",
")",
"for",
"place",
"in",
"self",
"]",
")",
"return",
"np",
".",
"array",
"(",
"[",
"points",
".",
"min",
"(",
"axis",
"="... | :returns: opposite vertices of the bounding prism for this
object.
:rtype: ndarray([min], [max]) | [
":",
"returns",
":",
"opposite",
"vertices",
"of",
"the",
"bounding",
"prism",
"for",
"this",
"object",
".",
":",
"rtype",
":",
"ndarray",
"(",
"[",
"min",
"]",
"[",
"max",
"]",
")"
] | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1841-L1848 | train | Returns the opposite vertices of the bounding prism for this Arc. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Space.get_seed | def get_seed(self):
"""
Collects the required information to generate a data estructure
that can be used to recreate exactly the same geometry object
via *\*\*kwargs*.
:returns: Object's sufficient info to initialize it.
:rtype: dict
..... | python | def get_seed(self):
"""
Collects the required information to generate a data estructure
that can be used to recreate exactly the same geometry object
via *\*\*kwargs*.
:returns: Object's sufficient info to initialize it.
:rtype: dict
..... | [
"def",
"get_seed",
"(",
"self",
")",
":",
"self",
".",
"seed",
"=",
"{",
"'places'",
":",
"[",
"place",
".",
"get_seed",
"(",
")",
"for",
"place",
"in",
"self",
"]",
"}",
"return",
"self",
".",
"seed"
] | Collects the required information to generate a data estructure
that can be used to recreate exactly the same geometry object
via *\*\*kwargs*.
:returns: Object's sufficient info to initialize it.
:rtype: dict
.. seealso::
* :... | [
"Collects",
"the",
"required",
"information",
"to",
"generate",
"a",
"data",
"estructure",
"that",
"can",
"be",
"used",
"to",
"recreate",
"exactly",
"the",
"same",
"geometry",
"object",
"via",
"*",
"\\",
"*",
"\\",
"*",
"kwargs",
"*",
".",
":",
"returns",
... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1850-L1869 | train | Returns the seed for the object. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Space.get_sets_index | def get_sets_index(self):
"""
Returns a one dimension array with the Place where the points
belong.
:returns: The ``pyny.Place`` where the points belong.
:rtype: list of int
"""
index = []
for i, place in enumerate(self):
in... | python | def get_sets_index(self):
"""
Returns a one dimension array with the Place where the points
belong.
:returns: The ``pyny.Place`` where the points belong.
:rtype: list of int
"""
index = []
for i, place in enumerate(self):
in... | [
"def",
"get_sets_index",
"(",
"self",
")",
":",
"index",
"=",
"[",
"]",
"for",
"i",
",",
"place",
"in",
"enumerate",
"(",
"self",
")",
":",
"index",
".",
"append",
"(",
"np",
".",
"ones",
"(",
"place",
".",
"set_of_points",
".",
"shape",
"[",
"0",
... | Returns a one dimension array with the Place where the points
belong.
:returns: The ``pyny.Place`` where the points belong.
:rtype: list of int | [
"Returns",
"a",
"one",
"dimension",
"array",
"with",
"the",
"Place",
"where",
"the",
"points",
"belong",
".",
":",
"returns",
":",
"The",
"pyny",
".",
"Place",
"where",
"the",
"points",
"belong",
".",
":",
"rtype",
":",
"list",
"of",
"int"
] | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1889-L1900 | train | Returns a one dimension array with the Place where the points belong. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Space.get_map | def get_map(self):
"""
Collects all the points coordinates from this ``pyny.Space``
instance.
In order to keep the reference, it returns an index with the
following key:
* The first column is the Place.
* The second column is the... | python | def get_map(self):
"""
Collects all the points coordinates from this ``pyny.Space``
instance.
In order to keep the reference, it returns an index with the
following key:
* The first column is the Place.
* The second column is the... | [
"def",
"get_map",
"(",
"self",
")",
":",
"seed",
"=",
"self",
".",
"get_seed",
"(",
")",
"[",
"'places'",
"]",
"# template\r",
"points",
"=",
"[",
"]",
"index",
"=",
"[",
"]",
"for",
"i",
",",
"place",
"in",
"enumerate",
"(",
"seed",
")",
":",
"#... | Collects all the points coordinates from this ``pyny.Space``
instance.
In order to keep the reference, it returns an index with the
following key:
* The first column is the Place.
* The second column is the body (-1: points, 0: surface,
... | [
"Collects",
"all",
"the",
"points",
"coordinates",
"from",
"this",
"pyny",
".",
"Space",
"instance",
".",
"In",
"order",
"to",
"keep",
"the",
"reference",
"it",
"returns",
"an",
"index",
"with",
"the",
"following",
"key",
":",
"*",
"The",
"first",
"column"... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1918-L1986 | train | Returns a list of tuples containing the index and points of the current instance. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Space.map2seed | def map2seed(self, map_):
"""
Returns a seed from an altered map. The map needs to have the
structure of this ``pyny.Space``, that is, the same as
``self.get_map()``.
:param map_: the points, and the same order, that appear at
``pyny.Space.get_map()`... | python | def map2seed(self, map_):
"""
Returns a seed from an altered map. The map needs to have the
structure of this ``pyny.Space``, that is, the same as
``self.get_map()``.
:param map_: the points, and the same order, that appear at
``pyny.Space.get_map()`... | [
"def",
"map2seed",
"(",
"self",
",",
"map_",
")",
":",
"seed",
"=",
"self",
".",
"get_seed",
"(",
")",
"[",
"'places'",
"]",
"# Template\r",
"o",
"=",
"0",
"for",
"i",
",",
"place",
"in",
"enumerate",
"(",
"seed",
")",
":",
"# Set of points [_, -1, 0, ... | Returns a seed from an altered map. The map needs to have the
structure of this ``pyny.Space``, that is, the same as
``self.get_map()``.
:param map_: the points, and the same order, that appear at
``pyny.Space.get_map()``.
:type map_: ndarray (shape=(N, 3))
... | [
"Returns",
"a",
"seed",
"from",
"an",
"altered",
"map",
".",
"The",
"map",
"needs",
"to",
"have",
"the",
"structure",
"of",
"this",
"pyny",
".",
"Space",
"that",
"is",
"the",
"same",
"as",
"self",
".",
"get_map",
"()",
".",
":",
"param",
"map_",
":",... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1988-L2033 | train | Returns a seed from an altered map. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Space.explode | def explode(self):
"""
Collects all the polygons, holes and points in the Space
packaged in a list. The returned geometries are not in *pyny3d*
form, instead the will be represented as *ndarrays*.
:returns: The polygons, the holes and the points.
:rtype: ... | python | def explode(self):
"""
Collects all the polygons, holes and points in the Space
packaged in a list. The returned geometries are not in *pyny3d*
form, instead the will be represented as *ndarrays*.
:returns: The polygons, the holes and the points.
:rtype: ... | [
"def",
"explode",
"(",
"self",
")",
":",
"seed",
"=",
"self",
".",
"get_seed",
"(",
")",
"[",
"'places'",
"]",
"points",
"=",
"[",
"]",
"polygons",
"=",
"[",
"]",
"holes",
"=",
"[",
"]",
"for",
"place",
"in",
"seed",
":",
"points",
".",
"append",... | Collects all the polygons, holes and points in the Space
packaged in a list. The returned geometries are not in *pyny3d*
form, instead the will be represented as *ndarrays*.
:returns: The polygons, the holes and the points.
:rtype: list | [
"Collects",
"all",
"the",
"polygons",
"holes",
"and",
"points",
"in",
"the",
"Space",
"packaged",
"in",
"a",
"list",
".",
"The",
"returned",
"geometries",
"are",
"not",
"in",
"*",
"pyny3d",
"*",
"form",
"instead",
"the",
"will",
"be",
"represented",
"as",
... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L2055-L2074 | train | Returns a list of lists containing all the polygons holes and points in the Space
packaged in a list. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Space.explode_map | def explode_map(self, map_):
"""
Much faster version of ``pyny.Space.explode()`` method for
previously locked ``pyny.Space``.
:param map_: the points, and the same order, that appear at
``pyny.Space.get_map()``. There is no need for the index if
... | python | def explode_map(self, map_):
"""
Much faster version of ``pyny.Space.explode()`` method for
previously locked ``pyny.Space``.
:param map_: the points, and the same order, that appear at
``pyny.Space.get_map()``. There is no need for the index if
... | [
"def",
"explode_map",
"(",
"self",
",",
"map_",
")",
":",
"if",
"self",
".",
"explode_map_schedule",
"is",
"None",
":",
"index",
"=",
"map_",
"[",
"0",
"]",
"points",
"=",
"map_",
"[",
"1",
"]",
"# points\r",
"k",
"=",
"index",
"[",
":",
",",
"1",
... | Much faster version of ``pyny.Space.explode()`` method for
previously locked ``pyny.Space``.
:param map_: the points, and the same order, that appear at
``pyny.Space.get_map()``. There is no need for the index if
locked.
:type map_: ndarray (shape=(N, 3)... | [
"Much",
"faster",
"version",
"of",
"pyny",
".",
"Space",
".",
"explode",
"()",
"method",
"for",
"previously",
"locked",
"pyny",
".",
"Space",
".",
":",
"param",
"map_",
":",
"the",
"points",
"and",
"the",
"same",
"order",
"that",
"appear",
"at",
"pyny",
... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L2076-L2134 | train | Returns the polygons the holes and the points in the map. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Space.get_height | def get_height(self, points, edge=True, attach=False, extra_height=0):
"""
Launch ``pyny.Place.get_height(points)`` recursively for all
the ``pyny.Place``.
The points outside the object will have a NaN value in the
z column. These point will not be stored but it w... | python | def get_height(self, points, edge=True, attach=False, extra_height=0):
"""
Launch ``pyny.Place.get_height(points)`` recursively for all
the ``pyny.Place``.
The points outside the object will have a NaN value in the
z column. These point will not be stored but it w... | [
"def",
"get_height",
"(",
"self",
",",
"points",
",",
"edge",
"=",
"True",
",",
"attach",
"=",
"False",
",",
"extra_height",
"=",
"0",
")",
":",
"for",
"place",
"in",
"self",
":",
"points",
"=",
"place",
".",
"get_height",
"(",
"points",
",",
"edge",... | Launch ``pyny.Place.get_height(points)`` recursively for all
the ``pyny.Place``.
The points outside the object will have a NaN value in the
z column. These point will not be stored but it will be
returned.
:param points: list of coordinates of the point... | [
"Launch",
"pyny",
".",
"Place",
".",
"get_height",
"(",
"points",
")",
"recursively",
"for",
"all",
"the",
"pyny",
".",
"Place",
".",
"The",
"points",
"outside",
"the",
"object",
"will",
"have",
"a",
"NaN",
"value",
"in",
"the",
"z",
"column",
".",
"Th... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L2136-L2161 | train | Launch the
method on the Place object and return the height of the resulting points. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Space.mesh | def mesh(self, mesh_size=1, extra_height=0.1, edge=True, attach=True):
"""
Launch `pyny.Place.mesh(points)` recursively for all
the ``pyny.Place`` individually.
:param mesh_size: distance between points.
:type mesh_size: float
:param extra_height: Adds an... | python | def mesh(self, mesh_size=1, extra_height=0.1, edge=True, attach=True):
"""
Launch `pyny.Place.mesh(points)` recursively for all
the ``pyny.Place`` individually.
:param mesh_size: distance between points.
:type mesh_size: float
:param extra_height: Adds an... | [
"def",
"mesh",
"(",
"self",
",",
"mesh_size",
"=",
"1",
",",
"extra_height",
"=",
"0.1",
",",
"edge",
"=",
"True",
",",
"attach",
"=",
"True",
")",
":",
"for",
"place",
"in",
"self",
":",
"place",
".",
"mesh",
"(",
"mesh_size",
",",
"extra_height",
... | Launch `pyny.Place.mesh(points)` recursively for all
the ``pyny.Place`` individually.
:param mesh_size: distance between points.
:type mesh_size: float
:param extra_height: Adds an extra height (z value) to the
resulting points.
:type extra_height: fl... | [
"Launch",
"pyny",
".",
"Place",
".",
"mesh",
"(",
"points",
")",
"recursively",
"for",
"all",
"the",
"pyny",
".",
"Place",
"individually",
".",
":",
"param",
"mesh_size",
":",
"distance",
"between",
"points",
".",
":",
"type",
"mesh_size",
":",
"float",
... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L2163-L2183 | train | Launch pyny. Place. mesh recursively for allded Place objects. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Space.move | def move(self, d_xyz, inplace=False):
"""
Translate the whole Space in x, y and z coordinates.
:param d_xyz: displacement in x, y(, and z).
:type d_xyz: tuple (len=2 or 3)
:param inplace: If True, the moved ``pyny.Space`` is copied and
added to the cu... | python | def move(self, d_xyz, inplace=False):
"""
Translate the whole Space in x, y and z coordinates.
:param d_xyz: displacement in x, y(, and z).
:type d_xyz: tuple (len=2 or 3)
:param inplace: If True, the moved ``pyny.Space`` is copied and
added to the cu... | [
"def",
"move",
"(",
"self",
",",
"d_xyz",
",",
"inplace",
"=",
"False",
")",
":",
"state",
"=",
"Polygon",
".",
"verify",
"Polygon",
".",
"verify",
"=",
"False",
"if",
"len",
"(",
"d_xyz",
")",
"==",
"2",
":",
"d_xyz",
"=",
"(",
"d_xyz",
"[",
"0"... | Translate the whole Space in x, y and z coordinates.
:param d_xyz: displacement in x, y(, and z).
:type d_xyz: tuple (len=2 or 3)
:param inplace: If True, the moved ``pyny.Space`` is copied and
added to the current ``pyny.Space``. If False, it returns
the... | [
"Translate",
"the",
"whole",
"Space",
"in",
"x",
"y",
"and",
"z",
"coordinates",
".",
":",
"param",
"d_xyz",
":",
"displacement",
"in",
"x",
"y",
"(",
"and",
"z",
")",
".",
":",
"type",
"d_xyz",
":",
"tuple",
"(",
"len",
"=",
"2",
"or",
"3",
")",... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L2185-L2211 | train | Move the whole Space in x y and z coordinates. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Space.rotate | def rotate(self, angle, direction='z', axis=None):
"""
Returns a new Space which is the same but rotated about a
given axis.
If the axis given is ``None``, the rotation will be computed
about the Space's centroid.
:param angle: Rotation angle (i... | python | def rotate(self, angle, direction='z', axis=None):
"""
Returns a new Space which is the same but rotated about a
given axis.
If the axis given is ``None``, the rotation will be computed
about the Space's centroid.
:param angle: Rotation angle (i... | [
"def",
"rotate",
"(",
"self",
",",
"angle",
",",
"direction",
"=",
"'z'",
",",
"axis",
"=",
"None",
")",
":",
"state",
"=",
"Polygon",
".",
"verify",
"Polygon",
".",
"verify",
"=",
"False",
"if",
"axis",
"is",
"None",
":",
"axis",
"=",
"self",
".",... | Returns a new Space which is the same but rotated about a
given axis.
If the axis given is ``None``, the rotation will be computed
about the Space's centroid.
:param angle: Rotation angle (in radians)
:type angle: float
:param direction: Axis di... | [
"Returns",
"a",
"new",
"Space",
"which",
"is",
"the",
"same",
"but",
"rotated",
"about",
"a",
"given",
"axis",
".",
"If",
"the",
"axis",
"given",
"is",
"None",
"the",
"rotation",
"will",
"be",
"computed",
"about",
"the",
"Space",
"s",
"centroid",
".",
... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L2213-L2251 | train | Returns a new space with the same but rotated about a specific axis. |
JoseAntFer/pyny3d | pyny3d/geoms.py | Space.matrix | def matrix(self, x=(0, 0), y=(0, 0) , z=(0, 0), inplace=True):
"""
Copy the ``pyny.Space`` along a 3D matrix given by the three
tuples x, y, z:
:param x: Number of copies and distance between them in this
direction.
:type x: tuple (len=2)
:par... | python | def matrix(self, x=(0, 0), y=(0, 0) , z=(0, 0), inplace=True):
"""
Copy the ``pyny.Space`` along a 3D matrix given by the three
tuples x, y, z:
:param x: Number of copies and distance between them in this
direction.
:type x: tuple (len=2)
:par... | [
"def",
"matrix",
"(",
"self",
",",
"x",
"=",
"(",
"0",
",",
"0",
")",
",",
"y",
"=",
"(",
"0",
",",
"0",
")",
",",
"z",
"=",
"(",
"0",
",",
"0",
")",
",",
"inplace",
"=",
"True",
")",
":",
"state",
"=",
"Polygon",
".",
"verify",
"Polygon"... | Copy the ``pyny.Space`` along a 3D matrix given by the three
tuples x, y, z:
:param x: Number of copies and distance between them in this
direction.
:type x: tuple (len=2)
:param inplace: If True, the moved ``pyny.Space`` is copied and
added to th... | [
"Copy",
"the",
"pyny",
".",
"Space",
"along",
"a",
"3D",
"matrix",
"given",
"by",
"the",
"three",
"tuples",
"x",
"y",
"z",
":",
":",
"param",
"x",
":",
"Number",
"of",
"copies",
"and",
"distance",
"between",
"them",
"in",
"this",
"direction",
".",
":... | fb81684935a24f7e50c975cb4383c81a63ab56df | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L2253-L2294 | train | Returns a new instance of the same class with the same attributes as the current one. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.