repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
BerkeleyAutomation/autolab_core
autolab_core/experiment_logger.py
ExperimentLogger.gen_experiment_ref
def gen_experiment_ref(experiment_tag, n=10): """ Generate a random string for naming. Parameters ---------- experiment_tag : :obj:`str` tag to prefix name with n : int number of random chars to use Returns ------- :obj:`str` ...
python
def gen_experiment_ref(experiment_tag, n=10): """ Generate a random string for naming. Parameters ---------- experiment_tag : :obj:`str` tag to prefix name with n : int number of random chars to use Returns ------- :obj:`str` ...
[ "def", "gen_experiment_ref", "(", "experiment_tag", ",", "n", "=", "10", ")", ":", "experiment_id", "=", "gen_experiment_id", "(", "n", "=", "n", ")", "return", "'{0}_{1}'", ".", "format", "(", "experiment_tag", ",", "experiment_id", ")" ]
Generate a random string for naming. Parameters ---------- experiment_tag : :obj:`str` tag to prefix name with n : int number of random chars to use Returns ------- :obj:`str` string experiment ref
[ "Generate", "a", "random", "string", "for", "naming", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/experiment_logger.py#L82-L98
train
BerkeleyAutomation/autolab_core
autolab_core/tensor_dataset.py
Tensor.add
def add(self, datapoint): """ Adds the datapoint to the tensor if room is available. """ if not self.is_full: self.set_datapoint(self.cur_index, datapoint) self.cur_index += 1
python
def add(self, datapoint): """ Adds the datapoint to the tensor if room is available. """ if not self.is_full: self.set_datapoint(self.cur_index, datapoint) self.cur_index += 1
[ "def", "add", "(", "self", ",", "datapoint", ")", ":", "if", "not", "self", ".", "is_full", ":", "self", ".", "set_datapoint", "(", "self", ".", "cur_index", ",", "datapoint", ")", "self", ".", "cur_index", "+=", "1" ]
Adds the datapoint to the tensor if room is available.
[ "Adds", "the", "datapoint", "to", "the", "tensor", "if", "room", "is", "available", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/tensor_dataset.py#L121-L125
train
BerkeleyAutomation/autolab_core
autolab_core/tensor_dataset.py
Tensor.add_batch
def add_batch(self, datapoints): """ Adds a batch of datapoints to the tensor if room is available. """ num_datapoints_to_add = datapoints.shape[0] end_index = self.cur_index + num_datapoints_to_add if end_index <= self.num_datapoints: self.data[self.cur_index:end_index,...] ...
python
def add_batch(self, datapoints): """ Adds a batch of datapoints to the tensor if room is available. """ num_datapoints_to_add = datapoints.shape[0] end_index = self.cur_index + num_datapoints_to_add if end_index <= self.num_datapoints: self.data[self.cur_index:end_index,...] ...
[ "def", "add_batch", "(", "self", ",", "datapoints", ")", ":", "num_datapoints_to_add", "=", "datapoints", ".", "shape", "[", "0", "]", "end_index", "=", "self", ".", "cur_index", "+", "num_datapoints_to_add", "if", "end_index", "<=", "self", ".", "num_datapoin...
Adds a batch of datapoints to the tensor if room is available.
[ "Adds", "a", "batch", "of", "datapoints", "to", "the", "tensor", "if", "room", "is", "available", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/tensor_dataset.py#L127-L133
train
BerkeleyAutomation/autolab_core
autolab_core/tensor_dataset.py
Tensor.datapoint
def datapoint(self, ind): """ Returns the datapoint at the given index. """ if self.height is None: return self.data[ind] return self.data[ind, ...].copy()
python
def datapoint(self, ind): """ Returns the datapoint at the given index. """ if self.height is None: return self.data[ind] return self.data[ind, ...].copy()
[ "def", "datapoint", "(", "self", ",", "ind", ")", ":", "if", "self", ".", "height", "is", "None", ":", "return", "self", ".", "data", "[", "ind", "]", "return", "self", ".", "data", "[", "ind", ",", "...", "]", ".", "copy", "(", ")" ]
Returns the datapoint at the given index.
[ "Returns", "the", "datapoint", "at", "the", "given", "index", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/tensor_dataset.py#L141-L145
train
BerkeleyAutomation/autolab_core
autolab_core/tensor_dataset.py
Tensor.set_datapoint
def set_datapoint(self, ind, datapoint): """ Sets the value of the datapoint at the given index. """ if ind >= self.num_datapoints: raise ValueError('Index %d out of bounds! Tensor has %d datapoints' %(ind, self.num_datapoints)) self.data[ind, ...] = np.array(datapoint).astype(self.d...
python
def set_datapoint(self, ind, datapoint): """ Sets the value of the datapoint at the given index. """ if ind >= self.num_datapoints: raise ValueError('Index %d out of bounds! Tensor has %d datapoints' %(ind, self.num_datapoints)) self.data[ind, ...] = np.array(datapoint).astype(self.d...
[ "def", "set_datapoint", "(", "self", ",", "ind", ",", "datapoint", ")", ":", "if", "ind", ">=", "self", ".", "num_datapoints", ":", "raise", "ValueError", "(", "'Index %d out of bounds! Tensor has %d datapoints'", "%", "(", "ind", ",", "self", ".", "num_datapoin...
Sets the value of the datapoint at the given index.
[ "Sets", "the", "value", "of", "the", "datapoint", "at", "the", "given", "index", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/tensor_dataset.py#L147-L151
train
BerkeleyAutomation/autolab_core
autolab_core/tensor_dataset.py
Tensor.data_slice
def data_slice(self, slice_ind): """ Returns a slice of datapoints """ if self.height is None: return self.data[slice_ind] return self.data[slice_ind, ...]
python
def data_slice(self, slice_ind): """ Returns a slice of datapoints """ if self.height is None: return self.data[slice_ind] return self.data[slice_ind, ...]
[ "def", "data_slice", "(", "self", ",", "slice_ind", ")", ":", "if", "self", ".", "height", "is", "None", ":", "return", "self", ".", "data", "[", "slice_ind", "]", "return", "self", ".", "data", "[", "slice_ind", ",", "...", "]" ]
Returns a slice of datapoints
[ "Returns", "a", "slice", "of", "datapoints" ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/tensor_dataset.py#L153-L157
train
BerkeleyAutomation/autolab_core
autolab_core/tensor_dataset.py
Tensor.save
def save(self, filename, compressed=True): """ Save a tensor to disk. """ # check for data if not self.has_data: return False # read ext and save accordingly _, file_ext = os.path.splitext(filename) if compressed: if file_ext != COMPRESSED_TENSOR_...
python
def save(self, filename, compressed=True): """ Save a tensor to disk. """ # check for data if not self.has_data: return False # read ext and save accordingly _, file_ext = os.path.splitext(filename) if compressed: if file_ext != COMPRESSED_TENSOR_...
[ "def", "save", "(", "self", ",", "filename", ",", "compressed", "=", "True", ")", ":", "# check for data", "if", "not", "self", ".", "has_data", ":", "return", "False", "# read ext and save accordingly", "_", ",", "file_ext", "=", "os", ".", "path", ".", "...
Save a tensor to disk.
[ "Save", "a", "tensor", "to", "disk", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/tensor_dataset.py#L159-L176
train
BerkeleyAutomation/autolab_core
autolab_core/tensor_dataset.py
Tensor.load
def load(filename, compressed=True, prealloc=None): """ Loads a tensor from disk. """ # switch load based on file ext _, file_ext = os.path.splitext(filename) if compressed: if file_ext != COMPRESSED_TENSOR_EXT: raise ValueError('Can only load compressed tenso...
python
def load(filename, compressed=True, prealloc=None): """ Loads a tensor from disk. """ # switch load based on file ext _, file_ext = os.path.splitext(filename) if compressed: if file_ext != COMPRESSED_TENSOR_EXT: raise ValueError('Can only load compressed tenso...
[ "def", "load", "(", "filename", ",", "compressed", "=", "True", ",", "prealloc", "=", "None", ")", ":", "# switch load based on file ext", "_", ",", "file_ext", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "if", "compressed", ":", "if", ...
Loads a tensor from disk.
[ "Loads", "a", "tensor", "from", "disk", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/tensor_dataset.py#L179-L200
train
BerkeleyAutomation/autolab_core
autolab_core/tensor_dataset.py
TensorDataset.datapoint_indices_for_tensor
def datapoint_indices_for_tensor(self, tensor_index): """ Returns the indices for all datapoints in the given tensor. """ if tensor_index >= self._num_tensors: raise ValueError('Tensor index %d is greater than the number of tensors (%d)' %(tensor_index, self._num_tensors)) return sel...
python
def datapoint_indices_for_tensor(self, tensor_index): """ Returns the indices for all datapoints in the given tensor. """ if tensor_index >= self._num_tensors: raise ValueError('Tensor index %d is greater than the number of tensors (%d)' %(tensor_index, self._num_tensors)) return sel...
[ "def", "datapoint_indices_for_tensor", "(", "self", ",", "tensor_index", ")", ":", "if", "tensor_index", ">=", "self", ".", "_num_tensors", ":", "raise", "ValueError", "(", "'Tensor index %d is greater than the number of tensors (%d)'", "%", "(", "tensor_index", ",", "s...
Returns the indices for all datapoints in the given tensor.
[ "Returns", "the", "indices", "for", "all", "datapoints", "in", "the", "given", "tensor", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/tensor_dataset.py#L415-L419
train
BerkeleyAutomation/autolab_core
autolab_core/tensor_dataset.py
TensorDataset.tensor_index
def tensor_index(self, datapoint_index): """ Returns the index of the tensor containing the referenced datapoint. """ if datapoint_index >= self._num_datapoints: raise ValueError('Datapoint index %d is greater than the number of datapoints (%d)' %(datapoint_index, self._num_datapoints)) ...
python
def tensor_index(self, datapoint_index): """ Returns the index of the tensor containing the referenced datapoint. """ if datapoint_index >= self._num_datapoints: raise ValueError('Datapoint index %d is greater than the number of datapoints (%d)' %(datapoint_index, self._num_datapoints)) ...
[ "def", "tensor_index", "(", "self", ",", "datapoint_index", ")", ":", "if", "datapoint_index", ">=", "self", ".", "_num_datapoints", ":", "raise", "ValueError", "(", "'Datapoint index %d is greater than the number of datapoints (%d)'", "%", "(", "datapoint_index", ",", ...
Returns the index of the tensor containing the referenced datapoint.
[ "Returns", "the", "index", "of", "the", "tensor", "containing", "the", "referenced", "datapoint", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/tensor_dataset.py#L421-L425
train
BerkeleyAutomation/autolab_core
autolab_core/tensor_dataset.py
TensorDataset.generate_tensor_filename
def generate_tensor_filename(self, field_name, file_num, compressed=True): """ Generate a filename for a tensor. """ file_ext = TENSOR_EXT if compressed: file_ext = COMPRESSED_TENSOR_EXT filename = os.path.join(self.filename, 'tensors', '%s_%05d%s' %(field_name, file_num, fil...
python
def generate_tensor_filename(self, field_name, file_num, compressed=True): """ Generate a filename for a tensor. """ file_ext = TENSOR_EXT if compressed: file_ext = COMPRESSED_TENSOR_EXT filename = os.path.join(self.filename, 'tensors', '%s_%05d%s' %(field_name, file_num, fil...
[ "def", "generate_tensor_filename", "(", "self", ",", "field_name", ",", "file_num", ",", "compressed", "=", "True", ")", ":", "file_ext", "=", "TENSOR_EXT", "if", "compressed", ":", "file_ext", "=", "COMPRESSED_TENSOR_EXT", "filename", "=", "os", ".", "path", ...
Generate a filename for a tensor.
[ "Generate", "a", "filename", "for", "a", "tensor", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/tensor_dataset.py#L427-L433
train
BerkeleyAutomation/autolab_core
autolab_core/tensor_dataset.py
TensorDataset._allocate_tensors
def _allocate_tensors(self): """ Allocates the tensors in the dataset. """ # init tensors dict self._tensors = {} # allocate tensor for each data field for field_name, field_spec in self._config['fields'].items(): # parse attributes field_dtype = np.dtype...
python
def _allocate_tensors(self): """ Allocates the tensors in the dataset. """ # init tensors dict self._tensors = {} # allocate tensor for each data field for field_name, field_spec in self._config['fields'].items(): # parse attributes field_dtype = np.dtype...
[ "def", "_allocate_tensors", "(", "self", ")", ":", "# init tensors dict", "self", ".", "_tensors", "=", "{", "}", "# allocate tensor for each data field", "for", "field_name", ",", "field_spec", "in", "self", ".", "_config", "[", "'fields'", "]", ".", "items", "...
Allocates the tensors in the dataset.
[ "Allocates", "the", "tensors", "in", "the", "dataset", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/tensor_dataset.py#L459-L479
train
BerkeleyAutomation/autolab_core
autolab_core/tensor_dataset.py
TensorDataset.add
def add(self, datapoint): """ Adds a datapoint to the file. """ # check access level if self._access_mode == READ_ONLY_ACCESS: raise ValueError('Cannot add datapoints with read-only access') # read tensor datapoint ind tensor_ind = self._num_datapoints // self._datap...
python
def add(self, datapoint): """ Adds a datapoint to the file. """ # check access level if self._access_mode == READ_ONLY_ACCESS: raise ValueError('Cannot add datapoints with read-only access') # read tensor datapoint ind tensor_ind = self._num_datapoints // self._datap...
[ "def", "add", "(", "self", ",", "datapoint", ")", ":", "# check access level", "if", "self", ".", "_access_mode", "==", "READ_ONLY_ACCESS", ":", "raise", "ValueError", "(", "'Cannot add datapoints with read-only access'", ")", "# read tensor datapoint ind", "tensor_ind", ...
Adds a datapoint to the file.
[ "Adds", "a", "datapoint", "to", "the", "file", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/tensor_dataset.py#L481-L527
train
BerkeleyAutomation/autolab_core
autolab_core/tensor_dataset.py
TensorDataset.datapoint
def datapoint(self, ind, field_names=None): """ Loads a tensor datapoint for a given global index. Parameters ---------- ind : int global index in the tensor field_names : :obj:`list` of str field names to load Returns ------- :ob...
python
def datapoint(self, ind, field_names=None): """ Loads a tensor datapoint for a given global index. Parameters ---------- ind : int global index in the tensor field_names : :obj:`list` of str field names to load Returns ------- :ob...
[ "def", "datapoint", "(", "self", ",", "ind", ",", "field_names", "=", "None", ")", ":", "# flush if necessary", "if", "self", ".", "_has_unsaved_data", ":", "self", ".", "flush", "(", ")", "# check valid input", "if", "ind", ">=", "self", ".", "_num_datapoin...
Loads a tensor datapoint for a given global index. Parameters ---------- ind : int global index in the tensor field_names : :obj:`list` of str field names to load Returns ------- :obj:`TensorDatapoint` the desired tensor datap...
[ "Loads", "a", "tensor", "datapoint", "for", "a", "given", "global", "index", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/tensor_dataset.py#L533-L567
train
BerkeleyAutomation/autolab_core
autolab_core/tensor_dataset.py
TensorDataset.tensor
def tensor(self, field_name, tensor_ind): """ Returns the tensor for a given field and tensor index. Parameters ---------- field_name : str the name of the field to load tensor_index : int the index of the tensor Returns ------- :...
python
def tensor(self, field_name, tensor_ind): """ Returns the tensor for a given field and tensor index. Parameters ---------- field_name : str the name of the field to load tensor_index : int the index of the tensor Returns ------- :...
[ "def", "tensor", "(", "self", ",", "field_name", ",", "tensor_ind", ")", ":", "if", "tensor_ind", "==", "self", ".", "_tensor_cache_file_num", "[", "field_name", "]", ":", "return", "self", ".", "_tensors", "[", "field_name", "]", "filename", "=", "self", ...
Returns the tensor for a given field and tensor index. Parameters ---------- field_name : str the name of the field to load tensor_index : int the index of the tensor Returns ------- :obj:`Tensor` the desired tensor
[ "Returns", "the", "tensor", "for", "a", "given", "field", "and", "tensor", "index", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/tensor_dataset.py#L569-L590
train
BerkeleyAutomation/autolab_core
autolab_core/tensor_dataset.py
TensorDataset.delete_last
def delete_last(self, num_to_delete=1): """ Deletes the last N datapoints from the dataset. Parameters ---------- num_to_delete : int the number of datapoints to remove from the end of the dataset """ # check access level if self._access_mode == READ_...
python
def delete_last(self, num_to_delete=1): """ Deletes the last N datapoints from the dataset. Parameters ---------- num_to_delete : int the number of datapoints to remove from the end of the dataset """ # check access level if self._access_mode == READ_...
[ "def", "delete_last", "(", "self", ",", "num_to_delete", "=", "1", ")", ":", "# check access level", "if", "self", ".", "_access_mode", "==", "READ_ONLY_ACCESS", ":", "raise", "ValueError", "(", "'Cannot delete datapoints with read-only access'", ")", "# check num to de...
Deletes the last N datapoints from the dataset. Parameters ---------- num_to_delete : int the number of datapoints to remove from the end of the dataset
[ "Deletes", "the", "last", "N", "datapoints", "from", "the", "dataset", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/tensor_dataset.py#L617-L677
train
BerkeleyAutomation/autolab_core
autolab_core/tensor_dataset.py
TensorDataset.write
def write(self): """ Writes all tensors to the next file number. """ # write the next file for all fields for field_name in self.field_names: filename = self.generate_tensor_filename(field_name, self._num_tensors-1) self._tensors[field_name].save(filename, compressed=True...
python
def write(self): """ Writes all tensors to the next file number. """ # write the next file for all fields for field_name in self.field_names: filename = self.generate_tensor_filename(field_name, self._num_tensors-1) self._tensors[field_name].save(filename, compressed=True...
[ "def", "write", "(", "self", ")", ":", "# write the next file for all fields", "for", "field_name", "in", "self", ".", "field_names", ":", "filename", "=", "self", ".", "generate_tensor_filename", "(", "field_name", ",", "self", ".", "_num_tensors", "-", "1", ")...
Writes all tensors to the next file number.
[ "Writes", "all", "tensors", "to", "the", "next", "file", "number", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/tensor_dataset.py#L696-L709
train
BerkeleyAutomation/autolab_core
autolab_core/tensor_dataset.py
TensorDataset.open
def open(dataset_dir, access_mode=READ_ONLY_ACCESS): """ Opens a tensor dataset. """ # check access mode if access_mode == WRITE_ACCESS: raise ValueError('Cannot open a dataset with write-only access') # read config try: # json load config_fil...
python
def open(dataset_dir, access_mode=READ_ONLY_ACCESS): """ Opens a tensor dataset. """ # check access mode if access_mode == WRITE_ACCESS: raise ValueError('Cannot open a dataset with write-only access') # read config try: # json load config_fil...
[ "def", "open", "(", "dataset_dir", ",", "access_mode", "=", "READ_ONLY_ACCESS", ")", ":", "# check access mode", "if", "access_mode", "==", "WRITE_ACCESS", ":", "raise", "ValueError", "(", "'Cannot open a dataset with write-only access'", ")", "# read config", "try", ":...
Opens a tensor dataset.
[ "Opens", "a", "tensor", "dataset", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/tensor_dataset.py#L716-L734
train
BerkeleyAutomation/autolab_core
autolab_core/tensor_dataset.py
TensorDataset.split
def split(self, split_name): """ Return the training and validation indices for the requested split. Parameters ---------- split_name : str name of the split Returns ------- :obj:`numpy.ndarray` array of training indices in the global dat...
python
def split(self, split_name): """ Return the training and validation indices for the requested split. Parameters ---------- split_name : str name of the split Returns ------- :obj:`numpy.ndarray` array of training indices in the global dat...
[ "def", "split", "(", "self", ",", "split_name", ")", ":", "if", "not", "self", ".", "has_split", "(", "split_name", ")", ":", "raise", "ValueError", "(", "'Split %s does not exist!'", "%", "(", "split_name", ")", ")", "metadata_filename", "=", "self", ".", ...
Return the training and validation indices for the requested split. Parameters ---------- split_name : str name of the split Returns ------- :obj:`numpy.ndarray` array of training indices in the global dataset :obj:`numpy.ndarray` ...
[ "Return", "the", "training", "and", "validation", "indices", "for", "the", "requested", "split", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/tensor_dataset.py#L736-L762
train
BerkeleyAutomation/autolab_core
autolab_core/tensor_dataset.py
TensorDataset.delete_split
def delete_split(self, split_name): """ Delete a split of the dataset. Parameters ---------- split_name : str name of the split to delete """ if self.has_split(split_name): shutil.rmtree(os.path.join(self.split_dir, split_name))
python
def delete_split(self, split_name): """ Delete a split of the dataset. Parameters ---------- split_name : str name of the split to delete """ if self.has_split(split_name): shutil.rmtree(os.path.join(self.split_dir, split_name))
[ "def", "delete_split", "(", "self", ",", "split_name", ")", ":", "if", "self", ".", "has_split", "(", "split_name", ")", ":", "shutil", ".", "rmtree", "(", "os", ".", "path", ".", "join", "(", "self", ".", "split_dir", ",", "split_name", ")", ")" ]
Delete a split of the dataset. Parameters ---------- split_name : str name of the split to delete
[ "Delete", "a", "split", "of", "the", "dataset", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/tensor_dataset.py#L878-L887
train
BerkeleyAutomation/autolab_core
autolab_core/yaml_config.py
YamlConfig._load_config
def _load_config(self, filename): """Loads a yaml configuration file from the given filename. Parameters ---------- filename : :obj:`str` The filename of the .yaml file that contains the configuration. """ # Read entire file for metadata fh = open(fil...
python
def _load_config(self, filename): """Loads a yaml configuration file from the given filename. Parameters ---------- filename : :obj:`str` The filename of the .yaml file that contains the configuration. """ # Read entire file for metadata fh = open(fil...
[ "def", "_load_config", "(", "self", ",", "filename", ")", ":", "# Read entire file for metadata", "fh", "=", "open", "(", "filename", ",", "'r'", ")", "self", ".", "file_contents", "=", "fh", ".", "read", "(", ")", "# Replace !include directives with content", "...
Loads a yaml configuration file from the given filename. Parameters ---------- filename : :obj:`str` The filename of the .yaml file that contains the configuration.
[ "Loads", "a", "yaml", "configuration", "file", "from", "the", "given", "filename", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/yaml_config.py#L75-L126
train
BerkeleyAutomation/autolab_core
autolab_core/yaml_config.py
YamlConfig.__convert_key
def __convert_key(expression): """Converts keys in YAML that reference other keys. """ if type(expression) is str and len(expression) > 2 and expression[1] == '!': expression = eval(expression[2:-1]) return expression
python
def __convert_key(expression): """Converts keys in YAML that reference other keys. """ if type(expression) is str and len(expression) > 2 and expression[1] == '!': expression = eval(expression[2:-1]) return expression
[ "def", "__convert_key", "(", "expression", ")", ":", "if", "type", "(", "expression", ")", "is", "str", "and", "len", "(", "expression", ")", ">", "2", "and", "expression", "[", "1", "]", "==", "'!'", ":", "expression", "=", "eval", "(", "expression", ...
Converts keys in YAML that reference other keys.
[ "Converts", "keys", "in", "YAML", "that", "reference", "other", "keys", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/yaml_config.py#L129-L134
train
BerkeleyAutomation/autolab_core
autolab_core/learning_analysis.py
ClassificationResult.make_summary_table
def make_summary_table(train_result, val_result, plot=True, save_dir=None, prepend="", save=False): """ Makes a matplotlib table object with relevant data. Thanks to Lucas Manuelli for the contribution. Parameters ---------- train_result: ClassificationResult ...
python
def make_summary_table(train_result, val_result, plot=True, save_dir=None, prepend="", save=False): """ Makes a matplotlib table object with relevant data. Thanks to Lucas Manuelli for the contribution. Parameters ---------- train_result: ClassificationResult ...
[ "def", "make_summary_table", "(", "train_result", ",", "val_result", ",", "plot", "=", "True", ",", "save_dir", "=", "None", ",", "prepend", "=", "\"\"", ",", "save", "=", "False", ")", ":", "table_key_list", "=", "[", "'error_rate'", ",", "'recall_at_99_pre...
Makes a matplotlib table object with relevant data. Thanks to Lucas Manuelli for the contribution. Parameters ---------- train_result: ClassificationResult result on train split val_result: ClassificationResult result on validation split save_di...
[ "Makes", "a", "matplotlib", "table", "object", "with", "relevant", "data", ".", "Thanks", "to", "Lucas", "Manuelli", "for", "the", "contribution", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/learning_analysis.py#L236-L304
train
BerkeleyAutomation/autolab_core
autolab_core/learning_analysis.py
BinaryClassificationResult.app_score
def app_score(self): """ Computes the area under the app curve. """ # compute curve precisions, pct_pred_pos, taus = self.precision_pct_pred_pos_curve(interval=False) # compute area app = 0 total = 0 for k in range(len(precisions)-1): # read cur data ...
python
def app_score(self): """ Computes the area under the app curve. """ # compute curve precisions, pct_pred_pos, taus = self.precision_pct_pred_pos_curve(interval=False) # compute area app = 0 total = 0 for k in range(len(precisions)-1): # read cur data ...
[ "def", "app_score", "(", "self", ")", ":", "# compute curve", "precisions", ",", "pct_pred_pos", ",", "taus", "=", "self", ".", "precision_pct_pred_pos_curve", "(", "interval", "=", "False", ")", "# compute area", "app", "=", "0", "total", "=", "0", "for", "...
Computes the area under the app curve.
[ "Computes", "the", "area", "under", "the", "app", "curve", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/learning_analysis.py#L467-L492
train
BerkeleyAutomation/autolab_core
autolab_core/learning_analysis.py
BinaryClassificationResult.accuracy_curve
def accuracy_curve(self, delta_tau=0.01): """ Computes the relationship between probability threshold and classification accuracy. """ # compute thresholds based on the sorted probabilities orig_thresh = self.threshold sorted_labels, sorted_probs = self.sorted_values sco...
python
def accuracy_curve(self, delta_tau=0.01): """ Computes the relationship between probability threshold and classification accuracy. """ # compute thresholds based on the sorted probabilities orig_thresh = self.threshold sorted_labels, sorted_probs = self.sorted_values sco...
[ "def", "accuracy_curve", "(", "self", ",", "delta_tau", "=", "0.01", ")", ":", "# compute thresholds based on the sorted probabilities", "orig_thresh", "=", "self", ".", "threshold", "sorted_labels", ",", "sorted_probs", "=", "self", ".", "sorted_values", "scores", "=...
Computes the relationship between probability threshold and classification accuracy.
[ "Computes", "the", "relationship", "between", "probability", "threshold", "and", "classification", "accuracy", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/learning_analysis.py#L515-L541
train
BerkeleyAutomation/autolab_core
autolab_core/learning_analysis.py
BinaryClassificationResult.f1_curve
def f1_curve(self, delta_tau=0.01): """ Computes the relationship between probability threshold and classification F1 score. """ # compute thresholds based on the sorted probabilities orig_thresh = self.threshold sorted_labels, sorted_probs = self.sorted_values scores = ...
python
def f1_curve(self, delta_tau=0.01): """ Computes the relationship between probability threshold and classification F1 score. """ # compute thresholds based on the sorted probabilities orig_thresh = self.threshold sorted_labels, sorted_probs = self.sorted_values scores = ...
[ "def", "f1_curve", "(", "self", ",", "delta_tau", "=", "0.01", ")", ":", "# compute thresholds based on the sorted probabilities", "orig_thresh", "=", "self", ".", "threshold", "sorted_labels", ",", "sorted_probs", "=", "self", ".", "sorted_values", "scores", "=", "...
Computes the relationship between probability threshold and classification F1 score.
[ "Computes", "the", "relationship", "between", "probability", "threshold", "and", "classification", "F1", "score", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/learning_analysis.py#L599-L625
train
BerkeleyAutomation/autolab_core
autolab_core/learning_analysis.py
BinaryClassificationResult.phi_coef_curve
def phi_coef_curve(self, delta_tau=0.01): """ Computes the relationship between probability threshold and classification phi coefficient. """ # compute thresholds based on the sorted probabilities orig_thresh = self.threshold sorted_labels, sorted_probs = self.sorted_values ...
python
def phi_coef_curve(self, delta_tau=0.01): """ Computes the relationship between probability threshold and classification phi coefficient. """ # compute thresholds based on the sorted probabilities orig_thresh = self.threshold sorted_labels, sorted_probs = self.sorted_values ...
[ "def", "phi_coef_curve", "(", "self", ",", "delta_tau", "=", "0.01", ")", ":", "# compute thresholds based on the sorted probabilities", "orig_thresh", "=", "self", ".", "threshold", "sorted_labels", ",", "sorted_probs", "=", "self", ".", "sorted_values", "scores", "=...
Computes the relationship between probability threshold and classification phi coefficient.
[ "Computes", "the", "relationship", "between", "probability", "threshold", "and", "classification", "phi", "coefficient", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/learning_analysis.py#L627-L653
train
BerkeleyAutomation/autolab_core
autolab_core/learning_analysis.py
BinaryClassificationResult.precision_pct_pred_pos_curve
def precision_pct_pred_pos_curve(self, interval=False, delta_tau=0.001): """ Computes the relationship between precision and the percent of positively classified datapoints . """ # compute thresholds based on the sorted probabilities orig_thresh = self.threshold sorted_labels, so...
python
def precision_pct_pred_pos_curve(self, interval=False, delta_tau=0.001): """ Computes the relationship between precision and the percent of positively classified datapoints . """ # compute thresholds based on the sorted probabilities orig_thresh = self.threshold sorted_labels, so...
[ "def", "precision_pct_pred_pos_curve", "(", "self", ",", "interval", "=", "False", ",", "delta_tau", "=", "0.001", ")", ":", "# compute thresholds based on the sorted probabilities", "orig_thresh", "=", "self", ".", "threshold", "sorted_labels", ",", "sorted_probs", "="...
Computes the relationship between precision and the percent of positively classified datapoints .
[ "Computes", "the", "relationship", "between", "precision", "and", "the", "percent", "of", "positively", "classified", "datapoints", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/learning_analysis.py#L655-L700
train
BerkeleyAutomation/autolab_core
autolab_core/utils.py
gen_experiment_id
def gen_experiment_id(n=10): """Generate a random string with n characters. Parameters ---------- n : int The length of the string to be generated. Returns ------- :obj:`str` A string with only alphabetic characters. """ chrs = 'abcdefghijklmnopqrstuvwxyz' inds...
python
def gen_experiment_id(n=10): """Generate a random string with n characters. Parameters ---------- n : int The length of the string to be generated. Returns ------- :obj:`str` A string with only alphabetic characters. """ chrs = 'abcdefghijklmnopqrstuvwxyz' inds...
[ "def", "gen_experiment_id", "(", "n", "=", "10", ")", ":", "chrs", "=", "'abcdefghijklmnopqrstuvwxyz'", "inds", "=", "np", ".", "random", ".", "randint", "(", "0", ",", "len", "(", "chrs", ")", ",", "size", "=", "n", ")", "return", "''", ".", "join",...
Generate a random string with n characters. Parameters ---------- n : int The length of the string to be generated. Returns ------- :obj:`str` A string with only alphabetic characters.
[ "Generate", "a", "random", "string", "with", "n", "characters", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/utils.py#L11-L26
train
BerkeleyAutomation/autolab_core
autolab_core/utils.py
histogram
def histogram(values, num_bins, bounds, normalized=True, plot=False, color='b'): """Generate a histogram plot. Parameters ---------- values : :obj:`numpy.ndarray` An array of values to put in the histogram. num_bins : int The number equal-width bins in the histogram. bounds : ...
python
def histogram(values, num_bins, bounds, normalized=True, plot=False, color='b'): """Generate a histogram plot. Parameters ---------- values : :obj:`numpy.ndarray` An array of values to put in the histogram. num_bins : int The number equal-width bins in the histogram. bounds : ...
[ "def", "histogram", "(", "values", ",", "num_bins", ",", "bounds", ",", "normalized", "=", "True", ",", "plot", "=", "False", ",", "color", "=", "'b'", ")", ":", "hist", ",", "bins", "=", "np", ".", "histogram", "(", "values", ",", "bins", "=", "nu...
Generate a histogram plot. Parameters ---------- values : :obj:`numpy.ndarray` An array of values to put in the histogram. num_bins : int The number equal-width bins in the histogram. bounds : :obj:`tuple` of float Two floats - a min and a max - that define the lower and u...
[ "Generate", "a", "histogram", "plot", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/utils.py#L64-L102
train
BerkeleyAutomation/autolab_core
autolab_core/utils.py
skew
def skew(xi): """Return the skew-symmetric matrix that can be used to calculate cross-products with vector xi. Multiplying this matrix by a vector `v` gives the same result as `xi x v`. Parameters ---------- xi : :obj:`numpy.ndarray` of float A 3-entry vector. Returns ----...
python
def skew(xi): """Return the skew-symmetric matrix that can be used to calculate cross-products with vector xi. Multiplying this matrix by a vector `v` gives the same result as `xi x v`. Parameters ---------- xi : :obj:`numpy.ndarray` of float A 3-entry vector. Returns ----...
[ "def", "skew", "(", "xi", ")", ":", "S", "=", "np", ".", "array", "(", "[", "[", "0", ",", "-", "xi", "[", "2", "]", ",", "xi", "[", "1", "]", "]", ",", "[", "xi", "[", "2", "]", ",", "0", ",", "-", "xi", "[", "0", "]", "]", ",", ...
Return the skew-symmetric matrix that can be used to calculate cross-products with vector xi. Multiplying this matrix by a vector `v` gives the same result as `xi x v`. Parameters ---------- xi : :obj:`numpy.ndarray` of float A 3-entry vector. Returns ------- :obj:`numpy.n...
[ "Return", "the", "skew", "-", "symmetric", "matrix", "that", "can", "be", "used", "to", "calculate", "cross", "-", "products", "with", "vector", "xi", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/utils.py#L104-L124
train
BerkeleyAutomation/autolab_core
autolab_core/utils.py
deskew
def deskew(S): """Converts a skew-symmetric cross-product matrix to its corresponding vector. Only works for 3x3 matrices. Parameters ---------- S : :obj:`numpy.ndarray` of float A 3x3 skew-symmetric matrix. Returns ------- :obj:`numpy.ndarray` of float A 3-entry vector...
python
def deskew(S): """Converts a skew-symmetric cross-product matrix to its corresponding vector. Only works for 3x3 matrices. Parameters ---------- S : :obj:`numpy.ndarray` of float A 3x3 skew-symmetric matrix. Returns ------- :obj:`numpy.ndarray` of float A 3-entry vector...
[ "def", "deskew", "(", "S", ")", ":", "x", "=", "np", ".", "zeros", "(", "3", ")", "x", "[", "0", "]", "=", "S", "[", "2", ",", "1", "]", "x", "[", "1", "]", "=", "S", "[", "0", ",", "2", "]", "x", "[", "2", "]", "=", "S", "[", "1"...
Converts a skew-symmetric cross-product matrix to its corresponding vector. Only works for 3x3 matrices. Parameters ---------- S : :obj:`numpy.ndarray` of float A 3x3 skew-symmetric matrix. Returns ------- :obj:`numpy.ndarray` of float A 3-entry vector that corresponds to t...
[ "Converts", "a", "skew", "-", "symmetric", "cross", "-", "product", "matrix", "to", "its", "corresponding", "vector", ".", "Only", "works", "for", "3x3", "matrices", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/utils.py#L126-L144
train
BerkeleyAutomation/autolab_core
autolab_core/utils.py
reverse_dictionary
def reverse_dictionary(d): """ Reverses the key value pairs for a given dictionary. Parameters ---------- d : :obj:`dict` dictionary to reverse Returns ------- :obj:`dict` dictionary with keys and values swapped """ rev_d = {} [rev_d.update({v:k}) for k, v in d....
python
def reverse_dictionary(d): """ Reverses the key value pairs for a given dictionary. Parameters ---------- d : :obj:`dict` dictionary to reverse Returns ------- :obj:`dict` dictionary with keys and values swapped """ rev_d = {} [rev_d.update({v:k}) for k, v in d....
[ "def", "reverse_dictionary", "(", "d", ")", ":", "rev_d", "=", "{", "}", "[", "rev_d", ".", "update", "(", "{", "v", ":", "k", "}", ")", "for", "k", ",", "v", "in", "d", ".", "items", "(", ")", "]", "return", "rev_d" ]
Reverses the key value pairs for a given dictionary. Parameters ---------- d : :obj:`dict` dictionary to reverse Returns ------- :obj:`dict` dictionary with keys and values swapped
[ "Reverses", "the", "key", "value", "pairs", "for", "a", "given", "dictionary", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/utils.py#L146-L161
train
BerkeleyAutomation/autolab_core
autolab_core/utils.py
filenames
def filenames(directory, tag='', sorted=False, recursive=False): """ Reads in all filenames from a directory that contain a specified substring. Parameters ---------- directory : :obj:`str` the directory to read from tag : :obj:`str` optional tag to match in the filenames sorted...
python
def filenames(directory, tag='', sorted=False, recursive=False): """ Reads in all filenames from a directory that contain a specified substring. Parameters ---------- directory : :obj:`str` the directory to read from tag : :obj:`str` optional tag to match in the filenames sorted...
[ "def", "filenames", "(", "directory", ",", "tag", "=", "''", ",", "sorted", "=", "False", ",", "recursive", "=", "False", ")", ":", "if", "recursive", ":", "f", "=", "[", "os", ".", "path", ".", "join", "(", "directory", ",", "f", ")", "for", "di...
Reads in all filenames from a directory that contain a specified substring. Parameters ---------- directory : :obj:`str` the directory to read from tag : :obj:`str` optional tag to match in the filenames sorted : bool whether or not to sort the filenames recursive : bool...
[ "Reads", "in", "all", "filenames", "from", "a", "directory", "that", "contain", "a", "specified", "substring", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/utils.py#L178-L203
train
BerkeleyAutomation/autolab_core
autolab_core/utils.py
sph2cart
def sph2cart(r, az, elev): """ Convert spherical to cartesian coordinates. Attributes ---------- r : float radius az : float aziumth (angle about z axis) elev : float elevation from xy plane Returns ------- float x-coordinate float y-coor...
python
def sph2cart(r, az, elev): """ Convert spherical to cartesian coordinates. Attributes ---------- r : float radius az : float aziumth (angle about z axis) elev : float elevation from xy plane Returns ------- float x-coordinate float y-coor...
[ "def", "sph2cart", "(", "r", ",", "az", ",", "elev", ")", ":", "x", "=", "r", "*", "np", ".", "cos", "(", "az", ")", "*", "np", ".", "sin", "(", "elev", ")", "y", "=", "r", "*", "np", ".", "sin", "(", "az", ")", "*", "np", ".", "sin", ...
Convert spherical to cartesian coordinates. Attributes ---------- r : float radius az : float aziumth (angle about z axis) elev : float elevation from xy plane Returns ------- float x-coordinate float y-coordinate float z-coordina...
[ "Convert", "spherical", "to", "cartesian", "coordinates", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/utils.py#L205-L229
train
BerkeleyAutomation/autolab_core
autolab_core/utils.py
cart2sph
def cart2sph(x, y, z): """ Convert cartesian to spherical coordinates. Attributes ---------- x : float x-coordinate y : float y-coordinate z : float z-coordinate Returns ------- float radius float aziumth float elevation "...
python
def cart2sph(x, y, z): """ Convert cartesian to spherical coordinates. Attributes ---------- x : float x-coordinate y : float y-coordinate z : float z-coordinate Returns ------- float radius float aziumth float elevation "...
[ "def", "cart2sph", "(", "x", ",", "y", ",", "z", ")", ":", "r", "=", "np", ".", "sqrt", "(", "x", "**", "2", "+", "y", "**", "2", "+", "z", "**", "2", ")", "if", "x", ">", "0", "and", "y", ">", "0", ":", "az", "=", "np", ".", "arctan"...
Convert cartesian to spherical coordinates. Attributes ---------- x : float x-coordinate y : float y-coordinate z : float z-coordinate Returns ------- float radius float aziumth float elevation
[ "Convert", "cartesian", "to", "spherical", "coordinates", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/utils.py#L231-L270
train
BerkeleyAutomation/autolab_core
autolab_core/utils.py
keyboard_input
def keyboard_input(message, yesno=False): """ Get keyboard input from a human, optionally reasking for valid yes or no input. Parameters ---------- message : :obj:`str` the message to display to the user yesno : :obj:`bool` whether or not to enforce yes or no inputs Ret...
python
def keyboard_input(message, yesno=False): """ Get keyboard input from a human, optionally reasking for valid yes or no input. Parameters ---------- message : :obj:`str` the message to display to the user yesno : :obj:`bool` whether or not to enforce yes or no inputs Ret...
[ "def", "keyboard_input", "(", "message", ",", "yesno", "=", "False", ")", ":", "# add space for readability", "message", "+=", "' '", "# add yes or no to message", "if", "yesno", ":", "message", "+=", "'[y/n] '", "# ask human", "human_input", "=", "input", "(", "m...
Get keyboard input from a human, optionally reasking for valid yes or no input. Parameters ---------- message : :obj:`str` the message to display to the user yesno : :obj:`bool` whether or not to enforce yes or no inputs Returns ------- :obj:`str` string inp...
[ "Get", "keyboard", "input", "from", "a", "human", "optionally", "reasking", "for", "valid", "yes", "or", "no", "input", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/utils.py#L272-L301
train
BerkeleyAutomation/autolab_core
autolab_core/dual_quaternion.py
DualQuaternion.interpolate
def interpolate(dq0, dq1, t): """Return the interpolation of two DualQuaternions. This uses the Dual Quaternion Linear Blending Method as described by Matthew Smith's 'Applications of Dual Quaternions in Three Dimensional Transformation and Interpolation' https://www.cosc.canterbury.ac....
python
def interpolate(dq0, dq1, t): """Return the interpolation of two DualQuaternions. This uses the Dual Quaternion Linear Blending Method as described by Matthew Smith's 'Applications of Dual Quaternions in Three Dimensional Transformation and Interpolation' https://www.cosc.canterbury.ac....
[ "def", "interpolate", "(", "dq0", ",", "dq1", ",", "t", ")", ":", "if", "not", "0", "<=", "t", "<=", "1", ":", "raise", "ValueError", "(", "\"Interpolation step must be between 0 and 1! Got {0}\"", ".", "format", "(", "t", ")", ")", "dqt", "=", "dq0", "*...
Return the interpolation of two DualQuaternions. This uses the Dual Quaternion Linear Blending Method as described by Matthew Smith's 'Applications of Dual Quaternions in Three Dimensional Transformation and Interpolation' https://www.cosc.canterbury.ac.nz/research/reports/HonsReps/2013/hons_13...
[ "Return", "the", "interpolation", "of", "two", "DualQuaternions", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/dual_quaternion.py#L129-L162
train
BerkeleyAutomation/autolab_core
autolab_core/csv_model.py
CSVModel._save
def _save(self): """Save the model to a .csv file """ # if not first time saving, copy .csv to a backup if os.path.isfile(self._full_filename): shutil.copyfile(self._full_filename, self._full_backup_filename) # write to csv with open(self._full_filename, 'w')...
python
def _save(self): """Save the model to a .csv file """ # if not first time saving, copy .csv to a backup if os.path.isfile(self._full_filename): shutil.copyfile(self._full_filename, self._full_backup_filename) # write to csv with open(self._full_filename, 'w')...
[ "def", "_save", "(", "self", ")", ":", "# if not first time saving, copy .csv to a backup", "if", "os", ".", "path", ".", "isfile", "(", "self", ".", "_full_filename", ")", ":", "shutil", ".", "copyfile", "(", "self", ".", "_full_filename", ",", "self", ".", ...
Save the model to a .csv file
[ "Save", "the", "model", "to", "a", ".", "csv", "file" ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/csv_model.py#L103-L115
train
BerkeleyAutomation/autolab_core
autolab_core/csv_model.py
CSVModel.insert
def insert(self, data): """Insert a row into the .csv file. Parameters ---------- data : :obj:`dict` A dictionary mapping keys (header strings) to values. Returns ------- int The UID for the new row. Raises ------ ...
python
def insert(self, data): """Insert a row into the .csv file. Parameters ---------- data : :obj:`dict` A dictionary mapping keys (header strings) to values. Returns ------- int The UID for the new row. Raises ------ ...
[ "def", "insert", "(", "self", ",", "data", ")", ":", "row", "=", "{", "key", ":", "self", ".", "_default_entry", "for", "key", "in", "self", ".", "_headers", "}", "row", "[", "'_uid'", "]", "=", "self", ".", "_get_new_uid", "(", ")", "for", "key", ...
Insert a row into the .csv file. Parameters ---------- data : :obj:`dict` A dictionary mapping keys (header strings) to values. Returns ------- int The UID for the new row. Raises ------ Exception If the value...
[ "Insert", "a", "row", "into", "the", ".", "csv", "file", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/csv_model.py#L117-L149
train
BerkeleyAutomation/autolab_core
autolab_core/csv_model.py
CSVModel.update_by_uid
def update_by_uid(self, uid, data): """Update a row with the given data. Parameters ---------- uid : int The UID of the row to update. data : :obj:`dict` A dictionary mapping keys (header strings) to values. Raises ------ Excepti...
python
def update_by_uid(self, uid, data): """Update a row with the given data. Parameters ---------- uid : int The UID of the row to update. data : :obj:`dict` A dictionary mapping keys (header strings) to values. Raises ------ Excepti...
[ "def", "update_by_uid", "(", "self", ",", "uid", ",", "data", ")", ":", "row", "=", "self", ".", "_table", "[", "uid", "+", "1", "]", "for", "key", ",", "val", "in", "data", ".", "items", "(", ")", ":", "if", "key", "==", "'_uid'", "or", "key",...
Update a row with the given data. Parameters ---------- uid : int The UID of the row to update. data : :obj:`dict` A dictionary mapping keys (header strings) to values. Raises ------ Exception If the value for a given header ...
[ "Update", "a", "row", "with", "the", "given", "data", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/csv_model.py#L151-L178
train
BerkeleyAutomation/autolab_core
autolab_core/csv_model.py
CSVModel.get_col
def get_col(self, col_name, filter = lambda _ : True): """Return all values in the column corresponding to col_name that satisfies filter, which is a function that takes in a value of the column's type and returns True or False Parameters ---------- col_name : str Na...
python
def get_col(self, col_name, filter = lambda _ : True): """Return all values in the column corresponding to col_name that satisfies filter, which is a function that takes in a value of the column's type and returns True or False Parameters ---------- col_name : str Na...
[ "def", "get_col", "(", "self", ",", "col_name", ",", "filter", "=", "lambda", "_", ":", "True", ")", ":", "if", "col_name", "not", "in", "self", ".", "_headers", ":", "raise", "ValueError", "(", "\"{} not found! Model has headers: {}\"", ".", "format", "(", ...
Return all values in the column corresponding to col_name that satisfies filter, which is a function that takes in a value of the column's type and returns True or False Parameters ---------- col_name : str Name of desired column filter : function, optional ...
[ "Return", "all", "values", "in", "the", "column", "corresponding", "to", "col_name", "that", "satisfies", "filter", "which", "is", "a", "function", "that", "takes", "in", "a", "value", "of", "the", "column", "s", "type", "and", "returns", "True", "or", "Fa...
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/csv_model.py#L212-L243
train
BerkeleyAutomation/autolab_core
autolab_core/csv_model.py
CSVModel.get_by_cols
def get_by_cols(self, cols, direction=1): """Return the first or last row that satisfies the given col value constraints, or None if no row contains the given value. Parameters ---------- cols: :obj:'dict' Dictionary of col values for a specific row. directio...
python
def get_by_cols(self, cols, direction=1): """Return the first or last row that satisfies the given col value constraints, or None if no row contains the given value. Parameters ---------- cols: :obj:'dict' Dictionary of col values for a specific row. directio...
[ "def", "get_by_cols", "(", "self", ",", "cols", ",", "direction", "=", "1", ")", ":", "if", "direction", "==", "1", ":", "iterator", "=", "range", "(", "self", ".", "num_rows", ")", "elif", "direction", "==", "-", "1", ":", "iterator", "=", "range", ...
Return the first or last row that satisfies the given col value constraints, or None if no row contains the given value. Parameters ---------- cols: :obj:'dict' Dictionary of col values for a specific row. direction: int, optional Either 1 or -1. 1 means ...
[ "Return", "the", "first", "or", "last", "row", "that", "satisfies", "the", "given", "col", "value", "constraints", "or", "None", "if", "no", "row", "contains", "the", "given", "value", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/csv_model.py#L245-L282
train
BerkeleyAutomation/autolab_core
autolab_core/csv_model.py
CSVModel.get_rows_by_cols
def get_rows_by_cols(self, matching_dict): """Return all rows where the cols match the elements given in the matching_dict Parameters ---------- matching_dict: :obj:'dict' Desired dictionary of col values. Returns ------- :obj:`list` A li...
python
def get_rows_by_cols(self, matching_dict): """Return all rows where the cols match the elements given in the matching_dict Parameters ---------- matching_dict: :obj:'dict' Desired dictionary of col values. Returns ------- :obj:`list` A li...
[ "def", "get_rows_by_cols", "(", "self", ",", "matching_dict", ")", ":", "result", "=", "[", "]", "for", "i", "in", "range", "(", "self", ".", "num_rows", ")", ":", "row", "=", "self", ".", "_table", "[", "i", "+", "1", "]", "matching", "=", "True",...
Return all rows where the cols match the elements given in the matching_dict Parameters ---------- matching_dict: :obj:'dict' Desired dictionary of col values. Returns ------- :obj:`list` A list of rows that satisfy the matching_dict
[ "Return", "all", "rows", "where", "the", "cols", "match", "the", "elements", "given", "in", "the", "matching_dict" ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/csv_model.py#L326-L351
train
BerkeleyAutomation/autolab_core
autolab_core/csv_model.py
CSVModel.next
def next(self): """ Returns the next row in the CSV, for iteration """ if self._cur_row >= len(self._table): raise StopIteration data = self._table[self._cur_row].copy() self._cur_row += 1 return data
python
def next(self): """ Returns the next row in the CSV, for iteration """ if self._cur_row >= len(self._table): raise StopIteration data = self._table[self._cur_row].copy() self._cur_row += 1 return data
[ "def", "next", "(", "self", ")", ":", "if", "self", ".", "_cur_row", ">=", "len", "(", "self", ".", "_table", ")", ":", "raise", "StopIteration", "data", "=", "self", ".", "_table", "[", "self", ".", "_cur_row", "]", ".", "copy", "(", ")", "self", ...
Returns the next row in the CSV, for iteration
[ "Returns", "the", "next", "row", "in", "the", "CSV", "for", "iteration" ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/csv_model.py#L358-L364
train
BerkeleyAutomation/autolab_core
autolab_core/csv_model.py
CSVModel.load
def load(full_filename): """Load a .csv file into a CSVModel. Parameters ---------- full_filename : :obj:`str` The file path to a .csv file. Returns ------- :obj:`CSVModel` The CSVModel initialized with the data in the given file. ...
python
def load(full_filename): """Load a .csv file into a CSVModel. Parameters ---------- full_filename : :obj:`str` The file path to a .csv file. Returns ------- :obj:`CSVModel` The CSVModel initialized with the data in the given file. ...
[ "def", "load", "(", "full_filename", ")", ":", "with", "open", "(", "full_filename", ",", "'r'", ")", "as", "file", ":", "reader", "=", "csv", ".", "DictReader", "(", "file", ")", "headers", "=", "reader", ".", "fieldnames", "if", "'_uid'", "not", "in"...
Load a .csv file into a CSVModel. Parameters ---------- full_filename : :obj:`str` The file path to a .csv file. Returns ------- :obj:`CSVModel` The CSVModel initialized with the data in the given file. Raises ------ Exce...
[ "Load", "a", ".", "csv", "file", "into", "a", "CSVModel", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/csv_model.py#L379-L438
train
BerkeleyAutomation/autolab_core
autolab_core/csv_model.py
CSVModel.get_or_create
def get_or_create(full_filename, headers_types=None, default_entry=''): """Load a .csv file into a CSVModel if the file exists, or create a new CSVModel with the given filename if the file does not exist. Parameters ---------- full_filename : :obj:`str` The file path...
python
def get_or_create(full_filename, headers_types=None, default_entry=''): """Load a .csv file into a CSVModel if the file exists, or create a new CSVModel with the given filename if the file does not exist. Parameters ---------- full_filename : :obj:`str` The file path...
[ "def", "get_or_create", "(", "full_filename", ",", "headers_types", "=", "None", ",", "default_entry", "=", "''", ")", ":", "# convert dictionaries to list", "if", "isinstance", "(", "headers_types", ",", "dict", ")", ":", "headers_types_list", "=", "[", "(", "k...
Load a .csv file into a CSVModel if the file exists, or create a new CSVModel with the given filename if the file does not exist. Parameters ---------- full_filename : :obj:`str` The file path to a .csv file. headers_types : :obj:`list` of :obj:`tuple` of :obj:`str`...
[ "Load", "a", ".", "csv", "file", "into", "a", "CSVModel", "if", "the", "file", "exists", "or", "create", "a", "new", "CSVModel", "with", "the", "given", "filename", "if", "the", "file", "does", "not", "exist", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/csv_model.py#L441-L472
train
BerkeleyAutomation/autolab_core
autolab_core/transformations.py
projection_matrix
def projection_matrix(point, normal, direction=None, perspective=None, pseudo=False): """Return matrix to project onto plane defined by point and normal. Using either perspective point, projection direction, or none of both. If pseudo is True, perspective projections will preserve re...
python
def projection_matrix(point, normal, direction=None, perspective=None, pseudo=False): """Return matrix to project onto plane defined by point and normal. Using either perspective point, projection direction, or none of both. If pseudo is True, perspective projections will preserve re...
[ "def", "projection_matrix", "(", "point", ",", "normal", ",", "direction", "=", "None", ",", "perspective", "=", "None", ",", "pseudo", "=", "False", ")", ":", "M", "=", "numpy", ".", "identity", "(", "4", ")", "point", "=", "numpy", ".", "array", "(...
Return matrix to project onto plane defined by point and normal. Using either perspective point, projection direction, or none of both. If pseudo is True, perspective projections will preserve relative depth such that Perspective = dot(Orthogonal, PseudoPerspective). >>> P = projection_matrix((0, 0, ...
[ "Return", "matrix", "to", "project", "onto", "plane", "defined", "by", "point", "and", "normal", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/transformations.py#L437-L496
train
BerkeleyAutomation/autolab_core
autolab_core/transformations.py
projection_from_matrix
def projection_from_matrix(matrix, pseudo=False): """Return projection plane and perspective point from projection matrix. Return values are same as arguments for projection_matrix function: point, normal, direction, perspective, and pseudo. >>> point = numpy.random.random(3) - 0.5 >>> normal = nu...
python
def projection_from_matrix(matrix, pseudo=False): """Return projection plane and perspective point from projection matrix. Return values are same as arguments for projection_matrix function: point, normal, direction, perspective, and pseudo. >>> point = numpy.random.random(3) - 0.5 >>> normal = nu...
[ "def", "projection_from_matrix", "(", "matrix", ",", "pseudo", "=", "False", ")", ":", "M", "=", "numpy", ".", "array", "(", "matrix", ",", "dtype", "=", "numpy", ".", "float64", ",", "copy", "=", "False", ")", "M33", "=", "M", "[", ":", "3", ",", ...
Return projection plane and perspective point from projection matrix. Return values are same as arguments for projection_matrix function: point, normal, direction, perspective, and pseudo. >>> point = numpy.random.random(3) - 0.5 >>> normal = numpy.random.random(3) - 0.5 >>> direct = numpy.random....
[ "Return", "projection", "plane", "and", "perspective", "point", "from", "projection", "matrix", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/transformations.py#L499-L569
train
BerkeleyAutomation/autolab_core
autolab_core/transformations.py
unit_vector
def unit_vector(data, axis=None, out=None): """Return ndarray normalized by length, i.e. eucledian norm, along axis. >>> v0 = numpy.random.random(3) >>> v1 = unit_vector(v0) >>> numpy.allclose(v1, v0 / numpy.linalg.norm(v0)) True >>> v0 = numpy.random.rand(5, 4, 3) >>> v1 = unit_vector(v0, ...
python
def unit_vector(data, axis=None, out=None): """Return ndarray normalized by length, i.e. eucledian norm, along axis. >>> v0 = numpy.random.random(3) >>> v1 = unit_vector(v0) >>> numpy.allclose(v1, v0 / numpy.linalg.norm(v0)) True >>> v0 = numpy.random.rand(5, 4, 3) >>> v1 = unit_vector(v0, ...
[ "def", "unit_vector", "(", "data", ",", "axis", "=", "None", ",", "out", "=", "None", ")", ":", "if", "out", "is", "None", ":", "data", "=", "numpy", ".", "array", "(", "data", ",", "dtype", "=", "numpy", ".", "float64", ",", "copy", "=", "True",...
Return ndarray normalized by length, i.e. eucledian norm, along axis. >>> v0 = numpy.random.random(3) >>> v1 = unit_vector(v0) >>> numpy.allclose(v1, v0 / numpy.linalg.norm(v0)) True >>> v0 = numpy.random.rand(5, 4, 3) >>> v1 = unit_vector(v0, axis=-1) >>> v2 = v0 / numpy.expand_dims(numpy....
[ "Return", "ndarray", "normalized", "by", "length", "i", ".", "e", ".", "eucledian", "norm", "along", "axis", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/transformations.py#L1574-L1615
train
BerkeleyAutomation/autolab_core
autolab_core/json_serialization.py
json_numpy_obj_hook
def json_numpy_obj_hook(dct): """Decodes a previously encoded numpy ndarray with proper shape and dtype. Parameters ---------- dct : :obj:`dict` The encoded dictionary. Returns ------- :obj:`numpy.ndarray` The ndarray that `dct` was encoding. """ if isinstance(dct, ...
python
def json_numpy_obj_hook(dct): """Decodes a previously encoded numpy ndarray with proper shape and dtype. Parameters ---------- dct : :obj:`dict` The encoded dictionary. Returns ------- :obj:`numpy.ndarray` The ndarray that `dct` was encoding. """ if isinstance(dct, ...
[ "def", "json_numpy_obj_hook", "(", "dct", ")", ":", "if", "isinstance", "(", "dct", ",", "dict", ")", "and", "'__ndarray__'", "in", "dct", ":", "data", "=", "np", ".", "asarray", "(", "dct", "[", "'__ndarray__'", "]", ",", "dtype", "=", "dct", "[", "...
Decodes a previously encoded numpy ndarray with proper shape and dtype. Parameters ---------- dct : :obj:`dict` The encoded dictionary. Returns ------- :obj:`numpy.ndarray` The ndarray that `dct` was encoding.
[ "Decodes", "a", "previously", "encoded", "numpy", "ndarray", "with", "proper", "shape", "and", "dtype", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/json_serialization.py#L45-L61
train
BerkeleyAutomation/autolab_core
autolab_core/json_serialization.py
dump
def dump(*args, **kwargs): """Dump a numpy.ndarray to file stream. This works exactly like the usual `json.dump()` function, but it uses our custom serializer. """ kwargs.update(dict(cls=NumpyEncoder, sort_keys=True, indent=4, sep...
python
def dump(*args, **kwargs): """Dump a numpy.ndarray to file stream. This works exactly like the usual `json.dump()` function, but it uses our custom serializer. """ kwargs.update(dict(cls=NumpyEncoder, sort_keys=True, indent=4, sep...
[ "def", "dump", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "dict", "(", "cls", "=", "NumpyEncoder", ",", "sort_keys", "=", "True", ",", "indent", "=", "4", ",", "separators", "=", "(", "','", ",", "': '", ")...
Dump a numpy.ndarray to file stream. This works exactly like the usual `json.dump()` function, but it uses our custom serializer.
[ "Dump", "a", "numpy", ".", "ndarray", "to", "file", "stream", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/json_serialization.py#L63-L73
train
BerkeleyAutomation/autolab_core
autolab_core/json_serialization.py
load
def load(*args, **kwargs): """Load an numpy.ndarray from a file stream. This works exactly like the usual `json.load()` function, but it uses our custom deserializer. """ kwargs.update(dict(object_hook=json_numpy_obj_hook)) return _json.load(*args, **kwargs)
python
def load(*args, **kwargs): """Load an numpy.ndarray from a file stream. This works exactly like the usual `json.load()` function, but it uses our custom deserializer. """ kwargs.update(dict(object_hook=json_numpy_obj_hook)) return _json.load(*args, **kwargs)
[ "def", "load", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "dict", "(", "object_hook", "=", "json_numpy_obj_hook", ")", ")", "return", "_json", ".", "load", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
Load an numpy.ndarray from a file stream. This works exactly like the usual `json.load()` function, but it uses our custom deserializer.
[ "Load", "an", "numpy", ".", "ndarray", "from", "a", "file", "stream", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/json_serialization.py#L75-L82
train
BerkeleyAutomation/autolab_core
autolab_core/json_serialization.py
NumpyEncoder.default
def default(self, obj): """Converts an ndarray into a dictionary for efficient serialization. The dict has three keys: - dtype : The datatype of the array as a string. - shape : The shape of the array as a tuple. - __ndarray__ : The data of the array as a list. Paramete...
python
def default(self, obj): """Converts an ndarray into a dictionary for efficient serialization. The dict has three keys: - dtype : The datatype of the array as a string. - shape : The shape of the array as a tuple. - __ndarray__ : The data of the array as a list. Paramete...
[ "def", "default", "(", "self", ",", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "np", ".", "ndarray", ")", ":", "return", "dict", "(", "__ndarray__", "=", "obj", ".", "tolist", "(", ")", ",", "dtype", "=", "str", "(", "obj", ".", "dtype...
Converts an ndarray into a dictionary for efficient serialization. The dict has three keys: - dtype : The datatype of the array as a string. - shape : The shape of the array as a tuple. - __ndarray__ : The data of the array as a list. Parameters ---------- obj :...
[ "Converts", "an", "ndarray", "into", "a", "dictionary", "for", "efficient", "serialization", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/json_serialization.py#L15-L43
train
BerkeleyAutomation/autolab_core
autolab_core/random_variables.py
RandomVariable._preallocate_samples
def _preallocate_samples(self): """Preallocate samples for faster adaptive sampling. """ self.prealloc_samples_ = [] for i in range(self.num_prealloc_samples_): self.prealloc_samples_.append(self.sample())
python
def _preallocate_samples(self): """Preallocate samples for faster adaptive sampling. """ self.prealloc_samples_ = [] for i in range(self.num_prealloc_samples_): self.prealloc_samples_.append(self.sample())
[ "def", "_preallocate_samples", "(", "self", ")", ":", "self", ".", "prealloc_samples_", "=", "[", "]", "for", "i", "in", "range", "(", "self", ".", "num_prealloc_samples_", ")", ":", "self", ".", "prealloc_samples_", ".", "append", "(", "self", ".", "sampl...
Preallocate samples for faster adaptive sampling.
[ "Preallocate", "samples", "for", "faster", "adaptive", "sampling", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/random_variables.py#L30-L35
train
BerkeleyAutomation/autolab_core
autolab_core/random_variables.py
RandomVariable.rvs
def rvs(self, size=1, iteration=1): """Sample the random variable, using the preallocated samples if possible. Parameters ---------- size : int The number of samples to generate. iteration : int The location in the preallocated sample array to st...
python
def rvs(self, size=1, iteration=1): """Sample the random variable, using the preallocated samples if possible. Parameters ---------- size : int The number of samples to generate. iteration : int The location in the preallocated sample array to st...
[ "def", "rvs", "(", "self", ",", "size", "=", "1", ",", "iteration", "=", "1", ")", ":", "if", "self", ".", "num_prealloc_samples_", ">", "0", ":", "samples", "=", "[", "]", "for", "i", "in", "range", "(", "size", ")", ":", "samples", ".", "append...
Sample the random variable, using the preallocated samples if possible. Parameters ---------- size : int The number of samples to generate. iteration : int The location in the preallocated sample array to start sampling from. Returns...
[ "Sample", "the", "random", "variable", "using", "the", "preallocated", "samples", "if", "possible", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/random_variables.py#L54-L81
train
BerkeleyAutomation/autolab_core
autolab_core/random_variables.py
IsotropicGaussianRigidTransformRandomVariable.sample
def sample(self, size=1): """ Sample rigid transform random variables. Parameters ---------- size : int number of sample to take Returns ------- :obj:`list` of :obj:`RigidTransform` sampled rigid transformations """ ...
python
def sample(self, size=1): """ Sample rigid transform random variables. Parameters ---------- size : int number of sample to take Returns ------- :obj:`list` of :obj:`RigidTransform` sampled rigid transformations """ ...
[ "def", "sample", "(", "self", ",", "size", "=", "1", ")", ":", "samples", "=", "[", "]", "for", "i", "in", "range", "(", "size", ")", ":", "# sample random pose", "xi", "=", "self", ".", "_r_xi_rv", ".", "rvs", "(", "size", "=", "1", ")", "S_xi",...
Sample rigid transform random variables. Parameters ---------- size : int number of sample to take Returns ------- :obj:`list` of :obj:`RigidTransform` sampled rigid transformations
[ "Sample", "rigid", "transform", "random", "variables", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/random_variables.py#L221-L249
train
BerkeleyAutomation/autolab_core
autolab_core/data_stream_recorder.py
DataStreamRecorder._flush
def _flush(self): """ Returns a list of all current data """ if self._recording: raise Exception("Cannot flush data queue while recording!") if self._saving_cache: logging.warn("Flush when using cache means unsaved data will be lost and not returned!") self._c...
python
def _flush(self): """ Returns a list of all current data """ if self._recording: raise Exception("Cannot flush data queue while recording!") if self._saving_cache: logging.warn("Flush when using cache means unsaved data will be lost and not returned!") self._c...
[ "def", "_flush", "(", "self", ")", ":", "if", "self", ".", "_recording", ":", "raise", "Exception", "(", "\"Cannot flush data queue while recording!\"", ")", "if", "self", ".", "_saving_cache", ":", "logging", ".", "warn", "(", "\"Flush when using cache means unsave...
Returns a list of all current data
[ "Returns", "a", "list", "of", "all", "current", "data" ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/data_stream_recorder.py#L193-L202
train
BerkeleyAutomation/autolab_core
autolab_core/data_stream_recorder.py
DataStreamRecorder._stop
def _stop(self): """ Stops recording. Returns all recorded data and their timestamps. Destroys recorder process.""" self._pause() self._cmds_q.put(("stop",)) try: self._recorder.terminate() except Exception: pass self._recording = False
python
def _stop(self): """ Stops recording. Returns all recorded data and their timestamps. Destroys recorder process.""" self._pause() self._cmds_q.put(("stop",)) try: self._recorder.terminate() except Exception: pass self._recording = False
[ "def", "_stop", "(", "self", ")", ":", "self", ".", "_pause", "(", ")", "self", ".", "_cmds_q", ".", "put", "(", "(", "\"stop\"", ",", ")", ")", "try", ":", "self", ".", "_recorder", ".", "terminate", "(", ")", "except", "Exception", ":", "pass", ...
Stops recording. Returns all recorded data and their timestamps. Destroys recorder process.
[ "Stops", "recording", ".", "Returns", "all", "recorded", "data", "and", "their", "timestamps", ".", "Destroys", "recorder", "process", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/data_stream_recorder.py#L209-L217
train
BerkeleyAutomation/autolab_core
autolab_core/completer.py
Completer._listdir
def _listdir(self, root): "List directory 'root' appending the path separator to subdirs." res = [] for name in os.listdir(root): path = os.path.join(root, name) if os.path.isdir(path): name += os.sep res.append(name) return res
python
def _listdir(self, root): "List directory 'root' appending the path separator to subdirs." res = [] for name in os.listdir(root): path = os.path.join(root, name) if os.path.isdir(path): name += os.sep res.append(name) return res
[ "def", "_listdir", "(", "self", ",", "root", ")", ":", "res", "=", "[", "]", "for", "name", "in", "os", ".", "listdir", "(", "root", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "root", ",", "name", ")", "if", "os", ".", "path"...
List directory 'root' appending the path separator to subdirs.
[ "List", "directory", "root", "appending", "the", "path", "separator", "to", "subdirs", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/completer.py#L24-L32
train
BerkeleyAutomation/autolab_core
autolab_core/completer.py
Completer.complete_extra
def complete_extra(self, args): "Completions for the 'extra' command." # treat the last arg as a path and complete it if len(args) == 0: return self._listdir('./') return self._complete_path(args[-1])
python
def complete_extra(self, args): "Completions for the 'extra' command." # treat the last arg as a path and complete it if len(args) == 0: return self._listdir('./') return self._complete_path(args[-1])
[ "def", "complete_extra", "(", "self", ",", "args", ")", ":", "# treat the last arg as a path and complete it", "if", "len", "(", "args", ")", "==", "0", ":", "return", "self", ".", "_listdir", "(", "'./'", ")", "return", "self", ".", "_complete_path", "(", "...
Completions for the 'extra' command.
[ "Completions", "for", "the", "extra", "command", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/completer.py#L51-L56
train
BerkeleyAutomation/autolab_core
autolab_core/completer.py
Completer.complete
def complete(self, text, state): "Generic readline completion entry point." # dexnet entity tab completion results = [w for w in self.words if w.startswith(text)] + [None] if results != [None]: return results[state] buffer = readline.get_line_buffer() line =...
python
def complete(self, text, state): "Generic readline completion entry point." # dexnet entity tab completion results = [w for w in self.words if w.startswith(text)] + [None] if results != [None]: return results[state] buffer = readline.get_line_buffer() line =...
[ "def", "complete", "(", "self", ",", "text", ",", "state", ")", ":", "# dexnet entity tab completion", "results", "=", "[", "w", "for", "w", "in", "self", ".", "words", "if", "w", ".", "startswith", "(", "text", ")", "]", "+", "[", "None", "]", "if",...
Generic readline completion entry point.
[ "Generic", "readline", "completion", "entry", "point", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/completer.py#L58-L78
train
BerkeleyAutomation/autolab_core
autolab_core/data_stream_syncer.py
DataStreamSyncer.stop
def stop(self): """ Stops syncer operations. Destroys syncer process. """ self._cmds_q.put(("stop",)) for recorder in self._data_stream_recorders: recorder._stop() try: self._syncer.terminate() except Exception: pass
python
def stop(self): """ Stops syncer operations. Destroys syncer process. """ self._cmds_q.put(("stop",)) for recorder in self._data_stream_recorders: recorder._stop() try: self._syncer.terminate() except Exception: pass
[ "def", "stop", "(", "self", ")", ":", "self", ".", "_cmds_q", ".", "put", "(", "(", "\"stop\"", ",", ")", ")", "for", "recorder", "in", "self", ".", "_data_stream_recorders", ":", "recorder", ".", "_stop", "(", ")", "try", ":", "self", ".", "_syncer"...
Stops syncer operations. Destroys syncer process.
[ "Stops", "syncer", "operations", ".", "Destroys", "syncer", "process", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/data_stream_syncer.py#L123-L131
train
BerkeleyAutomation/autolab_core
autolab_core/logger.py
configure_root
def configure_root(): """Configure the root logger.""" root_logger = logging.getLogger() # clear any existing handles to streams because we don't want duplicate logs # NOTE: we assume that any stream handles we find are to ROOT_LOG_STREAM, which is usually the case(because it is stdout). This is fine b...
python
def configure_root(): """Configure the root logger.""" root_logger = logging.getLogger() # clear any existing handles to streams because we don't want duplicate logs # NOTE: we assume that any stream handles we find are to ROOT_LOG_STREAM, which is usually the case(because it is stdout). This is fine b...
[ "def", "configure_root", "(", ")", ":", "root_logger", "=", "logging", ".", "getLogger", "(", ")", "# clear any existing handles to streams because we don't want duplicate logs", "# NOTE: we assume that any stream handles we find are to ROOT_LOG_STREAM, which is usually the case(because it...
Configure the root logger.
[ "Configure", "the", "root", "logger", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/logger.py#L14-L39
train
BerkeleyAutomation/autolab_core
autolab_core/logger.py
add_root_log_file
def add_root_log_file(log_file): """ Add a log file to the root logger. Parameters ---------- log_file :obj:`str` The path to the log file. """ root_logger = logging.getLogger() # add a file handle to the root logger hdlr = logging.FileHandler(log_file) formatter = logg...
python
def add_root_log_file(log_file): """ Add a log file to the root logger. Parameters ---------- log_file :obj:`str` The path to the log file. """ root_logger = logging.getLogger() # add a file handle to the root logger hdlr = logging.FileHandler(log_file) formatter = logg...
[ "def", "add_root_log_file", "(", "log_file", ")", ":", "root_logger", "=", "logging", ".", "getLogger", "(", ")", "# add a file handle to the root logger", "hdlr", "=", "logging", ".", "FileHandler", "(", "log_file", ")", "formatter", "=", "logging", ".", "Formatt...
Add a log file to the root logger. Parameters ---------- log_file :obj:`str` The path to the log file.
[ "Add", "a", "log", "file", "to", "the", "root", "logger", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/logger.py#L41-L57
train
BerkeleyAutomation/autolab_core
autolab_core/logger.py
Logger.add_log_file
def add_log_file(logger, log_file, global_log_file=False): """ Add a log file to this logger. If global_log_file is true, log_file will be handed the root logger, otherwise it will only be used by this particular logger. Parameters ---------- logger :obj:`logging.Logger` ...
python
def add_log_file(logger, log_file, global_log_file=False): """ Add a log file to this logger. If global_log_file is true, log_file will be handed the root logger, otherwise it will only be used by this particular logger. Parameters ---------- logger :obj:`logging.Logger` ...
[ "def", "add_log_file", "(", "logger", ",", "log_file", ",", "global_log_file", "=", "False", ")", ":", "if", "global_log_file", ":", "add_root_log_file", "(", "log_file", ")", "else", ":", "hdlr", "=", "logging", ".", "FileHandler", "(", "log_file", ")", "fo...
Add a log file to this logger. If global_log_file is true, log_file will be handed the root logger, otherwise it will only be used by this particular logger. Parameters ---------- logger :obj:`logging.Logger` The logger. log_file :obj:`str` The path to the log fi...
[ "Add", "a", "log", "file", "to", "this", "logger", ".", "If", "global_log_file", "is", "true", "log_file", "will", "be", "handed", "the", "root", "logger", "otherwise", "it", "will", "only", "be", "used", "by", "this", "particular", "logger", "." ]
8f3813f6401972868cc5e3981ba1b4382d4418d5
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/logger.py#L128-L148
train
googlefonts/fontbakery
Lib/fontbakery/checkrunner.py
get_module_profile
def get_module_profile(module, name=None): """ Get or create a profile from a module and return it. If the name `module.profile` is present the value of that is returned. Otherwise, if the name `module.profile_factory` is present, a new profile is created using `module.profile_factory` and then `profile.auto...
python
def get_module_profile(module, name=None): """ Get or create a profile from a module and return it. If the name `module.profile` is present the value of that is returned. Otherwise, if the name `module.profile_factory` is present, a new profile is created using `module.profile_factory` and then `profile.auto...
[ "def", "get_module_profile", "(", "module", ",", "name", "=", "None", ")", ":", "try", ":", "# if profile is defined we just use it", "return", "module", ".", "profile", "except", "AttributeError", ":", "# > 'module' object has no attribute 'profile'", "# try to create one ...
Get or create a profile from a module and return it. If the name `module.profile` is present the value of that is returned. Otherwise, if the name `module.profile_factory` is present, a new profile is created using `module.profile_factory` and then `profile.auto_register` is called with the module namespace. ...
[ "Get", "or", "create", "a", "profile", "from", "a", "module", "and", "return", "it", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/checkrunner.py#L1626-L1659
train
googlefonts/fontbakery
Lib/fontbakery/checkrunner.py
CheckRunner.iterargs
def iterargs(self): """ uses the singular name as key """ iterargs = OrderedDict() for name in self._iterargs: plural = self._profile.iterargs[name] iterargs[name] = tuple(self._values[plural]) return iterargs
python
def iterargs(self): """ uses the singular name as key """ iterargs = OrderedDict() for name in self._iterargs: plural = self._profile.iterargs[name] iterargs[name] = tuple(self._values[plural]) return iterargs
[ "def", "iterargs", "(", "self", ")", ":", "iterargs", "=", "OrderedDict", "(", ")", "for", "name", "in", "self", ".", "_iterargs", ":", "plural", "=", "self", ".", "_profile", ".", "iterargs", "[", "name", "]", "iterargs", "[", "name", "]", "=", "tup...
uses the singular name as key
[ "uses", "the", "singular", "name", "as", "key" ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/checkrunner.py#L270-L276
train
googlefonts/fontbakery
Lib/fontbakery/checkrunner.py
CheckRunner._exec_check
def _exec_check(self, check: FontbakeryCallable, args: Dict[str, Any]): """ Yields check sub results. Each check result is a tuple of: (<Status>, mixed message) `status`: must be an instance of Status. If one of the `status` entries in one of the results is FAIL, the whole check is cons...
python
def _exec_check(self, check: FontbakeryCallable, args: Dict[str, Any]): """ Yields check sub results. Each check result is a tuple of: (<Status>, mixed message) `status`: must be an instance of Status. If one of the `status` entries in one of the results is FAIL, the whole check is cons...
[ "def", "_exec_check", "(", "self", ",", "check", ":", "FontbakeryCallable", ",", "args", ":", "Dict", "[", "str", ",", "Any", "]", ")", ":", "try", ":", "# A check can be either a normal function that returns one Status or a", "# generator that yields one or more. The lat...
Yields check sub results. Each check result is a tuple of: (<Status>, mixed message) `status`: must be an instance of Status. If one of the `status` entries in one of the results is FAIL, the whole check is considered failed. WARN is most likely a PASS in a non strict mode and a ...
[ "Yields", "check", "sub", "results", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/checkrunner.py#L318-L352
train
googlefonts/fontbakery
Lib/fontbakery/checkrunner.py
CheckRunner.check_order
def check_order(self, order): """ order must be a subset of self.order """ own_order = self.order for item in order: if item not in own_order: raise ValueError(f'Order item {item} not found.') return order
python
def check_order(self, order): """ order must be a subset of self.order """ own_order = self.order for item in order: if item not in own_order: raise ValueError(f'Order item {item} not found.') return order
[ "def", "check_order", "(", "self", ",", "order", ")", ":", "own_order", "=", "self", ".", "order", "for", "item", "in", "order", ":", "if", "item", "not", "in", "own_order", ":", "raise", "ValueError", "(", "f'Order item {item} not found.'", ")", "return", ...
order must be a subset of self.order
[ "order", "must", "be", "a", "subset", "of", "self", ".", "order" ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/checkrunner.py#L622-L630
train
googlefonts/fontbakery
Lib/fontbakery/checkrunner.py
Section.add_check
def add_check(self, check): """ Please use rather `register_check` as a decorator. """ if self._add_check_callback is not None: if not self._add_check_callback(self, check): # rejected, skip! return False self._checkid2index[check.id] = len(self._checks) self._checks.appen...
python
def add_check(self, check): """ Please use rather `register_check` as a decorator. """ if self._add_check_callback is not None: if not self._add_check_callback(self, check): # rejected, skip! return False self._checkid2index[check.id] = len(self._checks) self._checks.appen...
[ "def", "add_check", "(", "self", ",", "check", ")", ":", "if", "self", ".", "_add_check_callback", "is", "not", "None", ":", "if", "not", "self", ".", "_add_check_callback", "(", "self", ",", "check", ")", ":", "# rejected, skip!", "return", "False", "self...
Please use rather `register_check` as a decorator.
[ "Please", "use", "rather", "register_check", "as", "a", "decorator", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/checkrunner.py#L732-L743
train
googlefonts/fontbakery
Lib/fontbakery/checkrunner.py
Section.merge_section
def merge_section(self, section, filter_func=None): """ Add section.checks to self, if not skipped by self._add_check_callback. order, description, etc. are not updated. """ for check in section.checks: if filter_func and not filter_func(check): continue self.add_check(check)
python
def merge_section(self, section, filter_func=None): """ Add section.checks to self, if not skipped by self._add_check_callback. order, description, etc. are not updated. """ for check in section.checks: if filter_func and not filter_func(check): continue self.add_check(check)
[ "def", "merge_section", "(", "self", ",", "section", ",", "filter_func", "=", "None", ")", ":", "for", "check", "in", "section", ".", "checks", ":", "if", "filter_func", "and", "not", "filter_func", "(", "check", ")", ":", "continue", "self", ".", "add_c...
Add section.checks to self, if not skipped by self._add_check_callback. order, description, etc. are not updated.
[ "Add", "section", ".", "checks", "to", "self", "if", "not", "skipped", "by", "self", ".", "_add_check_callback", ".", "order", "description", "etc", ".", "are", "not", "updated", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/checkrunner.py#L745-L753
train
googlefonts/fontbakery
Lib/fontbakery/checkrunner.py
Profile.validate_values
def validate_values(self, values): """ Validate values if they are registered as expected_values and present. * If they are not registered they shouldn't be used anywhere at all because profile can self check (profile.check_dependencies) for missing/undefined dependencies. * If they are no...
python
def validate_values(self, values): """ Validate values if they are registered as expected_values and present. * If they are not registered they shouldn't be used anywhere at all because profile can self check (profile.check_dependencies) for missing/undefined dependencies. * If they are no...
[ "def", "validate_values", "(", "self", ",", "values", ")", ":", "format_message", "=", "'{}: {} (value: {})'", ".", "format", "messages", "=", "[", "]", "for", "name", ",", "value", "in", "values", ".", "items", "(", ")", ":", "if", "name", "not", "in", ...
Validate values if they are registered as expected_values and present. * If they are not registered they shouldn't be used anywhere at all because profile can self check (profile.check_dependencies) for missing/undefined dependencies. * If they are not present in values but registered as expected_...
[ "Validate", "values", "if", "they", "are", "registered", "as", "expected_values", "and", "present", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/checkrunner.py#L993-L1017
train
googlefonts/fontbakery
Lib/fontbakery/checkrunner.py
Profile._get_aggregate_args
def _get_aggregate_args(self, item, key): """ Get all arguments or mandatory arguments of the item. Item is a check or a condition, which means it can be dependent on more conditions, this climbs down all the way. """ if not key in ('args', 'mandatoryArgs'): raise TypeError('key mus...
python
def _get_aggregate_args(self, item, key): """ Get all arguments or mandatory arguments of the item. Item is a check or a condition, which means it can be dependent on more conditions, this climbs down all the way. """ if not key in ('args', 'mandatoryArgs'): raise TypeError('key mus...
[ "def", "_get_aggregate_args", "(", "self", ",", "item", ",", "key", ")", ":", "if", "not", "key", "in", "(", "'args'", ",", "'mandatoryArgs'", ")", ":", "raise", "TypeError", "(", "'key must be \"args\" or \"mandatoryArgs\", got {}'", ")", ".", "format", "(", ...
Get all arguments or mandatory arguments of the item. Item is a check or a condition, which means it can be dependent on more conditions, this climbs down all the way.
[ "Get", "all", "arguments", "or", "mandatory", "arguments", "of", "the", "item", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/checkrunner.py#L1055-L1079
train
googlefonts/fontbakery
Lib/fontbakery/checkrunner.py
Profile.get_iterargs
def get_iterargs(self, item): """ Returns a tuple of all iterags for item, sorted by name.""" # iterargs should always be mandatory, unless there's a good reason # not to, which I can't think of right now. args = self._get_aggregate_args(item, 'mandatoryArgs') return tuple(sorted([arg for arg in ar...
python
def get_iterargs(self, item): """ Returns a tuple of all iterags for item, sorted by name.""" # iterargs should always be mandatory, unless there's a good reason # not to, which I can't think of right now. args = self._get_aggregate_args(item, 'mandatoryArgs') return tuple(sorted([arg for arg in ar...
[ "def", "get_iterargs", "(", "self", ",", "item", ")", ":", "# iterargs should always be mandatory, unless there's a good reason", "# not to, which I can't think of right now.", "args", "=", "self", ".", "_get_aggregate_args", "(", "item", ",", "'mandatoryArgs'", ")", "return"...
Returns a tuple of all iterags for item, sorted by name.
[ "Returns", "a", "tuple", "of", "all", "iterags", "for", "item", "sorted", "by", "name", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/checkrunner.py#L1081-L1087
train
googlefonts/fontbakery
Lib/fontbakery/checkrunner.py
Profile.auto_register
def auto_register(self, symbol_table, filter_func=None, profile_imports=None): """ Register items from `symbol_table` in the profile. Get all items from `symbol_table` dict and from `symbol_table.profile_imports` if it is present. If they an item is an instance of FontBakeryCheck, FontBaker...
python
def auto_register(self, symbol_table, filter_func=None, profile_imports=None): """ Register items from `symbol_table` in the profile. Get all items from `symbol_table` dict and from `symbol_table.profile_imports` if it is present. If they an item is an instance of FontBakeryCheck, FontBaker...
[ "def", "auto_register", "(", "self", ",", "symbol_table", ",", "filter_func", "=", "None", ",", "profile_imports", "=", "None", ")", ":", "if", "profile_imports", ":", "symbol_table", "=", "symbol_table", ".", "copy", "(", ")", "# Avoid messing with original table...
Register items from `symbol_table` in the profile. Get all items from `symbol_table` dict and from `symbol_table.profile_imports` if it is present. If they an item is an instance of FontBakeryCheck, FontBakeryCondition or FontBakeryExpectedValue and register it in the default section. If ...
[ "Register", "items", "from", "symbol_table", "in", "the", "profile", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/checkrunner.py#L1417-L1481
train
googlefonts/fontbakery
Lib/fontbakery/checkrunner.py
Profile.merge_profile
def merge_profile(self, profile, filter_func=None): """Copy all namespace items from profile to self. Namespace items are: 'iterargs', 'derived_iterables', 'aliases', 'conditions', 'expected_values' Don't change any contents of profile ever! That means sections are cloned not ...
python
def merge_profile(self, profile, filter_func=None): """Copy all namespace items from profile to self. Namespace items are: 'iterargs', 'derived_iterables', 'aliases', 'conditions', 'expected_values' Don't change any contents of profile ever! That means sections are cloned not ...
[ "def", "merge_profile", "(", "self", ",", "profile", ",", "filter_func", "=", "None", ")", ":", "# 'iterargs', 'derived_iterables', 'aliases', 'conditions', 'expected_values'", "for", "ns_type", "in", "self", ".", "_valid_namespace_types", ":", "# this will raise a NamespaceE...
Copy all namespace items from profile to self. Namespace items are: 'iterargs', 'derived_iterables', 'aliases', 'conditions', 'expected_values' Don't change any contents of profile ever! That means sections are cloned not used directly filter_func: see description in auto_reg...
[ "Copy", "all", "namespace", "items", "from", "profile", "to", "self", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/checkrunner.py#L1483-L1517
train
googlefonts/fontbakery
Lib/fontbakery/checkrunner.py
Profile.serialize_identity
def serialize_identity(self, identity): """ Return a json string that can also be used as a key. The JSON is explicitly unambiguous in the item order entries (dictionaries are not ordered usually) Otherwise it is valid JSON """ section, check, iterargs = identity values = map( # se...
python
def serialize_identity(self, identity): """ Return a json string that can also be used as a key. The JSON is explicitly unambiguous in the item order entries (dictionaries are not ordered usually) Otherwise it is valid JSON """ section, check, iterargs = identity values = map( # se...
[ "def", "serialize_identity", "(", "self", ",", "identity", ")", ":", "section", ",", "check", ",", "iterargs", "=", "identity", "values", "=", "map", "(", "# separators are without space, which is the default in JavaScript;", "# just in case we need to make these keys in JS."...
Return a json string that can also be used as a key. The JSON is explicitly unambiguous in the item order entries (dictionaries are not ordered usually) Otherwise it is valid JSON
[ "Return", "a", "json", "string", "that", "can", "also", "be", "used", "as", "a", "key", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/checkrunner.py#L1550-L1570
train
googlefonts/fontbakery
Lib/fontbakery/commands/check_profile.py
get_profile
def get_profile(): """ Prefetch the profile module, to fill some holes in the help text.""" argument_parser = ThrowingArgumentParser(add_help=False) argument_parser.add_argument('profile') try: args, _ = argument_parser.parse_known_args() except ArgumentParserError: # silently fails, the main parser w...
python
def get_profile(): """ Prefetch the profile module, to fill some holes in the help text.""" argument_parser = ThrowingArgumentParser(add_help=False) argument_parser.add_argument('profile') try: args, _ = argument_parser.parse_known_args() except ArgumentParserError: # silently fails, the main parser w...
[ "def", "get_profile", "(", ")", ":", "argument_parser", "=", "ThrowingArgumentParser", "(", "add_help", "=", "False", ")", "argument_parser", ".", "add_argument", "(", "'profile'", ")", "try", ":", "args", ",", "_", "=", "argument_parser", ".", "parse_known_args...
Prefetch the profile module, to fill some holes in the help text.
[ "Prefetch", "the", "profile", "module", "to", "fill", "some", "holes", "in", "the", "help", "text", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/commands/check_profile.py#L193-L206
train
googlefonts/fontbakery
Lib/fontbakery/commands/generate_glyphdata.py
collate_fonts_data
def collate_fonts_data(fonts_data): """Collate individual fonts data into a single glyph data list.""" glyphs = {} for family in fonts_data: for glyph in family: if glyph['unicode'] not in glyphs: glyphs[glyph['unicode']] = glyph else: c = gly...
python
def collate_fonts_data(fonts_data): """Collate individual fonts data into a single glyph data list.""" glyphs = {} for family in fonts_data: for glyph in family: if glyph['unicode'] not in glyphs: glyphs[glyph['unicode']] = glyph else: c = gly...
[ "def", "collate_fonts_data", "(", "fonts_data", ")", ":", "glyphs", "=", "{", "}", "for", "family", "in", "fonts_data", ":", "for", "glyph", "in", "family", ":", "if", "glyph", "[", "'unicode'", "]", "not", "in", "glyphs", ":", "glyphs", "[", "glyph", ...
Collate individual fonts data into a single glyph data list.
[ "Collate", "individual", "fonts", "data", "into", "a", "single", "glyph", "data", "list", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/commands/generate_glyphdata.py#L35-L46
train
googlefonts/fontbakery
Lib/fontbakery/profiles/adobefonts.py
com_adobe_fonts_check_family_consistent_upm
def com_adobe_fonts_check_family_consistent_upm(ttFonts): """Fonts have consistent Units Per Em?""" upm_set = set() for ttFont in ttFonts: upm_set.add(ttFont['head'].unitsPerEm) if len(upm_set) > 1: yield FAIL, ("Fonts have different units per em: {}." ).format(sorte...
python
def com_adobe_fonts_check_family_consistent_upm(ttFonts): """Fonts have consistent Units Per Em?""" upm_set = set() for ttFont in ttFonts: upm_set.add(ttFont['head'].unitsPerEm) if len(upm_set) > 1: yield FAIL, ("Fonts have different units per em: {}." ).format(sorte...
[ "def", "com_adobe_fonts_check_family_consistent_upm", "(", "ttFonts", ")", ":", "upm_set", "=", "set", "(", ")", "for", "ttFont", "in", "ttFonts", ":", "upm_set", ".", "add", "(", "ttFont", "[", "'head'", "]", ".", "unitsPerEm", ")", "if", "len", "(", "upm...
Fonts have consistent Units Per Em?
[ "Fonts", "have", "consistent", "Units", "Per", "Em?" ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/adobefonts.py#L27-L36
train
googlefonts/fontbakery
Lib/fontbakery/profiles/adobefonts.py
com_adobe_fonts_check_find_empty_letters
def com_adobe_fonts_check_find_empty_letters(ttFont): """Letters in font have glyphs that are not empty?""" cmap = ttFont.getBestCmap() passed = True # http://unicode.org/reports/tr44/#General_Category_Values letter_categories = { 'Ll', 'Lm', 'Lo', 'Lt', 'Lu', } invisible_letters = ...
python
def com_adobe_fonts_check_find_empty_letters(ttFont): """Letters in font have glyphs that are not empty?""" cmap = ttFont.getBestCmap() passed = True # http://unicode.org/reports/tr44/#General_Category_Values letter_categories = { 'Ll', 'Lm', 'Lo', 'Lt', 'Lu', } invisible_letters = ...
[ "def", "com_adobe_fonts_check_find_empty_letters", "(", "ttFont", ")", ":", "cmap", "=", "ttFont", ".", "getBestCmap", "(", ")", "passed", "=", "True", "# http://unicode.org/reports/tr44/#General_Category_Values", "letter_categories", "=", "{", "'Ll'", ",", "'Lm'", ",",...
Letters in font have glyphs that are not empty?
[ "Letters", "in", "font", "have", "glyphs", "that", "are", "not", "empty?" ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/adobefonts.py#L81-L103
train
googlefonts/fontbakery
Lib/fontbakery/profiles/name.py
com_adobe_fonts_check_name_empty_records
def com_adobe_fonts_check_name_empty_records(ttFont): """Check name table for empty records.""" failed = False for name_record in ttFont['name'].names: name_string = name_record.toUnicode().strip() if len(name_string) == 0: failed = True name_key = tuple([name_record....
python
def com_adobe_fonts_check_name_empty_records(ttFont): """Check name table for empty records.""" failed = False for name_record in ttFont['name'].names: name_string = name_record.toUnicode().strip() if len(name_string) == 0: failed = True name_key = tuple([name_record....
[ "def", "com_adobe_fonts_check_name_empty_records", "(", "ttFont", ")", ":", "failed", "=", "False", "for", "name_record", "in", "ttFont", "[", "'name'", "]", ".", "names", ":", "name_string", "=", "name_record", ".", "toUnicode", "(", ")", ".", "strip", "(", ...
Check name table for empty records.
[ "Check", "name", "table", "for", "empty", "records", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/name.py#L20-L33
train
googlefonts/fontbakery
Lib/fontbakery/profiles/name.py
com_google_fonts_check_name_no_copyright_on_description
def com_google_fonts_check_name_no_copyright_on_description(ttFont): """Description strings in the name table must not contain copyright info.""" failed = False for name in ttFont['name'].names: if 'opyright' in name.string.decode(name.getEncoding())\ and name.nameID == NameID.DESCRIPTION: failed...
python
def com_google_fonts_check_name_no_copyright_on_description(ttFont): """Description strings in the name table must not contain copyright info.""" failed = False for name in ttFont['name'].names: if 'opyright' in name.string.decode(name.getEncoding())\ and name.nameID == NameID.DESCRIPTION: failed...
[ "def", "com_google_fonts_check_name_no_copyright_on_description", "(", "ttFont", ")", ":", "failed", "=", "False", "for", "name", "in", "ttFont", "[", "'name'", "]", ".", "names", ":", "if", "'opyright'", "in", "name", ".", "string", ".", "decode", "(", "name"...
Description strings in the name table must not contain copyright info.
[ "Description", "strings", "in", "the", "name", "table", "must", "not", "contain", "copyright", "info", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/name.py#L42-L58
train
googlefonts/fontbakery
Lib/fontbakery/profiles/name.py
com_google_fonts_check_monospace
def com_google_fonts_check_monospace(ttFont, glyph_metrics_stats): """Checking correctness of monospaced metadata. There are various metadata in the OpenType spec to specify if a font is monospaced or not. If the font is not trully monospaced, then no monospaced metadata should be set (as sometimes they mist...
python
def com_google_fonts_check_monospace(ttFont, glyph_metrics_stats): """Checking correctness of monospaced metadata. There are various metadata in the OpenType spec to specify if a font is monospaced or not. If the font is not trully monospaced, then no monospaced metadata should be set (as sometimes they mist...
[ "def", "com_google_fonts_check_monospace", "(", "ttFont", ",", "glyph_metrics_stats", ")", ":", "from", "fontbakery", ".", "constants", "import", "(", "IsFixedWidth", ",", "PANOSE_Proportion", ")", "failed", "=", "False", "# Note: These values are read from the dict here on...
Checking correctness of monospaced metadata. There are various metadata in the OpenType spec to specify if a font is monospaced or not. If the font is not trully monospaced, then no monospaced metadata should be set (as sometimes they mistakenly are...) Monospace fonts must: * post.isFixedWidth "Set to 0...
[ "Checking", "correctness", "of", "monospaced", "metadata", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/name.py#L66-L177
train
googlefonts/fontbakery
Lib/fontbakery/profiles/name.py
com_google_fonts_check_name_line_breaks
def com_google_fonts_check_name_line_breaks(ttFont): """Name table entries should not contain line-breaks.""" failed = False for name in ttFont["name"].names: string = name.string.decode(name.getEncoding()) if "\n" in string: failed = True yield FAIL, ("Name entry {} on platform {} contains" ...
python
def com_google_fonts_check_name_line_breaks(ttFont): """Name table entries should not contain line-breaks.""" failed = False for name in ttFont["name"].names: string = name.string.decode(name.getEncoding()) if "\n" in string: failed = True yield FAIL, ("Name entry {} on platform {} contains" ...
[ "def", "com_google_fonts_check_name_line_breaks", "(", "ttFont", ")", ":", "failed", "=", "False", "for", "name", "in", "ttFont", "[", "\"name\"", "]", ".", "names", ":", "string", "=", "name", ".", "string", ".", "decode", "(", "name", ".", "getEncoding", ...
Name table entries should not contain line-breaks.
[ "Name", "table", "entries", "should", "not", "contain", "line", "-", "breaks", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/name.py#L183-L195
train
googlefonts/fontbakery
Lib/fontbakery/profiles/name.py
com_google_fonts_check_name_match_familyname_fullfont
def com_google_fonts_check_name_match_familyname_fullfont(ttFont): """Does full font name begin with the font family name?""" from fontbakery.utils import get_name_entry_strings familyname = get_name_entry_strings(ttFont, NameID.FONT_FAMILY_NAME) fullfontname = get_name_entry_strings(ttFont, NameID.FULL_FONT_NA...
python
def com_google_fonts_check_name_match_familyname_fullfont(ttFont): """Does full font name begin with the font family name?""" from fontbakery.utils import get_name_entry_strings familyname = get_name_entry_strings(ttFont, NameID.FONT_FAMILY_NAME) fullfontname = get_name_entry_strings(ttFont, NameID.FULL_FONT_NA...
[ "def", "com_google_fonts_check_name_match_familyname_fullfont", "(", "ttFont", ")", ":", "from", "fontbakery", ".", "utils", "import", "get_name_entry_strings", "familyname", "=", "get_name_entry_strings", "(", "ttFont", ",", "NameID", ".", "FONT_FAMILY_NAME", ")", "fullf...
Does full font name begin with the font family name?
[ "Does", "full", "font", "name", "begin", "with", "the", "font", "family", "name?" ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/name.py#L201-L232
train
googlefonts/fontbakery
Lib/fontbakery/profiles/name.py
com_google_fonts_check_family_naming_recommendations
def com_google_fonts_check_family_naming_recommendations(ttFont): """Font follows the family naming recommendations?""" # See http://forum.fontlab.com/index.php?topic=313.0 import re from fontbakery.utils import get_name_entry_strings bad_entries = [] # <Postscript name> may contain only a-zA-Z0-9 # and ...
python
def com_google_fonts_check_family_naming_recommendations(ttFont): """Font follows the family naming recommendations?""" # See http://forum.fontlab.com/index.php?topic=313.0 import re from fontbakery.utils import get_name_entry_strings bad_entries = [] # <Postscript name> may contain only a-zA-Z0-9 # and ...
[ "def", "com_google_fonts_check_family_naming_recommendations", "(", "ttFont", ")", ":", "# See http://forum.fontlab.com/index.php?topic=313.0", "import", "re", "from", "fontbakery", ".", "utils", "import", "get_name_entry_strings", "bad_entries", "=", "[", "]", "# <Postscript n...
Font follows the family naming recommendations?
[ "Font", "follows", "the", "family", "naming", "recommendations?" ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/name.py#L238-L332
train
googlefonts/fontbakery
Lib/fontbakery/profiles/name.py
com_google_fonts_check_name_rfn
def com_google_fonts_check_name_rfn(ttFont): """Name table strings must not contain the string 'Reserved Font Name'.""" failed = False for entry in ttFont["name"].names: string = entry.toUnicode() if "reserved font name" in string.lower(): yield WARN, ("Name table entry (\"{}\")" ...
python
def com_google_fonts_check_name_rfn(ttFont): """Name table strings must not contain the string 'Reserved Font Name'.""" failed = False for entry in ttFont["name"].names: string = entry.toUnicode() if "reserved font name" in string.lower(): yield WARN, ("Name table entry (\"{}\")" ...
[ "def", "com_google_fonts_check_name_rfn", "(", "ttFont", ")", ":", "failed", "=", "False", "for", "entry", "in", "ttFont", "[", "\"name\"", "]", ".", "names", ":", "string", "=", "entry", ".", "toUnicode", "(", ")", "if", "\"reserved font name\"", "in", "str...
Name table strings must not contain the string 'Reserved Font Name'.
[ "Name", "table", "strings", "must", "not", "contain", "the", "string", "Reserved", "Font", "Name", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/name.py#L338-L351
train
googlefonts/fontbakery
Lib/fontbakery/profiles/name.py
com_adobe_fonts_check_family_max_4_fonts_per_family_name
def com_adobe_fonts_check_family_max_4_fonts_per_family_name(ttFonts): """Verify that each group of fonts with the same nameID 1 has maximum of 4 fonts""" from collections import Counter from fontbakery.utils import get_name_entry_strings failed = False family_names = list() for ttFont in ttFonts: na...
python
def com_adobe_fonts_check_family_max_4_fonts_per_family_name(ttFonts): """Verify that each group of fonts with the same nameID 1 has maximum of 4 fonts""" from collections import Counter from fontbakery.utils import get_name_entry_strings failed = False family_names = list() for ttFont in ttFonts: na...
[ "def", "com_adobe_fonts_check_family_max_4_fonts_per_family_name", "(", "ttFonts", ")", ":", "from", "collections", "import", "Counter", "from", "fontbakery", ".", "utils", "import", "get_name_entry_strings", "failed", "=", "False", "family_names", "=", "list", "(", ")"...
Verify that each group of fonts with the same nameID 1 has maximum of 4 fonts
[ "Verify", "that", "each", "group", "of", "fonts", "with", "the", "same", "nameID", "1", "has", "maximum", "of", "4", "fonts" ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/name.py#L421-L445
train
googlefonts/fontbakery
Lib/fontbakery/profiles/cmap.py
com_google_fonts_check_family_equal_unicode_encodings
def com_google_fonts_check_family_equal_unicode_encodings(ttFonts): """Fonts have equal unicode encodings?""" encoding = None failed = False for ttFont in ttFonts: cmap = None for table in ttFont['cmap'].tables: if table.format == 4: cmap = table break # Could a font lack a for...
python
def com_google_fonts_check_family_equal_unicode_encodings(ttFonts): """Fonts have equal unicode encodings?""" encoding = None failed = False for ttFont in ttFonts: cmap = None for table in ttFont['cmap'].tables: if table.format == 4: cmap = table break # Could a font lack a for...
[ "def", "com_google_fonts_check_family_equal_unicode_encodings", "(", "ttFonts", ")", ":", "encoding", "=", "None", "failed", "=", "False", "for", "ttFont", "in", "ttFonts", ":", "cmap", "=", "None", "for", "table", "in", "ttFont", "[", "'cmap'", "]", ".", "tab...
Fonts have equal unicode encodings?
[ "Fonts", "have", "equal", "unicode", "encodings?" ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/cmap.py#L10-L30
train
googlefonts/fontbakery
Lib/fontbakery/profiles/cmap.py
com_google_fonts_check_all_glyphs_have_codepoints
def com_google_fonts_check_all_glyphs_have_codepoints(ttFont): """Check all glyphs have codepoints assigned.""" failed = False for subtable in ttFont['cmap'].tables: if subtable.isUnicode(): for item in subtable.cmap.items(): codepoint = item[0] if codepoint is None: failed = T...
python
def com_google_fonts_check_all_glyphs_have_codepoints(ttFont): """Check all glyphs have codepoints assigned.""" failed = False for subtable in ttFont['cmap'].tables: if subtable.isUnicode(): for item in subtable.cmap.items(): codepoint = item[0] if codepoint is None: failed = T...
[ "def", "com_google_fonts_check_all_glyphs_have_codepoints", "(", "ttFont", ")", ":", "failed", "=", "False", "for", "subtable", "in", "ttFont", "[", "'cmap'", "]", ".", "tables", ":", "if", "subtable", ".", "isUnicode", "(", ")", ":", "for", "item", "in", "s...
Check all glyphs have codepoints assigned.
[ "Check", "all", "glyphs", "have", "codepoints", "assigned", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/cmap.py#L42-L54
train
googlefonts/fontbakery
Lib/fontbakery/reporters/__init__.py
FontbakeryReporter.run
def run(self, order=None): """ self.runner must be present """ for event in self.runner.run(order=order): self.receive(event)
python
def run(self, order=None): """ self.runner must be present """ for event in self.runner.run(order=order): self.receive(event)
[ "def", "run", "(", "self", ",", "order", "=", "None", ")", ":", "for", "event", "in", "self", ".", "runner", ".", "run", "(", "order", "=", "order", ")", ":", "self", ".", "receive", "(", "event", ")" ]
self.runner must be present
[ "self", ".", "runner", "must", "be", "present" ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/reporters/__init__.py#L45-L50
train
googlefonts/fontbakery
Lib/fontbakery/profiles/universal.py
com_google_fonts_check_name_trailing_spaces
def com_google_fonts_check_name_trailing_spaces(ttFont): """Name table records must not have trailing spaces.""" failed = False for name_record in ttFont['name'].names: name_string = name_record.toUnicode() if name_string != name_string.strip(): failed = True name_key = tuple([name_record.plat...
python
def com_google_fonts_check_name_trailing_spaces(ttFont): """Name table records must not have trailing spaces.""" failed = False for name_record in ttFont['name'].names: name_string = name_record.toUnicode() if name_string != name_string.strip(): failed = True name_key = tuple([name_record.plat...
[ "def", "com_google_fonts_check_name_trailing_spaces", "(", "ttFont", ")", ":", "failed", "=", "False", "for", "name_record", "in", "ttFont", "[", "'name'", "]", ".", "names", ":", "name_string", "=", "name_record", ".", "toUnicode", "(", ")", "if", "name_string"...
Name table records must not have trailing spaces.
[ "Name", "table", "records", "must", "not", "have", "trailing", "spaces", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/universal.py#L45-L61
train
googlefonts/fontbakery
Lib/fontbakery/profiles/universal.py
com_google_fonts_check_family_single_directory
def com_google_fonts_check_family_single_directory(fonts): """Checking all files are in the same directory. If the set of font files passed in the command line is not all in the same directory, then we warn the user since the tool will interpret the set of files as belonging to a single family (and it is unlik...
python
def com_google_fonts_check_family_single_directory(fonts): """Checking all files are in the same directory. If the set of font files passed in the command line is not all in the same directory, then we warn the user since the tool will interpret the set of files as belonging to a single family (and it is unlik...
[ "def", "com_google_fonts_check_family_single_directory", "(", "fonts", ")", ":", "directories", "=", "[", "]", "for", "target_file", "in", "fonts", ":", "directory", "=", "os", ".", "path", ".", "dirname", "(", "target_file", ")", "if", "directory", "not", "in...
Checking all files are in the same directory. If the set of font files passed in the command line is not all in the same directory, then we warn the user since the tool will interpret the set of files as belonging to a single family (and it is unlikely that the user would store the files from a single family s...
[ "Checking", "all", "files", "are", "in", "the", "same", "directory", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/universal.py#L194-L218
train
googlefonts/fontbakery
Lib/fontbakery/profiles/universal.py
com_google_fonts_check_ftxvalidator
def com_google_fonts_check_ftxvalidator(font): """Checking with ftxvalidator.""" import plistlib try: import subprocess ftx_cmd = [ "ftxvalidator", "-t", "all", # execute all checks font ] ftx_output = subprocess.check_output(ftx_cmd, stderr=subprocess.STDOUT) ...
python
def com_google_fonts_check_ftxvalidator(font): """Checking with ftxvalidator.""" import plistlib try: import subprocess ftx_cmd = [ "ftxvalidator", "-t", "all", # execute all checks font ] ftx_output = subprocess.check_output(ftx_cmd, stderr=subprocess.STDOUT) ...
[ "def", "com_google_fonts_check_ftxvalidator", "(", "font", ")", ":", "import", "plistlib", "try", ":", "import", "subprocess", "ftx_cmd", "=", "[", "\"ftxvalidator\"", ",", "\"-t\"", ",", "\"all\"", ",", "# execute all checks", "font", "]", "ftx_output", "=", "sub...
Checking with ftxvalidator.
[ "Checking", "with", "ftxvalidator", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/universal.py#L258-L292
train
googlefonts/fontbakery
Lib/fontbakery/profiles/universal.py
com_google_fonts_check_ots
def com_google_fonts_check_ots(font): """Checking with ots-sanitize.""" import ots try: process = ots.sanitize(font, check=True, capture_output=True) except ots.CalledProcessError as e: yield FAIL, ( "ots-sanitize returned an error code ({}). Output follows:\n\n{}{}" ).format(e.returncode, e....
python
def com_google_fonts_check_ots(font): """Checking with ots-sanitize.""" import ots try: process = ots.sanitize(font, check=True, capture_output=True) except ots.CalledProcessError as e: yield FAIL, ( "ots-sanitize returned an error code ({}). Output follows:\n\n{}{}" ).format(e.returncode, e....
[ "def", "com_google_fonts_check_ots", "(", "font", ")", ":", "import", "ots", "try", ":", "process", "=", "ots", ".", "sanitize", "(", "font", ",", "check", "=", "True", ",", "capture_output", "=", "True", ")", "except", "ots", ".", "CalledProcessError", "a...
Checking with ots-sanitize.
[ "Checking", "with", "ots", "-", "sanitize", "." ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/universal.py#L298-L314
train
googlefonts/fontbakery
Lib/fontbakery/profiles/universal.py
com_google_fonts_check_fontbakery_version
def com_google_fonts_check_fontbakery_version(): """Do we have the latest version of FontBakery installed?""" try: import subprocess installed_str = None latest_str = None is_latest = False failed = False pip_cmd = ["pip", "search", "fontbakery"] pip_output = subprocess.check_output(pip...
python
def com_google_fonts_check_fontbakery_version(): """Do we have the latest version of FontBakery installed?""" try: import subprocess installed_str = None latest_str = None is_latest = False failed = False pip_cmd = ["pip", "search", "fontbakery"] pip_output = subprocess.check_output(pip...
[ "def", "com_google_fonts_check_fontbakery_version", "(", ")", ":", "try", ":", "import", "subprocess", "installed_str", "=", "None", "latest_str", "=", "None", "is_latest", "=", "False", "failed", "=", "False", "pip_cmd", "=", "[", "\"pip\"", ",", "\"search\"", ...
Do we have the latest version of FontBakery installed?
[ "Do", "we", "have", "the", "latest", "version", "of", "FontBakery", "installed?" ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/universal.py#L343-L373
train
googlefonts/fontbakery
Lib/fontbakery/profiles/universal.py
com_google_fonts_check_fontforge_stderr
def com_google_fonts_check_fontforge_stderr(font, fontforge_check_results): """FontForge validation outputs error messages?""" if "skip" in fontforge_check_results: yield SKIP, fontforge_check_results["skip"] return filtered_err_msgs = "" for line in fontforge_check_results["ff_err_messages"].split('\n...
python
def com_google_fonts_check_fontforge_stderr(font, fontforge_check_results): """FontForge validation outputs error messages?""" if "skip" in fontforge_check_results: yield SKIP, fontforge_check_results["skip"] return filtered_err_msgs = "" for line in fontforge_check_results["ff_err_messages"].split('\n...
[ "def", "com_google_fonts_check_fontforge_stderr", "(", "font", ",", "fontforge_check_results", ")", ":", "if", "\"skip\"", "in", "fontforge_check_results", ":", "yield", "SKIP", ",", "fontforge_check_results", "[", "\"skip\"", "]", "return", "filtered_err_msgs", "=", "\...
FontForge validation outputs error messages?
[ "FontForge", "validation", "outputs", "error", "messages?" ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/universal.py#L380-L401
train
googlefonts/fontbakery
Lib/fontbakery/profiles/universal.py
com_google_fonts_check_mandatory_glyphs
def com_google_fonts_check_mandatory_glyphs(ttFont): """Font contains .notdef as first glyph? The OpenType specification v1.8.2 recommends that the first glyph is the .notdef glyph without a codepoint assigned and with a drawing. https://docs.microsoft.com/en-us/typography/opentype/spec/recom#glyph-0-the-notd...
python
def com_google_fonts_check_mandatory_glyphs(ttFont): """Font contains .notdef as first glyph? The OpenType specification v1.8.2 recommends that the first glyph is the .notdef glyph without a codepoint assigned and with a drawing. https://docs.microsoft.com/en-us/typography/opentype/spec/recom#glyph-0-the-notd...
[ "def", "com_google_fonts_check_mandatory_glyphs", "(", "ttFont", ")", ":", "from", "fontbakery", ".", "utils", "import", "glyph_has_ink", "if", "(", "ttFont", ".", "getGlyphOrder", "(", ")", "[", "0", "]", "==", "\".notdef\"", "and", "\".notdef\"", "not", "in", ...
Font contains .notdef as first glyph? The OpenType specification v1.8.2 recommends that the first glyph is the .notdef glyph without a codepoint assigned and with a drawing. https://docs.microsoft.com/en-us/typography/opentype/spec/recom#glyph-0-the-notdef-glyph Pre-v1.8, it was recommended that a font shoul...
[ "Font", "contains", ".", "notdef", "as", "first", "glyph?" ]
b355aea2e619a4477769e060d24c32448aa65399
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/universal.py#L559-L586
train