Skip to content

Commit

Permalink
More spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
dkfellows committed Apr 6, 2023
1 parent 5b302f0 commit 3d6a809
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 53 deletions.
8 changes: 8 additions & 0 deletions .pylint_dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ ASB
sPyNNaker
CFF
Zenodo
DBs

# Sphinx keyword
py
rtype

# Python types
Expand All @@ -33,6 +35,8 @@ traceback
timedelta
RawConfigParser
AbstractBase
LogCapture
ZipFile

# Python pseudo-types
iterable
Expand All @@ -54,8 +58,12 @@ datetime
configparser
numpy
testfixtures
abc

# Misc
haha
stdin
whitespace
ids
submessage
subclassed
31 changes: 19 additions & 12 deletions spinn_utilities/bytestring_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,34 @@
# limitations under the License.


def as_string(bytestring, start=None, end=None):
def as_string(byte_string, start=None, end=None):
"""
Returns the length and the hex values.
The length is always the full length irrespective of the start and end.
:param bytes bytestring: data as a byte string
:param start: the inclusive start of the slice to return. May be `None`
:param end: the exclusive end of the slice to return. May be `None`
:return: The length of the byte string and the hex values, comma separated
:param bytes byte_string: data as a byte string
:param int start:
The inclusive start of the slice to convert to hexadecimal.
May be `None`
:param int end:
The exclusive end of the slice to convert to hexadecimal. May be `None`
:return:
The length of the byte string and the comma separated hex values, as a
descriptive string
:rtype: str
"""
return "(" + str(len(bytestring)) + ")" + as_hex(bytestring, start, end)
return "(" + str(len(byte_string)) + ")" + as_hex(byte_string, start, end)


def as_hex(bytestring, start=None, end=None):
def as_hex(byte_string, start=None, end=None):
"""
Returns the byte string as string showing the hex values
:param bytes bytestring: data as a byte string
:param start: the inclusive start of the slice to return. May be `None`
:param end: the exclusive end of the slice to return. May be `None`
:return: Comma separated hex values
:param bytes byte_string: data as a byte string
:param int start: the inclusive start of the slice to return. May be `None`
:param int end: the exclusive end of the slice to return. May be `None`
:return: Comma-separated hex values
:rtype: str
"""
return ','.join('%02x' % i for i in iter(bytestring[start:end]))
return ','.join('%02x' % i for i in iter(byte_string[start:end]))
8 changes: 4 additions & 4 deletions spinn_utilities/config_holder.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ def clear_cfg_files(unittest_mode):
__unittest_mode = unittest_mode


def set_cfg_files(configfile, default):
def set_cfg_files(config_file, default):
"""
Adds the configuration files to be loaded.
:param str configfile:
:param str config_file:
The base name of the configuration file(s).
Should not include any path components.
:param str default:
Full path to the extra file to get default configurations from.
"""
global __config_file
__config_file = configfile
__config_file = config_file
add_default_cfg(default)


Expand Down Expand Up @@ -349,7 +349,7 @@ def _check_cfg_file(config1, cfg_path):

def _check_cfgs(path):
"""
A testing function check local cfg files against the defaults.
A testing function check local configuration files against the defaults.
It only checks that the option exists in a default.
It does not check if the option is used or if the value is the expected
Expand Down
23 changes: 12 additions & 11 deletions spinn_utilities/data/utils_data_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,20 @@ class UtilsDataWriter(UtilsDataView):
Creating a new instant of the Writer will clear out any data added by the
previous instance.
Unittest can create a writer by doing `...Writer.mock()` or
`Writer.setup()`
The mock method adds some default data such as directories and
a Virtual 8 * 8 Machine, as well as allowing some backdoor methods.
`...Writer.mock()` is the recommended one for unit tests
Unit tests can create a writer by doing `...Writer.mock()` or
`Writer.setup()`.
The `mock` method adds some default data such as directories and
a Virtual 8 * 8 Machine, as well as allowing some back-door methods.
`...Writer.mock()` is the recommended one for unit tests;
`setup()` is more like what ASB does and allows for state changes such as
`writer.start_running`
`writer.start_running`.
ASB `__init__()` (or it subclasses) will create a new writer
so a call to `sim.setup` will clear all previously held data
so a call to `sim.setup` will clear all previously held data.
As the Writers are not designed for general usage the methods can change
without notice.
.. warning::
As the Writers are not designed for general usage the methods can
change without notice.
"""
__data = _UtilsDataModel()
__slots__ = []
Expand Down Expand Up @@ -107,7 +108,7 @@ def setup(cls):

def _mock(self):
"""
This method should only be called by mock (via init).
This method should only be called by `mock` (via `__init__`).
"""
self.__data._clear()
self.__data._data_status = DataStatus.MOCKED
Expand All @@ -116,7 +117,7 @@ def _mock(self):

def _setup(self):
"""
This method should only be called by setup (via init).
This method should only be called by `setup` (via `__init__`).
"""
self.__data._clear()
self.__data._data_status = DataStatus.SETUP
Expand Down
9 changes: 5 additions & 4 deletions spinn_utilities/find_max_success.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ def find_max_success(max_possible, check):
:param max_possible: The maximum value that should be tested.
:type max_possible: int
:param check: A boolean function that given an int value returns
True for every value up and including the cutoff and
True for every value up and including the cut-off and
False for every value greater than the cutoff
:type check: ~typing.Callable[[int], bool]
:return: The highest value that returns true for the check
but is not more than the max_possible
"""
Expand All @@ -44,9 +45,9 @@ def search_for_max_success(best_success, min_fail, check):
but must be greater than best_success but may also be negative
:type min_fail: int
:param check: A boolean function that given an int value returns
True for every value up and including the cutoff and
False for every value greater than the cutoff
:type check: callable(int, bool)
True for every value up and including the cut-off and
False for every value greater than the cut-off
:type check: ~typing.Callable[[int], bool]
:return: The highest value that returns true in the range between
`best_success` and `min_fail` (both exclusive ends) or `best_success`
if the whole range fails or is empty.
Expand Down
22 changes: 11 additions & 11 deletions spinn_utilities/helpful_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ def lcm(*numbers):
"""
Lowest common multiple of 0, 1 or more integers.
GIGO: If any of the values are anything except positive int values
GIGO: If any of the values are anything except positive `int` values
this function will either produce incorrect results or raise an exception.
:param numbers: The Positive integers to get the lcm for.
:param numbers: The Positive integers to get the LCM for.
This can be zero, one or more int values or
a singleton which is an iterator (possibly empty) of ints.
:return: the lcm or 1 if numbers is empty or an empty iterator
a singleton which is an iterator (possibly empty) of `int`\\s.
:return: the LCM, or 1 if `numbers` is empty or an empty iterator
:rtype: int
:raises TypeError: If any value can not be interpreted as an Integer
:raises TypeError: If any value cannot be interpreted as an integer
:raises ZeroDivisionError: May be raised if one of the values is zero
"""
if len(numbers) == 1:
Expand All @@ -66,15 +66,15 @@ def gcd(*numbers):
"""
Greatest common divisor of 1 or more integers.
GIGO: If any of the values are anything except positive int values
GIGO: If any of the values are anything except positive `int` values
this function will either produce incorrect results or raise an exception.
:param numbers: The Positive integers to get the GCD for.
This can be one or more int values or
a singleton which is an iterator (not empty) of ints.
:return: the gcd or 1 if numbers is empty or an empty iterator
:param numbers: The positive integers to get the GCD for.
This can be one or more `int` values or
a singleton which is an iterator (*not* empty) of `int`\\s.
:return: the GCD
:rtype: int
:raises TypeError: If any value can not be interpreted as an Integer or
:raises TypeError: If any value cannot be interpreted as an integer or
if no values are provided
:raises ZeroDivisionError: May be raised if one of the values is zero
"""
Expand Down
4 changes: 2 additions & 2 deletions spinn_utilities/log_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def store_log(self, level, message, timestamp=None):
:param int level: The logging level.
:param str message: The logged message.
:param timestamp: The timestamp of the message.
:type timestamp: datatime or None
:param timestamp: The time-stamp of the message.
:type timestamp: ~datetime.datetime or None
"""

@abstractmethod
Expand Down
16 changes: 8 additions & 8 deletions spinn_utilities/ranged/abstract_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_value(self, key):
:param key: The key or keys to get the value of. Use `None` for all
:type key: str or iterable(str) or None
:return: If key is a str, this returns the single object.
If key is iterable (list, tuple, set, etc) of str (or `None`),
If key is iterable (list, tuple, set, etc.) of str (or `None`),
returns a dictionary object
:raises ~spinn_utilities.ranged.MultipleValuesException:
If even one of the keys has multiple values set.
Expand Down Expand Up @@ -98,7 +98,7 @@ def iter_all_values(self, key, update_save=False):
faster but behaviour is *undefined* and *unchecked* if *any*
values are changed during iteration.
:return: If key is a str, this yields single objects.
If key is iterable (list, tuple, set, etc) of str (or `None`),
If key is iterable (list, tuple, set, etc.) of str (or `None`),
yields dictionary objects
"""

Expand All @@ -118,7 +118,7 @@ def get_ranges(self, key=None):
`start` is *inclusive* so is the first ID in the range.
`stop` is *exclusive* so is the last ID in the range + 1.
If `key` is a str, `value` is a single object.
If `key` is iterable (list, tuple, set, etc) of str (or `None`)
If `key` is iterable (list, tuple, set, etc.) of str (or `None`)
`value` is a dictionary object
"""
return list(self.iter_ranges(key=key))
Expand All @@ -141,7 +141,7 @@ def iter_ranges(self, key=None):
`start` is *inclusive* so is the first ID in the range.
`stop` is *exclusive* so is the last ID in the range + 1.
If `key` is a str, `value` is a single object.
If `key` is iterable (list, tuple, set, etc) of str (or `None`),
If `key` is iterable (list, tuple, set, etc.) of str (or `None`),
`value` is a dictionary object
"""

Expand All @@ -166,7 +166,7 @@ def items(self):
Works only if the whole ranges/view has single values.
If the ``key`` is a str, the ``value``\\s are single objects.
If the ``key`` is iterable (list, tuple, set, etc) of str (or `None`),
If the ``key`` is iterable (list, tuple, set, etc.) of str (or `None`),
the ``value``\\s are dictionary objects.
:return: List of (``key``, ``value``) tuples
Expand All @@ -186,7 +186,7 @@ def iteritems(self):
Works only if the whole ranges/view has single values.
If the ``key`` is a str, the ``value``\\s are single objects.
If the ``key`` is iterable (list, tuple, set, etc) of str (or `None`),
If the ``key`` is iterable (list, tuple, set, etc.) of str (or `None`),
the ``value``\\s are dictionary objects
This function is safe for value updates but may miss new keys
Expand All @@ -206,7 +206,7 @@ def values(self):
Works only if the whole ranges/view has single values.
If a key is a str, its value is a single object.
If a key is an iterable (list, tuple, set, etc) of str (or `None`),
If a key is an iterable (list, tuple, set, etc.) of str (or `None`),
its value is a dictionary object.
:return: List of values
Expand All @@ -225,7 +225,7 @@ def itervalues(self):
Works only if the whole ranges/view has single values.
If a key is a str, its value is a single object.
If a key is an iterable (list, tuple, set, etc) of str (or `None`),
If a key is an iterable (list, tuple, set, etc.) of str (or `None`),
its value is a dictionary object.
This function is safe for value updates but may miss new keys
Expand Down
2 changes: 1 addition & 1 deletion spinn_utilities/ranged/abstract_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AbstractList(AbstractSized, metaclass=AbstractBase):
Functions that change the size of the list are *not* supported.
These include::
`__setitem__` where key >= len
`__setitem__` where `key` >= `len`
`__delitem__`
`append`
`extend`
Expand Down

0 comments on commit 3d6a809

Please sign in to comment.