Skip to content

Commit

Permalink
WIP status of dim_order branch
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Tiemann <[email protected]>
  • Loading branch information
MichaelTiemannOSC committed Oct 28, 2023
1 parent 69f9474 commit e3d9bdc
Show file tree
Hide file tree
Showing 17 changed files with 987 additions and 1,018 deletions.
2 changes: 0 additions & 2 deletions pint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
UndefinedUnitError,
UnitStrippedWarning,
)
from .formatting import formatter, register_unit_format
from .registry import ApplicationRegistry, LazyRegistry, UnitRegistry
from .util import logger, pi_theorem # noqa: F401

Expand Down Expand Up @@ -134,7 +133,6 @@ def get_application_registry():
"RedefinitionError",
"UndefinedUnitError",
"UnitStrippedWarning",
"formatter",
"get_application_registry",
"set_application_registry",
"register_unit_format",
Expand Down
12 changes: 6 additions & 6 deletions pint/_vendor/flexparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def _build_delimiter_pattern(delimiters: ty.Tuple[str, ...]) -> re.Pattern:
DelimiterDictT = ty.Dict[str, ty.Tuple[DelimiterInclude, DelimiterAction]]


class Spliter:
class Splitter:
"""Content iterator splitting according to given delimiters.
The pattern can be changed dynamically sending a new pattern to the generator,
Expand Down Expand Up @@ -458,24 +458,24 @@ def __init__(
self, content: str, delimiters: DelimiterDictT, strip_spaces: bool = True
):
self._cache = collections.deque()
self._spliter = Spliter(content, delimiters)
self._splitter = Splitter(content, delimiters)
self._strip_spaces = strip_spaces

def __iter__(self):
return self

def set_delimiters(self, delimiters: DelimiterDictT):
self._spliter.set_delimiters(delimiters)
self._splitter.set_delimiters(delimiters)
if self._cache:
value = self.peek()
# Elements are 1 based indexing, while splitter is 0 based.
self._spliter.set_position(value.start_line - 1, value.start_col)
self._splitter.set_position(value.start_line - 1, value.start_col)
self._cache.clear()

def _get_next_strip(self) -> Statement:
part = ""
while not part:
start_line, start_col, end_line, end_col, part = next(self._spliter)
start_line, start_col, end_line, end_col, part = next(self._splitter)
lo = len(part)
part = part.lstrip()
start_col += lo - len(part)
Expand All @@ -494,7 +494,7 @@ def _get_next(self) -> Statement:

part = ""
while not part:
start_line, start_col, end_line, end_col, part = next(self._spliter)
start_line, start_col, end_line, end_col, part = next(self._splitter)

return Statement.from_statement_iterator_element(
(start_line + 1, start_col, end_line + 1, end_col, part)
Expand Down
2 changes: 0 additions & 2 deletions pint/default_en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
@defaults
group = international
system = mks
# This default order for sorting dimensions was described in the proposed ISO 80000 specification.
dim_order = [ "[substance]", "[mass]", "[current]", "[luminosity]", "[length]", "[]", "[time]", "[temperature]", ]
@end


Expand Down
3 changes: 2 additions & 1 deletion pint/delegates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@

from . import txt_defparser
from .base_defparser import ParserConfig, build_disk_cache_class
from .base_formatter import Formatter

__all__ = ["txt_defparser", "ParserConfig", "build_disk_cache_class"]
__all__ = ["txt_defparser", "ParserConfig", "build_disk_cache_class", "Formatter"]
Loading

0 comments on commit e3d9bdc

Please sign in to comment.