repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
djgagne/hagelslag
hagelslag/util/convert_mrms_grids.py
MRMSGrid.load_data
def load_data(self): """ Loads data from MRMS GRIB2 files and handles compression duties if files are compressed. """ data = [] loaded_dates = [] loaded_indices = [] for t, timestamp in enumerate(self.all_dates): date_str = timestamp.date().strftime("%...
python
def load_data(self): """ Loads data from MRMS GRIB2 files and handles compression duties if files are compressed. """ data = [] loaded_dates = [] loaded_indices = [] for t, timestamp in enumerate(self.all_dates): date_str = timestamp.date().strftime("%...
[ "def", "load_data", "(", "self", ")", ":", "data", "=", "[", "]", "loaded_dates", "=", "[", "]", "loaded_indices", "=", "[", "]", "for", "t", ",", "timestamp", "in", "enumerate", "(", "self", ".", "all_dates", ")", ":", "date_str", "=", "timestamp", ...
Loads data from MRMS GRIB2 files and handles compression duties if files are compressed.
[ "Loads", "data", "from", "MRMS", "GRIB2", "files", "and", "handles", "compression", "duties", "if", "files", "are", "compressed", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/util/convert_mrms_grids.py#L134-L174
djgagne/hagelslag
hagelslag/util/convert_mrms_grids.py
MRMSGrid.interpolate_grid
def interpolate_grid(self, in_lon, in_lat): """ Interpolates MRMS data to a different grid using cubic bivariate splines """ out_data = np.zeros((self.data.shape[0], in_lon.shape[0], in_lon.shape[1])) for d in range(self.data.shape[0]): print("Loading ", d, self.varia...
python
def interpolate_grid(self, in_lon, in_lat): """ Interpolates MRMS data to a different grid using cubic bivariate splines """ out_data = np.zeros((self.data.shape[0], in_lon.shape[0], in_lon.shape[1])) for d in range(self.data.shape[0]): print("Loading ", d, self.varia...
[ "def", "interpolate_grid", "(", "self", ",", "in_lon", ",", "in_lat", ")", ":", "out_data", "=", "np", ".", "zeros", "(", "(", "self", ".", "data", ".", "shape", "[", "0", "]", ",", "in_lon", ".", "shape", "[", "0", "]", ",", "in_lon", ".", "shap...
Interpolates MRMS data to a different grid using cubic bivariate splines
[ "Interpolates", "MRMS", "data", "to", "a", "different", "grid", "using", "cubic", "bivariate", "splines" ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/util/convert_mrms_grids.py#L176-L197
djgagne/hagelslag
hagelslag/util/convert_mrms_grids.py
MRMSGrid.max_neighbor
def max_neighbor(self, in_lon, in_lat, radius=0.05): """ Finds the largest value within a given radius of a point on the interpolated grid. Args: in_lon: 2D array of longitude values in_lat: 2D array of latitude values radius: radius of influence for largest ...
python
def max_neighbor(self, in_lon, in_lat, radius=0.05): """ Finds the largest value within a given radius of a point on the interpolated grid. Args: in_lon: 2D array of longitude values in_lat: 2D array of latitude values radius: radius of influence for largest ...
[ "def", "max_neighbor", "(", "self", ",", "in_lon", ",", "in_lat", ",", "radius", "=", "0.05", ")", ":", "out_data", "=", "np", ".", "zeros", "(", "(", "self", ".", "data", ".", "shape", "[", "0", "]", ",", "in_lon", ".", "shape", "[", "0", "]", ...
Finds the largest value within a given radius of a point on the interpolated grid. Args: in_lon: 2D array of longitude values in_lat: 2D array of latitude values radius: radius of influence for largest neighbor search in degrees Returns: Array of interpo...
[ "Finds", "the", "largest", "value", "within", "a", "given", "radius", "of", "a", "point", "on", "the", "interpolated", "grid", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/util/convert_mrms_grids.py#L199-L226
djgagne/hagelslag
hagelslag/util/convert_mrms_grids.py
MRMSGrid.interpolate_to_netcdf
def interpolate_to_netcdf(self, in_lon, in_lat, out_path, date_unit="seconds since 1970-01-01T00:00", interp_type="spline"): """ Calls the interpolation function and then saves the MRMS data to a netCDF file. It will also create separate directories for each variab...
python
def interpolate_to_netcdf(self, in_lon, in_lat, out_path, date_unit="seconds since 1970-01-01T00:00", interp_type="spline"): """ Calls the interpolation function and then saves the MRMS data to a netCDF file. It will also create separate directories for each variab...
[ "def", "interpolate_to_netcdf", "(", "self", ",", "in_lon", ",", "in_lat", ",", "out_path", ",", "date_unit", "=", "\"seconds since 1970-01-01T00:00\"", ",", "interp_type", "=", "\"spline\"", ")", ":", "if", "interp_type", "==", "\"spline\"", ":", "out_data", "=",...
Calls the interpolation function and then saves the MRMS data to a netCDF file. It will also create separate directories for each variable if they are not already available.
[ "Calls", "the", "interpolation", "function", "and", "then", "saves", "the", "MRMS", "data", "to", "a", "netCDF", "file", ".", "It", "will", "also", "create", "separate", "directories", "for", "each", "variable", "if", "they", "are", "not", "already", "availa...
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/util/convert_mrms_grids.py#L228-L276
nion-software/nionswift
nion/swift/model/HardwareSource.py
get_data_generator_by_id
def get_data_generator_by_id(hardware_source_id, sync=True): """ Return a generator for data. :param bool sync: whether to wait for current frame to finish then collect next frame NOTE: a new ndarray is created for each call. """ hardware_source = HardwareSourceManager().get_hardwa...
python
def get_data_generator_by_id(hardware_source_id, sync=True): """ Return a generator for data. :param bool sync: whether to wait for current frame to finish then collect next frame NOTE: a new ndarray is created for each call. """ hardware_source = HardwareSourceManager().get_hardwa...
[ "def", "get_data_generator_by_id", "(", "hardware_source_id", ",", "sync", "=", "True", ")", ":", "hardware_source", "=", "HardwareSourceManager", "(", ")", ".", "get_hardware_source_for_hardware_source_id", "(", "hardware_source_id", ")", "def", "get_last_data", "(", "...
Return a generator for data. :param bool sync: whether to wait for current frame to finish then collect next frame NOTE: a new ndarray is created for each call.
[ "Return", "a", "generator", "for", "data", "." ]
train
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/HardwareSource.py#L1053-L1064
nion-software/nionswift
nion/swift/model/HardwareSource.py
parse_hardware_aliases_config_file
def parse_hardware_aliases_config_file(config_path): """ Parse config file for aliases and automatically register them. Returns True if alias file was found and parsed (successfully or unsuccessfully). Returns False if alias file was not found. Config file is a standard .ini file ...
python
def parse_hardware_aliases_config_file(config_path): """ Parse config file for aliases and automatically register them. Returns True if alias file was found and parsed (successfully or unsuccessfully). Returns False if alias file was not found. Config file is a standard .ini file ...
[ "def", "parse_hardware_aliases_config_file", "(", "config_path", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "config_path", ")", ":", "logging", ".", "info", "(", "\"Parsing alias file {:s}\"", ".", "format", "(", "config_path", ")", ")", "try", ":"...
Parse config file for aliases and automatically register them. Returns True if alias file was found and parsed (successfully or unsuccessfully). Returns False if alias file was not found. Config file is a standard .ini file with a section
[ "Parse", "config", "file", "for", "aliases", "and", "automatically", "register", "them", "." ]
train
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/HardwareSource.py#L1072-L1101
nion-software/nionswift
nion/swift/model/HardwareSource.py
HardwareSourceManager.make_instrument_alias
def make_instrument_alias(self, instrument_id, alias_instrument_id, display_name): """ Configure an alias. Callers can use the alias to refer to the instrument or hardware source. The alias should be lowercase, no spaces. The display name may be used to display alias to the ...
python
def make_instrument_alias(self, instrument_id, alias_instrument_id, display_name): """ Configure an alias. Callers can use the alias to refer to the instrument or hardware source. The alias should be lowercase, no spaces. The display name may be used to display alias to the ...
[ "def", "make_instrument_alias", "(", "self", ",", "instrument_id", ",", "alias_instrument_id", ",", "display_name", ")", ":", "self", ".", "__aliases", "[", "alias_instrument_id", "]", "=", "(", "instrument_id", ",", "display_name", ")", "for", "f", "in", "self"...
Configure an alias. Callers can use the alias to refer to the instrument or hardware source. The alias should be lowercase, no spaces. The display name may be used to display alias to the user. Neither the original instrument or hardware source id and the alias id should ever ...
[ "Configure", "an", "alias", "." ]
train
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/HardwareSource.py#L168-L182
nion-software/nionswift
nion/swift/model/HardwareSource.py
DataChannel.update
def update(self, data_and_metadata: DataAndMetadata.DataAndMetadata, state: str, sub_area, view_id) -> None: """Called from hardware source when new data arrives.""" self.__state = state self.__sub_area = sub_area hardware_source_id = self.__hardware_source.hardware_source_id ch...
python
def update(self, data_and_metadata: DataAndMetadata.DataAndMetadata, state: str, sub_area, view_id) -> None: """Called from hardware source when new data arrives.""" self.__state = state self.__sub_area = sub_area hardware_source_id = self.__hardware_source.hardware_source_id ch...
[ "def", "update", "(", "self", ",", "data_and_metadata", ":", "DataAndMetadata", ".", "DataAndMetadata", ",", "state", ":", "str", ",", "sub_area", ",", "view_id", ")", "->", "None", ":", "self", ".", "__state", "=", "state", "self", ".", "__sub_area", "=",...
Called from hardware source when new data arrives.
[ "Called", "from", "hardware", "source", "when", "new", "data", "arrives", "." ]
train
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/HardwareSource.py#L487-L536
nion-software/nionswift
nion/swift/model/HardwareSource.py
DataChannel.start
def start(self): """Called from hardware source when data starts streaming.""" old_start_count = self.__start_count self.__start_count += 1 if old_start_count == 0: self.data_channel_start_event.fire()
python
def start(self): """Called from hardware source when data starts streaming.""" old_start_count = self.__start_count self.__start_count += 1 if old_start_count == 0: self.data_channel_start_event.fire()
[ "def", "start", "(", "self", ")", ":", "old_start_count", "=", "self", ".", "__start_count", "self", ".", "__start_count", "+=", "1", "if", "old_start_count", "==", "0", ":", "self", ".", "data_channel_start_event", ".", "fire", "(", ")" ]
Called from hardware source when data starts streaming.
[ "Called", "from", "hardware", "source", "when", "data", "starts", "streaming", "." ]
train
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/HardwareSource.py#L538-L543
nion-software/nionswift
nion/swift/model/HardwareSource.py
SumProcessor.connect_data_item_reference
def connect_data_item_reference(self, data_item_reference): """Connect to the data item reference, creating a crop graphic if necessary. If the data item reference does not yet have an associated data item, add a listener and wait for the data item to be set, then connect. """ d...
python
def connect_data_item_reference(self, data_item_reference): """Connect to the data item reference, creating a crop graphic if necessary. If the data item reference does not yet have an associated data item, add a listener and wait for the data item to be set, then connect. """ d...
[ "def", "connect_data_item_reference", "(", "self", ",", "data_item_reference", ")", ":", "display_item", "=", "data_item_reference", ".", "display_item", "data_item", "=", "display_item", ".", "data_item", "if", "display_item", "else", "None", "if", "data_item", "and"...
Connect to the data item reference, creating a crop graphic if necessary. If the data item reference does not yet have an associated data item, add a listener and wait for the data item to be set, then connect.
[ "Connect", "to", "the", "data", "item", "reference", "creating", "a", "crop", "graphic", "if", "necessary", "." ]
train
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/HardwareSource.py#L1001-L1015
nion-software/nionswift
nion/swift/model/HardwareSource.py
DataChannelBuffer.grab_earliest
def grab_earliest(self, timeout: float=None) -> typing.List[DataAndMetadata.DataAndMetadata]: """Grab the earliest data from the buffer, blocking until one is available.""" timeout = timeout if timeout is not None else 10.0 with self.__buffer_lock: if len(self.__buffer) == 0: ...
python
def grab_earliest(self, timeout: float=None) -> typing.List[DataAndMetadata.DataAndMetadata]: """Grab the earliest data from the buffer, blocking until one is available.""" timeout = timeout if timeout is not None else 10.0 with self.__buffer_lock: if len(self.__buffer) == 0: ...
[ "def", "grab_earliest", "(", "self", ",", "timeout", ":", "float", "=", "None", ")", "->", "typing", ".", "List", "[", "DataAndMetadata", ".", "DataAndMetadata", "]", ":", "timeout", "=", "timeout", "if", "timeout", "is", "not", "None", "else", "10.0", "...
Grab the earliest data from the buffer, blocking until one is available.
[ "Grab", "the", "earliest", "data", "from", "the", "buffer", "blocking", "until", "one", "is", "available", "." ]
train
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/HardwareSource.py#L1194-L1206
nion-software/nionswift
nion/swift/model/HardwareSource.py
DataChannelBuffer.grab_next
def grab_next(self, timeout: float=None) -> typing.List[DataAndMetadata.DataAndMetadata]: """Grab the next data to finish from the buffer, blocking until one is available.""" with self.__buffer_lock: self.__buffer = list() return self.grab_latest(timeout)
python
def grab_next(self, timeout: float=None) -> typing.List[DataAndMetadata.DataAndMetadata]: """Grab the next data to finish from the buffer, blocking until one is available.""" with self.__buffer_lock: self.__buffer = list() return self.grab_latest(timeout)
[ "def", "grab_next", "(", "self", ",", "timeout", ":", "float", "=", "None", ")", "->", "typing", ".", "List", "[", "DataAndMetadata", ".", "DataAndMetadata", "]", ":", "with", "self", ".", "__buffer_lock", ":", "self", ".", "__buffer", "=", "list", "(", ...
Grab the next data to finish from the buffer, blocking until one is available.
[ "Grab", "the", "next", "data", "to", "finish", "from", "the", "buffer", "blocking", "until", "one", "is", "available", "." ]
train
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/HardwareSource.py#L1208-L1212
nion-software/nionswift
nion/swift/model/HardwareSource.py
DataChannelBuffer.grab_following
def grab_following(self, timeout: float=None) -> typing.List[DataAndMetadata.DataAndMetadata]: """Grab the next data to start from the buffer, blocking until one is available.""" self.grab_next(timeout) return self.grab_next(timeout)
python
def grab_following(self, timeout: float=None) -> typing.List[DataAndMetadata.DataAndMetadata]: """Grab the next data to start from the buffer, blocking until one is available.""" self.grab_next(timeout) return self.grab_next(timeout)
[ "def", "grab_following", "(", "self", ",", "timeout", ":", "float", "=", "None", ")", "->", "typing", ".", "List", "[", "DataAndMetadata", ".", "DataAndMetadata", "]", ":", "self", ".", "grab_next", "(", "timeout", ")", "return", "self", ".", "grab_next", ...
Grab the next data to start from the buffer, blocking until one is available.
[ "Grab", "the", "next", "data", "to", "start", "from", "the", "buffer", "blocking", "until", "one", "is", "available", "." ]
train
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/HardwareSource.py#L1214-L1217
nion-software/nionswift
nion/swift/model/HardwareSource.py
DataChannelBuffer.pause
def pause(self) -> None: """Pause recording. Thread safe and UI safe.""" with self.__state_lock: if self.__state == DataChannelBuffer.State.started: self.__state = DataChannelBuffer.State.paused
python
def pause(self) -> None: """Pause recording. Thread safe and UI safe.""" with self.__state_lock: if self.__state == DataChannelBuffer.State.started: self.__state = DataChannelBuffer.State.paused
[ "def", "pause", "(", "self", ")", "->", "None", ":", "with", "self", ".", "__state_lock", ":", "if", "self", ".", "__state", "==", "DataChannelBuffer", ".", "State", ".", "started", ":", "self", ".", "__state", "=", "DataChannelBuffer", ".", "State", "."...
Pause recording. Thread safe and UI safe.
[ "Pause", "recording", "." ]
train
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/HardwareSource.py#L1226-L1232
nion-software/nionswift
nion/swift/model/HardwareSource.py
DataChannelBuffer.resume
def resume(self) -> None: """Resume recording after pause. Thread safe and UI safe.""" with self.__state_lock: if self.__state == DataChannelBuffer.State.paused: self.__state = DataChannelBuffer.State.started
python
def resume(self) -> None: """Resume recording after pause. Thread safe and UI safe.""" with self.__state_lock: if self.__state == DataChannelBuffer.State.paused: self.__state = DataChannelBuffer.State.started
[ "def", "resume", "(", "self", ")", "->", "None", ":", "with", "self", ".", "__state_lock", ":", "if", "self", ".", "__state", "==", "DataChannelBuffer", ".", "State", ".", "paused", ":", "self", ".", "__state", "=", "DataChannelBuffer", ".", "State", "."...
Resume recording after pause. Thread safe and UI safe.
[ "Resume", "recording", "after", "pause", "." ]
train
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/HardwareSource.py#L1234-L1240
nvictus/priority-queue-dictionary
pqdict/__init__.py
nlargest
def nlargest(n, mapping): """ Takes a mapping and returns the n keys associated with the largest values in descending order. If the mapping has fewer than n items, all its keys are returned. Equivalent to: ``next(zip(*heapq.nlargest(mapping.items(), key=lambda x: x[1])))`` Returns ...
python
def nlargest(n, mapping): """ Takes a mapping and returns the n keys associated with the largest values in descending order. If the mapping has fewer than n items, all its keys are returned. Equivalent to: ``next(zip(*heapq.nlargest(mapping.items(), key=lambda x: x[1])))`` Returns ...
[ "def", "nlargest", "(", "n", ",", "mapping", ")", ":", "try", ":", "it", "=", "mapping", ".", "iteritems", "(", ")", "except", "AttributeError", ":", "it", "=", "iter", "(", "mapping", ".", "items", "(", ")", ")", "pq", "=", "minpq", "(", ")", "t...
Takes a mapping and returns the n keys associated with the largest values in descending order. If the mapping has fewer than n items, all its keys are returned. Equivalent to: ``next(zip(*heapq.nlargest(mapping.items(), key=lambda x: x[1])))`` Returns ------- list of up to n keys from ...
[ "Takes", "a", "mapping", "and", "returns", "the", "n", "keys", "associated", "with", "the", "largest", "values", "in", "descending", "order", ".", "If", "the", "mapping", "has", "fewer", "than", "n", "items", "all", "its", "keys", "are", "returned", "." ]
train
https://github.com/nvictus/priority-queue-dictionary/blob/577f9d3086058bec0e49cc2050dd9454b788d93b/pqdict/__init__.py#L512-L543
nvictus/priority-queue-dictionary
pqdict/__init__.py
pqdict.fromkeys
def fromkeys(cls, iterable, value, **kwargs): """ Return a new pqict mapping keys from an iterable to the same value. """ return cls(((k, value) for k in iterable), **kwargs)
python
def fromkeys(cls, iterable, value, **kwargs): """ Return a new pqict mapping keys from an iterable to the same value. """ return cls(((k, value) for k in iterable), **kwargs)
[ "def", "fromkeys", "(", "cls", ",", "iterable", ",", "value", ",", "*", "*", "kwargs", ")", ":", "return", "cls", "(", "(", "(", "k", ",", "value", ")", "for", "k", "in", "iterable", ")", ",", "*", "*", "kwargs", ")" ]
Return a new pqict mapping keys from an iterable to the same value.
[ "Return", "a", "new", "pqict", "mapping", "keys", "from", "an", "iterable", "to", "the", "same", "value", "." ]
train
https://github.com/nvictus/priority-queue-dictionary/blob/577f9d3086058bec0e49cc2050dd9454b788d93b/pqdict/__init__.py#L121-L126
nvictus/priority-queue-dictionary
pqdict/__init__.py
pqdict.copy
def copy(self): """ Return a shallow copy of a pqdict. """ return self.__class__(self, key=self._keyfn, precedes=self._precedes)
python
def copy(self): """ Return a shallow copy of a pqdict. """ return self.__class__(self, key=self._keyfn, precedes=self._precedes)
[ "def", "copy", "(", "self", ")", ":", "return", "self", ".", "__class__", "(", "self", ",", "key", "=", "self", ".", "_keyfn", ",", "precedes", "=", "self", ".", "_precedes", ")" ]
Return a shallow copy of a pqdict.
[ "Return", "a", "shallow", "copy", "of", "a", "pqdict", "." ]
train
https://github.com/nvictus/priority-queue-dictionary/blob/577f9d3086058bec0e49cc2050dd9454b788d93b/pqdict/__init__.py#L201-L206
nvictus/priority-queue-dictionary
pqdict/__init__.py
pqdict.pop
def pop(self, key=__marker, default=__marker): """ If ``key`` is in the pqdict, remove it and return its priority value, else return ``default``. If ``default`` is not provided and ``key`` is not in the pqdict, raise a ``KeyError``. If ``key`` is not provided, remove the top ite...
python
def pop(self, key=__marker, default=__marker): """ If ``key`` is in the pqdict, remove it and return its priority value, else return ``default``. If ``default`` is not provided and ``key`` is not in the pqdict, raise a ``KeyError``. If ``key`` is not provided, remove the top ite...
[ "def", "pop", "(", "self", ",", "key", "=", "__marker", ",", "default", "=", "__marker", ")", ":", "heap", "=", "self", ".", "_heap", "position", "=", "self", ".", "_position", "# pq semantics: remove and return top *key* (value is discarded)", "if", "key", "is"...
If ``key`` is in the pqdict, remove it and return its priority value, else return ``default``. If ``default`` is not provided and ``key`` is not in the pqdict, raise a ``KeyError``. If ``key`` is not provided, remove the top item and return its key, or raise ``KeyError`` if the pqdict i...
[ "If", "key", "is", "in", "the", "pqdict", "remove", "it", "and", "return", "its", "priority", "value", "else", "return", "default", ".", "If", "default", "is", "not", "provided", "and", "key", "is", "not", "in", "the", "pqdict", "raise", "a", "KeyError",...
train
https://github.com/nvictus/priority-queue-dictionary/blob/577f9d3086058bec0e49cc2050dd9454b788d93b/pqdict/__init__.py#L208-L243
nvictus/priority-queue-dictionary
pqdict/__init__.py
pqdict.popitem
def popitem(self): """ Remove and return the item with highest priority. Raises ``KeyError`` if pqdict is empty. """ heap = self._heap position = self._position try: end = heap.pop(-1) except IndexError: raise KeyError('pqdict is ...
python
def popitem(self): """ Remove and return the item with highest priority. Raises ``KeyError`` if pqdict is empty. """ heap = self._heap position = self._position try: end = heap.pop(-1) except IndexError: raise KeyError('pqdict is ...
[ "def", "popitem", "(", "self", ")", ":", "heap", "=", "self", ".", "_heap", "position", "=", "self", ".", "_position", "try", ":", "end", "=", "heap", ".", "pop", "(", "-", "1", ")", "except", "IndexError", ":", "raise", "KeyError", "(", "'pqdict is ...
Remove and return the item with highest priority. Raises ``KeyError`` if pqdict is empty.
[ "Remove", "and", "return", "the", "item", "with", "highest", "priority", ".", "Raises", "KeyError", "if", "pqdict", "is", "empty", "." ]
train
https://github.com/nvictus/priority-queue-dictionary/blob/577f9d3086058bec0e49cc2050dd9454b788d93b/pqdict/__init__.py#L260-L282
nvictus/priority-queue-dictionary
pqdict/__init__.py
pqdict.topitem
def topitem(self): """ Return the item with highest priority. Raises ``KeyError`` if pqdict is empty. """ try: node = self._heap[0] except IndexError: raise KeyError('pqdict is empty') return node.key, node.value
python
def topitem(self): """ Return the item with highest priority. Raises ``KeyError`` if pqdict is empty. """ try: node = self._heap[0] except IndexError: raise KeyError('pqdict is empty') return node.key, node.value
[ "def", "topitem", "(", "self", ")", ":", "try", ":", "node", "=", "self", ".", "_heap", "[", "0", "]", "except", "IndexError", ":", "raise", "KeyError", "(", "'pqdict is empty'", ")", "return", "node", ".", "key", ",", "node", ".", "value" ]
Return the item with highest priority. Raises ``KeyError`` if pqdict is empty.
[ "Return", "the", "item", "with", "highest", "priority", ".", "Raises", "KeyError", "if", "pqdict", "is", "empty", "." ]
train
https://github.com/nvictus/priority-queue-dictionary/blob/577f9d3086058bec0e49cc2050dd9454b788d93b/pqdict/__init__.py#L284-L294
nvictus/priority-queue-dictionary
pqdict/__init__.py
pqdict.additem
def additem(self, key, value): """ Add a new item. Raises ``KeyError`` if key is already in the pqdict. """ if key in self._position: raise KeyError('%s is already in the queue' % repr(key)) self[key] = value
python
def additem(self, key, value): """ Add a new item. Raises ``KeyError`` if key is already in the pqdict. """ if key in self._position: raise KeyError('%s is already in the queue' % repr(key)) self[key] = value
[ "def", "additem", "(", "self", ",", "key", ",", "value", ")", ":", "if", "key", "in", "self", ".", "_position", ":", "raise", "KeyError", "(", "'%s is already in the queue'", "%", "repr", "(", "key", ")", ")", "self", "[", "key", "]", "=", "value" ]
Add a new item. Raises ``KeyError`` if key is already in the pqdict.
[ "Add", "a", "new", "item", ".", "Raises", "KeyError", "if", "key", "is", "already", "in", "the", "pqdict", "." ]
train
https://github.com/nvictus/priority-queue-dictionary/blob/577f9d3086058bec0e49cc2050dd9454b788d93b/pqdict/__init__.py#L296-L303
nvictus/priority-queue-dictionary
pqdict/__init__.py
pqdict.pushpopitem
def pushpopitem(self, key, value, node_factory=_Node): """ Equivalent to inserting a new item followed by removing the top priority item, but faster. Raises ``KeyError`` if the new key is already in the pqdict. """ heap = self._heap position = self._position ...
python
def pushpopitem(self, key, value, node_factory=_Node): """ Equivalent to inserting a new item followed by removing the top priority item, but faster. Raises ``KeyError`` if the new key is already in the pqdict. """ heap = self._heap position = self._position ...
[ "def", "pushpopitem", "(", "self", ",", "key", ",", "value", ",", "node_factory", "=", "_Node", ")", ":", "heap", "=", "self", ".", "_heap", "position", "=", "self", ".", "_position", "precedes", "=", "self", ".", "_precedes", "prio", "=", "self", ".",...
Equivalent to inserting a new item followed by removing the top priority item, but faster. Raises ``KeyError`` if the new key is already in the pqdict.
[ "Equivalent", "to", "inserting", "a", "new", "item", "followed", "by", "removing", "the", "top", "priority", "item", "but", "faster", ".", "Raises", "KeyError", "if", "the", "new", "key", "is", "already", "in", "the", "pqdict", "." ]
train
https://github.com/nvictus/priority-queue-dictionary/blob/577f9d3086058bec0e49cc2050dd9454b788d93b/pqdict/__init__.py#L305-L324
nvictus/priority-queue-dictionary
pqdict/__init__.py
pqdict.updateitem
def updateitem(self, key, new_val): """ Update the priority value of an existing item. Raises ``KeyError`` if key is not in the pqdict. """ if key not in self._position: raise KeyError(key) self[key] = new_val
python
def updateitem(self, key, new_val): """ Update the priority value of an existing item. Raises ``KeyError`` if key is not in the pqdict. """ if key not in self._position: raise KeyError(key) self[key] = new_val
[ "def", "updateitem", "(", "self", ",", "key", ",", "new_val", ")", ":", "if", "key", "not", "in", "self", ".", "_position", ":", "raise", "KeyError", "(", "key", ")", "self", "[", "key", "]", "=", "new_val" ]
Update the priority value of an existing item. Raises ``KeyError`` if key is not in the pqdict.
[ "Update", "the", "priority", "value", "of", "an", "existing", "item", ".", "Raises", "KeyError", "if", "key", "is", "not", "in", "the", "pqdict", "." ]
train
https://github.com/nvictus/priority-queue-dictionary/blob/577f9d3086058bec0e49cc2050dd9454b788d93b/pqdict/__init__.py#L326-L334
nvictus/priority-queue-dictionary
pqdict/__init__.py
pqdict.replace_key
def replace_key(self, key, new_key): """ Replace the key of an existing heap node in place. Raises ``KeyError`` if the key to replace does not exist or if the new key is already in the pqdict. """ heap = self._heap position = self._position if new_key in ...
python
def replace_key(self, key, new_key): """ Replace the key of an existing heap node in place. Raises ``KeyError`` if the key to replace does not exist or if the new key is already in the pqdict. """ heap = self._heap position = self._position if new_key in ...
[ "def", "replace_key", "(", "self", ",", "key", ",", "new_key", ")", ":", "heap", "=", "self", ".", "_heap", "position", "=", "self", ".", "_position", "if", "new_key", "in", "self", ":", "raise", "KeyError", "(", "'%s is already in the queue'", "%", "repr"...
Replace the key of an existing heap node in place. Raises ``KeyError`` if the key to replace does not exist or if the new key is already in the pqdict.
[ "Replace", "the", "key", "of", "an", "existing", "heap", "node", "in", "place", ".", "Raises", "KeyError", "if", "the", "key", "to", "replace", "does", "not", "exist", "or", "if", "the", "new", "key", "is", "already", "in", "the", "pqdict", "." ]
train
https://github.com/nvictus/priority-queue-dictionary/blob/577f9d3086058bec0e49cc2050dd9454b788d93b/pqdict/__init__.py#L336-L349
nvictus/priority-queue-dictionary
pqdict/__init__.py
pqdict.swap_priority
def swap_priority(self, key1, key2): """ Fast way to swap the priority level of two items in the pqdict. Raises ``KeyError`` if either key does not exist. """ heap = self._heap position = self._position if key1 not in self or key2 not in self: raise K...
python
def swap_priority(self, key1, key2): """ Fast way to swap the priority level of two items in the pqdict. Raises ``KeyError`` if either key does not exist. """ heap = self._heap position = self._position if key1 not in self or key2 not in self: raise K...
[ "def", "swap_priority", "(", "self", ",", "key1", ",", "key2", ")", ":", "heap", "=", "self", ".", "_heap", "position", "=", "self", ".", "_position", "if", "key1", "not", "in", "self", "or", "key2", "not", "in", "self", ":", "raise", "KeyError", "po...
Fast way to swap the priority level of two items in the pqdict. Raises ``KeyError`` if either key does not exist.
[ "Fast", "way", "to", "swap", "the", "priority", "level", "of", "two", "items", "in", "the", "pqdict", ".", "Raises", "KeyError", "if", "either", "key", "does", "not", "exist", "." ]
train
https://github.com/nvictus/priority-queue-dictionary/blob/577f9d3086058bec0e49cc2050dd9454b788d93b/pqdict/__init__.py#L351-L363
nvictus/priority-queue-dictionary
pqdict/__init__.py
pqdict.heapify
def heapify(self, key=__marker): """ Repair a broken heap. If the state of an item's priority value changes you can re-sort the relevant item only by providing ``key``. """ if key is self.__marker: n = len(self._heap) for pos in reversed(range(n//2)): ...
python
def heapify(self, key=__marker): """ Repair a broken heap. If the state of an item's priority value changes you can re-sort the relevant item only by providing ``key``. """ if key is self.__marker: n = len(self._heap) for pos in reversed(range(n//2)): ...
[ "def", "heapify", "(", "self", ",", "key", "=", "__marker", ")", ":", "if", "key", "is", "self", ".", "__marker", ":", "n", "=", "len", "(", "self", ".", "_heap", ")", "for", "pos", "in", "reversed", "(", "range", "(", "n", "//", "2", ")", ")",...
Repair a broken heap. If the state of an item's priority value changes you can re-sort the relevant item only by providing ``key``.
[ "Repair", "a", "broken", "heap", ".", "If", "the", "state", "of", "an", "item", "s", "priority", "value", "changes", "you", "can", "re", "-", "sort", "the", "relevant", "item", "only", "by", "providing", "key", "." ]
train
https://github.com/nvictus/priority-queue-dictionary/blob/577f9d3086058bec0e49cc2050dd9454b788d93b/pqdict/__init__.py#L398-L413
ajk8/hatchery
hatchery/project.py
package_has_version_file
def package_has_version_file(package_name): """ Check to make sure _version.py is contained in the package """ version_file_path = helpers.package_file_path('_version.py', package_name) return os.path.isfile(version_file_path)
python
def package_has_version_file(package_name): """ Check to make sure _version.py is contained in the package """ version_file_path = helpers.package_file_path('_version.py', package_name) return os.path.isfile(version_file_path)
[ "def", "package_has_version_file", "(", "package_name", ")", ":", "version_file_path", "=", "helpers", ".", "package_file_path", "(", "'_version.py'", ",", "package_name", ")", "return", "os", ".", "path", ".", "isfile", "(", "version_file_path", ")" ]
Check to make sure _version.py is contained in the package
[ "Check", "to", "make", "sure", "_version", ".", "py", "is", "contained", "in", "the", "package" ]
train
https://github.com/ajk8/hatchery/blob/e068c9f5366d2c98225babb03d4cde36c710194f/hatchery/project.py#L45-L48
ajk8/hatchery
hatchery/project.py
get_project_name
def get_project_name(): """ Grab the project name out of setup.py """ setup_py_content = helpers.get_file_content('setup.py') ret = helpers.value_of_named_argument_in_function( 'name', 'setup', setup_py_content, resolve_varname=True ) if ret and ret[0] == ret[-1] in ('"', "'"): ret =...
python
def get_project_name(): """ Grab the project name out of setup.py """ setup_py_content = helpers.get_file_content('setup.py') ret = helpers.value_of_named_argument_in_function( 'name', 'setup', setup_py_content, resolve_varname=True ) if ret and ret[0] == ret[-1] in ('"', "'"): ret =...
[ "def", "get_project_name", "(", ")", ":", "setup_py_content", "=", "helpers", ".", "get_file_content", "(", "'setup.py'", ")", "ret", "=", "helpers", ".", "value_of_named_argument_in_function", "(", "'name'", ",", "'setup'", ",", "setup_py_content", ",", "resolve_va...
Grab the project name out of setup.py
[ "Grab", "the", "project", "name", "out", "of", "setup", ".", "py" ]
train
https://github.com/ajk8/hatchery/blob/e068c9f5366d2c98225babb03d4cde36c710194f/hatchery/project.py#L78-L86
ajk8/hatchery
hatchery/project.py
get_version
def get_version(package_name, ignore_cache=False): """ Get the version which is currently configured by the package """ if ignore_cache: with microcache.temporarily_disabled(): found = helpers.regex_in_package_file( VERSION_SET_REGEX, '_version.py', package_name, return_match...
python
def get_version(package_name, ignore_cache=False): """ Get the version which is currently configured by the package """ if ignore_cache: with microcache.temporarily_disabled(): found = helpers.regex_in_package_file( VERSION_SET_REGEX, '_version.py', package_name, return_match...
[ "def", "get_version", "(", "package_name", ",", "ignore_cache", "=", "False", ")", ":", "if", "ignore_cache", ":", "with", "microcache", ".", "temporarily_disabled", "(", ")", ":", "found", "=", "helpers", ".", "regex_in_package_file", "(", "VERSION_SET_REGEX", ...
Get the version which is currently configured by the package
[ "Get", "the", "version", "which", "is", "currently", "configured", "by", "the", "package" ]
train
https://github.com/ajk8/hatchery/blob/e068c9f5366d2c98225babb03d4cde36c710194f/hatchery/project.py#L89-L103
ajk8/hatchery
hatchery/project.py
set_version
def set_version(package_name, version_str): """ Set the version in _version.py to version_str """ current_version = get_version(package_name) version_file_path = helpers.package_file_path('_version.py', package_name) version_file_content = helpers.get_file_content(version_file_path) version_file_con...
python
def set_version(package_name, version_str): """ Set the version in _version.py to version_str """ current_version = get_version(package_name) version_file_path = helpers.package_file_path('_version.py', package_name) version_file_content = helpers.get_file_content(version_file_path) version_file_con...
[ "def", "set_version", "(", "package_name", ",", "version_str", ")", ":", "current_version", "=", "get_version", "(", "package_name", ")", "version_file_path", "=", "helpers", ".", "package_file_path", "(", "'_version.py'", ",", "package_name", ")", "version_file_conte...
Set the version in _version.py to version_str
[ "Set", "the", "version", "in", "_version", ".", "py", "to", "version_str" ]
train
https://github.com/ajk8/hatchery/blob/e068c9f5366d2c98225babb03d4cde36c710194f/hatchery/project.py#L106-L113
ajk8/hatchery
hatchery/project.py
version_is_valid
def version_is_valid(version_str): """ Check to see if the version specified is a valid as far as pkg_resources is concerned >>> version_is_valid('blah') False >>> version_is_valid('1.2.3') True """ try: packaging.version.Version(version_str) except packaging.version.InvalidVers...
python
def version_is_valid(version_str): """ Check to see if the version specified is a valid as far as pkg_resources is concerned >>> version_is_valid('blah') False >>> version_is_valid('1.2.3') True """ try: packaging.version.Version(version_str) except packaging.version.InvalidVers...
[ "def", "version_is_valid", "(", "version_str", ")", ":", "try", ":", "packaging", ".", "version", ".", "Version", "(", "version_str", ")", "except", "packaging", ".", "version", ".", "InvalidVersion", ":", "return", "False", "return", "True" ]
Check to see if the version specified is a valid as far as pkg_resources is concerned >>> version_is_valid('blah') False >>> version_is_valid('1.2.3') True
[ "Check", "to", "see", "if", "the", "version", "specified", "is", "a", "valid", "as", "far", "as", "pkg_resources", "is", "concerned" ]
train
https://github.com/ajk8/hatchery/blob/e068c9f5366d2c98225babb03d4cde36c710194f/hatchery/project.py#L116-L128
ajk8/hatchery
hatchery/project.py
_get_uploaded_versions_warehouse
def _get_uploaded_versions_warehouse(project_name, index_url, requests_verify=True): """ Query the pypi index at index_url using warehouse api to find all of the "releases" """ url = '/'.join((index_url, project_name, 'json')) response = requests.get(url, verify=requests_verify) if response.status_code ...
python
def _get_uploaded_versions_warehouse(project_name, index_url, requests_verify=True): """ Query the pypi index at index_url using warehouse api to find all of the "releases" """ url = '/'.join((index_url, project_name, 'json')) response = requests.get(url, verify=requests_verify) if response.status_code ...
[ "def", "_get_uploaded_versions_warehouse", "(", "project_name", ",", "index_url", ",", "requests_verify", "=", "True", ")", ":", "url", "=", "'/'", ".", "join", "(", "(", "index_url", ",", "project_name", ",", "'json'", ")", ")", "response", "=", "requests", ...
Query the pypi index at index_url using warehouse api to find all of the "releases"
[ "Query", "the", "pypi", "index", "at", "index_url", "using", "warehouse", "api", "to", "find", "all", "of", "the", "releases" ]
train
https://github.com/ajk8/hatchery/blob/e068c9f5366d2c98225babb03d4cde36c710194f/hatchery/project.py#L131-L137
ajk8/hatchery
hatchery/project.py
_get_uploaded_versions_pypicloud
def _get_uploaded_versions_pypicloud(project_name, index_url, requests_verify=True): """ Query the pypi index at index_url using pypicloud api to find all versions """ api_url = index_url for suffix in ('/pypi', '/pypi/', '/simple', '/simple/'): if api_url.endswith(suffix): api_url = api...
python
def _get_uploaded_versions_pypicloud(project_name, index_url, requests_verify=True): """ Query the pypi index at index_url using pypicloud api to find all versions """ api_url = index_url for suffix in ('/pypi', '/pypi/', '/simple', '/simple/'): if api_url.endswith(suffix): api_url = api...
[ "def", "_get_uploaded_versions_pypicloud", "(", "project_name", ",", "index_url", ",", "requests_verify", "=", "True", ")", ":", "api_url", "=", "index_url", "for", "suffix", "in", "(", "'/pypi'", ",", "'/pypi/'", ",", "'/simple'", ",", "'/simple/'", ")", ":", ...
Query the pypi index at index_url using pypicloud api to find all versions
[ "Query", "the", "pypi", "index", "at", "index_url", "using", "pypicloud", "api", "to", "find", "all", "versions" ]
train
https://github.com/ajk8/hatchery/blob/e068c9f5366d2c98225babb03d4cde36c710194f/hatchery/project.py#L140-L151
ajk8/hatchery
hatchery/project.py
version_already_uploaded
def version_already_uploaded(project_name, version_str, index_url, requests_verify=True): """ Check to see if the version specified has already been uploaded to the configured index """ all_versions = _get_uploaded_versions(project_name, index_url, requests_verify) return version_str in all_versions
python
def version_already_uploaded(project_name, version_str, index_url, requests_verify=True): """ Check to see if the version specified has already been uploaded to the configured index """ all_versions = _get_uploaded_versions(project_name, index_url, requests_verify) return version_str in all_versions
[ "def", "version_already_uploaded", "(", "project_name", ",", "version_str", ",", "index_url", ",", "requests_verify", "=", "True", ")", ":", "all_versions", "=", "_get_uploaded_versions", "(", "project_name", ",", "index_url", ",", "requests_verify", ")", "return", ...
Check to see if the version specified has already been uploaded to the configured index
[ "Check", "to", "see", "if", "the", "version", "specified", "has", "already", "been", "uploaded", "to", "the", "configured", "index" ]
train
https://github.com/ajk8/hatchery/blob/e068c9f5366d2c98225babb03d4cde36c710194f/hatchery/project.py#L168-L172
ajk8/hatchery
hatchery/project.py
convert_readme_to_rst
def convert_readme_to_rst(): """ Attempt to convert a README.md file into README.rst """ project_files = os.listdir('.') for filename in project_files: if filename.lower() == 'readme': raise ProjectError( 'found {} in project directory...'.format(filename) + ...
python
def convert_readme_to_rst(): """ Attempt to convert a README.md file into README.rst """ project_files = os.listdir('.') for filename in project_files: if filename.lower() == 'readme': raise ProjectError( 'found {} in project directory...'.format(filename) + ...
[ "def", "convert_readme_to_rst", "(", ")", ":", "project_files", "=", "os", ".", "listdir", "(", "'.'", ")", "for", "filename", "in", "project_files", ":", "if", "filename", ".", "lower", "(", ")", "==", "'readme'", ":", "raise", "ProjectError", "(", "'foun...
Attempt to convert a README.md file into README.rst
[ "Attempt", "to", "convert", "a", "README", ".", "md", "file", "into", "README", ".", "rst" ]
train
https://github.com/ajk8/hatchery/blob/e068c9f5366d2c98225babb03d4cde36c710194f/hatchery/project.py#L208-L235
ajk8/hatchery
hatchery/project.py
get_packaged_files
def get_packaged_files(package_name): """ Collect relative paths to all files which have already been packaged """ if not os.path.isdir('dist'): return [] return [os.path.join('dist', filename) for filename in os.listdir('dist')]
python
def get_packaged_files(package_name): """ Collect relative paths to all files which have already been packaged """ if not os.path.isdir('dist'): return [] return [os.path.join('dist', filename) for filename in os.listdir('dist')]
[ "def", "get_packaged_files", "(", "package_name", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "'dist'", ")", ":", "return", "[", "]", "return", "[", "os", ".", "path", ".", "join", "(", "'dist'", ",", "filename", ")", "for", "filenam...
Collect relative paths to all files which have already been packaged
[ "Collect", "relative", "paths", "to", "all", "files", "which", "have", "already", "been", "packaged" ]
train
https://github.com/ajk8/hatchery/blob/e068c9f5366d2c98225babb03d4cde36c710194f/hatchery/project.py#L238-L242
ajk8/hatchery
hatchery/project.py
multiple_packaged_versions
def multiple_packaged_versions(package_name): """ Look through built package directory and see if there are multiple versions there """ dist_files = os.listdir('dist') versions = set() for filename in dist_files: version = funcy.re_find(r'{}-(.+).tar.gz'.format(package_name), filename) i...
python
def multiple_packaged_versions(package_name): """ Look through built package directory and see if there are multiple versions there """ dist_files = os.listdir('dist') versions = set() for filename in dist_files: version = funcy.re_find(r'{}-(.+).tar.gz'.format(package_name), filename) i...
[ "def", "multiple_packaged_versions", "(", "package_name", ")", ":", "dist_files", "=", "os", ".", "listdir", "(", "'dist'", ")", "versions", "=", "set", "(", ")", "for", "filename", "in", "dist_files", ":", "version", "=", "funcy", ".", "re_find", "(", "r'...
Look through built package directory and see if there are multiple versions there
[ "Look", "through", "built", "package", "directory", "and", "see", "if", "there", "are", "multiple", "versions", "there" ]
train
https://github.com/ajk8/hatchery/blob/e068c9f5366d2c98225babb03d4cde36c710194f/hatchery/project.py#L245-L253
djgagne/hagelslag
hagelslag/data/HailForecastGrid.py
HailForecastGrid.period_neighborhood_probability
def period_neighborhood_probability(self, radius, smoothing, threshold, stride,start_time,end_time): """ Calculate the neighborhood probability over the full period of the forecast Args: radius: circular radius from each point in km smoothing: width of Gaussian smoother ...
python
def period_neighborhood_probability(self, radius, smoothing, threshold, stride,start_time,end_time): """ Calculate the neighborhood probability over the full period of the forecast Args: radius: circular radius from each point in km smoothing: width of Gaussian smoother ...
[ "def", "period_neighborhood_probability", "(", "self", ",", "radius", ",", "smoothing", ",", "threshold", ",", "stride", ",", "start_time", ",", "end_time", ")", ":", "neighbor_x", "=", "self", ".", "x", "[", ":", ":", "stride", ",", ":", ":", "stride", ...
Calculate the neighborhood probability over the full period of the forecast Args: radius: circular radius from each point in km smoothing: width of Gaussian smoother in km threshold: intensity of exceedance stride: number of grid points to skip for reduced neighb...
[ "Calculate", "the", "neighborhood", "probability", "over", "the", "full", "period", "of", "the", "forecast" ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/data/HailForecastGrid.py#L94-L123
base4sistemas/satcfe
satcfe/resposta/consultarnumerosessao.py
RespostaConsultarNumeroSessao.analisar
def analisar(retorno): """Constrói uma :class:`RespostaSAT` ou especialização dependendo da função SAT encontrada na sessão consultada. :param unicode retorno: Retorno da função ``ConsultarNumeroSessao``. """ if '|' not in retorno: raise ErroRespostaSATInvalida('Resp...
python
def analisar(retorno): """Constrói uma :class:`RespostaSAT` ou especialização dependendo da função SAT encontrada na sessão consultada. :param unicode retorno: Retorno da função ``ConsultarNumeroSessao``. """ if '|' not in retorno: raise ErroRespostaSATInvalida('Resp...
[ "def", "analisar", "(", "retorno", ")", ":", "if", "'|'", "not", "in", "retorno", ":", "raise", "ErroRespostaSATInvalida", "(", "'Resposta nao possui pipes '", "'separando os campos: {!r}'", ".", "format", "(", "retorno", ")", ")", "resposta", "=", "_RespostaParcial...
Constrói uma :class:`RespostaSAT` ou especialização dependendo da função SAT encontrada na sessão consultada. :param unicode retorno: Retorno da função ``ConsultarNumeroSessao``.
[ "Constrói", "uma", ":", "class", ":", "RespostaSAT", "ou", "especialização", "dependendo", "da", "função", "SAT", "encontrada", "na", "sessão", "consultada", "." ]
train
https://github.com/base4sistemas/satcfe/blob/cb8e8815f4133d3e3d94cf526fa86767b4521ed9/satcfe/resposta/consultarnumerosessao.py#L65-L81
base4sistemas/satcfe
satcfe/resposta/padrao.py
analisar_retorno
def analisar_retorno(retorno, classe_resposta=RespostaSAT, campos=RespostaSAT.CAMPOS, campos_alternativos=[], funcao=None, manter_verbatim=True): """Analisa o retorno (supostamente um retorno de uma função do SAT) conforme o padrão e campos esperados. O retorno deverá possuir dados separados ent...
python
def analisar_retorno(retorno, classe_resposta=RespostaSAT, campos=RespostaSAT.CAMPOS, campos_alternativos=[], funcao=None, manter_verbatim=True): """Analisa o retorno (supostamente um retorno de uma função do SAT) conforme o padrão e campos esperados. O retorno deverá possuir dados separados ent...
[ "def", "analisar_retorno", "(", "retorno", ",", "classe_resposta", "=", "RespostaSAT", ",", "campos", "=", "RespostaSAT", ".", "CAMPOS", ",", "campos_alternativos", "=", "[", "]", ",", "funcao", "=", "None", ",", "manter_verbatim", "=", "True", ")", ":", "if...
Analisa o retorno (supostamente um retorno de uma função do SAT) conforme o padrão e campos esperados. O retorno deverá possuir dados separados entre si através de pipes e o número de campos deverá coincidir com os campos especificados. O campos devem ser especificados como uma tupla onde cada elemento...
[ "Analisa", "o", "retorno", "(", "supostamente", "um", "retorno", "de", "uma", "função", "do", "SAT", ")", "conforme", "o", "padrão", "e", "campos", "esperados", ".", "O", "retorno", "deverá", "possuir", "dados", "separados", "entre", "si", "através", "de", ...
train
https://github.com/base4sistemas/satcfe/blob/cb8e8815f4133d3e3d94cf526fa86767b4521ed9/satcfe/resposta/padrao.py#L175-L268
base4sistemas/satcfe
satcfe/resposta/padrao.py
RespostaSAT.comunicar_certificado_icpbrasil
def comunicar_certificado_icpbrasil(retorno): """Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.comunicar_certificado_icpbrasil`. """ resposta = analisar_retorno(forcar_unicode(retorno), funcao='ComunicarCertificadoICPB...
python
def comunicar_certificado_icpbrasil(retorno): """Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.comunicar_certificado_icpbrasil`. """ resposta = analisar_retorno(forcar_unicode(retorno), funcao='ComunicarCertificadoICPB...
[ "def", "comunicar_certificado_icpbrasil", "(", "retorno", ")", ":", "resposta", "=", "analisar_retorno", "(", "forcar_unicode", "(", "retorno", ")", ",", "funcao", "=", "'ComunicarCertificadoICPBRASIL'", ")", "if", "resposta", ".", "EEEEE", "not", "in", "(", "'050...
Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.comunicar_certificado_icpbrasil`.
[ "Constrói", "uma", ":", "class", ":", "RespostaSAT", "para", "o", "retorno", "(", "unicode", ")", "da", "função", ":", "meth", ":", "~satcfe", ".", "base", ".", "FuncoesSAT", ".", "comunicar_certificado_icpbrasil", "." ]
train
https://github.com/base4sistemas/satcfe/blob/cb8e8815f4133d3e3d94cf526fa86767b4521ed9/satcfe/resposta/padrao.py#L80-L88
base4sistemas/satcfe
satcfe/resposta/padrao.py
RespostaSAT.consultar_sat
def consultar_sat(retorno): """Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.consultar_sat`. """ resposta = analisar_retorno(forcar_unicode(retorno), funcao='ConsultarSAT') if resposta.EEEEE not in ('08000',): ...
python
def consultar_sat(retorno): """Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.consultar_sat`. """ resposta = analisar_retorno(forcar_unicode(retorno), funcao='ConsultarSAT') if resposta.EEEEE not in ('08000',): ...
[ "def", "consultar_sat", "(", "retorno", ")", ":", "resposta", "=", "analisar_retorno", "(", "forcar_unicode", "(", "retorno", ")", ",", "funcao", "=", "'ConsultarSAT'", ")", "if", "resposta", ".", "EEEEE", "not", "in", "(", "'08000'", ",", ")", ":", "raise...
Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.consultar_sat`.
[ "Constrói", "uma", ":", "class", ":", "RespostaSAT", "para", "o", "retorno", "(", "unicode", ")", "da", "função", ":", "meth", ":", "~satcfe", ".", "base", ".", "FuncoesSAT", ".", "consultar_sat", "." ]
train
https://github.com/base4sistemas/satcfe/blob/cb8e8815f4133d3e3d94cf526fa86767b4521ed9/satcfe/resposta/padrao.py#L92-L100
base4sistemas/satcfe
satcfe/resposta/padrao.py
RespostaSAT.configurar_interface_de_rede
def configurar_interface_de_rede(retorno): """Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.configurar_interface_de_rede`. """ resposta = analisar_retorno(forcar_unicode(retorno), funcao='ConfigurarInterfaceDeRede') ...
python
def configurar_interface_de_rede(retorno): """Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.configurar_interface_de_rede`. """ resposta = analisar_retorno(forcar_unicode(retorno), funcao='ConfigurarInterfaceDeRede') ...
[ "def", "configurar_interface_de_rede", "(", "retorno", ")", ":", "resposta", "=", "analisar_retorno", "(", "forcar_unicode", "(", "retorno", ")", ",", "funcao", "=", "'ConfigurarInterfaceDeRede'", ")", "if", "resposta", ".", "EEEEE", "not", "in", "(", "'12000'", ...
Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.configurar_interface_de_rede`.
[ "Constrói", "uma", ":", "class", ":", "RespostaSAT", "para", "o", "retorno", "(", "unicode", ")", "da", "função", ":", "meth", ":", "~satcfe", ".", "base", ".", "FuncoesSAT", ".", "configurar_interface_de_rede", "." ]
train
https://github.com/base4sistemas/satcfe/blob/cb8e8815f4133d3e3d94cf526fa86767b4521ed9/satcfe/resposta/padrao.py#L104-L112
base4sistemas/satcfe
satcfe/resposta/padrao.py
RespostaSAT.associar_assinatura
def associar_assinatura(retorno): """Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.associar_assinatura`. """ resposta = analisar_retorno(forcar_unicode(retorno), funcao='AssociarAssinatura') if resposta.EEEEE n...
python
def associar_assinatura(retorno): """Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.associar_assinatura`. """ resposta = analisar_retorno(forcar_unicode(retorno), funcao='AssociarAssinatura') if resposta.EEEEE n...
[ "def", "associar_assinatura", "(", "retorno", ")", ":", "resposta", "=", "analisar_retorno", "(", "forcar_unicode", "(", "retorno", ")", ",", "funcao", "=", "'AssociarAssinatura'", ")", "if", "resposta", ".", "EEEEE", "not", "in", "(", "'13000'", ",", ")", "...
Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.associar_assinatura`.
[ "Constrói", "uma", ":", "class", ":", "RespostaSAT", "para", "o", "retorno", "(", "unicode", ")", "da", "função", ":", "meth", ":", "~satcfe", ".", "base", ".", "FuncoesSAT", ".", "associar_assinatura", "." ]
train
https://github.com/base4sistemas/satcfe/blob/cb8e8815f4133d3e3d94cf526fa86767b4521ed9/satcfe/resposta/padrao.py#L116-L124
base4sistemas/satcfe
satcfe/resposta/padrao.py
RespostaSAT.atualizar_software_sat
def atualizar_software_sat(retorno): """Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.atualizar_software_sat`. """ resposta = analisar_retorno(forcar_unicode(retorno), funcao='AtualizarSoftwareSAT') if resposta...
python
def atualizar_software_sat(retorno): """Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.atualizar_software_sat`. """ resposta = analisar_retorno(forcar_unicode(retorno), funcao='AtualizarSoftwareSAT') if resposta...
[ "def", "atualizar_software_sat", "(", "retorno", ")", ":", "resposta", "=", "analisar_retorno", "(", "forcar_unicode", "(", "retorno", ")", ",", "funcao", "=", "'AtualizarSoftwareSAT'", ")", "if", "resposta", ".", "EEEEE", "not", "in", "(", "'14000'", ",", ")"...
Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.atualizar_software_sat`.
[ "Constrói", "uma", ":", "class", ":", "RespostaSAT", "para", "o", "retorno", "(", "unicode", ")", "da", "função", ":", "meth", ":", "~satcfe", ".", "base", ".", "FuncoesSAT", ".", "atualizar_software_sat", "." ]
train
https://github.com/base4sistemas/satcfe/blob/cb8e8815f4133d3e3d94cf526fa86767b4521ed9/satcfe/resposta/padrao.py#L128-L136
base4sistemas/satcfe
satcfe/resposta/padrao.py
RespostaSAT.bloquear_sat
def bloquear_sat(retorno): """Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.bloquear_sat`. """ resposta = analisar_retorno(forcar_unicode(retorno), funcao='BloquearSAT') if resposta.EEEEE not in ('16000',): ...
python
def bloquear_sat(retorno): """Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.bloquear_sat`. """ resposta = analisar_retorno(forcar_unicode(retorno), funcao='BloquearSAT') if resposta.EEEEE not in ('16000',): ...
[ "def", "bloquear_sat", "(", "retorno", ")", ":", "resposta", "=", "analisar_retorno", "(", "forcar_unicode", "(", "retorno", ")", ",", "funcao", "=", "'BloquearSAT'", ")", "if", "resposta", ".", "EEEEE", "not", "in", "(", "'16000'", ",", ")", ":", "raise",...
Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.bloquear_sat`.
[ "Constrói", "uma", ":", "class", ":", "RespostaSAT", "para", "o", "retorno", "(", "unicode", ")", "da", "função", ":", "meth", ":", "~satcfe", ".", "base", ".", "FuncoesSAT", ".", "bloquear_sat", "." ]
train
https://github.com/base4sistemas/satcfe/blob/cb8e8815f4133d3e3d94cf526fa86767b4521ed9/satcfe/resposta/padrao.py#L140-L148
base4sistemas/satcfe
satcfe/resposta/padrao.py
RespostaSAT.desbloquear_sat
def desbloquear_sat(retorno): """Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.desbloquear_sat`. """ resposta = analisar_retorno(forcar_unicode(retorno), funcao='DesbloquearSAT') if resposta.EEEEE not in ('1700...
python
def desbloquear_sat(retorno): """Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.desbloquear_sat`. """ resposta = analisar_retorno(forcar_unicode(retorno), funcao='DesbloquearSAT') if resposta.EEEEE not in ('1700...
[ "def", "desbloquear_sat", "(", "retorno", ")", ":", "resposta", "=", "analisar_retorno", "(", "forcar_unicode", "(", "retorno", ")", ",", "funcao", "=", "'DesbloquearSAT'", ")", "if", "resposta", ".", "EEEEE", "not", "in", "(", "'17000'", ",", ")", ":", "r...
Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.desbloquear_sat`.
[ "Constrói", "uma", ":", "class", ":", "RespostaSAT", "para", "o", "retorno", "(", "unicode", ")", "da", "função", ":", "meth", ":", "~satcfe", ".", "base", ".", "FuncoesSAT", ".", "desbloquear_sat", "." ]
train
https://github.com/base4sistemas/satcfe/blob/cb8e8815f4133d3e3d94cf526fa86767b4521ed9/satcfe/resposta/padrao.py#L152-L160
base4sistemas/satcfe
satcfe/resposta/padrao.py
RespostaSAT.trocar_codigo_de_ativacao
def trocar_codigo_de_ativacao(retorno): """Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.trocar_codigo_de_ativacao`. """ resposta = analisar_retorno(forcar_unicode(retorno), funcao='TrocarCodigoDeAtivacao') if ...
python
def trocar_codigo_de_ativacao(retorno): """Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.trocar_codigo_de_ativacao`. """ resposta = analisar_retorno(forcar_unicode(retorno), funcao='TrocarCodigoDeAtivacao') if ...
[ "def", "trocar_codigo_de_ativacao", "(", "retorno", ")", ":", "resposta", "=", "analisar_retorno", "(", "forcar_unicode", "(", "retorno", ")", ",", "funcao", "=", "'TrocarCodigoDeAtivacao'", ")", "if", "resposta", ".", "EEEEE", "not", "in", "(", "'18000'", ",", ...
Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.trocar_codigo_de_ativacao`.
[ "Constrói", "uma", ":", "class", ":", "RespostaSAT", "para", "o", "retorno", "(", "unicode", ")", "da", "função", ":", "meth", ":", "~satcfe", ".", "base", ".", "FuncoesSAT", ".", "trocar_codigo_de_ativacao", "." ]
train
https://github.com/base4sistemas/satcfe/blob/cb8e8815f4133d3e3d94cf526fa86767b4521ed9/satcfe/resposta/padrao.py#L164-L172
djgagne/hagelslag
hagelslag/data/ModelOutput.py
ModelOutput.load_data
def load_data(self): """ Load the specified variable from the ensemble files, then close the files. """ if self.ensemble_name.upper() == "SSEF": if self.variable[0:2] == "rh": pressure_level = self.variable[2:] relh_vars = ["sph", "tmp"] ...
python
def load_data(self): """ Load the specified variable from the ensemble files, then close the files. """ if self.ensemble_name.upper() == "SSEF": if self.variable[0:2] == "rh": pressure_level = self.variable[2:] relh_vars = ["sph", "tmp"] ...
[ "def", "load_data", "(", "self", ")", ":", "if", "self", ".", "ensemble_name", ".", "upper", "(", ")", "==", "\"SSEF\"", ":", "if", "self", ".", "variable", "[", "0", ":", "2", "]", "==", "\"rh\"", ":", "pressure_level", "=", "self", ".", "variable",...
Load the specified variable from the ensemble files, then close the files.
[ "Load", "the", "specified", "variable", "from", "the", "ensemble", "files", "then", "close", "the", "files", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/data/ModelOutput.py#L67-L172
djgagne/hagelslag
hagelslag/data/ModelOutput.py
ModelOutput.load_map_info
def load_map_info(self, map_file): """ Load map projection information and create latitude, longitude, x, y, i, and j grids for the projection. Args: map_file: File specifying the projection information. """ if self.ensemble_name.upper() == "SSEF": proj_d...
python
def load_map_info(self, map_file): """ Load map projection information and create latitude, longitude, x, y, i, and j grids for the projection. Args: map_file: File specifying the projection information. """ if self.ensemble_name.upper() == "SSEF": proj_d...
[ "def", "load_map_info", "(", "self", ",", "map_file", ")", ":", "if", "self", ".", "ensemble_name", ".", "upper", "(", ")", "==", "\"SSEF\"", ":", "proj_dict", ",", "grid_dict", "=", "read_arps_map_file", "(", "map_file", ")", "self", ".", "dx", "=", "in...
Load map projection information and create latitude, longitude, x, y, i, and j grids for the projection. Args: map_file: File specifying the projection information.
[ "Load", "map", "projection", "information", "and", "create", "latitude", "longitude", "x", "y", "i", "and", "j", "grids", "for", "the", "projection", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/data/ModelOutput.py#L174-L204
djgagne/hagelslag
hagelslag/processing/STObject.py
read_geojson
def read_geojson(filename): """ Reads a geojson file containing an STObject and initializes a new STObject from the information in the file. Args: filename: Name of the geojson file Returns: an STObject """ json_file = open(filename) data = json.load(json_file) json_fil...
python
def read_geojson(filename): """ Reads a geojson file containing an STObject and initializes a new STObject from the information in the file. Args: filename: Name of the geojson file Returns: an STObject """ json_file = open(filename) data = json.load(json_file) json_fil...
[ "def", "read_geojson", "(", "filename", ")", ":", "json_file", "=", "open", "(", "filename", ")", "data", "=", "json", ".", "load", "(", "json_file", ")", "json_file", ".", "close", "(", ")", "times", "=", "data", "[", "\"properties\"", "]", "[", "\"ti...
Reads a geojson file containing an STObject and initializes a new STObject from the information in the file. Args: filename: Name of the geojson file Returns: an STObject
[ "Reads", "a", "geojson", "file", "containing", "an", "STObject", "and", "initializes", "a", "new", "STObject", "from", "the", "information", "in", "the", "file", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L540-L572
djgagne/hagelslag
hagelslag/processing/STObject.py
STObject.center_of_mass
def center_of_mass(self, time): """ Calculate the center of mass at a given timestep. Args: time: Time at which the center of mass calculation is performed Returns: The x- and y-coordinates of the center of mass. """ if self.start_time <= time <=...
python
def center_of_mass(self, time): """ Calculate the center of mass at a given timestep. Args: time: Time at which the center of mass calculation is performed Returns: The x- and y-coordinates of the center of mass. """ if self.start_time <= time <=...
[ "def", "center_of_mass", "(", "self", ",", "time", ")", ":", "if", "self", ".", "start_time", "<=", "time", "<=", "self", ".", "end_time", ":", "diff", "=", "time", "-", "self", ".", "start_time", "valid", "=", "np", ".", "flatnonzero", "(", "self", ...
Calculate the center of mass at a given timestep. Args: time: Time at which the center of mass calculation is performed Returns: The x- and y-coordinates of the center of mass.
[ "Calculate", "the", "center", "of", "mass", "at", "a", "given", "timestep", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L78-L102
djgagne/hagelslag
hagelslag/processing/STObject.py
STObject.trajectory
def trajectory(self): """ Calculates the center of mass for each time step and outputs an array Returns: """ traj = np.zeros((2, self.times.size)) for t, time in enumerate(self.times): traj[:, t] = self.center_of_mass(time) return traj
python
def trajectory(self): """ Calculates the center of mass for each time step and outputs an array Returns: """ traj = np.zeros((2, self.times.size)) for t, time in enumerate(self.times): traj[:, t] = self.center_of_mass(time) return traj
[ "def", "trajectory", "(", "self", ")", ":", "traj", "=", "np", ".", "zeros", "(", "(", "2", ",", "self", ".", "times", ".", "size", ")", ")", "for", "t", ",", "time", "in", "enumerate", "(", "self", ".", "times", ")", ":", "traj", "[", ":", "...
Calculates the center of mass for each time step and outputs an array Returns:
[ "Calculates", "the", "center", "of", "mass", "for", "each", "time", "step", "and", "outputs", "an", "array" ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L143-L153
djgagne/hagelslag
hagelslag/processing/STObject.py
STObject.get_corner
def get_corner(self, time): """ Gets the corner array indices of the STObject at a given time that corresponds to the upper left corner of the bounding box for the STObject. Args: time: time at which the corner is being extracted. Returns: corner inde...
python
def get_corner(self, time): """ Gets the corner array indices of the STObject at a given time that corresponds to the upper left corner of the bounding box for the STObject. Args: time: time at which the corner is being extracted. Returns: corner inde...
[ "def", "get_corner", "(", "self", ",", "time", ")", ":", "if", "self", ".", "start_time", "<=", "time", "<=", "self", ".", "end_time", ":", "diff", "=", "time", "-", "self", ".", "start_time", "return", "self", ".", "i", "[", "diff", "]", "[", "0",...
Gets the corner array indices of the STObject at a given time that corresponds to the upper left corner of the bounding box for the STObject. Args: time: time at which the corner is being extracted. Returns: corner index.
[ "Gets", "the", "corner", "array", "indices", "of", "the", "STObject", "at", "a", "given", "time", "that", "corresponds", "to", "the", "upper", "left", "corner", "of", "the", "bounding", "box", "for", "the", "STObject", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L155-L170
djgagne/hagelslag
hagelslag/processing/STObject.py
STObject.size
def size(self, time): """ Gets the size of the object at a given time. Args: time: Time value being queried. Returns: size of the object in pixels """ if self.start_time <= time <= self.end_time: return self.masks[time - self.start_ti...
python
def size(self, time): """ Gets the size of the object at a given time. Args: time: Time value being queried. Returns: size of the object in pixels """ if self.start_time <= time <= self.end_time: return self.masks[time - self.start_ti...
[ "def", "size", "(", "self", ",", "time", ")", ":", "if", "self", ".", "start_time", "<=", "time", "<=", "self", ".", "end_time", ":", "return", "self", ".", "masks", "[", "time", "-", "self", ".", "start_time", "]", ".", "sum", "(", ")", "else", ...
Gets the size of the object at a given time. Args: time: Time value being queried. Returns: size of the object in pixels
[ "Gets", "the", "size", "of", "the", "object", "at", "a", "given", "time", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L172-L185
djgagne/hagelslag
hagelslag/processing/STObject.py
STObject.max_size
def max_size(self): """ Gets the largest size of the object over all timesteps. Returns: Maximum size of the object in pixels """ sizes = np.array([m.sum() for m in self.masks]) return sizes.max()
python
def max_size(self): """ Gets the largest size of the object over all timesteps. Returns: Maximum size of the object in pixels """ sizes = np.array([m.sum() for m in self.masks]) return sizes.max()
[ "def", "max_size", "(", "self", ")", ":", "sizes", "=", "np", ".", "array", "(", "[", "m", ".", "sum", "(", ")", "for", "m", "in", "self", ".", "masks", "]", ")", "return", "sizes", ".", "max", "(", ")" ]
Gets the largest size of the object over all timesteps. Returns: Maximum size of the object in pixels
[ "Gets", "the", "largest", "size", "of", "the", "object", "over", "all", "timesteps", ".", "Returns", ":", "Maximum", "size", "of", "the", "object", "in", "pixels" ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L187-L195
djgagne/hagelslag
hagelslag/processing/STObject.py
STObject.max_intensity
def max_intensity(self, time): """ Calculate the maximum intensity found at a timestep. """ ti = np.where(time == self.times)[0][0] return self.timesteps[ti].max()
python
def max_intensity(self, time): """ Calculate the maximum intensity found at a timestep. """ ti = np.where(time == self.times)[0][0] return self.timesteps[ti].max()
[ "def", "max_intensity", "(", "self", ",", "time", ")", ":", "ti", "=", "np", ".", "where", "(", "time", "==", "self", ".", "times", ")", "[", "0", "]", "[", "0", "]", "return", "self", ".", "timesteps", "[", "ti", "]", ".", "max", "(", ")" ]
Calculate the maximum intensity found at a timestep.
[ "Calculate", "the", "maximum", "intensity", "found", "at", "a", "timestep", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L197-L203
djgagne/hagelslag
hagelslag/processing/STObject.py
STObject.extend
def extend(self, step): """ Adds the data from another STObject to this object. Args: step: another STObject being added after the current one in time. """ self.timesteps.extend(step.timesteps) self.masks.extend(step.masks) self.x.extend(step....
python
def extend(self, step): """ Adds the data from another STObject to this object. Args: step: another STObject being added after the current one in time. """ self.timesteps.extend(step.timesteps) self.masks.extend(step.masks) self.x.extend(step....
[ "def", "extend", "(", "self", ",", "step", ")", ":", "self", ".", "timesteps", ".", "extend", "(", "step", ".", "timesteps", ")", "self", ".", "masks", ".", "extend", "(", "step", ".", "masks", ")", "self", ".", "x", ".", "extend", "(", "step", "...
Adds the data from another STObject to this object. Args: step: another STObject being added after the current one in time.
[ "Adds", "the", "data", "from", "another", "STObject", "to", "this", "object", ".", "Args", ":", "step", ":", "another", "STObject", "being", "added", "after", "the", "current", "one", "in", "time", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L205-L224
djgagne/hagelslag
hagelslag/processing/STObject.py
STObject.boundary_polygon
def boundary_polygon(self, time): """ Get coordinates of object boundary in counter-clockwise order """ ti = np.where(time == self.times)[0][0] com_x, com_y = self.center_of_mass(time) # If at least one point along perimeter of the mask rectangle is unmasked, find_boundar...
python
def boundary_polygon(self, time): """ Get coordinates of object boundary in counter-clockwise order """ ti = np.where(time == self.times)[0][0] com_x, com_y = self.center_of_mass(time) # If at least one point along perimeter of the mask rectangle is unmasked, find_boundar...
[ "def", "boundary_polygon", "(", "self", ",", "time", ")", ":", "ti", "=", "np", ".", "where", "(", "time", "==", "self", ".", "times", ")", "[", "0", "]", "[", "0", "]", "com_x", ",", "com_y", "=", "self", ".", "center_of_mass", "(", "time", ")",...
Get coordinates of object boundary in counter-clockwise order
[ "Get", "coordinates", "of", "object", "boundary", "in", "counter", "-", "clockwise", "order" ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L226-L247
djgagne/hagelslag
hagelslag/processing/STObject.py
STObject.estimate_motion
def estimate_motion(self, time, intensity_grid, max_u, max_v): """ Estimate the motion of the object with cross-correlation on the intensity values from the previous time step. Args: time: time being evaluated. intensity_grid: 2D array of intensities used in cross correl...
python
def estimate_motion(self, time, intensity_grid, max_u, max_v): """ Estimate the motion of the object with cross-correlation on the intensity values from the previous time step. Args: time: time being evaluated. intensity_grid: 2D array of intensities used in cross correl...
[ "def", "estimate_motion", "(", "self", ",", "time", ",", "intensity_grid", ",", "max_u", ",", "max_v", ")", ":", "ti", "=", "np", ".", "where", "(", "time", "==", "self", ".", "times", ")", "[", "0", "]", "[", "0", "]", "mask_vals", "=", "np", "....
Estimate the motion of the object with cross-correlation on the intensity values from the previous time step. Args: time: time being evaluated. intensity_grid: 2D array of intensities used in cross correlation. max_u: Maximum x-component of motion. Used to limit search area....
[ "Estimate", "the", "motion", "of", "the", "object", "with", "cross", "-", "correlation", "on", "the", "intensity", "values", "from", "the", "previous", "time", "step", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L249-L293
djgagne/hagelslag
hagelslag/processing/STObject.py
STObject.count_overlap
def count_overlap(self, time, other_object, other_time): """ Counts the number of points that overlap between this STObject and another STObject. Used for tracking. """ ti = np.where(time == self.times)[0][0] ma = np.where(self.masks[ti].ravel() == 1) oti = np.where(other...
python
def count_overlap(self, time, other_object, other_time): """ Counts the number of points that overlap between this STObject and another STObject. Used for tracking. """ ti = np.where(time == self.times)[0][0] ma = np.where(self.masks[ti].ravel() == 1) oti = np.where(other...
[ "def", "count_overlap", "(", "self", ",", "time", ",", "other_object", ",", "other_time", ")", ":", "ti", "=", "np", ".", "where", "(", "time", "==", "self", ".", "times", ")", "[", "0", "]", "[", "0", "]", "ma", "=", "np", ".", "where", "(", "...
Counts the number of points that overlap between this STObject and another STObject. Used for tracking.
[ "Counts", "the", "number", "of", "points", "that", "overlap", "between", "this", "STObject", "and", "another", "STObject", ".", "Used", "for", "tracking", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L295-L310
djgagne/hagelslag
hagelslag/processing/STObject.py
STObject.extract_attribute_grid
def extract_attribute_grid(self, model_grid, potential=False, future=False): """ Extracts the data from a ModelOutput or ModelGrid object within the bounding box region of the STObject. Args: model_grid: A ModelGrid or ModelOutput Object potential: Extracts from ...
python
def extract_attribute_grid(self, model_grid, potential=False, future=False): """ Extracts the data from a ModelOutput or ModelGrid object within the bounding box region of the STObject. Args: model_grid: A ModelGrid or ModelOutput Object potential: Extracts from ...
[ "def", "extract_attribute_grid", "(", "self", ",", "model_grid", ",", "potential", "=", "False", ",", "future", "=", "False", ")", ":", "if", "potential", ":", "var_name", "=", "model_grid", ".", "variable", "+", "\"-potential\"", "timesteps", "=", "np", "."...
Extracts the data from a ModelOutput or ModelGrid object within the bounding box region of the STObject. Args: model_grid: A ModelGrid or ModelOutput Object potential: Extracts from the time before instead of the same time as the object
[ "Extracts", "the", "data", "from", "a", "ModelOutput", "or", "ModelGrid", "object", "within", "the", "bounding", "box", "region", "of", "the", "STObject", ".", "Args", ":", "model_grid", ":", "A", "ModelGrid", "or", "ModelOutput", "Object", "potential", ":", ...
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L312-L333
djgagne/hagelslag
hagelslag/processing/STObject.py
STObject.extract_attribute_array
def extract_attribute_array(self, data_array, var_name): """ Extracts data from a 2D array that has the same dimensions as the grid used to identify the object. Args: data_array: 2D numpy array """ if var_name not in self.attributes.keys(): self.attribut...
python
def extract_attribute_array(self, data_array, var_name): """ Extracts data from a 2D array that has the same dimensions as the grid used to identify the object. Args: data_array: 2D numpy array """ if var_name not in self.attributes.keys(): self.attribut...
[ "def", "extract_attribute_array", "(", "self", ",", "data_array", ",", "var_name", ")", ":", "if", "var_name", "not", "in", "self", ".", "attributes", ".", "keys", "(", ")", ":", "self", ".", "attributes", "[", "var_name", "]", "=", "[", "]", "for", "t...
Extracts data from a 2D array that has the same dimensions as the grid used to identify the object. Args: data_array: 2D numpy array
[ "Extracts", "data", "from", "a", "2D", "array", "that", "has", "the", "same", "dimensions", "as", "the", "grid", "used", "to", "identify", "the", "object", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L335-L346
djgagne/hagelslag
hagelslag/processing/STObject.py
STObject.extract_tendency_grid
def extract_tendency_grid(self, model_grid): """ Extracts the difference in model outputs Args: model_grid: ModelOutput or ModelGrid object. """ var_name = model_grid.variable + "-tendency" self.attributes[var_name] = [] timesteps = np.arange(self.st...
python
def extract_tendency_grid(self, model_grid): """ Extracts the difference in model outputs Args: model_grid: ModelOutput or ModelGrid object. """ var_name = model_grid.variable + "-tendency" self.attributes[var_name] = [] timesteps = np.arange(self.st...
[ "def", "extract_tendency_grid", "(", "self", ",", "model_grid", ")", ":", "var_name", "=", "model_grid", ".", "variable", "+", "\"-tendency\"", "self", ".", "attributes", "[", "var_name", "]", "=", "[", "]", "timesteps", "=", "np", ".", "arange", "(", "sel...
Extracts the difference in model outputs Args: model_grid: ModelOutput or ModelGrid object.
[ "Extracts", "the", "difference", "in", "model", "outputs" ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L349-L364
djgagne/hagelslag
hagelslag/processing/STObject.py
STObject.calc_attribute_statistics
def calc_attribute_statistics(self, statistic_name): """ Calculates summary statistics over the domains of each attribute. Args: statistic_name (string): numpy statistic, such as mean, std, max, min Returns: dict of statistics from each attribute grid. ...
python
def calc_attribute_statistics(self, statistic_name): """ Calculates summary statistics over the domains of each attribute. Args: statistic_name (string): numpy statistic, such as mean, std, max, min Returns: dict of statistics from each attribute grid. ...
[ "def", "calc_attribute_statistics", "(", "self", ",", "statistic_name", ")", ":", "stats", "=", "{", "}", "for", "var", ",", "grids", "in", "self", ".", "attributes", ".", "items", "(", ")", ":", "if", "len", "(", "grids", ")", ">", "1", ":", "stats"...
Calculates summary statistics over the domains of each attribute. Args: statistic_name (string): numpy statistic, such as mean, std, max, min Returns: dict of statistics from each attribute grid.
[ "Calculates", "summary", "statistics", "over", "the", "domains", "of", "each", "attribute", ".", "Args", ":", "statistic_name", "(", "string", ")", ":", "numpy", "statistic", "such", "as", "mean", "std", "max", "min" ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L366-L383
djgagne/hagelslag
hagelslag/processing/STObject.py
STObject.calc_attribute_statistic
def calc_attribute_statistic(self, attribute, statistic, time): """ Calculate statistics based on the values of an attribute. The following statistics are supported: mean, max, min, std, ptp (range), median, skew (mean - median), and percentile_(percentile value). Args: attr...
python
def calc_attribute_statistic(self, attribute, statistic, time): """ Calculate statistics based on the values of an attribute. The following statistics are supported: mean, max, min, std, ptp (range), median, skew (mean - median), and percentile_(percentile value). Args: attr...
[ "def", "calc_attribute_statistic", "(", "self", ",", "attribute", ",", "statistic", ",", "time", ")", ":", "ti", "=", "np", ".", "where", "(", "self", ".", "times", "==", "time", ")", "[", "0", "]", "[", "0", "]", "ma", "=", "np", ".", "where", "...
Calculate statistics based on the values of an attribute. The following statistics are supported: mean, max, min, std, ptp (range), median, skew (mean - median), and percentile_(percentile value). Args: attribute: Attribute extracted from model grid statistic: Name of statistic ...
[ "Calculate", "statistics", "based", "on", "the", "values", "of", "an", "attribute", ".", "The", "following", "statistics", "are", "supported", ":", "mean", "max", "min", "std", "ptp", "(", "range", ")", "median", "skew", "(", "mean", "-", "median", ")", ...
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L385-L419
djgagne/hagelslag
hagelslag/processing/STObject.py
STObject.calc_timestep_statistic
def calc_timestep_statistic(self, statistic, time): """ Calculate statistics from the primary attribute of the StObject. Args: statistic: statistic being calculated time: Timestep being investigated Returns: Value of the statistic """ ...
python
def calc_timestep_statistic(self, statistic, time): """ Calculate statistics from the primary attribute of the StObject. Args: statistic: statistic being calculated time: Timestep being investigated Returns: Value of the statistic """ ...
[ "def", "calc_timestep_statistic", "(", "self", ",", "statistic", ",", "time", ")", ":", "ti", "=", "np", ".", "where", "(", "self", ".", "times", "==", "time", ")", "[", "0", "]", "[", "0", "]", "ma", "=", "np", ".", "where", "(", "self", ".", ...
Calculate statistics from the primary attribute of the StObject. Args: statistic: statistic being calculated time: Timestep being investigated Returns: Value of the statistic
[ "Calculate", "statistics", "from", "the", "primary", "attribute", "of", "the", "StObject", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L421-L450
djgagne/hagelslag
hagelslag/processing/STObject.py
STObject.calc_shape_statistics
def calc_shape_statistics(self, stat_names): """ Calculate shape statistics using regionprops applied to the object mask. Args: stat_names: List of statistics to be extracted from those calculated by regionprops. Returns: Dictionary of shape statistics ...
python
def calc_shape_statistics(self, stat_names): """ Calculate shape statistics using regionprops applied to the object mask. Args: stat_names: List of statistics to be extracted from those calculated by regionprops. Returns: Dictionary of shape statistics ...
[ "def", "calc_shape_statistics", "(", "self", ",", "stat_names", ")", ":", "stats", "=", "{", "}", "try", ":", "all_props", "=", "[", "regionprops", "(", "m", ")", "for", "m", "in", "self", ".", "masks", "]", "except", "TypeError", ":", "print", "(", ...
Calculate shape statistics using regionprops applied to the object mask. Args: stat_names: List of statistics to be extracted from those calculated by regionprops. Returns: Dictionary of shape statistics
[ "Calculate", "shape", "statistics", "using", "regionprops", "applied", "to", "the", "object", "mask", ".", "Args", ":", "stat_names", ":", "List", "of", "statistics", "to", "be", "extracted", "from", "those", "calculated", "by", "regionprops", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L452-L470
djgagne/hagelslag
hagelslag/processing/STObject.py
STObject.calc_shape_step
def calc_shape_step(self, stat_names, time): """ Calculate shape statistics for a single time step Args: stat_names: List of shape statistics calculated from region props time: Time being investigated Returns: List of shape statistics """ ...
python
def calc_shape_step(self, stat_names, time): """ Calculate shape statistics for a single time step Args: stat_names: List of shape statistics calculated from region props time: Time being investigated Returns: List of shape statistics """ ...
[ "def", "calc_shape_step", "(", "self", ",", "stat_names", ",", "time", ")", ":", "ti", "=", "np", ".", "where", "(", "self", ".", "times", "==", "time", ")", "[", "0", "]", "[", "0", "]", "props", "=", "regionprops", "(", "self", ".", "masks", "[...
Calculate shape statistics for a single time step Args: stat_names: List of shape statistics calculated from region props time: Time being investigated Returns: List of shape statistics
[ "Calculate", "shape", "statistics", "for", "a", "single", "time", "step" ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L472-L498
djgagne/hagelslag
hagelslag/processing/STObject.py
STObject.to_geojson
def to_geojson(self, filename, proj, metadata=None): """ Output the data in the STObject to a geoJSON file. Args: filename: Name of the file proj: PyProj object for converting the x and y coordinates back to latitude and longitue values. metadata: Metadata de...
python
def to_geojson(self, filename, proj, metadata=None): """ Output the data in the STObject to a geoJSON file. Args: filename: Name of the file proj: PyProj object for converting the x and y coordinates back to latitude and longitue values. metadata: Metadata de...
[ "def", "to_geojson", "(", "self", ",", "filename", ",", "proj", ",", "metadata", "=", "None", ")", ":", "if", "metadata", "is", "None", ":", "metadata", "=", "{", "}", "json_obj", "=", "{", "\"type\"", ":", "\"FeatureCollection\"", ",", "\"features\"", "...
Output the data in the STObject to a geoJSON file. Args: filename: Name of the file proj: PyProj object for converting the x and y coordinates back to latitude and longitue values. metadata: Metadata describing the object to be included in the top-level properties.
[ "Output", "the", "data", "in", "the", "STObject", "to", "a", "geoJSON", "file", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L500-L538
nion-software/nionswift
nion/swift/model/MemoryStorageSystem.py
MemoryStorageSystem.rewrite_properties
def rewrite_properties(self, properties): """Set the properties and write to disk.""" with self.__library_storage_lock: self.__library_storage = properties self.__write_properties(None)
python
def rewrite_properties(self, properties): """Set the properties and write to disk.""" with self.__library_storage_lock: self.__library_storage = properties self.__write_properties(None)
[ "def", "rewrite_properties", "(", "self", ",", "properties", ")", ":", "with", "self", ".", "__library_storage_lock", ":", "self", ".", "__library_storage", "=", "properties", "self", ".", "__write_properties", "(", "None", ")" ]
Set the properties and write to disk.
[ "Set", "the", "properties", "and", "write", "to", "disk", "." ]
train
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/MemoryStorageSystem.py#L113-L117
mgraffg/EvoDAG
EvoDAG/population.py
BasePopulation.model
def model(self, v=None): "Returns the model of node v" if v is None: v = self.estopping hist = self.hist trace = self.trace(v) ins = None if self._base._probability_calibration is not None: node = hist[-1] node.normalize() X...
python
def model(self, v=None): "Returns the model of node v" if v is None: v = self.estopping hist = self.hist trace = self.trace(v) ins = None if self._base._probability_calibration is not None: node = hist[-1] node.normalize() X...
[ "def", "model", "(", "self", ",", "v", "=", "None", ")", ":", "if", "v", "is", "None", ":", "v", "=", "self", ".", "estopping", "hist", "=", "self", ".", "hist", "trace", "=", "self", ".", "trace", "(", "v", ")", "ins", "=", "None", "if", "se...
Returns the model of node v
[ "Returns", "the", "model", "of", "node", "v" ]
train
https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/population.py#L252-L274
mgraffg/EvoDAG
EvoDAG/population.py
BasePopulation.trace
def trace(self, n): "Restore the position in the history of individual v's nodes" trace_map = {} self._trace(n, trace_map) s = list(trace_map.keys()) s.sort() return s
python
def trace(self, n): "Restore the position in the history of individual v's nodes" trace_map = {} self._trace(n, trace_map) s = list(trace_map.keys()) s.sort() return s
[ "def", "trace", "(", "self", ",", "n", ")", ":", "trace_map", "=", "{", "}", "self", ".", "_trace", "(", "n", ",", "trace_map", ")", "s", "=", "list", "(", "trace_map", ".", "keys", "(", ")", ")", "s", ".", "sort", "(", ")", "return", "s" ]
Restore the position in the history of individual v's nodes
[ "Restore", "the", "position", "in", "the", "history", "of", "individual", "v", "s", "nodes" ]
train
https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/population.py#L276-L282
mgraffg/EvoDAG
EvoDAG/population.py
BasePopulation.tournament
def tournament(self, negative=False): """Tournament selection and when negative is True it performs negative tournament selection""" if self.generation <= self._random_generations and not negative: return self.random_selection() if not self._negative_selection and negative: ...
python
def tournament(self, negative=False): """Tournament selection and when negative is True it performs negative tournament selection""" if self.generation <= self._random_generations and not negative: return self.random_selection() if not self._negative_selection and negative: ...
[ "def", "tournament", "(", "self", ",", "negative", "=", "False", ")", ":", "if", "self", ".", "generation", "<=", "self", ".", "_random_generations", "and", "not", "negative", ":", "return", "self", ".", "random_selection", "(", ")", "if", "not", "self", ...
Tournament selection and when negative is True it performs negative tournament selection
[ "Tournament", "selection", "and", "when", "negative", "is", "True", "it", "performs", "negative", "tournament", "selection" ]
train
https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/population.py#L319-L333
mgraffg/EvoDAG
EvoDAG/population.py
BasePopulation.create_population
def create_population(self): "Create the initial population" base = self._base if base._share_inputs: used_inputs_var = SelectNumbers([x for x in range(base.nvar)]) used_inputs_naive = used_inputs_var if base._pr_variable == 0: used_inputs_var = Select...
python
def create_population(self): "Create the initial population" base = self._base if base._share_inputs: used_inputs_var = SelectNumbers([x for x in range(base.nvar)]) used_inputs_naive = used_inputs_var if base._pr_variable == 0: used_inputs_var = Select...
[ "def", "create_population", "(", "self", ")", ":", "base", "=", "self", ".", "_base", "if", "base", ".", "_share_inputs", ":", "used_inputs_var", "=", "SelectNumbers", "(", "[", "x", "for", "x", "in", "range", "(", "base", ".", "nvar", ")", "]", ")", ...
Create the initial population
[ "Create", "the", "initial", "population" ]
train
https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/population.py#L345-L390
mgraffg/EvoDAG
EvoDAG/population.py
BasePopulation.add
def add(self, v): "Add an individual to the population" self.population.append(v) self._current_popsize += 1 v.position = len(self._hist) self._hist.append(v) self.bsf = v self.estopping = v self._density += self.get_density(v)
python
def add(self, v): "Add an individual to the population" self.population.append(v) self._current_popsize += 1 v.position = len(self._hist) self._hist.append(v) self.bsf = v self.estopping = v self._density += self.get_density(v)
[ "def", "add", "(", "self", ",", "v", ")", ":", "self", ".", "population", ".", "append", "(", "v", ")", "self", ".", "_current_popsize", "+=", "1", "v", ".", "position", "=", "len", "(", "self", ".", "_hist", ")", "self", ".", "_hist", ".", "appe...
Add an individual to the population
[ "Add", "an", "individual", "to", "the", "population" ]
train
https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/population.py#L392-L400
mgraffg/EvoDAG
EvoDAG/population.py
BasePopulation.replace
def replace(self, v): """Replace an individual selected by negative tournament selection with individual v""" if self.popsize < self._popsize: return self.add(v) k = self.tournament(negative=True) self.clean(self.population[k]) self.population[k] = v v...
python
def replace(self, v): """Replace an individual selected by negative tournament selection with individual v""" if self.popsize < self._popsize: return self.add(v) k = self.tournament(negative=True) self.clean(self.population[k]) self.population[k] = v v...
[ "def", "replace", "(", "self", ",", "v", ")", ":", "if", "self", ".", "popsize", "<", "self", ".", "_popsize", ":", "return", "self", ".", "add", "(", "v", ")", "k", "=", "self", ".", "tournament", "(", "negative", "=", "True", ")", "self", ".", ...
Replace an individual selected by negative tournament selection with individual v
[ "Replace", "an", "individual", "selected", "by", "negative", "tournament", "selection", "with", "individual", "v" ]
train
https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/population.py#L402-L419
nion-software/nionswift
nion/swift/model/HDF5Handler.py
make_directory_if_needed
def make_directory_if_needed(directory_path): """ Make the directory path, if needed. """ if os.path.exists(directory_path): if not os.path.isdir(directory_path): raise OSError("Path is not a directory:", directory_path) else: os.makedirs(directory_path)
python
def make_directory_if_needed(directory_path): """ Make the directory path, if needed. """ if os.path.exists(directory_path): if not os.path.isdir(directory_path): raise OSError("Path is not a directory:", directory_path) else: os.makedirs(directory_path)
[ "def", "make_directory_if_needed", "(", "directory_path", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "directory_path", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "directory_path", ")", ":", "raise", "OSError", "(", "\"Path is ...
Make the directory path, if needed.
[ "Make", "the", "directory", "path", "if", "needed", "." ]
train
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/HDF5Handler.py#L18-L26
ajk8/hatchery
hatchery/main.py
hatchery
def hatchery(): """ Main entry point for the hatchery program """ args = docopt.docopt(__doc__) task_list = args['<task>'] if not task_list or 'help' in task_list or args['--help']: print(__doc__.format(version=_version.__version__, config_files=config.CONFIG_LOCATIONS)) return 0 l...
python
def hatchery(): """ Main entry point for the hatchery program """ args = docopt.docopt(__doc__) task_list = args['<task>'] if not task_list or 'help' in task_list or args['--help']: print(__doc__.format(version=_version.__version__, config_files=config.CONFIG_LOCATIONS)) return 0 l...
[ "def", "hatchery", "(", ")", ":", "args", "=", "docopt", ".", "docopt", "(", "__doc__", ")", "task_list", "=", "args", "[", "'<task>'", "]", "if", "not", "task_list", "or", "'help'", "in", "task_list", "or", "args", "[", "'--help'", "]", ":", "print", ...
Main entry point for the hatchery program
[ "Main", "entry", "point", "for", "the", "hatchery", "program" ]
train
https://github.com/ajk8/hatchery/blob/e068c9f5366d2c98225babb03d4cde36c710194f/hatchery/main.py#L379-L430
ajk8/hatchery
hatchery/executor.py
call
def call(cmd_args, suppress_output=False): """ Call an arbitary command and return the exit value, stdout, and stderr as a tuple Command can be passed in as either a string or iterable >>> result = call('hatchery', suppress_output=True) >>> result.exitval 0 >>> result = call(['hatchery', 'notr...
python
def call(cmd_args, suppress_output=False): """ Call an arbitary command and return the exit value, stdout, and stderr as a tuple Command can be passed in as either a string or iterable >>> result = call('hatchery', suppress_output=True) >>> result.exitval 0 >>> result = call(['hatchery', 'notr...
[ "def", "call", "(", "cmd_args", ",", "suppress_output", "=", "False", ")", ":", "if", "not", "funcy", ".", "is_list", "(", "cmd_args", ")", "and", "not", "funcy", ".", "is_tuple", "(", "cmd_args", ")", ":", "cmd_args", "=", "shlex", ".", "split", "(", ...
Call an arbitary command and return the exit value, stdout, and stderr as a tuple Command can be passed in as either a string or iterable >>> result = call('hatchery', suppress_output=True) >>> result.exitval 0 >>> result = call(['hatchery', 'notreal']) >>> result.exitval 1
[ "Call", "an", "arbitary", "command", "and", "return", "the", "exit", "value", "stdout", "and", "stderr", "as", "a", "tuple" ]
train
https://github.com/ajk8/hatchery/blob/e068c9f5366d2c98225babb03d4cde36c710194f/hatchery/executor.py#L66-L85
ajk8/hatchery
hatchery/executor.py
setup
def setup(cmd_args, suppress_output=False): """ Call a setup.py command or list of commands >>> result = setup('--name', suppress_output=True) >>> result.exitval 0 >>> result = setup('notreal') >>> result.exitval 1 """ if not funcy.is_list(cmd_args) and not funcy.is_tuple(cmd_args):...
python
def setup(cmd_args, suppress_output=False): """ Call a setup.py command or list of commands >>> result = setup('--name', suppress_output=True) >>> result.exitval 0 >>> result = setup('notreal') >>> result.exitval 1 """ if not funcy.is_list(cmd_args) and not funcy.is_tuple(cmd_args):...
[ "def", "setup", "(", "cmd_args", ",", "suppress_output", "=", "False", ")", ":", "if", "not", "funcy", ".", "is_list", "(", "cmd_args", ")", "and", "not", "funcy", ".", "is_tuple", "(", "cmd_args", ")", ":", "cmd_args", "=", "shlex", ".", "split", "(",...
Call a setup.py command or list of commands >>> result = setup('--name', suppress_output=True) >>> result.exitval 0 >>> result = setup('notreal') >>> result.exitval 1
[ "Call", "a", "setup", ".", "py", "command", "or", "list", "of", "commands" ]
train
https://github.com/ajk8/hatchery/blob/e068c9f5366d2c98225babb03d4cde36c710194f/hatchery/executor.py#L88-L101
djgagne/hagelslag
hagelslag/data/MRMSGrid.py
MRMSGrid.load_data
def load_data(self): """ Loads data files and stores the output in the data attribute. """ data = [] valid_dates = [] mrms_files = np.array(sorted(os.listdir(self.path + self.variable + "/"))) mrms_file_dates = np.array([m_file.split("_")[-2].split("-")[0] ...
python
def load_data(self): """ Loads data files and stores the output in the data attribute. """ data = [] valid_dates = [] mrms_files = np.array(sorted(os.listdir(self.path + self.variable + "/"))) mrms_file_dates = np.array([m_file.split("_")[-2].split("-")[0] ...
[ "def", "load_data", "(", "self", ")", ":", "data", "=", "[", "]", "valid_dates", "=", "[", "]", "mrms_files", "=", "np", ".", "array", "(", "sorted", "(", "os", ".", "listdir", "(", "self", ".", "path", "+", "self", ".", "variable", "+", "\"/\"", ...
Loads data files and stores the output in the data attribute.
[ "Loads", "data", "files", "and", "stores", "the", "output", "in", "the", "data", "attribute", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/data/MRMSGrid.py#L44-L82
djgagne/hagelslag
hagelslag/processing/EnhancedWatershedSegmenter.py
rescale_data
def rescale_data(data, data_min, data_max, out_min=0.0, out_max=100.0): """ Rescale your input data so that is ranges over integer values, which will perform better in the watershed. Args: data: 2D or 3D ndarray being rescaled data_min: minimum value of input data for scaling purposes ...
python
def rescale_data(data, data_min, data_max, out_min=0.0, out_max=100.0): """ Rescale your input data so that is ranges over integer values, which will perform better in the watershed. Args: data: 2D or 3D ndarray being rescaled data_min: minimum value of input data for scaling purposes ...
[ "def", "rescale_data", "(", "data", ",", "data_min", ",", "data_max", ",", "out_min", "=", "0.0", ",", "out_max", "=", "100.0", ")", ":", "return", "(", "out_max", "-", "out_min", ")", "/", "(", "data_max", "-", "data_min", ")", "*", "(", "data", "-"...
Rescale your input data so that is ranges over integer values, which will perform better in the watershed. Args: data: 2D or 3D ndarray being rescaled data_min: minimum value of input data for scaling purposes data_max: maximum value of input data for scaling purposes out_min: minim...
[ "Rescale", "your", "input", "data", "so", "that", "is", "ranges", "over", "integer", "values", "which", "will", "perform", "better", "in", "the", "watershed", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/EnhancedWatershedSegmenter.py#L297-L311
djgagne/hagelslag
hagelslag/processing/EnhancedWatershedSegmenter.py
EnhancedWatershed.label
def label(self, input_grid): """ Labels input grid using enhanced watershed algorithm. Args: input_grid (numpy.ndarray): Grid to be labeled. Returns: Array of labeled pixels """ marked = self.find_local_maxima(input_grid) marked = np.wher...
python
def label(self, input_grid): """ Labels input grid using enhanced watershed algorithm. Args: input_grid (numpy.ndarray): Grid to be labeled. Returns: Array of labeled pixels """ marked = self.find_local_maxima(input_grid) marked = np.wher...
[ "def", "label", "(", "self", ",", "input_grid", ")", ":", "marked", "=", "self", ".", "find_local_maxima", "(", "input_grid", ")", "marked", "=", "np", ".", "where", "(", "marked", ">=", "0", ",", "1", ",", "0", ")", "# splabel returns two things in a tupl...
Labels input grid using enhanced watershed algorithm. Args: input_grid (numpy.ndarray): Grid to be labeled. Returns: Array of labeled pixels
[ "Labels", "input", "grid", "using", "enhanced", "watershed", "algorithm", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/EnhancedWatershedSegmenter.py#L42-L57
djgagne/hagelslag
hagelslag/processing/EnhancedWatershedSegmenter.py
EnhancedWatershed.find_local_maxima
def find_local_maxima(self, input_grid): """ Finds the local maxima in the inputGrid and perform region growing to identify objects. Args: input_grid: Raw input data. Returns: array with labeled objects. """ pixels, q_data = self.quantize(input_g...
python
def find_local_maxima(self, input_grid): """ Finds the local maxima in the inputGrid and perform region growing to identify objects. Args: input_grid: Raw input data. Returns: array with labeled objects. """ pixels, q_data = self.quantize(input_g...
[ "def", "find_local_maxima", "(", "self", ",", "input_grid", ")", ":", "pixels", ",", "q_data", "=", "self", ".", "quantize", "(", "input_grid", ")", "centers", "=", "OrderedDict", "(", ")", "for", "p", "in", "pixels", ".", "keys", "(", ")", ":", "cente...
Finds the local maxima in the inputGrid and perform region growing to identify objects. Args: input_grid: Raw input data. Returns: array with labeled objects.
[ "Finds", "the", "local", "maxima", "in", "the", "inputGrid", "and", "perform", "region", "growing", "to", "identify", "objects", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/EnhancedWatershedSegmenter.py#L81-L166
djgagne/hagelslag
hagelslag/processing/EnhancedWatershedSegmenter.py
EnhancedWatershed.set_maximum
def set_maximum(self, q_data, marked, center, bin_lower, foothills): """ Grow a region at a certain bin level and check if the region has reached the maximum size. Args: q_data: Quantized data array marked: Array marking points that are objects center: Coordi...
python
def set_maximum(self, q_data, marked, center, bin_lower, foothills): """ Grow a region at a certain bin level and check if the region has reached the maximum size. Args: q_data: Quantized data array marked: Array marking points that are objects center: Coordi...
[ "def", "set_maximum", "(", "self", ",", "q_data", ",", "marked", ",", "center", ",", "bin_lower", ",", "foothills", ")", ":", "as_bin", "=", "[", "]", "# pixels to be included in peak", "as_glob", "=", "[", "]", "# pixels to be globbed up as part of foothills", "m...
Grow a region at a certain bin level and check if the region has reached the maximum size. Args: q_data: Quantized data array marked: Array marking points that are objects center: Coordinates of the center pixel of the region being grown bin_lower: Intensity leve...
[ "Grow", "a", "region", "at", "a", "certain", "bin", "level", "and", "check", "if", "the", "region", "has", "reached", "the", "maximum", "size", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/EnhancedWatershedSegmenter.py#L168-L221
djgagne/hagelslag
hagelslag/processing/EnhancedWatershedSegmenter.py
EnhancedWatershed.remove_foothills
def remove_foothills(self, q_data, marked, bin_num, bin_lower, centers, foothills): """ Mark points determined to be foothills as globbed, so that they are not included in future searches. Also searches neighboring points to foothill points to determine if they should also be considered ...
python
def remove_foothills(self, q_data, marked, bin_num, bin_lower, centers, foothills): """ Mark points determined to be foothills as globbed, so that they are not included in future searches. Also searches neighboring points to foothill points to determine if they should also be considered ...
[ "def", "remove_foothills", "(", "self", ",", "q_data", ",", "marked", ",", "bin_num", ",", "bin_lower", ",", "centers", ",", "foothills", ")", ":", "hills", "=", "[", "]", "for", "foot", "in", "foothills", ":", "center", "=", "foot", "[", "0", "]", "...
Mark points determined to be foothills as globbed, so that they are not included in future searches. Also searches neighboring points to foothill points to determine if they should also be considered foothills. Args: q_data: Quantized data marked: Marked bin_...
[ "Mark", "points", "determined", "to", "be", "foothills", "as", "globbed", "so", "that", "they", "are", "not", "included", "in", "future", "searches", ".", "Also", "searches", "neighboring", "points", "to", "foothill", "points", "to", "determine", "if", "they",...
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/EnhancedWatershedSegmenter.py#L223-L255
djgagne/hagelslag
hagelslag/processing/EnhancedWatershedSegmenter.py
EnhancedWatershed.quantize
def quantize(self, input_grid): """ Quantize a grid into discrete steps based on input parameters. Args: input_grid: 2-d array of values Returns: Dictionary of value pointing to pixel locations, and quantized 2-d array of data """ pixels = {} ...
python
def quantize(self, input_grid): """ Quantize a grid into discrete steps based on input parameters. Args: input_grid: 2-d array of values Returns: Dictionary of value pointing to pixel locations, and quantized 2-d array of data """ pixels = {} ...
[ "def", "quantize", "(", "self", ",", "input_grid", ")", ":", "pixels", "=", "{", "}", "for", "i", "in", "range", "(", "self", ".", "max_bin", "+", "1", ")", ":", "pixels", "[", "i", "]", "=", "[", "]", "data", "=", "(", "np", ".", "array", "(...
Quantize a grid into discrete steps based on input parameters. Args: input_grid: 2-d array of values Returns: Dictionary of value pointing to pixel locations, and quantized 2-d array of data
[ "Quantize", "a", "grid", "into", "discrete", "steps", "based", "on", "input", "parameters", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/EnhancedWatershedSegmenter.py#L270-L290
softvar/simplegist
simplegist/mygist.py
Mygist.listall
def listall(self): ''' will display all the filenames. Result can be stored in an array for easy fetching of gistNames for future purposes. eg. a = Gist().mygists().listall() print a[0] #to fetch first gistName ''' file_name = [] r = requests.get( '%s/users/%s/gists' % (BASE_URL, self.user), ...
python
def listall(self): ''' will display all the filenames. Result can be stored in an array for easy fetching of gistNames for future purposes. eg. a = Gist().mygists().listall() print a[0] #to fetch first gistName ''' file_name = [] r = requests.get( '%s/users/%s/gists' % (BASE_URL, self.user), ...
[ "def", "listall", "(", "self", ")", ":", "file_name", "=", "[", "]", "r", "=", "requests", ".", "get", "(", "'%s/users/%s/gists'", "%", "(", "BASE_URL", ",", "self", ".", "user", ")", ",", "headers", "=", "self", ".", "gist", ".", "header", ")", "r...
will display all the filenames. Result can be stored in an array for easy fetching of gistNames for future purposes. eg. a = Gist().mygists().listall() print a[0] #to fetch first gistName
[ "will", "display", "all", "the", "filenames", ".", "Result", "can", "be", "stored", "in", "an", "array", "for", "easy", "fetching", "of", "gistNames", "for", "future", "purposes", ".", "eg", ".", "a", "=", "Gist", "()", ".", "mygists", "()", ".", "list...
train
https://github.com/softvar/simplegist/blob/8d53edd15d76c7b10fb963a659c1cf9f46f5345d/simplegist/mygist.py#L13-L34
softvar/simplegist
simplegist/mygist.py
Mygist.content
def content(self, **args): ''' Doesn't require manual fetching of gistID of a gist passing gistName will return the content of gist. In case, names are ambigious, provide GistID or it will return the contents of recent ambigious gistname ''' self.gist_name = '' if 'name' in args: self.gist_name = arg...
python
def content(self, **args): ''' Doesn't require manual fetching of gistID of a gist passing gistName will return the content of gist. In case, names are ambigious, provide GistID or it will return the contents of recent ambigious gistname ''' self.gist_name = '' if 'name' in args: self.gist_name = arg...
[ "def", "content", "(", "self", ",", "*", "*", "args", ")", ":", "self", ".", "gist_name", "=", "''", "if", "'name'", "in", "args", ":", "self", ".", "gist_name", "=", "args", "[", "'name'", "]", "self", ".", "gist_id", "=", "self", ".", "getMyID", ...
Doesn't require manual fetching of gistID of a gist passing gistName will return the content of gist. In case, names are ambigious, provide GistID or it will return the contents of recent ambigious gistname
[ "Doesn", "t", "require", "manual", "fetching", "of", "gistID", "of", "a", "gist", "passing", "gistName", "will", "return", "the", "content", "of", "gist", ".", "In", "case", "names", "are", "ambigious", "provide", "GistID", "or", "it", "will", "return", "t...
train
https://github.com/softvar/simplegist/blob/8d53edd15d76c7b10fb963a659c1cf9f46f5345d/simplegist/mygist.py#L78-L109
softvar/simplegist
simplegist/mygist.py
Mygist.edit
def edit(self, **args): ''' Doesn't require manual fetching of gistID of a gist passing gistName will return edit the gist ''' self.gist_name = '' if 'description' in args: self.description = args['description'] else: self.description = '' if 'name' in args and 'id' in args: self.gist_name = ...
python
def edit(self, **args): ''' Doesn't require manual fetching of gistID of a gist passing gistName will return edit the gist ''' self.gist_name = '' if 'description' in args: self.description = args['description'] else: self.description = '' if 'name' in args and 'id' in args: self.gist_name = ...
[ "def", "edit", "(", "self", ",", "*", "*", "args", ")", ":", "self", ".", "gist_name", "=", "''", "if", "'description'", "in", "args", ":", "self", ".", "description", "=", "args", "[", "'description'", "]", "else", ":", "self", ".", "description", "...
Doesn't require manual fetching of gistID of a gist passing gistName will return edit the gist
[ "Doesn", "t", "require", "manual", "fetching", "of", "gistID", "of", "a", "gist", "passing", "gistName", "will", "return", "edit", "the", "gist" ]
train
https://github.com/softvar/simplegist/blob/8d53edd15d76c7b10fb963a659c1cf9f46f5345d/simplegist/mygist.py#L132-L195
softvar/simplegist
simplegist/mygist.py
Mygist.delete
def delete(self, **args): ''' Delete a gist by gistname/gistID ''' if 'name' in args: self.gist_name = args['name'] self.gist_id = self.getMyID(self.gist_name) elif 'id' in args: self.gist_id = args['id'] else: raise Exception('Provide GistName to delete') url = 'gists' if self.gist_id: ...
python
def delete(self, **args): ''' Delete a gist by gistname/gistID ''' if 'name' in args: self.gist_name = args['name'] self.gist_id = self.getMyID(self.gist_name) elif 'id' in args: self.gist_id = args['id'] else: raise Exception('Provide GistName to delete') url = 'gists' if self.gist_id: ...
[ "def", "delete", "(", "self", ",", "*", "*", "args", ")", ":", "if", "'name'", "in", "args", ":", "self", ".", "gist_name", "=", "args", "[", "'name'", "]", "self", ".", "gist_id", "=", "self", ".", "getMyID", "(", "self", ".", "gist_name", ")", ...
Delete a gist by gistname/gistID
[ "Delete", "a", "gist", "by", "gistname", "/", "gistID" ]
train
https://github.com/softvar/simplegist/blob/8d53edd15d76c7b10fb963a659c1cf9f46f5345d/simplegist/mygist.py#L198-L223
softvar/simplegist
simplegist/mygist.py
Mygist.starred
def starred(self, **args): ''' List the authenticated user's starred gists ''' ids =[] r = requests.get( '%s/gists/starred'%BASE_URL, headers=self.gist.header ) if 'limit' in args: limit = args['limit'] else: limit = len(r.json()) if (r.status_code == 200): for g in range(0,limit ): ...
python
def starred(self, **args): ''' List the authenticated user's starred gists ''' ids =[] r = requests.get( '%s/gists/starred'%BASE_URL, headers=self.gist.header ) if 'limit' in args: limit = args['limit'] else: limit = len(r.json()) if (r.status_code == 200): for g in range(0,limit ): ...
[ "def", "starred", "(", "self", ",", "*", "*", "args", ")", ":", "ids", "=", "[", "]", "r", "=", "requests", ".", "get", "(", "'%s/gists/starred'", "%", "BASE_URL", ",", "headers", "=", "self", ".", "gist", ".", "header", ")", "if", "'limit'", "in",...
List the authenticated user's starred gists
[ "List", "the", "authenticated", "user", "s", "starred", "gists" ]
train
https://github.com/softvar/simplegist/blob/8d53edd15d76c7b10fb963a659c1cf9f46f5345d/simplegist/mygist.py#L226-L246
softvar/simplegist
simplegist/mygist.py
Mygist.links
def links(self,**args): ''' Return Gist URL-Link, Clone-Link and Script-Link to embed ''' if 'name' in args: self.gist_name = args['name'] self.gist_id = self.getMyID(self.gist_name) elif 'id' in args: self.gist_id = args['id'] else: raise Exception('Gist Name/ID must be provided') if self.gis...
python
def links(self,**args): ''' Return Gist URL-Link, Clone-Link and Script-Link to embed ''' if 'name' in args: self.gist_name = args['name'] self.gist_id = self.getMyID(self.gist_name) elif 'id' in args: self.gist_id = args['id'] else: raise Exception('Gist Name/ID must be provided') if self.gis...
[ "def", "links", "(", "self", ",", "*", "*", "args", ")", ":", "if", "'name'", "in", "args", ":", "self", ".", "gist_name", "=", "args", "[", "'name'", "]", "self", ".", "gist_id", "=", "self", ".", "getMyID", "(", "self", ".", "gist_name", ")", "...
Return Gist URL-Link, Clone-Link and Script-Link to embed
[ "Return", "Gist", "URL", "-", "Link", "Clone", "-", "Link", "and", "Script", "-", "Link", "to", "embed" ]
train
https://github.com/softvar/simplegist/blob/8d53edd15d76c7b10fb963a659c1cf9f46f5345d/simplegist/mygist.py#L248-L275
djgagne/hagelslag
hagelslag/evaluation/NeighborEvaluator.py
NeighborEvaluator.load_forecasts
def load_forecasts(self): """ Load neighborhood probability forecasts. """ run_date_str = self.run_date.strftime("%Y%m%d") forecast_file = self.forecast_path + "{0}/{1}_{2}_{3}_consensus_{0}.nc".format(run_date_str, ...
python
def load_forecasts(self): """ Load neighborhood probability forecasts. """ run_date_str = self.run_date.strftime("%Y%m%d") forecast_file = self.forecast_path + "{0}/{1}_{2}_{3}_consensus_{0}.nc".format(run_date_str, ...
[ "def", "load_forecasts", "(", "self", ")", ":", "run_date_str", "=", "self", ".", "run_date", ".", "strftime", "(", "\"%Y%m%d\"", ")", "forecast_file", "=", "self", ".", "forecast_path", "+", "\"{0}/{1}_{2}_{3}_consensus_{0}.nc\"", ".", "format", "(", "run_date_st...
Load neighborhood probability forecasts.
[ "Load", "neighborhood", "probability", "forecasts", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/evaluation/NeighborEvaluator.py#L62-L93
djgagne/hagelslag
hagelslag/evaluation/NeighborEvaluator.py
NeighborEvaluator.load_obs
def load_obs(self, mask_threshold=0.5): """ Loads observations and masking grid (if needed). Args: mask_threshold: Values greater than the threshold are kept, others are masked. """ print("Loading obs ", self.run_date, self.model_name, self.forecast_variable) ...
python
def load_obs(self, mask_threshold=0.5): """ Loads observations and masking grid (if needed). Args: mask_threshold: Values greater than the threshold are kept, others are masked. """ print("Loading obs ", self.run_date, self.model_name, self.forecast_variable) ...
[ "def", "load_obs", "(", "self", ",", "mask_threshold", "=", "0.5", ")", ":", "print", "(", "\"Loading obs \"", ",", "self", ".", "run_date", ",", "self", ".", "model_name", ",", "self", ".", "forecast_variable", ")", "start_date", "=", "self", ".", "run_da...
Loads observations and masking grid (if needed). Args: mask_threshold: Values greater than the threshold are kept, others are masked.
[ "Loads", "observations", "and", "masking", "grid", "(", "if", "needed", ")", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/evaluation/NeighborEvaluator.py#L95-L114
djgagne/hagelslag
hagelslag/evaluation/NeighborEvaluator.py
NeighborEvaluator.load_coordinates
def load_coordinates(self): """ Loads lat-lon coordinates from a netCDF file. """ coord_file = Dataset(self.coordinate_file) if "lon" in coord_file.variables.keys(): self.coordinates["lon"] = coord_file.variables["lon"][:] self.coordinates["lat"] = coord_f...
python
def load_coordinates(self): """ Loads lat-lon coordinates from a netCDF file. """ coord_file = Dataset(self.coordinate_file) if "lon" in coord_file.variables.keys(): self.coordinates["lon"] = coord_file.variables["lon"][:] self.coordinates["lat"] = coord_f...
[ "def", "load_coordinates", "(", "self", ")", ":", "coord_file", "=", "Dataset", "(", "self", ".", "coordinate_file", ")", "if", "\"lon\"", "in", "coord_file", ".", "variables", ".", "keys", "(", ")", ":", "self", ".", "coordinates", "[", "\"lon\"", "]", ...
Loads lat-lon coordinates from a netCDF file.
[ "Loads", "lat", "-", "lon", "coordinates", "from", "a", "netCDF", "file", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/evaluation/NeighborEvaluator.py#L116-L127
djgagne/hagelslag
hagelslag/evaluation/NeighborEvaluator.py
NeighborEvaluator.evaluate_hourly_forecasts
def evaluate_hourly_forecasts(self): """ Calculates ROC curves and Reliability scores for each forecast hour. Returns: A pandas DataFrame containing forecast metadata as well as DistributedROC and Reliability objects. """ score_columns = ["Run_Date", "Forecast_Hour",...
python
def evaluate_hourly_forecasts(self): """ Calculates ROC curves and Reliability scores for each forecast hour. Returns: A pandas DataFrame containing forecast metadata as well as DistributedROC and Reliability objects. """ score_columns = ["Run_Date", "Forecast_Hour",...
[ "def", "evaluate_hourly_forecasts", "(", "self", ")", ":", "score_columns", "=", "[", "\"Run_Date\"", ",", "\"Forecast_Hour\"", ",", "\"Ensemble Name\"", ",", "\"Model_Name\"", ",", "\"Forecast_Variable\"", ",", "\"Neighbor_Radius\"", ",", "\"Smoothing_Radius\"", ",", "...
Calculates ROC curves and Reliability scores for each forecast hour. Returns: A pandas DataFrame containing forecast metadata as well as DistributedROC and Reliability objects.
[ "Calculates", "ROC", "curves", "and", "Reliability", "scores", "for", "each", "forecast", "hour", "." ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/evaluation/NeighborEvaluator.py#L129-L170
djgagne/hagelslag
hagelslag/evaluation/NeighborEvaluator.py
NeighborEvaluator.evaluate_period_forecasts
def evaluate_period_forecasts(self): """ Evaluates ROC and Reliability scores for forecasts over the full period from start hour to end hour Returns: A pandas DataFrame with full-period metadata and verification statistics """ score_columns = ["Run_Date", "Ensemble N...
python
def evaluate_period_forecasts(self): """ Evaluates ROC and Reliability scores for forecasts over the full period from start hour to end hour Returns: A pandas DataFrame with full-period metadata and verification statistics """ score_columns = ["Run_Date", "Ensemble N...
[ "def", "evaluate_period_forecasts", "(", "self", ")", ":", "score_columns", "=", "[", "\"Run_Date\"", ",", "\"Ensemble Name\"", ",", "\"Model_Name\"", ",", "\"Forecast_Variable\"", ",", "\"Neighbor_Radius\"", ",", "\"Smoothing_Radius\"", ",", "\"Size_Threshold\"", ",", ...
Evaluates ROC and Reliability scores for forecasts over the full period from start hour to end hour Returns: A pandas DataFrame with full-period metadata and verification statistics
[ "Evaluates", "ROC", "and", "Reliability", "scores", "for", "forecasts", "over", "the", "full", "period", "from", "start", "hour", "to", "end", "hour" ]
train
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/evaluation/NeighborEvaluator.py#L172-L227