Skip to content

Commit

Permalink
Expand prime superscript support (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtth authored Sep 14, 2023
1 parent af94576 commit df6df50
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
5 changes: 4 additions & 1 deletion opvious/modeling/identifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,10 @@ def format_quantifier(

def _first_available(name: Name, env: Environment) -> Name:
while name in env:
name += "'"
if name.endswith("}"):
name = name[:-1] + r" \prime}"
else:
name += "'"
return name


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "opvious"
version = "0.18.0rc1"
version = "0.18.0rc2"
description = "Opvious Python SDK"
authors = ["Opvious Engineering <[email protected]>"]
readme = "README.md"
Expand Down
15 changes: 13 additions & 2 deletions tests/test_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,18 +253,29 @@ async def test_definition_counts(self):
@pytest.mark.asyncio
async def test_global_name_collision(self):
class _Model(om.Model):
count = om.Variable.natural()
cost = om.Variable.natural()
step_count = om.Variable.natural()
step_cost = om.Variable.non_negative()
step_color = om.Variable.non_negative()

@om.objective
def minimize_cost(self):
return self.step_count() + self.step_cost() + self.step_color()
return (
self.count()
+ self.cost()
+ self.step_count()
+ self.step_cost()
+ self.step_color()
)

model = _Model()
spec = await client.annotate_specification(model.specification())
assert spec.annotation.issue_count == 0
assert r"\chi^\mathrm{step}''" in spec.sources[0].text
text = spec.sources[0].text
assert r"\chi^\mathrm{step \prime}" in text
assert r"\chi^\mathrm{step \prime \prime}" in text
assert r"\chi'" in text

@pytest.mark.asyncio
async def test_annotate_markdown_repr(self):
Expand Down

0 comments on commit df6df50

Please sign in to comment.