repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
Image.locate
def locate(self, store=current_store): """Gets the URL of the image from the ``store``. :param store: the storage which contains the image. :data:`~sqlalchemy_imageattach.context.current_store` by default :type store: :class:`~sqlalchemy_imageattach.s...
python
def locate(self, store=current_store): """Gets the URL of the image from the ``store``. :param store: the storage which contains the image. :data:`~sqlalchemy_imageattach.context.current_store` by default :type store: :class:`~sqlalchemy_imageattach.s...
[ "def", "locate", "(", "self", ",", "store", "=", "current_store", ")", ":", "if", "not", "isinstance", "(", "store", ",", "Store", ")", ":", "raise", "TypeError", "(", "'store must be an instance of '", "'sqlalchemy_imageattach.store.Store, not '", "+", "repr", "(...
Gets the URL of the image from the ``store``. :param store: the storage which contains the image. :data:`~sqlalchemy_imageattach.context.current_store` by default :type store: :class:`~sqlalchemy_imageattach.store.Store` :returns: the url of the image...
[ "Gets", "the", "URL", "of", "the", "image", "from", "the", "store", "." ]
b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L323-L338
train
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
BaseImageQuery._original_images
def _original_images(self, **kwargs): """A list of the original images. :returns: A list of the original images. :rtype: :class:`typing.Sequence`\ [:class:`Image`] """ def test(image): if not image.original: return False for filter, value...
python
def _original_images(self, **kwargs): """A list of the original images. :returns: A list of the original images. :rtype: :class:`typing.Sequence`\ [:class:`Image`] """ def test(image): if not image.original: return False for filter, value...
[ "def", "_original_images", "(", "self", ",", "**", "kwargs", ")", ":", "def", "test", "(", "image", ")", ":", "if", "not", "image", ".", "original", ":", "return", "False", "for", "filter", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", ...
A list of the original images. :returns: A list of the original images. :rtype: :class:`typing.Sequence`\ [:class:`Image`]
[ "A", "list", "of", "the", "original", "images", "." ]
b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L457-L494
train
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
BaseImageSet.from_file
def from_file(self, file, store=current_store, extra_args=None, extra_kwargs=None): """Stores the ``file`` for the image into the ``store``. :param file: the readable file of the image :type file: file-like object, :class:`file` :param store: the storage to store the f...
python
def from_file(self, file, store=current_store, extra_args=None, extra_kwargs=None): """Stores the ``file`` for the image into the ``store``. :param file: the readable file of the image :type file: file-like object, :class:`file` :param store: the storage to store the f...
[ "def", "from_file", "(", "self", ",", "file", ",", "store", "=", "current_store", ",", "extra_args", "=", "None", ",", "extra_kwargs", "=", "None", ")", ":", "if", "isinstance", "(", "file", ",", "cgi", ".", "FieldStorage", ")", ":", "file", "=", "file...
Stores the ``file`` for the image into the ``store``. :param file: the readable file of the image :type file: file-like object, :class:`file` :param store: the storage to store the file. :data:`~sqlalchemy_imageattach.context.current_store` by default...
[ "Stores", "the", "file", "for", "the", "image", "into", "the", "store", "." ]
b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L655-L688
train
benmoran56/esper
esper.py
World.clear_database
def clear_database(self) -> None: """Remove all Entities and Components from the World.""" self._next_entity_id = 0 self._dead_entities.clear() self._components.clear() self._entities.clear() self.clear_cache()
python
def clear_database(self) -> None: """Remove all Entities and Components from the World.""" self._next_entity_id = 0 self._dead_entities.clear() self._components.clear() self._entities.clear() self.clear_cache()
[ "def", "clear_database", "(", "self", ")", "->", "None", ":", "self", ".", "_next_entity_id", "=", "0", "self", ".", "_dead_entities", ".", "clear", "(", ")", "self", ".", "_components", ".", "clear", "(", ")", "self", ".", "_entities", ".", "clear", "...
Remove all Entities and Components from the World.
[ "Remove", "all", "Entities", "and", "Components", "from", "the", "World", "." ]
5b6cd0c51718d5dcfa0e5613f824b5251cf092ac
https://github.com/benmoran56/esper/blob/5b6cd0c51718d5dcfa0e5613f824b5251cf092ac/esper.py#L46-L52
train
benmoran56/esper
esper.py
World.add_processor
def add_processor(self, processor_instance: Processor, priority=0) -> None: """Add a Processor instance to the World. :param processor_instance: An instance of a Processor, subclassed from the Processor class :param priority: A higher number is processed first. """ asser...
python
def add_processor(self, processor_instance: Processor, priority=0) -> None: """Add a Processor instance to the World. :param processor_instance: An instance of a Processor, subclassed from the Processor class :param priority: A higher number is processed first. """ asser...
[ "def", "add_processor", "(", "self", ",", "processor_instance", ":", "Processor", ",", "priority", "=", "0", ")", "->", "None", ":", "assert", "issubclass", "(", "processor_instance", ".", "__class__", ",", "Processor", ")", "processor_instance", ".", "priority"...
Add a Processor instance to the World. :param processor_instance: An instance of a Processor, subclassed from the Processor class :param priority: A higher number is processed first.
[ "Add", "a", "Processor", "instance", "to", "the", "World", "." ]
5b6cd0c51718d5dcfa0e5613f824b5251cf092ac
https://github.com/benmoran56/esper/blob/5b6cd0c51718d5dcfa0e5613f824b5251cf092ac/esper.py#L54-L65
train
benmoran56/esper
esper.py
World.remove_processor
def remove_processor(self, processor_type: Processor) -> None: """Remove a Processor from the World, by type. :param processor_type: The class type of the Processor to remove. """ for processor in self._processors: if type(processor) == processor_type: proces...
python
def remove_processor(self, processor_type: Processor) -> None: """Remove a Processor from the World, by type. :param processor_type: The class type of the Processor to remove. """ for processor in self._processors: if type(processor) == processor_type: proces...
[ "def", "remove_processor", "(", "self", ",", "processor_type", ":", "Processor", ")", "->", "None", ":", "for", "processor", "in", "self", ".", "_processors", ":", "if", "type", "(", "processor", ")", "==", "processor_type", ":", "processor", ".", "world", ...
Remove a Processor from the World, by type. :param processor_type: The class type of the Processor to remove.
[ "Remove", "a", "Processor", "from", "the", "World", "by", "type", "." ]
5b6cd0c51718d5dcfa0e5613f824b5251cf092ac
https://github.com/benmoran56/esper/blob/5b6cd0c51718d5dcfa0e5613f824b5251cf092ac/esper.py#L67-L75
train
benmoran56/esper
esper.py
World.get_processor
def get_processor(self, processor_type: Type[P]) -> P: """Get a Processor instance, by type. This method returns a Processor instance by type. This could be useful in certain situations, such as wanting to call a method on a Processor, from within another Processor. :param proc...
python
def get_processor(self, processor_type: Type[P]) -> P: """Get a Processor instance, by type. This method returns a Processor instance by type. This could be useful in certain situations, such as wanting to call a method on a Processor, from within another Processor. :param proc...
[ "def", "get_processor", "(", "self", ",", "processor_type", ":", "Type", "[", "P", "]", ")", "->", "P", ":", "for", "processor", "in", "self", ".", "_processors", ":", "if", "type", "(", "processor", ")", "==", "processor_type", ":", "return", "processor...
Get a Processor instance, by type. This method returns a Processor instance by type. This could be useful in certain situations, such as wanting to call a method on a Processor, from within another Processor. :param processor_type: The type of the Processor you wish to retrieve. ...
[ "Get", "a", "Processor", "instance", "by", "type", "." ]
5b6cd0c51718d5dcfa0e5613f824b5251cf092ac
https://github.com/benmoran56/esper/blob/5b6cd0c51718d5dcfa0e5613f824b5251cf092ac/esper.py#L77-L89
train
benmoran56/esper
esper.py
World.create_entity
def create_entity(self, *components) -> int: """Create a new Entity. This method returns an Entity ID, which is just a plain integer. You can optionally pass one or more Component instances to be assigned to the Entity. :param components: Optional components to be assigned to t...
python
def create_entity(self, *components) -> int: """Create a new Entity. This method returns an Entity ID, which is just a plain integer. You can optionally pass one or more Component instances to be assigned to the Entity. :param components: Optional components to be assigned to t...
[ "def", "create_entity", "(", "self", ",", "*", "components", ")", "->", "int", ":", "self", ".", "_next_entity_id", "+=", "1", "for", "component", "in", "components", ":", "self", ".", "add_component", "(", "self", ".", "_next_entity_id", ",", "component", ...
Create a new Entity. This method returns an Entity ID, which is just a plain integer. You can optionally pass one or more Component instances to be assigned to the Entity. :param components: Optional components to be assigned to the entity on creation. :return: The next...
[ "Create", "a", "new", "Entity", "." ]
5b6cd0c51718d5dcfa0e5613f824b5251cf092ac
https://github.com/benmoran56/esper/blob/5b6cd0c51718d5dcfa0e5613f824b5251cf092ac/esper.py#L91-L109
train
benmoran56/esper
esper.py
World.delete_entity
def delete_entity(self, entity: int, immediate=False) -> None: """Delete an Entity from the World. Delete an Entity and all of it's assigned Component instances from the world. By default, Entity deletion is delayed until the next call to *World.process*. You can request immediate delet...
python
def delete_entity(self, entity: int, immediate=False) -> None: """Delete an Entity from the World. Delete an Entity and all of it's assigned Component instances from the world. By default, Entity deletion is delayed until the next call to *World.process*. You can request immediate delet...
[ "def", "delete_entity", "(", "self", ",", "entity", ":", "int", ",", "immediate", "=", "False", ")", "->", "None", ":", "if", "immediate", ":", "for", "component_type", "in", "self", ".", "_entities", "[", "entity", "]", ":", "self", ".", "_components", ...
Delete an Entity from the World. Delete an Entity and all of it's assigned Component instances from the world. By default, Entity deletion is delayed until the next call to *World.process*. You can request immediate deletion, however, by passing the "immediate=True" parameter. This shou...
[ "Delete", "an", "Entity", "from", "the", "World", "." ]
5b6cd0c51718d5dcfa0e5613f824b5251cf092ac
https://github.com/benmoran56/esper/blob/5b6cd0c51718d5dcfa0e5613f824b5251cf092ac/esper.py#L111-L135
train
benmoran56/esper
esper.py
World.component_for_entity
def component_for_entity(self, entity: int, component_type: Type[C]) -> C: """Retrieve a Component instance for a specific Entity. Retrieve a Component instance for a specific Entity. In some cases, it may be necessary to access a specific Component instance. For example: directly modif...
python
def component_for_entity(self, entity: int, component_type: Type[C]) -> C: """Retrieve a Component instance for a specific Entity. Retrieve a Component instance for a specific Entity. In some cases, it may be necessary to access a specific Component instance. For example: directly modif...
[ "def", "component_for_entity", "(", "self", ",", "entity", ":", "int", ",", "component_type", ":", "Type", "[", "C", "]", ")", "->", "C", ":", "return", "self", ".", "_entities", "[", "entity", "]", "[", "component_type", "]" ]
Retrieve a Component instance for a specific Entity. Retrieve a Component instance for a specific Entity. In some cases, it may be necessary to access a specific Component instance. For example: directly modifying a Component to handle user input. Raises a KeyError if the given Entity ...
[ "Retrieve", "a", "Component", "instance", "for", "a", "specific", "Entity", "." ]
5b6cd0c51718d5dcfa0e5613f824b5251cf092ac
https://github.com/benmoran56/esper/blob/5b6cd0c51718d5dcfa0e5613f824b5251cf092ac/esper.py#L137-L149
train
benmoran56/esper
esper.py
World.components_for_entity
def components_for_entity(self, entity: int) -> Tuple[C, ...]: """Retrieve all Components for a specific Entity, as a Tuple. Retrieve all Components for a specific Entity. The method is probably not appropriate to use in your Processors, but might be useful for saving state, or passing ...
python
def components_for_entity(self, entity: int) -> Tuple[C, ...]: """Retrieve all Components for a specific Entity, as a Tuple. Retrieve all Components for a specific Entity. The method is probably not appropriate to use in your Processors, but might be useful for saving state, or passing ...
[ "def", "components_for_entity", "(", "self", ",", "entity", ":", "int", ")", "->", "Tuple", "[", "C", ",", "...", "]", ":", "return", "tuple", "(", "self", ".", "_entities", "[", "entity", "]", ".", "values", "(", ")", ")" ]
Retrieve all Components for a specific Entity, as a Tuple. Retrieve all Components for a specific Entity. The method is probably not appropriate to use in your Processors, but might be useful for saving state, or passing specific Components between World instances. Unlike most other met...
[ "Retrieve", "all", "Components", "for", "a", "specific", "Entity", "as", "a", "Tuple", "." ]
5b6cd0c51718d5dcfa0e5613f824b5251cf092ac
https://github.com/benmoran56/esper/blob/5b6cd0c51718d5dcfa0e5613f824b5251cf092ac/esper.py#L151-L165
train
benmoran56/esper
esper.py
World.has_component
def has_component(self, entity: int, component_type: Any) -> bool: """Check if a specific Entity has a Component of a certain type. :param entity: The Entity you are querying. :param component_type: The type of Component to check for. :return: True if the Entity has a Component of this ...
python
def has_component(self, entity: int, component_type: Any) -> bool: """Check if a specific Entity has a Component of a certain type. :param entity: The Entity you are querying. :param component_type: The type of Component to check for. :return: True if the Entity has a Component of this ...
[ "def", "has_component", "(", "self", ",", "entity", ":", "int", ",", "component_type", ":", "Any", ")", "->", "bool", ":", "return", "component_type", "in", "self", ".", "_entities", "[", "entity", "]" ]
Check if a specific Entity has a Component of a certain type. :param entity: The Entity you are querying. :param component_type: The type of Component to check for. :return: True if the Entity has a Component of this type, otherwise False
[ "Check", "if", "a", "specific", "Entity", "has", "a", "Component", "of", "a", "certain", "type", "." ]
5b6cd0c51718d5dcfa0e5613f824b5251cf092ac
https://github.com/benmoran56/esper/blob/5b6cd0c51718d5dcfa0e5613f824b5251cf092ac/esper.py#L167-L175
train
benmoran56/esper
esper.py
World.add_component
def add_component(self, entity: int, component_instance: Any) -> None: """Add a new Component instance to an Entity. Add a Component instance to an Entiy. If a Component of the same type is already assigned to the Entity, it will be replaced. :param entity: The Entity to associate the ...
python
def add_component(self, entity: int, component_instance: Any) -> None: """Add a new Component instance to an Entity. Add a Component instance to an Entiy. If a Component of the same type is already assigned to the Entity, it will be replaced. :param entity: The Entity to associate the ...
[ "def", "add_component", "(", "self", ",", "entity", ":", "int", ",", "component_instance", ":", "Any", ")", "->", "None", ":", "component_type", "=", "type", "(", "component_instance", ")", "if", "component_type", "not", "in", "self", ".", "_components", ":"...
Add a new Component instance to an Entity. Add a Component instance to an Entiy. If a Component of the same type is already assigned to the Entity, it will be replaced. :param entity: The Entity to associate the Component with. :param component_instance: A Component instance.
[ "Add", "a", "new", "Component", "instance", "to", "an", "Entity", "." ]
5b6cd0c51718d5dcfa0e5613f824b5251cf092ac
https://github.com/benmoran56/esper/blob/5b6cd0c51718d5dcfa0e5613f824b5251cf092ac/esper.py#L177-L197
train
benmoran56/esper
esper.py
World.remove_component
def remove_component(self, entity: int, component_type: Any) -> int: """Remove a Component instance from an Entity, by type. A Component instance can be removed by providing it's type. For example: world.delete_component(enemy_a, Velocity) will remove the Velocity instance from the Enti...
python
def remove_component(self, entity: int, component_type: Any) -> int: """Remove a Component instance from an Entity, by type. A Component instance can be removed by providing it's type. For example: world.delete_component(enemy_a, Velocity) will remove the Velocity instance from the Enti...
[ "def", "remove_component", "(", "self", ",", "entity", ":", "int", ",", "component_type", ":", "Any", ")", "->", "int", ":", "self", ".", "_components", "[", "component_type", "]", ".", "discard", "(", "entity", ")", "if", "not", "self", ".", "_component...
Remove a Component instance from an Entity, by type. A Component instance can be removed by providing it's type. For example: world.delete_component(enemy_a, Velocity) will remove the Velocity instance from the Entity enemy_a. Raises a KeyError if either the given entity or Component t...
[ "Remove", "a", "Component", "instance", "from", "an", "Entity", "by", "type", "." ]
5b6cd0c51718d5dcfa0e5613f824b5251cf092ac
https://github.com/benmoran56/esper/blob/5b6cd0c51718d5dcfa0e5613f824b5251cf092ac/esper.py#L199-L222
train
benmoran56/esper
esper.py
World._get_component
def _get_component(self, component_type: Type[C]) -> Iterable[Tuple[int, C]]: """Get an iterator for Entity, Component pairs. :param component_type: The Component type to retrieve. :return: An iterator for (Entity, Component) tuples. """ entity_db = self._entities for e...
python
def _get_component(self, component_type: Type[C]) -> Iterable[Tuple[int, C]]: """Get an iterator for Entity, Component pairs. :param component_type: The Component type to retrieve. :return: An iterator for (Entity, Component) tuples. """ entity_db = self._entities for e...
[ "def", "_get_component", "(", "self", ",", "component_type", ":", "Type", "[", "C", "]", ")", "->", "Iterable", "[", "Tuple", "[", "int", ",", "C", "]", "]", ":", "entity_db", "=", "self", ".", "_entities", "for", "entity", "in", "self", ".", "_compo...
Get an iterator for Entity, Component pairs. :param component_type: The Component type to retrieve. :return: An iterator for (Entity, Component) tuples.
[ "Get", "an", "iterator", "for", "Entity", "Component", "pairs", "." ]
5b6cd0c51718d5dcfa0e5613f824b5251cf092ac
https://github.com/benmoran56/esper/blob/5b6cd0c51718d5dcfa0e5613f824b5251cf092ac/esper.py#L224-L233
train
benmoran56/esper
esper.py
World._get_components
def _get_components(self, *component_types: Type)-> Iterable[Tuple[int, ...]]: """Get an iterator for Entity and multiple Component sets. :param component_types: Two or more Component types. :return: An iterator for Entity, (Component1, Component2, etc) tuples. """ entit...
python
def _get_components(self, *component_types: Type)-> Iterable[Tuple[int, ...]]: """Get an iterator for Entity and multiple Component sets. :param component_types: Two or more Component types. :return: An iterator for Entity, (Component1, Component2, etc) tuples. """ entit...
[ "def", "_get_components", "(", "self", ",", "*", "component_types", ":", "Type", ")", "->", "Iterable", "[", "Tuple", "[", "int", ",", "...", "]", "]", ":", "entity_db", "=", "self", ".", "_entities", "comp_db", "=", "self", ".", "_components", "try", ...
Get an iterator for Entity and multiple Component sets. :param component_types: Two or more Component types. :return: An iterator for Entity, (Component1, Component2, etc) tuples.
[ "Get", "an", "iterator", "for", "Entity", "and", "multiple", "Component", "sets", "." ]
5b6cd0c51718d5dcfa0e5613f824b5251cf092ac
https://github.com/benmoran56/esper/blob/5b6cd0c51718d5dcfa0e5613f824b5251cf092ac/esper.py#L235-L249
train
benmoran56/esper
esper.py
World.try_component
def try_component(self, entity: int, component_type: Type): """Try to get a single component type for an Entity. This method will return the requested Component if it exists, but will pass silently if it does not. This allows a way to access optional Componen...
python
def try_component(self, entity: int, component_type: Type): """Try to get a single component type for an Entity. This method will return the requested Component if it exists, but will pass silently if it does not. This allows a way to access optional Componen...
[ "def", "try_component", "(", "self", ",", "entity", ":", "int", ",", "component_type", ":", "Type", ")", ":", "if", "component_type", "in", "self", ".", "_entities", "[", "entity", "]", ":", "yield", "self", ".", "_entities", "[", "entity", "]", "[", "...
Try to get a single component type for an Entity. This method will return the requested Component if it exists, but will pass silently if it does not. This allows a way to access optional Components that may or may not exist. :param entity: The Entity ID to ...
[ "Try", "to", "get", "a", "single", "component", "type", "for", "an", "Entity", ".", "This", "method", "will", "return", "the", "requested", "Component", "if", "it", "exists", "but", "will", "pass", "silently", "if", "it", "does", "not", ".", "This", "all...
5b6cd0c51718d5dcfa0e5613f824b5251cf092ac
https://github.com/benmoran56/esper/blob/5b6cd0c51718d5dcfa0e5613f824b5251cf092ac/esper.py#L259-L274
train
benmoran56/esper
esper.py
World._clear_dead_entities
def _clear_dead_entities(self): """Finalize deletion of any Entities that are marked dead. In the interest of performance, this method duplicates code from the `delete_entity` method. If that method is changed, those changes should be duplicated here as well. """ ...
python
def _clear_dead_entities(self): """Finalize deletion of any Entities that are marked dead. In the interest of performance, this method duplicates code from the `delete_entity` method. If that method is changed, those changes should be duplicated here as well. """ ...
[ "def", "_clear_dead_entities", "(", "self", ")", ":", "for", "entity", "in", "self", ".", "_dead_entities", ":", "for", "component_type", "in", "self", ".", "_entities", "[", "entity", "]", ":", "self", ".", "_components", "[", "component_type", "]", ".", ...
Finalize deletion of any Entities that are marked dead. In the interest of performance, this method duplicates code from the `delete_entity` method. If that method is changed, those changes should be duplicated here as well.
[ "Finalize", "deletion", "of", "any", "Entities", "that", "are", "marked", "dead", ".", "In", "the", "interest", "of", "performance", "this", "method", "duplicates", "code", "from", "the", "delete_entity", "method", ".", "If", "that", "method", "is", "changed",...
5b6cd0c51718d5dcfa0e5613f824b5251cf092ac
https://github.com/benmoran56/esper/blob/5b6cd0c51718d5dcfa0e5613f824b5251cf092ac/esper.py#L276-L294
train
benmoran56/esper
esper.py
World._timed_process
def _timed_process(self, *args, **kwargs): """Track Processor execution time for benchmarking.""" for processor in self._processors: start_time = _time.process_time() processor.process(*args, **kwargs) process_time = int(round((_time.process_time() - start_time) * 100...
python
def _timed_process(self, *args, **kwargs): """Track Processor execution time for benchmarking.""" for processor in self._processors: start_time = _time.process_time() processor.process(*args, **kwargs) process_time = int(round((_time.process_time() - start_time) * 100...
[ "def", "_timed_process", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "for", "processor", "in", "self", ".", "_processors", ":", "start_time", "=", "_time", ".", "process_time", "(", ")", "processor", ".", "process", "(", "*", "args", ...
Track Processor execution time for benchmarking.
[ "Track", "Processor", "execution", "time", "for", "benchmarking", "." ]
5b6cd0c51718d5dcfa0e5613f824b5251cf092ac
https://github.com/benmoran56/esper/blob/5b6cd0c51718d5dcfa0e5613f824b5251cf092ac/esper.py#L300-L306
train
benmoran56/esper
esper.py
World.process
def process(self, *args, **kwargs): """Call the process method on all Processors, in order of their priority. Call the *process* method on all assigned Processors, respecting their optional priority setting. In addition, any Entities that were marked for deletion since the last call to ...
python
def process(self, *args, **kwargs): """Call the process method on all Processors, in order of their priority. Call the *process* method on all assigned Processors, respecting their optional priority setting. In addition, any Entities that were marked for deletion since the last call to ...
[ "def", "process", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "self", ".", "_clear_dead_entities", "(", ")", "self", ".", "_process", "(", "*", "args", ",", "**", "kwargs", ")" ]
Call the process method on all Processors, in order of their priority. Call the *process* method on all assigned Processors, respecting their optional priority setting. In addition, any Entities that were marked for deletion since the last call to *World.process*, will be deleted at the...
[ "Call", "the", "process", "method", "on", "all", "Processors", "in", "order", "of", "their", "priority", "." ]
5b6cd0c51718d5dcfa0e5613f824b5251cf092ac
https://github.com/benmoran56/esper/blob/5b6cd0c51718d5dcfa0e5613f824b5251cf092ac/esper.py#L308-L320
train
benmoran56/esper
examples/pysdl2_example.py
texture_from_image
def texture_from_image(renderer, image_name): """Create an SDL2 Texture from an image file""" soft_surface = ext.load_image(image_name) texture = SDL_CreateTextureFromSurface(renderer.renderer, soft_surface) SDL_FreeSurface(soft_surface) return texture
python
def texture_from_image(renderer, image_name): """Create an SDL2 Texture from an image file""" soft_surface = ext.load_image(image_name) texture = SDL_CreateTextureFromSurface(renderer.renderer, soft_surface) SDL_FreeSurface(soft_surface) return texture
[ "def", "texture_from_image", "(", "renderer", ",", "image_name", ")", ":", "soft_surface", "=", "ext", ".", "load_image", "(", "image_name", ")", "texture", "=", "SDL_CreateTextureFromSurface", "(", "renderer", ".", "renderer", ",", "soft_surface", ")", "SDL_FreeS...
Create an SDL2 Texture from an image file
[ "Create", "an", "SDL2", "Texture", "from", "an", "image", "file" ]
5b6cd0c51718d5dcfa0e5613f824b5251cf092ac
https://github.com/benmoran56/esper/blob/5b6cd0c51718d5dcfa0e5613f824b5251cf092ac/examples/pysdl2_example.py#L76-L81
train
sdss/tree
tasks.py
setup_tree
def setup_tree(ctx, verbose=None, root=None, tree_dir=None, modules_dir=None): ''' Sets up the SDSS tree enviroment ''' print('Setting up the tree') ctx.run('python bin/setup_tree.py -t {0} -r {1} -m {2}'.format(tree_dir, root, modules_dir))
python
def setup_tree(ctx, verbose=None, root=None, tree_dir=None, modules_dir=None): ''' Sets up the SDSS tree enviroment ''' print('Setting up the tree') ctx.run('python bin/setup_tree.py -t {0} -r {1} -m {2}'.format(tree_dir, root, modules_dir))
[ "def", "setup_tree", "(", "ctx", ",", "verbose", "=", "None", ",", "root", "=", "None", ",", "tree_dir", "=", "None", ",", "modules_dir", "=", "None", ")", ":", "print", "(", "'Setting up the tree'", ")", "ctx", ".", "run", "(", "'python bin/setup_tree.py ...
Sets up the SDSS tree enviroment
[ "Sets", "up", "the", "SDSS", "tree", "enviroment" ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/tasks.py#L61-L64
train
sdss/tree
python/tree/tree.py
Tree.set_roots
def set_roots(self, uproot_with=None): ''' Set the roots of the tree in the os environment Parameters: uproot_with (str): A new TREE_DIR path used to override an existing TREE_DIR environment variable ''' # Check for TREE_DIR self.treedir = os.envir...
python
def set_roots(self, uproot_with=None): ''' Set the roots of the tree in the os environment Parameters: uproot_with (str): A new TREE_DIR path used to override an existing TREE_DIR environment variable ''' # Check for TREE_DIR self.treedir = os.envir...
[ "def", "set_roots", "(", "self", ",", "uproot_with", "=", "None", ")", ":", "self", ".", "treedir", "=", "os", ".", "environ", ".", "get", "(", "'TREE_DIR'", ",", "None", ")", "if", "not", "uproot_with", "else", "uproot_with", "if", "not", "self", ".",...
Set the roots of the tree in the os environment Parameters: uproot_with (str): A new TREE_DIR path used to override an existing TREE_DIR environment variable
[ "Set", "the", "roots", "of", "the", "tree", "in", "the", "os", "environment" ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/python/tree/tree.py#L75-L103
train
sdss/tree
python/tree/tree.py
Tree.load_config
def load_config(self, config=None): ''' loads a config file Parameters: config (str): Optional name of manual config file to load ''' # Read the config file cfgname = (config or self.config_name) cfgname = 'sdsswork' if cfgname is None else c...
python
def load_config(self, config=None): ''' loads a config file Parameters: config (str): Optional name of manual config file to load ''' # Read the config file cfgname = (config or self.config_name) cfgname = 'sdsswork' if cfgname is None else c...
[ "def", "load_config", "(", "self", ",", "config", "=", "None", ")", ":", "cfgname", "=", "(", "config", "or", "self", ".", "config_name", ")", "cfgname", "=", "'sdsswork'", "if", "cfgname", "is", "None", "else", "cfgname", "assert", "isinstance", "(", "c...
loads a config file Parameters: config (str): Optional name of manual config file to load
[ "loads", "a", "config", "file" ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/python/tree/tree.py#L105-L135
train
sdss/tree
python/tree/tree.py
Tree.branch_out
def branch_out(self, limb=None): ''' Set the individual section branches This adds the various sections of the config file into the tree environment for access later. Optically can specify a specific branch. This does not yet load them into the os environment. Parameters: ...
python
def branch_out(self, limb=None): ''' Set the individual section branches This adds the various sections of the config file into the tree environment for access later. Optically can specify a specific branch. This does not yet load them into the os environment. Parameters: ...
[ "def", "branch_out", "(", "self", ",", "limb", "=", "None", ")", ":", "if", "not", "limb", ":", "limbs", "=", "self", ".", "_cfg", ".", "sections", "(", ")", "else", ":", "limb", "=", "limb", "if", "isinstance", "(", "limb", ",", "list", ")", "el...
Set the individual section branches This adds the various sections of the config file into the tree environment for access later. Optically can specify a specific branch. This does not yet load them into the os environment. Parameters: limb (str/list): The ...
[ "Set", "the", "individual", "section", "branches" ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/python/tree/tree.py#L137-L172
train
sdss/tree
python/tree/tree.py
Tree.add_limbs
def add_limbs(self, key=None): ''' Add a new section from the tree into the existing os environment Parameters: key (str): The section name to grab from the environment ''' self.branch_out(limb=key) self.add_paths_to_os(key=key)
python
def add_limbs(self, key=None): ''' Add a new section from the tree into the existing os environment Parameters: key (str): The section name to grab from the environment ''' self.branch_out(limb=key) self.add_paths_to_os(key=key)
[ "def", "add_limbs", "(", "self", ",", "key", "=", "None", ")", ":", "self", ".", "branch_out", "(", "limb", "=", "key", ")", "self", ".", "add_paths_to_os", "(", "key", "=", "key", ")" ]
Add a new section from the tree into the existing os environment Parameters: key (str): The section name to grab from the environment
[ "Add", "a", "new", "section", "from", "the", "tree", "into", "the", "existing", "os", "environment" ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/python/tree/tree.py#L174-L183
train
sdss/tree
python/tree/tree.py
Tree.get_paths
def get_paths(self, key): ''' Retrieve a set of environment paths from the config Parameters: key (str): The section name to grab from the environment Returns: self.environ[newkey] (OrderedDict): An ordered dict containing all of the path...
python
def get_paths(self, key): ''' Retrieve a set of environment paths from the config Parameters: key (str): The section name to grab from the environment Returns: self.environ[newkey] (OrderedDict): An ordered dict containing all of the path...
[ "def", "get_paths", "(", "self", ",", "key", ")", ":", "newkey", "=", "key", "if", "key", "in", "self", ".", "environ", "else", "key", ".", "upper", "(", ")", "if", "key", ".", "upper", "(", ")", "in", "self", ".", "environ", "else", "None", "if"...
Retrieve a set of environment paths from the config Parameters: key (str): The section name to grab from the environment Returns: self.environ[newkey] (OrderedDict): An ordered dict containing all of the paths from the specified s...
[ "Retrieve", "a", "set", "of", "environment", "paths", "from", "the", "config" ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/python/tree/tree.py#L185-L202
train
sdss/tree
python/tree/tree.py
Tree.add_paths_to_os
def add_paths_to_os(self, key=None, update=None): ''' Add the paths in tree environ into the os environ This code goes through the tree environ and checks for existence in the os environ, then adds them Parameters: key (str): The section name to check agains...
python
def add_paths_to_os(self, key=None, update=None): ''' Add the paths in tree environ into the os environ This code goes through the tree environ and checks for existence in the os environ, then adds them Parameters: key (str): The section name to check agains...
[ "def", "add_paths_to_os", "(", "self", ",", "key", "=", "None", ",", "update", "=", "None", ")", ":", "if", "key", "is", "not", "None", ":", "allpaths", "=", "key", "if", "isinstance", "(", "key", ",", "list", ")", "else", "[", "key", "]", "else", ...
Add the paths in tree environ into the os environ This code goes through the tree environ and checks for existence in the os environ, then adds them Parameters: key (str): The section name to check against / add update (bool): If True, ov...
[ "Add", "the", "paths", "in", "tree", "environ", "into", "the", "os", "environ" ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/python/tree/tree.py#L204-L225
train
sdss/tree
python/tree/tree.py
Tree.check_paths
def check_paths(self, paths, update=None): ''' Check if the path is in the os environ, and if not add it Paramters: paths (OrderedDict): An ordered dict containing all of the paths from the a given section, as key:val = name:path update (bool): ...
python
def check_paths(self, paths, update=None): ''' Check if the path is in the os environ, and if not add it Paramters: paths (OrderedDict): An ordered dict containing all of the paths from the a given section, as key:val = name:path update (bool): ...
[ "def", "check_paths", "(", "self", ",", "paths", ",", "update", "=", "None", ")", ":", "exclude", "=", "[", "]", "if", "not", "self", ".", "exclude", "else", "self", ".", "exclude", "if", "isinstance", "(", "self", ".", "exclude", ",", "list", ")", ...
Check if the path is in the os environ, and if not add it Paramters: paths (OrderedDict): An ordered dict containing all of the paths from the a given section, as key:val = name:path update (bool): If True, overwrites existing tree environ...
[ "Check", "if", "the", "path", "is", "in", "the", "os", "environ", "and", "if", "not", "add", "it" ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/python/tree/tree.py#L227-L248
train
sdss/tree
python/tree/tree.py
Tree.replant_tree
def replant_tree(self, config=None, exclude=None): ''' Replant the tree with a different config setup Parameters: config (str): The config name to reload exclude (list): A list of environment variables to exclude from forced update...
python
def replant_tree(self, config=None, exclude=None): ''' Replant the tree with a different config setup Parameters: config (str): The config name to reload exclude (list): A list of environment variables to exclude from forced update...
[ "def", "replant_tree", "(", "self", ",", "config", "=", "None", ",", "exclude", "=", "None", ")", ":", "self", ".", "__init__", "(", "key", "=", "self", ".", "key", ",", "config", "=", "config", ",", "update", "=", "True", ",", "exclude", "=", "exc...
Replant the tree with a different config setup Parameters: config (str): The config name to reload exclude (list): A list of environment variables to exclude from forced updates
[ "Replant", "the", "tree", "with", "a", "different", "config", "setup" ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/python/tree/tree.py#L250-L262
train
sdss/tree
python/tree/misc/logger.py
print_exception_formatted
def print_exception_formatted(type, value, tb): """A custom hook for printing tracebacks with colours.""" tbtext = ''.join(traceback.format_exception(type, value, tb)) lexer = get_lexer_by_name('pytb', stripall=True) formatter = TerminalFormatter() sys.stderr.write(highlight(tbtext, lexer, formatte...
python
def print_exception_formatted(type, value, tb): """A custom hook for printing tracebacks with colours.""" tbtext = ''.join(traceback.format_exception(type, value, tb)) lexer = get_lexer_by_name('pytb', stripall=True) formatter = TerminalFormatter() sys.stderr.write(highlight(tbtext, lexer, formatte...
[ "def", "print_exception_formatted", "(", "type", ",", "value", ",", "tb", ")", ":", "tbtext", "=", "''", ".", "join", "(", "traceback", ".", "format_exception", "(", "type", ",", "value", ",", "tb", ")", ")", "lexer", "=", "get_lexer_by_name", "(", "'pyt...
A custom hook for printing tracebacks with colours.
[ "A", "custom", "hook", "for", "printing", "tracebacks", "with", "colours", "." ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/python/tree/misc/logger.py#L49-L55
train
sdss/tree
python/tree/misc/logger.py
colored_formatter
def colored_formatter(record): """Prints log messages with colours.""" colours = {'info': ('blue', 'normal'), 'debug': ('magenta', 'normal'), 'warning': ('yellow', 'normal'), 'print': ('green', 'normal'), 'error': ('red', 'bold')} levelname = rec...
python
def colored_formatter(record): """Prints log messages with colours.""" colours = {'info': ('blue', 'normal'), 'debug': ('magenta', 'normal'), 'warning': ('yellow', 'normal'), 'print': ('green', 'normal'), 'error': ('red', 'bold')} levelname = rec...
[ "def", "colored_formatter", "(", "record", ")", ":", "colours", "=", "{", "'info'", ":", "(", "'blue'", ",", "'normal'", ")", ",", "'debug'", ":", "(", "'magenta'", ",", "'normal'", ")", ",", "'warning'", ":", "(", "'yellow'", ",", "'normal'", ")", ","...
Prints log messages with colours.
[ "Prints", "log", "messages", "with", "colours", "." ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/python/tree/misc/logger.py#L58-L98
train
sdss/tree
python/tree/misc/logger.py
MyLogger._catch_exceptions
def _catch_exceptions(self, exctype, value, tb): """Catches all exceptions and logs them.""" # Now we log it. self.error('Uncaught exception', exc_info=(exctype, value, tb)) # First, we print to stdout with some colouring. print_exception_formatted(exctype, value, tb)
python
def _catch_exceptions(self, exctype, value, tb): """Catches all exceptions and logs them.""" # Now we log it. self.error('Uncaught exception', exc_info=(exctype, value, tb)) # First, we print to stdout with some colouring. print_exception_formatted(exctype, value, tb)
[ "def", "_catch_exceptions", "(", "self", ",", "exctype", ",", "value", ",", "tb", ")", ":", "self", ".", "error", "(", "'Uncaught exception'", ",", "exc_info", "=", "(", "exctype", ",", "value", ",", "tb", ")", ")", "print_exception_formatted", "(", "excty...
Catches all exceptions and logs them.
[ "Catches", "all", "exceptions", "and", "logs", "them", "." ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/python/tree/misc/logger.py#L205-L212
train
sdss/tree
python/tree/misc/logger.py
MyLogger._set_defaults
def _set_defaults(self, log_level=logging.INFO, redirect_stdout=False): """Reset logger to its initial state.""" # Remove all previous handlers for handler in self.handlers[:]: self.removeHandler(handler) # Set levels self.setLevel(logging.DEBUG) # Set up t...
python
def _set_defaults(self, log_level=logging.INFO, redirect_stdout=False): """Reset logger to its initial state.""" # Remove all previous handlers for handler in self.handlers[:]: self.removeHandler(handler) # Set levels self.setLevel(logging.DEBUG) # Set up t...
[ "def", "_set_defaults", "(", "self", ",", "log_level", "=", "logging", ".", "INFO", ",", "redirect_stdout", "=", "False", ")", ":", "for", "handler", "in", "self", ".", "handlers", "[", ":", "]", ":", "self", ".", "removeHandler", "(", "handler", ")", ...
Reset logger to its initial state.
[ "Reset", "logger", "to", "its", "initial", "state", "." ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/python/tree/misc/logger.py#L214-L239
train
sdss/tree
python/tree/misc/logger.py
MyLogger.start_file_logger
def start_file_logger(self, name, log_file_level=logging.DEBUG, log_file_path='./'): """Start file logging.""" log_file_path = os.path.expanduser(log_file_path) / '{}.log'.format(name) logdir = log_file_path.parent try: logdir.mkdir(parents=True, exist_ok=True) ...
python
def start_file_logger(self, name, log_file_level=logging.DEBUG, log_file_path='./'): """Start file logging.""" log_file_path = os.path.expanduser(log_file_path) / '{}.log'.format(name) logdir = log_file_path.parent try: logdir.mkdir(parents=True, exist_ok=True) ...
[ "def", "start_file_logger", "(", "self", ",", "name", ",", "log_file_level", "=", "logging", ".", "DEBUG", ",", "log_file_path", "=", "'./'", ")", ":", "log_file_path", "=", "os", ".", "path", ".", "expanduser", "(", "log_file_path", ")", "/", "'{}.log'", ...
Start file logging.
[ "Start", "file", "logging", "." ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/python/tree/misc/logger.py#L241-L265
train
sdss/tree
bin/setup_tree.py
create_index_page
def create_index_page(environ, defaults, envdir): ''' create the env index html page Builds the index.html page containing a table of symlinks to datamodel directories Parameters: environ (dict): A tree environment dictionary defaults (dict): The defaults di...
python
def create_index_page(environ, defaults, envdir): ''' create the env index html page Builds the index.html page containing a table of symlinks to datamodel directories Parameters: environ (dict): A tree environment dictionary defaults (dict): The defaults di...
[ "def", "create_index_page", "(", "environ", ",", "defaults", ",", "envdir", ")", ":", "header", "=", "footer", "=", "index", "=", "header", ".", "format", "(", "**", "defaults", ")", "index", "+=", "create_index_table", "(", "environ", ",", "envdir", ")", ...
create the env index html page Builds the index.html page containing a table of symlinks to datamodel directories Parameters: environ (dict): A tree environment dictionary defaults (dict): The defaults dictionary from environ['default'] envdir (str): ...
[ "create", "the", "env", "index", "html", "page", "Builds", "the", "index", ".", "html", "page", "containing", "a", "table", "of", "symlinks", "to", "datamodel", "directories" ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/bin/setup_tree.py#L113-L153
train
sdss/tree
bin/setup_tree.py
create_env
def create_env(environ, mirror=None, verbose=None): ''' create the env symlink directory structure Creates the env folder filled with symlinks to datamodel directories for a given tree config file. Parameters: environ (dict): A tree environment dictionary mirror (bool...
python
def create_env(environ, mirror=None, verbose=None): ''' create the env symlink directory structure Creates the env folder filled with symlinks to datamodel directories for a given tree config file. Parameters: environ (dict): A tree environment dictionary mirror (bool...
[ "def", "create_env", "(", "environ", ",", "mirror", "=", "None", ",", "verbose", "=", "None", ")", ":", "defaults", "=", "environ", "[", "'default'", "]", ".", "copy", "(", ")", "defaults", "[", "'url'", "]", "=", "\"https://data.mirror.sdss.org\"", "if", ...
create the env symlink directory structure Creates the env folder filled with symlinks to datamodel directories for a given tree config file. Parameters: environ (dict): A tree environment dictionary mirror (bool): If True, use the SAM url location ver...
[ "create", "the", "env", "symlink", "directory", "structure", "Creates", "the", "env", "folder", "filled", "with", "symlinks", "to", "datamodel", "directories", "for", "a", "given", "tree", "config", "file", "." ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/bin/setup_tree.py#L156-L196
train
sdss/tree
bin/setup_tree.py
check_sas_base_dir
def check_sas_base_dir(root=None): ''' Check for the SAS_BASE_DIR environment variable Will set the SAS_BASE_DIR in your local environment or prompt you to define one if is undefined Parameters: root (str): Optional override of the SAS_BASE_DIR envvar ''' sasbasedir = root...
python
def check_sas_base_dir(root=None): ''' Check for the SAS_BASE_DIR environment variable Will set the SAS_BASE_DIR in your local environment or prompt you to define one if is undefined Parameters: root (str): Optional override of the SAS_BASE_DIR envvar ''' sasbasedir = root...
[ "def", "check_sas_base_dir", "(", "root", "=", "None", ")", ":", "sasbasedir", "=", "root", "or", "os", ".", "getenv", "(", "\"SAS_BASE_DIR\"", ")", "if", "not", "sasbasedir", ":", "sasbasedir", "=", "input", "(", "'Enter a path for SAS_BASE_DIR: '", ")", "os"...
Check for the SAS_BASE_DIR environment variable Will set the SAS_BASE_DIR in your local environment or prompt you to define one if is undefined Parameters: root (str): Optional override of the SAS_BASE_DIR envvar
[ "Check", "for", "the", "SAS_BASE_DIR", "environment", "variable" ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/bin/setup_tree.py#L199-L213
train
sdss/tree
bin/setup_tree.py
write_file
def write_file(environ, term='bash', out_dir=None, tree_dir=None): ''' Write a tree environment file Loops over the tree environ and writes them out to a bash, tsch, or modules file Parameters: environ (dict): The tree dictionary environment term (str): The type...
python
def write_file(environ, term='bash', out_dir=None, tree_dir=None): ''' Write a tree environment file Loops over the tree environ and writes them out to a bash, tsch, or modules file Parameters: environ (dict): The tree dictionary environment term (str): The type...
[ "def", "write_file", "(", "environ", ",", "term", "=", "'bash'", ",", "out_dir", "=", "None", ",", "tree_dir", "=", "None", ")", ":", "name", "=", "environ", "[", "'default'", "]", "[", "'name'", "]", "header", "=", "write_header", "(", "term", "=", ...
Write a tree environment file Loops over the tree environ and writes them out to a bash, tsch, or modules file Parameters: environ (dict): The tree dictionary environment term (str): The type of shell header to write, can be "bash", "tsch", or "modules" tree...
[ "Write", "a", "tree", "environment", "file" ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/bin/setup_tree.py#L272-L319
train
sdss/tree
bin/setup_tree.py
get_tree
def get_tree(config=None): ''' Get the tree for a given config Parameters: config (str): The name of the tree config to load Returns: a Python Tree instance ''' path = os.path.dirname(os.path.abspath(__file__)) pypath = os.path.realpath(os.path.join(path, '..', 'pyt...
python
def get_tree(config=None): ''' Get the tree for a given config Parameters: config (str): The name of the tree config to load Returns: a Python Tree instance ''' path = os.path.dirname(os.path.abspath(__file__)) pypath = os.path.realpath(os.path.join(path, '..', 'pyt...
[ "def", "get_tree", "(", "config", "=", "None", ")", ":", "path", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "__file__", ")", ")", "pypath", "=", "os", ".", "path", ".", "realpath", "(", "os", ".", "path",...
Get the tree for a given config Parameters: config (str): The name of the tree config to load Returns: a Python Tree instance
[ "Get", "the", "tree", "for", "a", "given", "config" ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/bin/setup_tree.py#L322-L339
train
sdss/tree
bin/setup_tree.py
copy_modules
def copy_modules(filespath=None, modules_path=None, verbose=None): ''' Copy over the tree module files into your path ''' # find or define a modules path if not modules_path: modulepath = os.getenv("MODULEPATH") if not modulepath: modules_path = input('Enter the root path for yo...
python
def copy_modules(filespath=None, modules_path=None, verbose=None): ''' Copy over the tree module files into your path ''' # find or define a modules path if not modules_path: modulepath = os.getenv("MODULEPATH") if not modulepath: modules_path = input('Enter the root path for yo...
[ "def", "copy_modules", "(", "filespath", "=", "None", ",", "modules_path", "=", "None", ",", "verbose", "=", "None", ")", ":", "if", "not", "modules_path", ":", "modulepath", "=", "os", ".", "getenv", "(", "\"MODULEPATH\"", ")", "if", "not", "modulepath", ...
Copy over the tree module files into your path
[ "Copy", "over", "the", "tree", "module", "files", "into", "your", "path" ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/bin/setup_tree.py#L342-L380
train
sdss/tree
python/tree/misc/docutree.py
_indent
def _indent(text, level=1): ''' Does a proper indenting for Sphinx rst ''' prefix = ' ' * (4 * level) def prefixed_lines(): for line in text.splitlines(True): yield (prefix + line if line.strip() else line) return ''.join(prefixed_lines())
python
def _indent(text, level=1): ''' Does a proper indenting for Sphinx rst ''' prefix = ' ' * (4 * level) def prefixed_lines(): for line in text.splitlines(True): yield (prefix + line if line.strip() else line) return ''.join(prefixed_lines())
[ "def", "_indent", "(", "text", ",", "level", "=", "1", ")", ":", "prefix", "=", "' '", "*", "(", "4", "*", "level", ")", "def", "prefixed_lines", "(", ")", ":", "for", "line", "in", "text", ".", "splitlines", "(", "True", ")", ":", "yield", "(", ...
Does a proper indenting for Sphinx rst
[ "Does", "a", "proper", "indenting", "for", "Sphinx", "rst" ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/python/tree/misc/docutree.py#L22-L31
train
sdss/tree
setup.py
get_requirements
def get_requirements(opts): ''' Get the proper requirements file based on the optional argument ''' if opts.dev: name = 'requirements_dev.txt' elif opts.doc: name = 'requirements_doc.txt' else: name = 'requirements.txt' requirements_file = os.path.join(os.path.dirname(__fil...
python
def get_requirements(opts): ''' Get the proper requirements file based on the optional argument ''' if opts.dev: name = 'requirements_dev.txt' elif opts.doc: name = 'requirements_doc.txt' else: name = 'requirements.txt' requirements_file = os.path.join(os.path.dirname(__fil...
[ "def", "get_requirements", "(", "opts", ")", ":", "if", "opts", ".", "dev", ":", "name", "=", "'requirements_dev.txt'", "elif", "opts", ".", "doc", ":", "name", "=", "'requirements_doc.txt'", "else", ":", "name", "=", "'requirements.txt'", "requirements_file", ...
Get the proper requirements file based on the optional argument
[ "Get", "the", "proper", "requirements", "file", "based", "on", "the", "optional", "argument" ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/setup.py#L54-L67
train
sdss/tree
setup.py
remove_args
def remove_args(parser): ''' Remove custom arguments from the parser ''' arguments = [] for action in list(parser._get_optional_actions()): if '--help' not in action.option_strings: arguments += action.option_strings for arg in arguments: if arg in sys.argv: sys...
python
def remove_args(parser): ''' Remove custom arguments from the parser ''' arguments = [] for action in list(parser._get_optional_actions()): if '--help' not in action.option_strings: arguments += action.option_strings for arg in arguments: if arg in sys.argv: sys...
[ "def", "remove_args", "(", "parser", ")", ":", "arguments", "=", "[", "]", "for", "action", "in", "list", "(", "parser", ".", "_get_optional_actions", "(", ")", ")", ":", "if", "'--help'", "not", "in", "action", ".", "option_strings", ":", "arguments", "...
Remove custom arguments from the parser
[ "Remove", "custom", "arguments", "from", "the", "parser" ]
f61fe0876c138ccb61874912d4b8590dadfa835c
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/setup.py#L70-L80
train
sarugaku/shellingham
tasks/__init__.py
_render_log
def _render_log(): """Totally tap into Towncrier internals to get an in-memory result. """ config = load_config(ROOT) definitions = config['types'] fragments, fragment_filenames = find_fragments( pathlib.Path(config['directory']).absolute(), config['sections'], None, ...
python
def _render_log(): """Totally tap into Towncrier internals to get an in-memory result. """ config = load_config(ROOT) definitions = config['types'] fragments, fragment_filenames = find_fragments( pathlib.Path(config['directory']).absolute(), config['sections'], None, ...
[ "def", "_render_log", "(", ")", ":", "config", "=", "load_config", "(", "ROOT", ")", "definitions", "=", "config", "[", "'types'", "]", "fragments", ",", "fragment_filenames", "=", "find_fragments", "(", "pathlib", ".", "Path", "(", "config", "[", "'director...
Totally tap into Towncrier internals to get an in-memory result.
[ "Totally", "tap", "into", "Towncrier", "internals", "to", "get", "an", "in", "-", "memory", "result", "." ]
295fc3094ef05437597ea0baa02f5cd7a3335d28
https://github.com/sarugaku/shellingham/blob/295fc3094ef05437597ea0baa02f5cd7a3335d28/tasks/__init__.py#L49-L67
train
sods/paramz
paramz/core/nameable.py
adjust_name_for_printing
def adjust_name_for_printing(name): """ Make sure a name can be printed, alongside used as a variable name. """ if name is not None: name2 = name name = name.replace(" ", "_").replace(".", "_").replace("-", "_m_") name = name.replace("+", "_p_").replace("!", "_I_") name =...
python
def adjust_name_for_printing(name): """ Make sure a name can be printed, alongside used as a variable name. """ if name is not None: name2 = name name = name.replace(" ", "_").replace(".", "_").replace("-", "_m_") name = name.replace("+", "_p_").replace("!", "_I_") name =...
[ "def", "adjust_name_for_printing", "(", "name", ")", ":", "if", "name", "is", "not", "None", ":", "name2", "=", "name", "name", "=", "name", ".", "replace", "(", "\" \"", ",", "\"_\"", ")", ".", "replace", "(", "\".\"", ",", "\"_\"", ")", ".", "repla...
Make sure a name can be printed, alongside used as a variable name.
[ "Make", "sure", "a", "name", "can", "be", "printed", "alongside", "used", "as", "a", "variable", "name", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/nameable.py#L33-L47
train
sods/paramz
paramz/core/nameable.py
Nameable.name
def name(self, name): """ Set the name of this object. Tell the parent if the name has changed. """ from_name = self.name assert isinstance(name, str) self._name = name if self.has_parent(): self._parent_._name_changed(self, from_name)
python
def name(self, name): """ Set the name of this object. Tell the parent if the name has changed. """ from_name = self.name assert isinstance(name, str) self._name = name if self.has_parent(): self._parent_._name_changed(self, from_name)
[ "def", "name", "(", "self", ",", "name", ")", ":", "from_name", "=", "self", ".", "name", "assert", "isinstance", "(", "name", ",", "str", ")", "self", ".", "_name", "=", "name", "if", "self", ".", "has_parent", "(", ")", ":", "self", ".", "_parent...
Set the name of this object. Tell the parent if the name has changed.
[ "Set", "the", "name", "of", "this", "object", ".", "Tell", "the", "parent", "if", "the", "name", "has", "changed", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/nameable.py#L65-L74
train
sods/paramz
paramz/core/nameable.py
Nameable.hierarchy_name
def hierarchy_name(self, adjust_for_printing=True): """ return the name for this object with the parents names attached by dots. :param bool adjust_for_printing: whether to call :func:`~adjust_for_printing()` on the names, recursively ...
python
def hierarchy_name(self, adjust_for_printing=True): """ return the name for this object with the parents names attached by dots. :param bool adjust_for_printing: whether to call :func:`~adjust_for_printing()` on the names, recursively ...
[ "def", "hierarchy_name", "(", "self", ",", "adjust_for_printing", "=", "True", ")", ":", "if", "adjust_for_printing", ":", "adjust", "=", "lambda", "x", ":", "adjust_name_for_printing", "(", "x", ")", "else", ":", "adjust", "=", "lambda", "x", ":", "x", "i...
return the name for this object with the parents names attached by dots. :param bool adjust_for_printing: whether to call :func:`~adjust_for_printing()` on the names, recursively
[ "return", "the", "name", "for", "this", "object", "with", "the", "parents", "names", "attached", "by", "dots", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/nameable.py#L76-L88
train
sods/paramz
paramz/parameterized.py
Parameterized.grep_param_names
def grep_param_names(self, regexp): """ create a list of parameters, matching regular expression regexp """ if not isinstance(regexp, _pattern_type): regexp = compile(regexp) found_params = [] def visit(innerself, regexp): if (innerself is not self) and regexp...
python
def grep_param_names(self, regexp): """ create a list of parameters, matching regular expression regexp """ if not isinstance(regexp, _pattern_type): regexp = compile(regexp) found_params = [] def visit(innerself, regexp): if (innerself is not self) and regexp...
[ "def", "grep_param_names", "(", "self", ",", "regexp", ")", ":", "if", "not", "isinstance", "(", "regexp", ",", "_pattern_type", ")", ":", "regexp", "=", "compile", "(", "regexp", ")", "found_params", "=", "[", "]", "def", "visit", "(", "innerself", ",",...
create a list of parameters, matching regular expression regexp
[ "create", "a", "list", "of", "parameters", "matching", "regular", "expression", "regexp" ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/parameterized.py#L282-L292
train
sods/paramz
paramz/param.py
Param._setup_observers
def _setup_observers(self): """ Setup the default observers 1: pass through to parent, if present """ if self.has_parent(): self.add_observer(self._parent_, self._parent_._pass_through_notify_observers, -np.inf)
python
def _setup_observers(self): """ Setup the default observers 1: pass through to parent, if present """ if self.has_parent(): self.add_observer(self._parent_, self._parent_._pass_through_notify_observers, -np.inf)
[ "def", "_setup_observers", "(", "self", ")", ":", "if", "self", ".", "has_parent", "(", ")", ":", "self", ".", "add_observer", "(", "self", ".", "_parent_", ",", "self", ".", "_parent_", ".", "_pass_through_notify_observers", ",", "-", "np", ".", "inf", ...
Setup the default observers 1: pass through to parent, if present
[ "Setup", "the", "default", "observers" ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/param.py#L211-L218
train
sods/paramz
paramz/param.py
Param._repr_html_
def _repr_html_(self, indices=None, iops=None, lx=None, li=None, lls=None): """Representation of the parameter in html for notebook display.""" filter_ = self._current_slice_ vals = self.flat if indices is None: indices = self._indices(filter_) if iops is None: ravi =...
python
def _repr_html_(self, indices=None, iops=None, lx=None, li=None, lls=None): """Representation of the parameter in html for notebook display.""" filter_ = self._current_slice_ vals = self.flat if indices is None: indices = self._indices(filter_) if iops is None: ravi =...
[ "def", "_repr_html_", "(", "self", ",", "indices", "=", "None", ",", "iops", "=", "None", ",", "lx", "=", "None", ",", "li", "=", "None", ",", "lls", "=", "None", ")", ":", "filter_", "=", "self", ".", "_current_slice_", "vals", "=", "self", ".", ...
Representation of the parameter in html for notebook display.
[ "Representation", "of", "the", "parameter", "in", "html", "for", "notebook", "display", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/param.py#L275-L311
train
sods/paramz
paramz/core/observable.py
Observable.add_observer
def add_observer(self, observer, callble, priority=0): """ Add an observer `observer` with the callback `callble` and priority `priority` to this observers list. """ self.observers.add(priority, observer, callble)
python
def add_observer(self, observer, callble, priority=0): """ Add an observer `observer` with the callback `callble` and priority `priority` to this observers list. """ self.observers.add(priority, observer, callble)
[ "def", "add_observer", "(", "self", ",", "observer", ",", "callble", ",", "priority", "=", "0", ")", ":", "self", ".", "observers", ".", "add", "(", "priority", ",", "observer", ",", "callble", ")" ]
Add an observer `observer` with the callback `callble` and priority `priority` to this observers list.
[ "Add", "an", "observer", "observer", "with", "the", "callback", "callble", "and", "priority", "priority", "to", "this", "observers", "list", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/observable.py#L49-L54
train
sods/paramz
paramz/core/observable.py
Observable.notify_observers
def notify_observers(self, which=None, min_priority=None): """ Notifies all observers. Which is the element, which kicked off this notification loop. The first argument will be self, the second `which`. .. note:: notifies only observers with priority p > min_prior...
python
def notify_observers(self, which=None, min_priority=None): """ Notifies all observers. Which is the element, which kicked off this notification loop. The first argument will be self, the second `which`. .. note:: notifies only observers with priority p > min_prior...
[ "def", "notify_observers", "(", "self", ",", "which", "=", "None", ",", "min_priority", "=", "None", ")", ":", "if", "self", ".", "_update_on", ":", "if", "which", "is", "None", ":", "which", "=", "self", "if", "min_priority", "is", "None", ":", "[", ...
Notifies all observers. Which is the element, which kicked off this notification loop. The first argument will be self, the second `which`. .. note:: notifies only observers with priority p > min_priority! :param min_priority: only notify observers with priori...
[ "Notifies", "all", "observers", ".", "Which", "is", "the", "element", "which", "kicked", "off", "this", "notification", "loop", ".", "The", "first", "argument", "will", "be", "self", "the", "second", "which", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/observable.py#L75-L96
train
sods/paramz
paramz/core/constrainable.py
Constrainable.constrain_fixed
def constrain_fixed(self, value=None, warning=True, trigger_parent=True): """ Constrain this parameter to be fixed to the current value it carries. This does not override the previous constraints, so unfixing will restore the constraint set before fixing. :param warning: print ...
python
def constrain_fixed(self, value=None, warning=True, trigger_parent=True): """ Constrain this parameter to be fixed to the current value it carries. This does not override the previous constraints, so unfixing will restore the constraint set before fixing. :param warning: print ...
[ "def", "constrain_fixed", "(", "self", ",", "value", "=", "None", ",", "warning", "=", "True", ",", "trigger_parent", "=", "True", ")", ":", "if", "value", "is", "not", "None", ":", "self", "[", ":", "]", "=", "value", "index", "=", "self", ".", "_...
Constrain this parameter to be fixed to the current value it carries. This does not override the previous constraints, so unfixing will restore the constraint set before fixing. :param warning: print a warning for overwriting constraints.
[ "Constrain", "this", "parameter", "to", "be", "fixed", "to", "the", "current", "value", "it", "carries", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/constrainable.py#L52-L68
train
sods/paramz
paramz/core/constrainable.py
Constrainable.unconstrain_fixed
def unconstrain_fixed(self): """ This parameter will no longer be fixed. If there was a constraint on this parameter when fixing it, it will be constraint with that previous constraint. """ unconstrained = self.unconstrain(__fixed__) self._highest_parent_._set_un...
python
def unconstrain_fixed(self): """ This parameter will no longer be fixed. If there was a constraint on this parameter when fixing it, it will be constraint with that previous constraint. """ unconstrained = self.unconstrain(__fixed__) self._highest_parent_._set_un...
[ "def", "unconstrain_fixed", "(", "self", ")", ":", "unconstrained", "=", "self", ".", "unconstrain", "(", "__fixed__", ")", "self", ".", "_highest_parent_", ".", "_set_unfixed", "(", "self", ",", "unconstrained", ")", "return", "unconstrained" ]
This parameter will no longer be fixed. If there was a constraint on this parameter when fixing it, it will be constraint with that previous constraint.
[ "This", "parameter", "will", "no", "longer", "be", "fixed", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/constrainable.py#L71-L82
train
sods/paramz
paramz/core/gradcheckable.py
Gradcheckable.checkgrad
def checkgrad(self, verbose=0, step=1e-6, tolerance=1e-3, df_tolerance=1e-12): """ Check the gradient of this parameter with respect to the highest parent's objective function. This is a three point estimate of the gradient, wiggling at the parameters with a stepsize step. ...
python
def checkgrad(self, verbose=0, step=1e-6, tolerance=1e-3, df_tolerance=1e-12): """ Check the gradient of this parameter with respect to the highest parent's objective function. This is a three point estimate of the gradient, wiggling at the parameters with a stepsize step. ...
[ "def", "checkgrad", "(", "self", ",", "verbose", "=", "0", ",", "step", "=", "1e-6", ",", "tolerance", "=", "1e-3", ",", "df_tolerance", "=", "1e-12", ")", ":", "if", "self", ".", "has_parent", "(", ")", ":", "return", "self", ".", "_highest_parent_", ...
Check the gradient of this parameter with respect to the highest parent's objective function. This is a three point estimate of the gradient, wiggling at the parameters with a stepsize step. The check passes if either the ratio or the difference between numerical and analytical g...
[ "Check", "the", "gradient", "of", "this", "parameter", "with", "respect", "to", "the", "highest", "parent", "s", "objective", "function", ".", "This", "is", "a", "three", "point", "estimate", "of", "the", "gradient", "wiggling", "at", "the", "parameters", "w...
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/gradcheckable.py#L44-L69
train
sods/paramz
paramz/optimization/optimization.py
opt_tnc.opt
def opt(self, x_init, f_fp=None, f=None, fp=None): """ Run the TNC optimizer """ tnc_rcstrings = ['Local minimum', 'Converged', 'XConverged', 'Maximum number of f evaluations reached', 'Line search failed', 'Function is constant'] assert f_fp != None, "TNC requires...
python
def opt(self, x_init, f_fp=None, f=None, fp=None): """ Run the TNC optimizer """ tnc_rcstrings = ['Local minimum', 'Converged', 'XConverged', 'Maximum number of f evaluations reached', 'Line search failed', 'Function is constant'] assert f_fp != None, "TNC requires...
[ "def", "opt", "(", "self", ",", "x_init", ",", "f_fp", "=", "None", ",", "f", "=", "None", ",", "fp", "=", "None", ")", ":", "tnc_rcstrings", "=", "[", "'Local minimum'", ",", "'Converged'", ",", "'XConverged'", ",", "'Maximum number of f evaluations reached...
Run the TNC optimizer
[ "Run", "the", "TNC", "optimizer" ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/optimization/optimization.py#L75-L98
train
sods/paramz
paramz/optimization/optimization.py
opt_simplex.opt
def opt(self, x_init, f_fp=None, f=None, fp=None): """ The simplex optimizer does not require gradients. """ statuses = ['Converged', 'Maximum number of function evaluations made', 'Maximum number of iterations reached'] opt_dict = {} if self.xtol is not None: ...
python
def opt(self, x_init, f_fp=None, f=None, fp=None): """ The simplex optimizer does not require gradients. """ statuses = ['Converged', 'Maximum number of function evaluations made', 'Maximum number of iterations reached'] opt_dict = {} if self.xtol is not None: ...
[ "def", "opt", "(", "self", ",", "x_init", ",", "f_fp", "=", "None", ",", "f", "=", "None", ",", "fp", "=", "None", ")", ":", "statuses", "=", "[", "'Converged'", ",", "'Maximum number of function evaluations made'", ",", "'Maximum number of iterations reached'",...
The simplex optimizer does not require gradients.
[ "The", "simplex", "optimizer", "does", "not", "require", "gradients", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/optimization/optimization.py#L166-L188
train
sods/paramz
paramz/caching.py
Cacher.combine_inputs
def combine_inputs(self, args, kw, ignore_args): "Combines the args and kw in a unique way, such that ordering of kwargs does not lead to recompute" inputs= args + tuple(c[1] for c in sorted(kw.items(), key=lambda x: x[0])) # REMOVE the ignored arguments from input and PREVENT it from being chec...
python
def combine_inputs(self, args, kw, ignore_args): "Combines the args and kw in a unique way, such that ordering of kwargs does not lead to recompute" inputs= args + tuple(c[1] for c in sorted(kw.items(), key=lambda x: x[0])) # REMOVE the ignored arguments from input and PREVENT it from being chec...
[ "def", "combine_inputs", "(", "self", ",", "args", ",", "kw", ",", "ignore_args", ")", ":", "\"Combines the args and kw in a unique way, such that ordering of kwargs does not lead to recompute\"", "inputs", "=", "args", "+", "tuple", "(", "c", "[", "1", "]", "for", "c...
Combines the args and kw in a unique way, such that ordering of kwargs does not lead to recompute
[ "Combines", "the", "args", "and", "kw", "in", "a", "unique", "way", "such", "that", "ordering", "of", "kwargs", "does", "not", "lead", "to", "recompute" ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/caching.py#L90-L94
train
sods/paramz
paramz/caching.py
Cacher.ensure_cache_length
def ensure_cache_length(self): "Ensures the cache is within its limits and has one place free" if len(self.order) == self.limit: # we have reached the limit, so lets release one element cache_id = self.order.popleft() combined_args_kw = self.cached_inputs[cache_id] ...
python
def ensure_cache_length(self): "Ensures the cache is within its limits and has one place free" if len(self.order) == self.limit: # we have reached the limit, so lets release one element cache_id = self.order.popleft() combined_args_kw = self.cached_inputs[cache_id] ...
[ "def", "ensure_cache_length", "(", "self", ")", ":", "\"Ensures the cache is within its limits and has one place free\"", "if", "len", "(", "self", ".", "order", ")", "==", "self", ".", "limit", ":", "cache_id", "=", "self", ".", "order", ".", "popleft", "(", ")...
Ensures the cache is within its limits and has one place free
[ "Ensures", "the", "cache", "is", "within", "its", "limits", "and", "has", "one", "place", "free" ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/caching.py#L101-L132
train
sods/paramz
paramz/caching.py
Cacher.add_to_cache
def add_to_cache(self, cache_id, inputs, output): """This adds cache_id to the cache, with inputs and output""" self.inputs_changed[cache_id] = False self.cached_outputs[cache_id] = output self.order.append(cache_id) self.cached_inputs[cache_id] = inputs for a in inputs: ...
python
def add_to_cache(self, cache_id, inputs, output): """This adds cache_id to the cache, with inputs and output""" self.inputs_changed[cache_id] = False self.cached_outputs[cache_id] = output self.order.append(cache_id) self.cached_inputs[cache_id] = inputs for a in inputs: ...
[ "def", "add_to_cache", "(", "self", ",", "cache_id", ",", "inputs", ",", "output", ")", ":", "self", ".", "inputs_changed", "[", "cache_id", "]", "=", "False", "self", ".", "cached_outputs", "[", "cache_id", "]", "=", "output", "self", ".", "order", ".",...
This adds cache_id to the cache, with inputs and output
[ "This", "adds", "cache_id", "to", "the", "cache", "with", "inputs", "and", "output" ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/caching.py#L134-L147
train
sods/paramz
paramz/caching.py
Cacher.on_cache_changed
def on_cache_changed(self, direct, which=None): """ A callback funtion, which sets local flags when the elements of some cached inputs change this function gets 'hooked up' to the inputs when we cache them, and upon their elements being changed we update here. """ for what in [d...
python
def on_cache_changed(self, direct, which=None): """ A callback funtion, which sets local flags when the elements of some cached inputs change this function gets 'hooked up' to the inputs when we cache them, and upon their elements being changed we update here. """ for what in [d...
[ "def", "on_cache_changed", "(", "self", ",", "direct", ",", "which", "=", "None", ")", ":", "for", "what", "in", "[", "direct", ",", "which", "]", ":", "ind_id", "=", "self", ".", "id", "(", "what", ")", "_", ",", "cache_ids", "=", "self", ".", "...
A callback funtion, which sets local flags when the elements of some cached inputs change this function gets 'hooked up' to the inputs when we cache them, and upon their elements being changed we update here.
[ "A", "callback", "funtion", "which", "sets", "local", "flags", "when", "the", "elements", "of", "some", "cached", "inputs", "change" ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/caching.py#L194-L204
train
sods/paramz
paramz/caching.py
Cacher.reset
def reset(self): """ Totally reset the cache """ [a().remove_observer(self, self.on_cache_changed) if (a() is not None) else None for [a, _] in self.cached_input_ids.values()] self.order = collections.deque() self.cached_inputs = {} # point from cache_ids to a list of [...
python
def reset(self): """ Totally reset the cache """ [a().remove_observer(self, self.on_cache_changed) if (a() is not None) else None for [a, _] in self.cached_input_ids.values()] self.order = collections.deque() self.cached_inputs = {} # point from cache_ids to a list of [...
[ "def", "reset", "(", "self", ")", ":", "[", "a", "(", ")", ".", "remove_observer", "(", "self", ",", "self", ".", "on_cache_changed", ")", "if", "(", "a", "(", ")", "is", "not", "None", ")", "else", "None", "for", "[", "a", ",", "_", "]", "in",...
Totally reset the cache
[ "Totally", "reset", "the", "cache" ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/caching.py#L206-L223
train
sods/paramz
paramz/caching.py
FunctionCache.disable_caching
def disable_caching(self): "Disable the cache of this object. This also removes previously cached results" self.caching_enabled = False for c in self.values(): c.disable_cacher()
python
def disable_caching(self): "Disable the cache of this object. This also removes previously cached results" self.caching_enabled = False for c in self.values(): c.disable_cacher()
[ "def", "disable_caching", "(", "self", ")", ":", "\"Disable the cache of this object. This also removes previously cached results\"", "self", ".", "caching_enabled", "=", "False", "for", "c", "in", "self", ".", "values", "(", ")", ":", "c", ".", "disable_cacher", "(",...
Disable the cache of this object. This also removes previously cached results
[ "Disable", "the", "cache", "of", "this", "object", ".", "This", "also", "removes", "previously", "cached", "results" ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/caching.py#L246-L250
train
sods/paramz
paramz/caching.py
FunctionCache.enable_caching
def enable_caching(self): "Enable the cache of this object." self.caching_enabled = True for c in self.values(): c.enable_cacher()
python
def enable_caching(self): "Enable the cache of this object." self.caching_enabled = True for c in self.values(): c.enable_cacher()
[ "def", "enable_caching", "(", "self", ")", ":", "\"Enable the cache of this object.\"", "self", ".", "caching_enabled", "=", "True", "for", "c", "in", "self", ".", "values", "(", ")", ":", "c", ".", "enable_cacher", "(", ")" ]
Enable the cache of this object.
[ "Enable", "the", "cache", "of", "this", "object", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/caching.py#L252-L256
train
sods/paramz
paramz/core/lists_and_dicts.py
ObserverList.remove
def remove(self, priority, observer, callble): """ Remove one observer, which had priority and callble. """ self.flush() for i in range(len(self) - 1, -1, -1): p,o,c = self[i] if priority==p and observer==o and callble==c: del self._poc[i]
python
def remove(self, priority, observer, callble): """ Remove one observer, which had priority and callble. """ self.flush() for i in range(len(self) - 1, -1, -1): p,o,c = self[i] if priority==p and observer==o and callble==c: del self._poc[i]
[ "def", "remove", "(", "self", ",", "priority", ",", "observer", ",", "callble", ")", ":", "self", ".", "flush", "(", ")", "for", "i", "in", "range", "(", "len", "(", "self", ")", "-", "1", ",", "-", "1", ",", "-", "1", ")", ":", "p", ",", "...
Remove one observer, which had priority and callble.
[ "Remove", "one", "observer", "which", "had", "priority", "and", "callble", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/lists_and_dicts.py#L78-L86
train
sods/paramz
paramz/core/lists_and_dicts.py
ObserverList.add
def add(self, priority, observer, callble): """ Add an observer with priority and callble """ #if observer is not None: ins = 0 for pr, _, _ in self: if priority > pr: break ins += 1 self._poc.insert(ins, (priority, weakref....
python
def add(self, priority, observer, callble): """ Add an observer with priority and callble """ #if observer is not None: ins = 0 for pr, _, _ in self: if priority > pr: break ins += 1 self._poc.insert(ins, (priority, weakref....
[ "def", "add", "(", "self", ",", "priority", ",", "observer", ",", "callble", ")", ":", "ins", "=", "0", "for", "pr", ",", "_", ",", "_", "in", "self", ":", "if", "priority", ">", "pr", ":", "break", "ins", "+=", "1", "self", ".", "_poc", ".", ...
Add an observer with priority and callble
[ "Add", "an", "observer", "with", "priority", "and", "callble" ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/lists_and_dicts.py#L91-L101
train
sods/paramz
paramz/core/index_operations.py
ParameterIndexOperations.properties_for
def properties_for(self, index): """ Returns a list of properties, such that each entry in the list corresponds to the element of the index given. Example: let properties: 'one':[1,2,3,4], 'two':[3,5,6] >>> properties_for([2,3,5]) [['one'], ['one', 'two'], ['two...
python
def properties_for(self, index): """ Returns a list of properties, such that each entry in the list corresponds to the element of the index given. Example: let properties: 'one':[1,2,3,4], 'two':[3,5,6] >>> properties_for([2,3,5]) [['one'], ['one', 'two'], ['two...
[ "def", "properties_for", "(", "self", ",", "index", ")", ":", "return", "vectorize", "(", "lambda", "i", ":", "[", "prop", "for", "prop", "in", "self", ".", "properties", "(", ")", "if", "i", "in", "self", "[", "prop", "]", "]", ",", "otypes", "=",...
Returns a list of properties, such that each entry in the list corresponds to the element of the index given. Example: let properties: 'one':[1,2,3,4], 'two':[3,5,6] >>> properties_for([2,3,5]) [['one'], ['one', 'two'], ['two']]
[ "Returns", "a", "list", "of", "properties", "such", "that", "each", "entry", "in", "the", "list", "corresponds", "to", "the", "element", "of", "the", "index", "given", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/index_operations.py#L132-L143
train
sods/paramz
paramz/core/index_operations.py
ParameterIndexOperations.properties_dict_for
def properties_dict_for(self, index): """ Return a dictionary, containing properties as keys and indices as index Thus, the indices for each constraint, which is contained will be collected as one dictionary Example: let properties: 'one':[1,2,3,4], 'two':[3,5,6] ...
python
def properties_dict_for(self, index): """ Return a dictionary, containing properties as keys and indices as index Thus, the indices for each constraint, which is contained will be collected as one dictionary Example: let properties: 'one':[1,2,3,4], 'two':[3,5,6] ...
[ "def", "properties_dict_for", "(", "self", ",", "index", ")", ":", "props", "=", "self", ".", "properties_for", "(", "index", ")", "prop_index", "=", "extract_properties_to_index", "(", "index", ",", "props", ")", "return", "prop_index" ]
Return a dictionary, containing properties as keys and indices as index Thus, the indices for each constraint, which is contained will be collected as one dictionary Example: let properties: 'one':[1,2,3,4], 'two':[3,5,6] >>> properties_dict_for([2,3,5]) {'one':[2,3], '...
[ "Return", "a", "dictionary", "containing", "properties", "as", "keys", "and", "indices", "as", "index", "Thus", "the", "indices", "for", "each", "constraint", "which", "is", "contained", "will", "be", "collected", "as", "one", "dictionary" ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/index_operations.py#L145-L159
train
sods/paramz
paramz/model.py
Model.optimize
def optimize(self, optimizer=None, start=None, messages=False, max_iters=1000, ipython_notebook=True, clear_after_finish=False, **kwargs): """ Optimize the model using self.log_likelihood and self.log_likelihood_gradient, as well as self.priors. kwargs are passed to the optimizer. They can be: ...
python
def optimize(self, optimizer=None, start=None, messages=False, max_iters=1000, ipython_notebook=True, clear_after_finish=False, **kwargs): """ Optimize the model using self.log_likelihood and self.log_likelihood_gradient, as well as self.priors. kwargs are passed to the optimizer. They can be: ...
[ "def", "optimize", "(", "self", ",", "optimizer", "=", "None", ",", "start", "=", "None", ",", "messages", "=", "False", ",", "max_iters", "=", "1000", ",", "ipython_notebook", "=", "True", ",", "clear_after_finish", "=", "False", ",", "**", "kwargs", ")...
Optimize the model using self.log_likelihood and self.log_likelihood_gradient, as well as self.priors. kwargs are passed to the optimizer. They can be: :param max_iters: maximum number of function evaluations :type max_iters: int :messages: True: Display messages during optimisation, "...
[ "Optimize", "the", "model", "using", "self", ".", "log_likelihood", "and", "self", ".", "log_likelihood_gradient", "as", "well", "as", "self", ".", "priors", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/model.py#L65-L116
train
sods/paramz
paramz/model.py
Model.optimize_restarts
def optimize_restarts(self, num_restarts=10, robust=False, verbose=True, parallel=False, num_processes=None, **kwargs): """ Perform random restarts of the model, and set the model to the best seen solution. If the robust flag is set, exceptions raised during optimizations will b...
python
def optimize_restarts(self, num_restarts=10, robust=False, verbose=True, parallel=False, num_processes=None, **kwargs): """ Perform random restarts of the model, and set the model to the best seen solution. If the robust flag is set, exceptions raised during optimizations will b...
[ "def", "optimize_restarts", "(", "self", ",", "num_restarts", "=", "10", ",", "robust", "=", "False", ",", "verbose", "=", "True", ",", "parallel", "=", "False", ",", "num_processes", "=", "None", ",", "**", "kwargs", ")", ":", "initial_length", "=", "le...
Perform random restarts of the model, and set the model to the best seen solution. If the robust flag is set, exceptions raised during optimizations will be handled silently. If _all_ runs fail, the model is reset to the existing parameter values. \*\*kwargs are passed to the ...
[ "Perform", "random", "restarts", "of", "the", "model", "and", "set", "the", "model", "to", "the", "best", "seen", "solution", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/model.py#L118-L190
train
sods/paramz
paramz/model.py
Model._grads
def _grads(self, x): """ Gets the gradients from the likelihood and the priors. Failures are handled robustly. The algorithm will try several times to return the gradients, and will raise the original exception if the objective cannot be computed. :param x: the paramete...
python
def _grads(self, x): """ Gets the gradients from the likelihood and the priors. Failures are handled robustly. The algorithm will try several times to return the gradients, and will raise the original exception if the objective cannot be computed. :param x: the paramete...
[ "def", "_grads", "(", "self", ",", "x", ")", ":", "try", ":", "self", ".", "optimizer_array", "=", "x", "self", ".", "obj_grads", "=", "self", ".", "_transform_gradients", "(", "self", ".", "objective_function_gradients", "(", ")", ")", "self", ".", "_fa...
Gets the gradients from the likelihood and the priors. Failures are handled robustly. The algorithm will try several times to return the gradients, and will raise the original exception if the objective cannot be computed. :param x: the parameters of the model. :type x: np.arra...
[ "Gets", "the", "gradients", "from", "the", "likelihood", "and", "the", "priors", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/model.py#L225-L246
train
sods/paramz
paramz/model.py
Model._objective
def _objective(self, x): """ The objective function passed to the optimizer. It combines the likelihood and the priors. Failures are handled robustly. The algorithm will try several times to return the objective, and will raise the original exception if the objective can...
python
def _objective(self, x): """ The objective function passed to the optimizer. It combines the likelihood and the priors. Failures are handled robustly. The algorithm will try several times to return the objective, and will raise the original exception if the objective can...
[ "def", "_objective", "(", "self", ",", "x", ")", ":", "try", ":", "self", ".", "optimizer_array", "=", "x", "obj", "=", "self", ".", "objective_function", "(", ")", "self", ".", "_fail_count", "=", "0", "except", "(", "LinAlgError", ",", "ZeroDivisionErr...
The objective function passed to the optimizer. It combines the likelihood and the priors. Failures are handled robustly. The algorithm will try several times to return the objective, and will raise the original exception if the objective cannot be computed. :param x: the param...
[ "The", "objective", "function", "passed", "to", "the", "optimizer", ".", "It", "combines", "the", "likelihood", "and", "the", "priors", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/model.py#L248-L269
train
sods/paramz
paramz/model.py
Model._repr_html_
def _repr_html_(self): """Representation of the model in html for notebook display.""" model_details = [['<b>Model</b>', self.name + '<br>'], ['<b>Objective</b>', '{}<br>'.format(float(self.objective_function()))], ["<b>Number of Parameters</b>", '{}<br>...
python
def _repr_html_(self): """Representation of the model in html for notebook display.""" model_details = [['<b>Model</b>', self.name + '<br>'], ['<b>Objective</b>', '{}<br>'.format(float(self.objective_function()))], ["<b>Number of Parameters</b>", '{}<br>...
[ "def", "_repr_html_", "(", "self", ")", ":", "model_details", "=", "[", "[", "'<b>Model</b>'", ",", "self", ".", "name", "+", "'<br>'", "]", ",", "[", "'<b>Objective</b>'", ",", "'{}<br>'", ".", "format", "(", "float", "(", "self", ".", "objective_function...
Representation of the model in html for notebook display.
[ "Representation", "of", "the", "model", "in", "html", "for", "notebook", "display", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/model.py#L410-L427
train
sods/paramz
paramz/core/indexable.py
Indexable.add_index_operation
def add_index_operation(self, name, operations): """ Add index operation with name to the operations given. raises: attribute error if operations exist. """ if name not in self._index_operations: self._add_io(name, operations) else: raise Attribut...
python
def add_index_operation(self, name, operations): """ Add index operation with name to the operations given. raises: attribute error if operations exist. """ if name not in self._index_operations: self._add_io(name, operations) else: raise Attribut...
[ "def", "add_index_operation", "(", "self", ",", "name", ",", "operations", ")", ":", "if", "name", "not", "in", "self", ".", "_index_operations", ":", "self", ".", "_add_io", "(", "name", ",", "operations", ")", "else", ":", "raise", "AttributeError", "(",...
Add index operation with name to the operations given. raises: attribute error if operations exist.
[ "Add", "index", "operation", "with", "name", "to", "the", "operations", "given", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/indexable.py#L81-L90
train
sods/paramz
paramz/core/indexable.py
Indexable._offset_for
def _offset_for(self, param): """ Return the offset of the param inside this parameterized object. This does not need to account for shaped parameters, as it basically just sums up the parameter sizes which come before param. """ if param.has_parent(): p = par...
python
def _offset_for(self, param): """ Return the offset of the param inside this parameterized object. This does not need to account for shaped parameters, as it basically just sums up the parameter sizes which come before param. """ if param.has_parent(): p = par...
[ "def", "_offset_for", "(", "self", ",", "param", ")", ":", "if", "param", ".", "has_parent", "(", ")", ":", "p", "=", "param", ".", "_parent_", ".", "_get_original", "(", "param", ")", "if", "p", "in", "self", ".", "parameters", ":", "return", "reduc...
Return the offset of the param inside this parameterized object. This does not need to account for shaped parameters, as it basically just sums up the parameter sizes which come before param.
[ "Return", "the", "offset", "of", "the", "param", "inside", "this", "parameterized", "object", ".", "This", "does", "not", "need", "to", "account", "for", "shaped", "parameters", "as", "it", "basically", "just", "sums", "up", "the", "parameter", "sizes", "whi...
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/indexable.py#L130-L141
train
sods/paramz
paramz/core/indexable.py
Indexable._raveled_index_for
def _raveled_index_for(self, param): """ get the raveled index for a param that is an int array, containing the indexes for the flattened param inside this parameterized logic. !Warning! be sure to call this method on the highest parent of a hierarchy, as it uses the fix...
python
def _raveled_index_for(self, param): """ get the raveled index for a param that is an int array, containing the indexes for the flattened param inside this parameterized logic. !Warning! be sure to call this method on the highest parent of a hierarchy, as it uses the fix...
[ "def", "_raveled_index_for", "(", "self", ",", "param", ")", ":", "from", ".", ".", "param", "import", "ParamConcatenation", "if", "isinstance", "(", "param", ",", "ParamConcatenation", ")", ":", "return", "np", ".", "hstack", "(", "(", "self", ".", "_rave...
get the raveled index for a param that is an int array, containing the indexes for the flattened param inside this parameterized logic. !Warning! be sure to call this method on the highest parent of a hierarchy, as it uses the fixes to do its work
[ "get", "the", "raveled", "index", "for", "a", "param", "that", "is", "an", "int", "array", "containing", "the", "indexes", "for", "the", "flattened", "param", "inside", "this", "parameterized", "logic", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/indexable.py#L150-L162
train
sods/paramz
paramz/core/observable_array.py
ObsAr.copy
def copy(self): """ Make a copy. This means, we delete all observers and return a copy of this array. It will still be an ObsAr! """ from .lists_and_dicts import ObserverList memo = {} memo[id(self)] = self memo[id(self.observers)] = ObserverList() ...
python
def copy(self): """ Make a copy. This means, we delete all observers and return a copy of this array. It will still be an ObsAr! """ from .lists_and_dicts import ObserverList memo = {} memo[id(self)] = self memo[id(self.observers)] = ObserverList() ...
[ "def", "copy", "(", "self", ")", ":", "from", ".", "lists_and_dicts", "import", "ObserverList", "memo", "=", "{", "}", "memo", "[", "id", "(", "self", ")", "]", "=", "self", "memo", "[", "id", "(", "self", ".", "observers", ")", "]", "=", "Observer...
Make a copy. This means, we delete all observers and return a copy of this array. It will still be an ObsAr!
[ "Make", "a", "copy", ".", "This", "means", "we", "delete", "all", "observers", "and", "return", "a", "copy", "of", "this", "array", ".", "It", "will", "still", "be", "an", "ObsAr!" ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/observable_array.py#L91-L100
train
sods/paramz
paramz/core/updateable.py
Updateable.update_model
def update_model(self, updates=None): """ Get or set, whether automatic updates are performed. When updates are off, the model might be in a non-working state. To make the model work turn updates on again. :param bool|None updates: bool: whether to do updates ...
python
def update_model(self, updates=None): """ Get or set, whether automatic updates are performed. When updates are off, the model might be in a non-working state. To make the model work turn updates on again. :param bool|None updates: bool: whether to do updates ...
[ "def", "update_model", "(", "self", ",", "updates", "=", "None", ")", ":", "if", "updates", "is", "None", ":", "return", "self", ".", "_update_on", "assert", "isinstance", "(", "updates", ",", "bool", ")", ",", "\"updates are either on (True) or off (False)\"", ...
Get or set, whether automatic updates are performed. When updates are off, the model might be in a non-working state. To make the model work turn updates on again. :param bool|None updates: bool: whether to do updates None: get the current update state
[ "Get", "or", "set", "whether", "automatic", "updates", "are", "performed", ".", "When", "updates", "are", "off", "the", "model", "might", "be", "in", "a", "non", "-", "working", "state", ".", "To", "make", "the", "model", "work", "turn", "updates", "on",...
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/updateable.py#L42-L60
train
sods/paramz
paramz/core/updateable.py
Updateable.trigger_update
def trigger_update(self, trigger_parent=True): """ Update the model from the current state. Make sure that updates are on, otherwise this method will do nothing :param bool trigger_parent: Whether to trigger the parent, after self has updated """ if not self.upda...
python
def trigger_update(self, trigger_parent=True): """ Update the model from the current state. Make sure that updates are on, otherwise this method will do nothing :param bool trigger_parent: Whether to trigger the parent, after self has updated """ if not self.upda...
[ "def", "trigger_update", "(", "self", ",", "trigger_parent", "=", "True", ")", ":", "if", "not", "self", ".", "update_model", "(", ")", "or", "(", "hasattr", "(", "self", ",", "\"_in_init_\"", ")", "and", "self", ".", "_in_init_", ")", ":", "return", "...
Update the model from the current state. Make sure that updates are on, otherwise this method will do nothing :param bool trigger_parent: Whether to trigger the parent, after self has updated
[ "Update", "the", "model", "from", "the", "current", "state", ".", "Make", "sure", "that", "updates", "are", "on", "otherwise", "this", "method", "will", "do", "nothing" ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/updateable.py#L68-L79
train
sods/paramz
paramz/core/parameter_core.py
OptimizationHandlable.optimizer_array
def optimizer_array(self): """ Array for the optimizer to work on. This array always lives in the space for the optimizer. Thus, it is untransformed, going from Transformations. Setting this array, will make sure the transformed parameters for this model will be set acco...
python
def optimizer_array(self): """ Array for the optimizer to work on. This array always lives in the space for the optimizer. Thus, it is untransformed, going from Transformations. Setting this array, will make sure the transformed parameters for this model will be set acco...
[ "def", "optimizer_array", "(", "self", ")", ":", "if", "self", ".", "__dict__", ".", "get", "(", "'_optimizer_copy_'", ",", "None", ")", "is", "None", "or", "self", ".", "size", "!=", "self", ".", "_optimizer_copy_", ".", "size", ":", "self", ".", "_op...
Array for the optimizer to work on. This array always lives in the space for the optimizer. Thus, it is untransformed, going from Transformations. Setting this array, will make sure the transformed parameters for this model will be set accordingly. It has to be set with an array, retrie...
[ "Array", "for", "the", "optimizer", "to", "work", "on", ".", "This", "array", "always", "lives", "in", "the", "space", "for", "the", "optimizer", ".", "Thus", "it", "is", "untransformed", "going", "from", "Transformations", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L67-L93
train
sods/paramz
paramz/core/parameter_core.py
OptimizationHandlable._trigger_params_changed
def _trigger_params_changed(self, trigger_parent=True): """ First tell all children to update, then update yourself. If trigger_parent is True, we will tell the parent, otherwise not. """ [p._trigger_params_changed(trigger_parent=False) for p in self.parameters if not p....
python
def _trigger_params_changed(self, trigger_parent=True): """ First tell all children to update, then update yourself. If trigger_parent is True, we will tell the parent, otherwise not. """ [p._trigger_params_changed(trigger_parent=False) for p in self.parameters if not p....
[ "def", "_trigger_params_changed", "(", "self", ",", "trigger_parent", "=", "True", ")", ":", "[", "p", ".", "_trigger_params_changed", "(", "trigger_parent", "=", "False", ")", "for", "p", "in", "self", ".", "parameters", "if", "not", "p", ".", "is_fixed", ...
First tell all children to update, then update yourself. If trigger_parent is True, we will tell the parent, otherwise not.
[ "First", "tell", "all", "children", "to", "update", "then", "update", "yourself", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L126-L134
train
sods/paramz
paramz/core/parameter_core.py
OptimizationHandlable._transform_gradients
def _transform_gradients(self, g): """ Transform the gradients by multiplying the gradient factor for each constraint to it. """ #py3 fix #[np.put(g, i, c.gradfactor(self.param_array[i], g[i])) for c, i in self.constraints.iteritems() if c != __fixed__] [np.put(g,...
python
def _transform_gradients(self, g): """ Transform the gradients by multiplying the gradient factor for each constraint to it. """ #py3 fix #[np.put(g, i, c.gradfactor(self.param_array[i], g[i])) for c, i in self.constraints.iteritems() if c != __fixed__] [np.put(g,...
[ "def", "_transform_gradients", "(", "self", ",", "g", ")", ":", "[", "np", ".", "put", "(", "g", ",", "i", ",", "c", ".", "gradfactor", "(", "self", ".", "param_array", "[", "i", "]", ",", "g", "[", "i", "]", ")", ")", "for", "c", ",", "i", ...
Transform the gradients by multiplying the gradient factor for each constraint to it.
[ "Transform", "the", "gradients", "by", "multiplying", "the", "gradient", "factor", "for", "each", "constraint", "to", "it", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L143-L152
train
sods/paramz
paramz/core/parameter_core.py
OptimizationHandlable.parameter_names
def parameter_names(self, add_self=False, adjust_for_printing=False, recursive=True, intermediate=False): """ Get the names of all parameters of this model or parameter. It starts from the parameterized object you are calling this method on. Note: This does not unravel multidimensional ...
python
def parameter_names(self, add_self=False, adjust_for_printing=False, recursive=True, intermediate=False): """ Get the names of all parameters of this model or parameter. It starts from the parameterized object you are calling this method on. Note: This does not unravel multidimensional ...
[ "def", "parameter_names", "(", "self", ",", "add_self", "=", "False", ",", "adjust_for_printing", "=", "False", ",", "recursive", "=", "True", ",", "intermediate", "=", "False", ")", ":", "if", "adjust_for_printing", ":", "adjust", "=", "adjust_name_for_printing...
Get the names of all parameters of this model or parameter. It starts from the parameterized object you are calling this method on. Note: This does not unravel multidimensional parameters, use parameter_names_flat to unravel parameters! :param bool add_self: whether to add the ow...
[ "Get", "the", "names", "of", "all", "parameters", "of", "this", "model", "or", "parameter", ".", "It", "starts", "from", "the", "parameterized", "object", "you", "are", "calling", "this", "method", "on", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L174-L199
train
sods/paramz
paramz/core/parameter_core.py
OptimizationHandlable.parameter_names_flat
def parameter_names_flat(self, include_fixed=False): """ Return the flattened parameter names for all subsequent parameters of this parameter. We do not include the name for self here! If you want the names for fixed parameters as well in this list, set include_fixed to True. ...
python
def parameter_names_flat(self, include_fixed=False): """ Return the flattened parameter names for all subsequent parameters of this parameter. We do not include the name for self here! If you want the names for fixed parameters as well in this list, set include_fixed to True. ...
[ "def", "parameter_names_flat", "(", "self", ",", "include_fixed", "=", "False", ")", ":", "name_list", "=", "[", "]", "for", "p", "in", "self", ".", "flattened_parameters", ":", "name", "=", "p", ".", "hierarchy_name", "(", ")", "if", "p", ".", "size", ...
Return the flattened parameter names for all subsequent parameters of this parameter. We do not include the name for self here! If you want the names for fixed parameters as well in this list, set include_fixed to True. if not hasattr(obj, 'cache'): obj.cache = Funct...
[ "Return", "the", "flattened", "parameter", "names", "for", "all", "subsequent", "parameters", "of", "this", "parameter", ".", "We", "do", "not", "include", "the", "name", "for", "self", "here!" ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L201-L223
train
sods/paramz
paramz/core/parameter_core.py
OptimizationHandlable._propagate_param_grad
def _propagate_param_grad(self, parray, garray): """ For propagating the param_array and gradient_array. This ensures the in memory view of each subsequent array. 1.) connect param_array of children to self.param_array 2.) tell all children to propagate further """ ...
python
def _propagate_param_grad(self, parray, garray): """ For propagating the param_array and gradient_array. This ensures the in memory view of each subsequent array. 1.) connect param_array of children to self.param_array 2.) tell all children to propagate further """ ...
[ "def", "_propagate_param_grad", "(", "self", ",", "parray", ",", "garray", ")", ":", "pi_old_size", "=", "0", "for", "pi", "in", "self", ".", "parameters", ":", "pislice", "=", "slice", "(", "pi_old_size", ",", "pi_old_size", "+", "pi", ".", "size", ")",...
For propagating the param_array and gradient_array. This ensures the in memory view of each subsequent array. 1.) connect param_array of children to self.param_array 2.) tell all children to propagate further
[ "For", "propagating", "the", "param_array", "and", "gradient_array", ".", "This", "ensures", "the", "in", "memory", "view", "of", "each", "subsequent", "array", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L270-L296
train
sods/paramz
paramz/core/parameter_core.py
Parameterizable.initialize_parameter
def initialize_parameter(self): """ Call this function to initialize the model, if you built it without initialization. This HAS to be called manually before optmizing or it will be causing unexpected behaviour, if not errors! """ #logger.debug("connecting parameters") ...
python
def initialize_parameter(self): """ Call this function to initialize the model, if you built it without initialization. This HAS to be called manually before optmizing or it will be causing unexpected behaviour, if not errors! """ #logger.debug("connecting parameters") ...
[ "def", "initialize_parameter", "(", "self", ")", ":", "self", ".", "_highest_parent_", ".", "_notify_parent_change", "(", ")", "self", ".", "_highest_parent_", ".", "_connect_parameters", "(", ")", "self", ".", "_highest_parent_", ".", "_connect_fixes", "(", ")", ...
Call this function to initialize the model, if you built it without initialization. This HAS to be called manually before optmizing or it will be causing unexpected behaviour, if not errors!
[ "Call", "this", "function", "to", "initialize", "the", "model", "if", "you", "built", "it", "without", "initialization", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L326-L337
train
sods/paramz
paramz/core/parameter_core.py
Parameterizable.traverse_parents
def traverse_parents(self, visit, *args, **kwargs): """ Traverse the hierarchy upwards, visiting all parents and their children except self. See "visitor pattern" in literature. This is implemented in pre-order fashion. Example: parents = [] self.traverse_parents(parent...
python
def traverse_parents(self, visit, *args, **kwargs): """ Traverse the hierarchy upwards, visiting all parents and their children except self. See "visitor pattern" in literature. This is implemented in pre-order fashion. Example: parents = [] self.traverse_parents(parent...
[ "def", "traverse_parents", "(", "self", ",", "visit", ",", "*", "args", ",", "**", "kwargs", ")", ":", "if", "self", ".", "has_parent", "(", ")", ":", "self", ".", "__visited", "=", "True", "self", ".", "_parent_", ".", "traverse_parents", "(", "visit"...
Traverse the hierarchy upwards, visiting all parents and their children except self. See "visitor pattern" in literature. This is implemented in pre-order fashion. Example: parents = [] self.traverse_parents(parents.append) print parents
[ "Traverse", "the", "hierarchy", "upwards", "visiting", "all", "parents", "and", "their", "children", "except", "self", ".", "See", "visitor", "pattern", "in", "literature", ".", "This", "is", "implemented", "in", "pre", "-", "order", "fashion", "." ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L395-L410
train
sods/paramz
paramz/examples/ridge_regression.py
RidgeRegression.phi
def phi(self, Xpred, degrees=None): """ Compute the design matrix for this model using the degrees given by the index array in degrees :param array-like Xpred: inputs to compute the design matrix for :param array-like degrees: array of degrees to use [default=range(self....
python
def phi(self, Xpred, degrees=None): """ Compute the design matrix for this model using the degrees given by the index array in degrees :param array-like Xpred: inputs to compute the design matrix for :param array-like degrees: array of degrees to use [default=range(self....
[ "def", "phi", "(", "self", ",", "Xpred", ",", "degrees", "=", "None", ")", ":", "assert", "Xpred", ".", "shape", "[", "1", "]", "==", "self", ".", "X", ".", "shape", "[", "1", "]", ",", "\"Need to predict with same shape as training data.\"", "if", "degr...
Compute the design matrix for this model using the degrees given by the index array in degrees :param array-like Xpred: inputs to compute the design matrix for :param array-like degrees: array of degrees to use [default=range(self.degree+1)] :returns array-like phi: The design m...
[ "Compute", "the", "design", "matrix", "for", "this", "model", "using", "the", "degrees", "given", "by", "the", "index", "array", "in", "degrees" ]
ae6fc6274b70fb723d91e48fc5026a9bc5a06508
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/examples/ridge_regression.py#L57-L75
train
PyAr/fades
fades/main.py
consolidate_dependencies
def consolidate_dependencies(needs_ipython, child_program, requirement_files, manual_dependencies): """Parse files, get deps and merge them. Deps read later overwrite those read earlier.""" # We get the logger here because it's not defined at module level logger = logging.getLog...
python
def consolidate_dependencies(needs_ipython, child_program, requirement_files, manual_dependencies): """Parse files, get deps and merge them. Deps read later overwrite those read earlier.""" # We get the logger here because it's not defined at module level logger = logging.getLog...
[ "def", "consolidate_dependencies", "(", "needs_ipython", ",", "child_program", ",", "requirement_files", ",", "manual_dependencies", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "'fades'", ")", "if", "needs_ipython", ":", "logger", ".", "debug", "(",...
Parse files, get deps and merge them. Deps read later overwrite those read earlier.
[ "Parse", "files", "get", "deps", "and", "merge", "them", ".", "Deps", "read", "later", "overwrite", "those", "read", "earlier", "." ]
e5ea457b09b105f321d4f81772f25e8695159604
https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/main.py#L56-L95
train
PyAr/fades
fades/main.py
detect_inside_virtualenv
def detect_inside_virtualenv(prefix, real_prefix, base_prefix): """Tell if fades is running inside a virtualenv. The params 'real_prefix' and 'base_prefix' may be None. This is copied from pip code (slightly modified), see https://github.com/pypa/pip/blob/281eb61b09d87765d7c2b92f6982b3fe76ccb0af/...
python
def detect_inside_virtualenv(prefix, real_prefix, base_prefix): """Tell if fades is running inside a virtualenv. The params 'real_prefix' and 'base_prefix' may be None. This is copied from pip code (slightly modified), see https://github.com/pypa/pip/blob/281eb61b09d87765d7c2b92f6982b3fe76ccb0af/...
[ "def", "detect_inside_virtualenv", "(", "prefix", ",", "real_prefix", ",", "base_prefix", ")", ":", "if", "real_prefix", "is", "not", "None", ":", "return", "True", "if", "base_prefix", "is", "None", ":", "return", "False", "return", "prefix", "!=", "base_pref...
Tell if fades is running inside a virtualenv. The params 'real_prefix' and 'base_prefix' may be None. This is copied from pip code (slightly modified), see https://github.com/pypa/pip/blob/281eb61b09d87765d7c2b92f6982b3fe76ccb0af/ pip/locations.py#L39
[ "Tell", "if", "fades", "is", "running", "inside", "a", "virtualenv", "." ]
e5ea457b09b105f321d4f81772f25e8695159604
https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/main.py#L137-L154
train
PyAr/fades
fades/main.py
_get_normalized_args
def _get_normalized_args(parser): """Return the parsed command line arguments. Support the case when executed from a shebang, where all the parameters come in sys.argv[1] in a single string separated by spaces (in this case, the third parameter is what is being executed) """ env = os.enviro...
python
def _get_normalized_args(parser): """Return the parsed command line arguments. Support the case when executed from a shebang, where all the parameters come in sys.argv[1] in a single string separated by spaces (in this case, the third parameter is what is being executed) """ env = os.enviro...
[ "def", "_get_normalized_args", "(", "parser", ")", ":", "env", "=", "os", ".", "environ", "if", "'_'", "in", "env", "and", "env", "[", "'_'", "]", "!=", "sys", ".", "argv", "[", "0", "]", "and", "len", "(", "sys", ".", "argv", ")", ">=", "1", "...
Return the parsed command line arguments. Support the case when executed from a shebang, where all the parameters come in sys.argv[1] in a single string separated by spaces (in this case, the third parameter is what is being executed)
[ "Return", "the", "parsed", "command", "line", "arguments", "." ]
e5ea457b09b105f321d4f81772f25e8695159604
https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/main.py#L157-L169
train
PyAr/fades
fades/parsing.py
parse_fade_requirement
def parse_fade_requirement(text): """Return a requirement and repo from the given text, already parsed and converted.""" text = text.strip() if "::" in text: repo_raw, requirement = text.split("::", 1) try: repo = {'pypi': REPO_PYPI, 'vcs': REPO_VCS}[repo_raw] except Key...
python
def parse_fade_requirement(text): """Return a requirement and repo from the given text, already parsed and converted.""" text = text.strip() if "::" in text: repo_raw, requirement = text.split("::", 1) try: repo = {'pypi': REPO_PYPI, 'vcs': REPO_VCS}[repo_raw] except Key...
[ "def", "parse_fade_requirement", "(", "text", ")", ":", "text", "=", "text", ".", "strip", "(", ")", "if", "\"::\"", "in", "text", ":", "repo_raw", ",", "requirement", "=", "text", ".", "split", "(", "\"::\"", ",", "1", ")", "try", ":", "repo", "=", ...
Return a requirement and repo from the given text, already parsed and converted.
[ "Return", "a", "requirement", "and", "repo", "from", "the", "given", "text", "already", "parsed", "and", "converted", "." ]
e5ea457b09b105f321d4f81772f25e8695159604
https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/parsing.py#L67-L89
train
PyAr/fades
fades/parsing.py
_parse_content
def _parse_content(fh): """Parse the content of a script to find marked dependencies.""" content = iter(fh) deps = {} for line in content: # quickly discard most of the lines if 'fades' not in line: continue # discard other string with 'fades' that isn't a comment ...
python
def _parse_content(fh): """Parse the content of a script to find marked dependencies.""" content = iter(fh) deps = {} for line in content: # quickly discard most of the lines if 'fades' not in line: continue # discard other string with 'fades' that isn't a comment ...
[ "def", "_parse_content", "(", "fh", ")", ":", "content", "=", "iter", "(", "fh", ")", "deps", "=", "{", "}", "for", "line", "in", "content", ":", "if", "'fades'", "not", "in", "line", ":", "continue", "if", "'#'", "not", "in", "line", ":", "continu...
Parse the content of a script to find marked dependencies.
[ "Parse", "the", "content", "of", "a", "script", "to", "find", "marked", "dependencies", "." ]
e5ea457b09b105f321d4f81772f25e8695159604
https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/parsing.py#L92-L169
train
PyAr/fades
fades/parsing.py
_parse_docstring
def _parse_docstring(fh): """Parse the docstrings of a script to find marked dependencies.""" find_fades = re.compile(r'\b(fades)\b:').search for line in fh: if line.startswith("'"): quote = "'" break if line.startswith('"'): quote = '"' break...
python
def _parse_docstring(fh): """Parse the docstrings of a script to find marked dependencies.""" find_fades = re.compile(r'\b(fades)\b:').search for line in fh: if line.startswith("'"): quote = "'" break if line.startswith('"'): quote = '"' break...
[ "def", "_parse_docstring", "(", "fh", ")", ":", "find_fades", "=", "re", ".", "compile", "(", "r'\\b(fades)\\b:'", ")", ".", "search", "for", "line", "in", "fh", ":", "if", "line", ".", "startswith", "(", "\"'\"", ")", ":", "quote", "=", "\"'\"", "brea...
Parse the docstrings of a script to find marked dependencies.
[ "Parse", "the", "docstrings", "of", "a", "script", "to", "find", "marked", "dependencies", "." ]
e5ea457b09b105f321d4f81772f25e8695159604
https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/parsing.py#L172-L209
train
PyAr/fades
fades/parsing.py
_parse_requirement
def _parse_requirement(iterable): """Actually parse the requirements, from file or manually specified.""" deps = {} for line in iterable: line = line.strip() if not line or line[0] == '#': continue parsed_req = parse_fade_requirement(line) if parsed_req is None: ...
python
def _parse_requirement(iterable): """Actually parse the requirements, from file or manually specified.""" deps = {} for line in iterable: line = line.strip() if not line or line[0] == '#': continue parsed_req = parse_fade_requirement(line) if parsed_req is None: ...
[ "def", "_parse_requirement", "(", "iterable", ")", ":", "deps", "=", "{", "}", "for", "line", "in", "iterable", ":", "line", "=", "line", ".", "strip", "(", ")", "if", "not", "line", "or", "line", "[", "0", "]", "==", "'#'", ":", "continue", "parse...
Actually parse the requirements, from file or manually specified.
[ "Actually", "parse", "the", "requirements", "from", "file", "or", "manually", "specified", "." ]
e5ea457b09b105f321d4f81772f25e8695159604
https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/parsing.py#L212-L226
train
PyAr/fades
fades/parsing.py
_read_lines
def _read_lines(filepath): """Read a req file to a list to support nested requirement files.""" with open(filepath, 'rt', encoding='utf8') as fh: for line in fh: line = line.strip() if line.startswith("-r"): logger.debug("Reading deps from nested requirement file:...
python
def _read_lines(filepath): """Read a req file to a list to support nested requirement files.""" with open(filepath, 'rt', encoding='utf8') as fh: for line in fh: line = line.strip() if line.startswith("-r"): logger.debug("Reading deps from nested requirement file:...
[ "def", "_read_lines", "(", "filepath", ")", ":", "with", "open", "(", "filepath", ",", "'rt'", ",", "encoding", "=", "'utf8'", ")", "as", "fh", ":", "for", "line", "in", "fh", ":", "line", "=", "line", ".", "strip", "(", ")", "if", "line", ".", "...
Read a req file to a list to support nested requirement files.
[ "Read", "a", "req", "file", "to", "a", "list", "to", "support", "nested", "requirement", "files", "." ]
e5ea457b09b105f321d4f81772f25e8695159604
https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/parsing.py#L236-L253
train
PyAr/fades
fades/envbuilder.py
create_venv
def create_venv(requested_deps, interpreter, is_current, options, pip_options): """Create a new virtualvenv with the requirements of this script.""" # create virtualenv env = _FadesEnvBuilder() env_path, env_bin_path, pip_installed = env.create_env(interpreter, is_current, options) venv_data = {} ...
python
def create_venv(requested_deps, interpreter, is_current, options, pip_options): """Create a new virtualvenv with the requirements of this script.""" # create virtualenv env = _FadesEnvBuilder() env_path, env_bin_path, pip_installed = env.create_env(interpreter, is_current, options) venv_data = {} ...
[ "def", "create_venv", "(", "requested_deps", ",", "interpreter", ",", "is_current", ",", "options", ",", "pip_options", ")", ":", "env", "=", "_FadesEnvBuilder", "(", ")", "env_path", ",", "env_bin_path", ",", "pip_installed", "=", "env", ".", "create_env", "(...
Create a new virtualvenv with the requirements of this script.
[ "Create", "a", "new", "virtualvenv", "with", "the", "requirements", "of", "this", "script", "." ]
e5ea457b09b105f321d4f81772f25e8695159604
https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/envbuilder.py#L124-L168
train
PyAr/fades
fades/envbuilder.py
destroy_venv
def destroy_venv(env_path, venvscache=None): """Destroy a venv.""" # remove the venv itself in disk logger.debug("Destroying virtualenv at: %s", env_path) shutil.rmtree(env_path, ignore_errors=True) # remove venv from cache if venvscache is not None: venvscache.remove(env_path)
python
def destroy_venv(env_path, venvscache=None): """Destroy a venv.""" # remove the venv itself in disk logger.debug("Destroying virtualenv at: %s", env_path) shutil.rmtree(env_path, ignore_errors=True) # remove venv from cache if venvscache is not None: venvscache.remove(env_path)
[ "def", "destroy_venv", "(", "env_path", ",", "venvscache", "=", "None", ")", ":", "logger", ".", "debug", "(", "\"Destroying virtualenv at: %s\"", ",", "env_path", ")", "shutil", ".", "rmtree", "(", "env_path", ",", "ignore_errors", "=", "True", ")", "if", "...
Destroy a venv.
[ "Destroy", "a", "venv", "." ]
e5ea457b09b105f321d4f81772f25e8695159604
https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/envbuilder.py#L171-L179
train
PyAr/fades
fades/envbuilder.py
_FadesEnvBuilder.create_with_virtualenv
def create_with_virtualenv(self, interpreter, virtualenv_options): """Create a virtualenv using the virtualenv lib.""" args = ['virtualenv', '--python', interpreter, self.env_path] args.extend(virtualenv_options) if not self.pip_installed: args.insert(3, '--no-pip') t...
python
def create_with_virtualenv(self, interpreter, virtualenv_options): """Create a virtualenv using the virtualenv lib.""" args = ['virtualenv', '--python', interpreter, self.env_path] args.extend(virtualenv_options) if not self.pip_installed: args.insert(3, '--no-pip') t...
[ "def", "create_with_virtualenv", "(", "self", ",", "interpreter", ",", "virtualenv_options", ")", ":", "args", "=", "[", "'virtualenv'", ",", "'--python'", ",", "interpreter", ",", "self", ".", "env_path", "]", "args", ".", "extend", "(", "virtualenv_options", ...
Create a virtualenv using the virtualenv lib.
[ "Create", "a", "virtualenv", "using", "the", "virtualenv", "lib", "." ]
e5ea457b09b105f321d4f81772f25e8695159604
https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/envbuilder.py#L75-L93
train