text
stringlengths
81
112k
Feed stub def _feed(self, cube, data_sources, data_sinks, global_iter_args): """ Feed stub """ try: self._feed_impl(cube, data_sources, data_sinks, global_iter_args) except Exception as e: montblanc.log.exception("Feed Exception") raise
Implementation of staging_area feeding def _feed_impl(self, cube, data_sources, data_sinks, global_iter_args): """ Implementation of staging_area feeding """ session = self._tf_session FD = self._tf_feed_data LSA = FD.local # Get source strides out before the local sizes are mo...
Call the tensorflow compute def _compute(self, feed_dict, shard): """ Call the tensorflow compute """ try: descriptor, enq = self._tfrun(self._tf_expr[shard], feed_dict=feed_dict) self._inputs_waiting.decrement(shard) except Exception as e: montblanc.log.ex...
Consume stub def _consume(self, data_sinks, cube, global_iter_args): """ Consume stub """ try: return self._consume_impl(data_sinks, cube, global_iter_args) except Exception as e: montblanc.log.exception("Consumer Exception") raise e, None, sys.exc_info()[2]
Consume def _consume_impl(self, data_sinks, cube, global_iter_args): """ Consume """ LSA = self._tf_feed_data.local output = self._tfrun(LSA.output.get_op) # Expect the descriptor in the first tuple position assert len(output) > 0 assert LSA.output.fed_arrays[0] == 'de...
Produces a SolverConfiguration object, inherited from a simple python dict, and containing the options required to configure the RIME Solver. Keyword arguments ----------------- Any keyword arguments are inserted into the returned dict. Returns ------- A SolverConfiguration object....
Returns a dictionary of beam filename pairs, keyed on correlation,from the cartesian product of correlations and real, imaginary pairs Given 'beam_$(corr)_$(reim).fits' returns: { 'xx' : ('beam_xx_re.fits', 'beam_xx_im.fits'), 'xy' : ('beam_xy_re.fits', 'beam_xy_im.fits'), ... '...
Given a {correlation: filename} mapping for filenames returns a {correlation: file handle} mapping def _open_fits_files(filenames): """ Given a {correlation: filename} mapping for filenames returns a {correlation: file handle} mapping """ kw = { 'mode' : 'update', 'memmap' : False } def _f...
Create a FitsAxes object def _create_axes(filenames, file_dict): """ Create a FitsAxes object """ try: # Loop through the file_dictionary, finding the # first open FITS file. f = iter(f for tup in file_dict.itervalues() for f in tup if f is not None).next() except StopI...
Initialise the object by generating appropriate filenames, opening associated file handles and inspecting the FITS axes of these files. def _initialise(self, feed_type="linear"): """ Initialise the object by generating appropriate filenames, opening associated file handles and i...
ebeam cube data source def ebeam(self, context): """ ebeam cube data source """ if context.shape != self.shape: raise ValueError("Partial feeding of the " "beam cube is not yet supported %s %s." % (context.shape, self.shape)) ebeam = np.empty(context.shape, context....
model visibility data sink def model_vis(self, context): """ model visibility data sink """ column = self._vis_column msshape = None # Do we have a column descriptor for the supplied column? try: coldesc = self._manager.column_descriptors[column] except KeyE...
Decorator for caching data source return values Create a key index for the proxied array in the context. Iterate over the array shape descriptor e.g. (ntime, nbl, 3) returning tuples containing the lower and upper extents of string dimensions. Takes (0, d) in the case of an integer dimensions. def...
Decorator returning a method that proxies a data source. def _proxy(method): """ Decorator returning a method that proxies a data source. """ @functools.wraps(method) def memoizer(self, context): return method(context) return memoizer
Perform any logic on solution start def start(self, start_context): """ Perform any logic on solution start """ for p in self._providers: p.start(start_context) if self._clear_start: self.clear_cache()
Perform any logic on solution stop def stop(self, stop_context): """ Perform any logic on solution stop """ for p in self._providers: p.stop(stop_context) if self._clear_stop: self.clear_cache()
Compute base antenna pairs def default_base_ant_pairs(self, context): """ Compute base antenna pairs """ k = 0 if context.cfg['auto_correlations'] == True else 1 na = context.dim_global_size('na') gen = (i.astype(context.dtype) for i in np.triu_indices(na, k)) # Cache np.triu_indices(na, k) as its...
Default antenna1 values def default_antenna1(self, context): """ Default antenna1 values """ ant1, ant2 = default_base_ant_pairs(self, context) (tl, tu), (bl, bu) = context.dim_extents('ntime', 'nbl') ant1_result = np.empty(context.shape, context.dtype) ant1_result[:,:] = ant1[np.newaxis,bl:bu] ...
Default antenna2 values def default_antenna2(self, context): """ Default antenna2 values """ ant1, ant2 = default_base_ant_pairs(self, context) (tl, tu), (bl, bu) = context.dim_extents('ntime', 'nbl') ant2_result = np.empty(context.shape, context.dtype) ant2_result[:,:] = ant2[np.newaxis,bl:bu] ...
Returns [[1, 0], tiled up to other dimensions [0, 1]] def identity_on_pols(self, context): """ Returns [[1, 0], tiled up to other dimensions [0, 1]] """ A = np.empty(context.shape, context.dtype) A[:,:,:] = [[[1,0,0,1]]] return A
Returns [[1, 0], tiled up to other dimensions [0, 0]] def default_stokes(self, context): """ Returns [[1, 0], tiled up to other dimensions [0, 0]] """ A = np.empty(context.shape, context.dtype) A[:,:,:] = [[[1,0,0,0]]] return A
Frequency data source def frequency(self, context): """ Frequency data source """ channels = self._manager.spectral_window_table.getcol(MS.CHAN_FREQ) return channels.reshape(context.shape).astype(context.dtype)
Reference frequency data source def ref_frequency(self, context): """ Reference frequency data source """ num_chans = self._manager.spectral_window_table.getcol(MS.NUM_CHAN) ref_freqs = self._manager.spectral_window_table.getcol(MS.REF_FREQUENCY) data = np.hstack((np.repeat(rf, bs) for...
Per-antenna UVW coordinate data source def uvw(self, context): """ Per-antenna UVW coordinate data source """ # Hacky access of private member cube = context._cube # Create antenna1 source context a1_actual = cube.array("antenna1", reify=True) a1_ctx = SourceContext("a...
antenna1 data source def antenna1(self, context): """ antenna1 data source """ lrow, urow = MS.uvw_row_extents(context) antenna1 = self._manager.ordered_uvw_table.getcol( MS.ANTENNA1, startrow=lrow, nrow=urow-lrow) return antenna1.reshape(context.shape).astype(context.dtype...
antenna2 data source def antenna2(self, context): """ antenna2 data source """ lrow, urow = MS.uvw_row_extents(context) antenna2 = self._manager.ordered_uvw_table.getcol( MS.ANTENNA2, startrow=lrow, nrow=urow-lrow) return antenna2.reshape(context.shape).astype(context.dtype...
parallactic angle data source def parallactic_angles(self, context): """ parallactic angle data source """ # Time and antenna extents (lt, ut), (la, ua) = context.dim_extents('ntime', 'na') return (mbu.parallactic_angles(self._times[lt:ut], self._antenna_positions[la:ua...
Observed visibility data source def observed_vis(self, context): """ Observed visibility data source """ lrow, urow = MS.row_extents(context) data = self._manager.ordered_main_table.getcol( self._vis_column, startrow=lrow, nrow=urow-lrow) return data.reshape(context.shape)...
Flag data source def flag(self, context): """ Flag data source """ lrow, urow = MS.row_extents(context) flag = self._manager.ordered_main_table.getcol( MS.FLAG, startrow=lrow, nrow=urow-lrow) return flag.reshape(context.shape).astype(context.dtype)
Weight data source def weight(self, context): """ Weight data source """ lrow, urow = MS.row_extents(context) weight = self._manager.ordered_main_table.getcol( MS.WEIGHT, startrow=lrow, nrow=urow-lrow) # WEIGHT is applied across all channels weight = np.repeat(weig...
Load the tensorflow library def load_tf_lib(): """ Load the tensorflow library """ from os.path import join as pjoin import pkg_resources import tensorflow as tf path = pjoin('ext', 'rime.so') rime_lib_path = pkg_resources.resource_filename("montblanc", path) return tf.load_op_library(rim...
Raise any errors associated with the validator. Parameters ---------- validator : :class:`cerberus.Validator` Validator Raises ------ ValueError Raised if errors existed on `validator`. Message describing each error and information associated with the configurat...
Take a multiline text and indent it as a block def indented(text, level, indent=2): """Take a multiline text and indent it as a block""" return "\n".join("%s%s" % (level * indent * " ", s) for s in text.splitlines())
Put curly brackets round an indented text def dumped(text, level, indent=2): """Put curly brackets round an indented text""" return indented("{\n%s\n}" % indented(text, level + 1, indent) or "None", level, indent) + "\n"
Perform a shell-based file copy. Copying in this way allows the possibility of undo, auto-renaming, and showing the "flying file" animation during the copy. The default options allow for undo, don't automatically clobber on a name clash, automatically rename on collision and display the animation. ...
Perform a shell-based file move. Moving in this way allows the possibility of undo, auto-renaming, and showing the "flying file" animation during the copy. The default options allow for undo, don't automatically clobber on a name clash, automatically rename on collision and display the animation. ...
Perform a shell-based file rename. Renaming in this way allows the possibility of undo, auto-renaming, and showing the "flying file" animation during the copy. The default options allow for undo, don't automatically clobber on a name clash, automatically rename on collision and display the animatio...
Perform a shell-based file delete. Deleting in this way uses the system recycle bin, allows the possibility of undo, and showing the "flying file" animation during the delete. The default options allow for undo, don't automatically clobber on a name clash and display the animation. def delete_file...
Pick out info from MS documents with embedded structured storage(typically MS Word docs etc.) Returns a dictionary of information found def structured_storage(filename): """Pick out info from MS documents with embedded structured storage(typically MS Word docs etc.) Returns a dictionary of info...
Create a Windows shortcut: Path - As what file should the shortcut be created? Target - What command should the desktop use? Arguments - What arguments should be supplied to the command? StartIn - What folder should the command start in? Icon -(filename, index) What icon should be used for the shor...
Restore the most recent version of a filepath, returning the filepath it was restored to(as rename-on-collision will apply if a file already exists at that path). def undelete(self, original_filepath): """Restore the most recent version of a filepath, returning the filepath it was resto...
Given a list of arrays to feed in fed_arrays, return a list of associated queue types, obtained from tuples in the data_sources dictionary def _get_queue_types(fed_arrays, data_sources): """ Given a list of arrays to feed in fed_arrays, return a list of associated queue types, obtained from tuples ...
Arguments name: string Name of the queue queue_size: integer Size of the queue fed_arrays: list array names that will be fed by this queue data_sources: dict (lambda/method, dtype) tuples, keyed on array names def create_queue_wrapper(name...
Parses a string, containing assign statements into a dictionary. .. code-block:: python h5 = katdal.open('123456789.h5') kwargs = parse_python_assigns("spw=3; scans=[1,2];" "targets='bpcal,radec';" "channels=slice(0,20...
Returns a dictionary of sink methods found on this object, keyed on method name. Sink methods are identified by (self, context) arguments on this object. For example: def f(self, context): ... is a sink method, but def f(self, ctx): ... is not. def find_sinks(obj): """ ...
Returns a dictionary of sink methods found on this object, keyed on method name. Sink methods are identified by (self, context) arguments on this object. For example: def f(self, context): ... is a sink method, but def f(self, ctx): ... is not....
numba implementation of antenna_uvw def _antenna_uvw(uvw, antenna1, antenna2, chunks, nr_of_antenna): """ numba implementation of antenna_uvw """ if antenna1.ndim != 1: raise ValueError("antenna1 shape should be (row,)") if antenna2.ndim != 1: raise ValueError("antenna2 shape should be (r...
Raises informative exception for an invalid decomposition def _raise_decomposition_errors(uvw, antenna1, antenna2, chunks, ant_uvw, max_err): """ Raises informative exception for an invalid decomposition """ start = 0 problem_str = [] for ci, chunk in enumerate(chunks...
Raises an informative error for missing antenna def _raise_missing_antenna_errors(ant_uvw, max_err): """ Raises an informative error for missing antenna """ # Find antenna uvw coordinates where any UVW component was nan # nan + real == nan problems = np.nonzero(np.add.reduce(np.isnan(ant_uvw), axis=2)...
Computes per-antenna UVW coordinates from baseline ``uvw``, ``antenna1`` and ``antenna2`` coordinates logically grouped into baseline chunks. The example below illustrates two baseline chunks of size 6 and 5, respectively. .. code-block:: python uvw = ... ant1 = np.array([0, 0, 0,...
Returns a dictionary mapping source types to number of sources. If the number of sources for the source type is supplied in the kwargs these will be placed in the dictionary. e.g. if we have 'point', 'gaussian' and 'sersic' source types, then default_sources(point=10, gaussian=20) will re...
Converts a source type to number of sources mapping into a source numbering variable to number of sources mapping. If, for example, we have 'point', 'gaussian' and 'sersic' source types, then passing the following dict as an argument sources_to_nr_vars({'point':10, 'gaussian': 20}) will return an...
Given a range of source numbers, as well as a dictionary containing the numbers of each source, returns a dictionary containing tuples of the start and end index for each source variable type. def source_range_tuple(start, end, nr_var_dict): """ Given a range of source numbers, as well as a diction...
Given a range of source numbers, as well as a dictionary containing the numbers of each source, returns a dictionary containing tuples of the start and end index for each source variable type. def source_range(start, end, nr_var_dict): """ Given a range of source numbers, as well as a dictionary ...
Given a range of source numbers, as well as a dictionary containing the numbers of each source, returns a dictionary containing slices for each source variable type. def source_range_slices(start, end, nr_var_dict): """ Given a range of source numbers, as well as a dictionary containing the numbers...
Return a lm coordinate array to montblanc def point_lm(self, context): """ Return a lm coordinate array to montblanc """ lm = np.empty(context.shape, context.dtype) # Print the array schema montblanc.log.info(context.array_schema.shape) # Print the space of iteration mo...
Return a stokes parameter array to montblanc def point_stokes(self, context): """ Return a stokes parameter array to montblanc """ stokes = np.empty(context.shape, context.dtype) stokes[:,:,0] = 1 stokes[:,:,1:4] = 0 return stokes
Return a reference frequency array to montblanc def ref_frequency(self, context): """ Return a reference frequency array to montblanc """ ref_freq = np.empty(context.shape, context.dtype) ref_freq[:] = 1.415e9 return ref_freq
Update this authorization. :param list scopes: (optional), replaces the authorization scopes with these :param list add_scopes: (optional), scopes to be added :param list rm_scopes: (optional), scopes to be removed :param str note: (optional), new note about authorization ...
Iterate over the labels for every issue associated with this milestone. .. versionchanged:: 0.9 Add etag parameter. :param int number: (optional), number of labels to return. Default: -1 returns all available labels. :param str etag: (optional), ETag header fro...
Get reference to currently running function from inspect/trace stack frame. Parameters ---------- frame : stack frame Stack frame obtained via trace or inspect Returns ------- fnc : function reference Currently running function def current_function(frame): """ Get referenc...
Get name of module of currently running function from inspect/trace stack frame. Parameters ---------- frame : stack frame Stack frame obtained via trace or inspect Returns ------- modname : string Currently running function module name def current_module_name(frame): """ ...
Build a record of called functions using the trace mechanism def _trace(self, frame, event, arg): """ Build a record of called functions using the trace mechanism """ # Return if this is not a function call if event != 'call': return # Filter calling and ca...
Stop tracing def stop(self): """Stop tracing""" # Stop tracing sys.settrace(None) # Build group structure if group filter is defined if self.grpflt is not None: # Iterate over graph nodes (functions) for k in self.fncts: # Construct grou...
Default colour generating function Parameters ---------- n : int Number of colours to generate h0 : float Initial H value in HSV colour specification hr : float Size of H value range to use for colour generation (final H value is h0 + hr)...
Construct call graph Parameters ---------- fnm : None or string, optional (default None) Filename of graph file to be written. File type is determined by the file extentions (e.g. dot for 'graph.dot' and SVG for 'graph.svg'). If None, a file is not written. ...
Create a review comment on this pull request. All parameters are required by the GitHub API. :param str body: The comment text itself :param str commit_id: The SHA of the commit to comment on :param str path: The relative path of the file to comment on :param int position: The ...
Return the diff def diff(self): """Return the diff""" resp = self._get(self._api, headers={'Accept': 'application/vnd.github.diff'}) return resp.content if self._boolean(resp, 200, 404) else None
Checks to see if the pull request was merged. :returns: bool def is_merged(self): """Checks to see if the pull request was merged. :returns: bool """ url = self._build_url('merge', base_url=self._api) return self._boolean(self._get(url), 204, 404)
Iterate over the comments on this pull request. :param int number: (optional), number of comments to return. Default: -1 returns all available comments. :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`ReviewCo...
Iterate over the files associated with this pull request. :param int number: (optional), number of files to return. Default: -1 returns all available files. :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Pull...
Iterate over the issue comments on this pull request. :param int number: (optional), number of comments to return. Default: -1 returns all available comments. :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Is...
Merge this pull request. :param str commit_message: (optional), message to be used for the merge commit :returns: bool def merge(self, commit_message='', sha=None): """Merge this pull request. :param str commit_message: (optional), message to be used for the me...
Return the patch def patch(self): """Return the patch""" resp = self._get(self._api, headers={'Accept': 'application/vnd.github.patch'}) return resp.content if self._boolean(resp, 200, 404) else None
Update this pull request. :param str title: (optional), title of the pull :param str body: (optional), body of the pull request :param str state: (optional), ('open', 'closed') :returns: bool def update(self, title=None, body=None, state=None): """Update this pull request. ...
Reply to this review comment with a new review comment. :param str body: The text of the comment. :returns: The created review comment. :rtype: :class:`~github3.pulls.ReviewComment` def reply(self, body): """Reply to this review comment with a new review comment. :param str bo...
Add ``login`` to this team. :returns: bool def add_member(self, login): """Add ``login`` to this team. :returns: bool """ warnings.warn( 'This is no longer supported by the GitHub API, see ' 'https://developer.github.com/changes/2014-09-23-one-more-week...
Add ``repo`` to this team. :param str repo: (required), form: 'user/repo' :returns: bool def add_repo(self, repo): """Add ``repo`` to this team. :param str repo: (required), form: 'user/repo' :returns: bool """ url = self._build_url('repos', repo, base_url=self...
Edit this team. :param str name: (required) :param str permission: (optional), ('pull', 'push', 'admin') :returns: bool def edit(self, name, permission=''): """Edit this team. :param str name: (required) :param str permission: (optional), ('pull', 'push', 'admin') ...
Checks if this team has access to ``repo`` :param str repo: (required), form: 'user/repo' :returns: bool def has_repo(self, repo): """Checks if this team has access to ``repo`` :param str repo: (required), form: 'user/repo' :returns: bool """ url = self._build_...
Invite the user to join this team. This returns a dictionary like so:: {'state': 'pending', 'url': 'https://api.github.com/teams/...'} :param str username: (required), user to invite to join this team. :returns: dictionary def invite(self, username): """Invite the user to...
Retrieve the membership information for the user. :param str username: (required), name of the user :returns: dictionary def membership_for(self, username): """Retrieve the membership information for the user. :param str username: (required), name of the user :returns: diction...
Remove ``login`` from this team. :param str login: (required), login of the member to remove :returns: bool def remove_member(self, login): """Remove ``login`` from this team. :param str login: (required), login of the member to remove :returns: bool """ warnin...
Revoke this user's team membership. :param str username: (required), name of the team member :returns: bool def revoke_membership(self, username): """Revoke this user's team membership. :param str username: (required), name of the team member :returns: bool """ ...
Remove ``repo`` from this team. :param str repo: (required), form: 'user/repo' :returns: bool def remove_repo(self, repo): """Remove ``repo`` from this team. :param str repo: (required), form: 'user/repo' :returns: bool """ url = self._build_url('repos', repo, ...
Add ``login`` to ``team`` and thereby to this organization. .. warning:: This method is no longer valid. To add a member to a team, you must now retrieve the team directly, and use the ``invite`` method. Any user that is to be added to an organization, must be added...
Add ``repo`` to ``team``. .. note:: This method is of complexity O(n). This iterates over all teams in your organization and only adds the repo when the team name matches the team parameter above. If you want constant time, you should retrieve the team and call `...
Create a repository for this organization if the authenticated user is a member. :param str name: (required), name of the repository :param str description: (optional) :param str homepage: (optional) :param bool private: (optional), If ``True``, create a private repo...
Conceal ``login``'s membership in this organization. :returns: bool def conceal_member(self, login): """Conceal ``login``'s membership in this organization. :returns: bool """ url = self._build_url('public_members', login, base_url=self._api) return self._boolean(self....
Assuming the authenticated user owns this organization, create and return a new team. :param str name: (required), name to be given to the team :param list repo_names: (optional) repositories, e.g. ['github/dotfiles'] :param str permission: (optional), options: ...
Edit this organization. :param str billing_email: (optional) Billing email address (private) :param str company: (optional) :param str email: (optional) Public email address :param str location: (optional) :param str name: (optional) :returns: bool def edit(self, ...
Check if the user with login ``login`` is a public member. :returns: bool def is_public_member(self, login): """Check if the user with login ``login`` is a public member. :returns: bool """ url = self._build_url('public_members', login, base_url=self._api) return self....
Iterate over repos for this organization. :param str type: (optional), accepted values: ('all', 'public', 'member', 'private', 'forks', 'sources'), API default: 'all' :param int number: (optional), number of members to return. Default: -1 will return all available. ...
Iterate over teams that are part of this organization. :param int number: (optional), number of teams to return. Default: -1 returns all available teams. :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Team <T...
Make ``login``'s membership in this organization public. :returns: bool def publicize_member(self, login): """Make ``login``'s membership in this organization public. :returns: bool """ url = self._build_url('public_members', login, base_url=self._api) return self._boo...
Remove ``repo`` from ``team``. :param str repo: (required), form: 'user/repo' :param str team: (required) :returns: bool def remove_repo(self, repo, team): """Remove ``repo`` from ``team``. :param str repo: (required), form: 'user/repo' :param str team: (required) ...
Returns Team object with information about team specified by ``team_id``. :param int team_id: (required), unique id for the team :returns: :class:`Team <Team>` def team(self, team_id): """Returns Team object with information about team specified by ``team_id``. :param ...
Edit the user's membership. :param str state: (required), the state the membership should be in. Only accepts ``"active"``. :returns: itself def edit(self, state): """Edit the user's membership. :param str state: (required), the state the membership should be in. ...
Users with push access to the repository can delete a release. :returns: True if successful; False if not successful def delete(self): """Users with push access to the repository can delete a release. :returns: True if successful; False if not successful """ url = self._api ...
Users with push access to the repository can edit a release. If the edit is successful, this object will update itself. :param str tag_name: (optional), Name of the tag to use :param str target_commitish: (optional), The "commitish" value that determines where the Git tag is create...