Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backmerge: #2512 - Equilibrium Half Arrows are displayed incorrect when saved to PNG (svg) by default size #2538

Merged
merged 15 commits into from
Oct 10, 2024
Merged
38 changes: 22 additions & 16 deletions .github/workflows/indigo-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
git fetch --tags -f
- name: Check
run: |
python3 -m pip install -r api/python/requirements_dev.txt
python3 -m pip install -r api/python/requirements_dev.txt --break-system-packages
.ci/static_analysis_check.sh

build_indigo_libs_x86_64:
Expand Down Expand Up @@ -208,7 +208,7 @@ jobs:
name: indigo-libs-macos-aarch64
path: dist/
- name: Install Python test dependencies
run: python3 -m pip install -r api/python/requirements_dev.txt
run: python3 -m pip install -r api/python/requirements_dev.txt --break-system-packages
- name: Build wrappers
run: |
mkdir build
Expand Down Expand Up @@ -267,16 +267,16 @@ jobs:
name: indigo-python
path: dist/
- name: Install Pillow
run: python3 -m pip install Pillow==9.5.0
run: python -m pip install Pillow --break-system-packages
- name: Install wrappers Linux
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: python3 -m pip install dist/*manylinux1_x86_64*.whl
run: python3 -m pip install dist/*manylinux1_x86_64*.whl --break-system-packages
- name: Install wrappers Windows
if: ${{ startsWith(matrix.os, 'windows') }}
run: Get-ChildItem dist -Filter *win_amd64*.whl -Recurse | % { python3 -m pip install $_.FullName }
- name: Install wrappers macOS
if: ${{ startsWith(matrix.os, 'macos') }}
run: python3 -m pip install dist/*macosx_10_7_intel*.whl
run: python3 -m pip install dist/*macosx_10_7_intel*.whl --break-system-packages
- name: Test
run: python3 -Wignore api/tests/integration/test.py -t 1 -j junit_report.xml
- name: Publish Test Report
Expand Down Expand Up @@ -322,7 +322,7 @@ jobs:
run: |
apt update
apt install -y --no-install-recommends python3 python3-pip
python3 -m pip install Pillow==9.5.0
apt install -y python3-pil
python3 -m pip install dist/*manylinux2014_aarch64*.whl
python3 api/tests/integration/test.py -p basic/basic.py -t 1 -j junit_report.xml
- name: Publish Test Report
Expand Down Expand Up @@ -361,13 +361,13 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: '3.9'
architecture: x86
- name: Install Pillow
run: python -m pip install Pillow==9.5.0
run: python -m pip install Pillow --break-system-packages
- name: Install wrappers Windows
if: ${{ startsWith(matrix.os, 'windows') }}
run: Get-ChildItem dist -Filter *win32*.whl -Recurse | % { python -m pip install $_.FullName }
run: Get-ChildItem dist -Filter *win32*.whl -Recurse | % { python -m pip install $_.FullName --break-system-packages }
- name: Test
run: python api/tests/integration/test.py -t 1 -p basic/basic.py -j junit_report.xml
- name: Publish Test Report
Expand Down Expand Up @@ -516,7 +516,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ macos-13, ubuntu-latest, windows-latest ]
# os: [ macos-13, ubuntu-latest, windows-latest ]
os: [ macos-13, windows-latest ]
runs-on: ${{ matrix.os }}
needs: build_indigo_wrappers
steps:
Expand Down Expand Up @@ -547,6 +548,11 @@ jobs:
run: |
curl -Lo dotnet.tar.gz https://download.visualstudio.microsoft.com/download/pr/270b615f-5281-4c58-980f-d9f7a08db642/3e874492a9cb0d5b87195c596b46d609/dotnet-sdk-6.0.421-osx-x64.tar.gz
mkdir -p ${{ github.workspace }}/tmp/dotnet && tar zxf dotnet.tar.gz -C ${{ github.workspace }}/tmp/dotnet
- name: Install dotnet 6 linux
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
sudo apt update
sudo apt install -y dotnet-host dotnet-sdk-6.0
- name: Prepare UNIX
if: ${{ !startsWith(matrix.os, 'windows') }}
run: |
Expand Down Expand Up @@ -649,7 +655,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ '3.7', '3.10' ]
python-version: [ '3.9', '3.10' ]
needs: build_indigo_wrappers
steps:
- uses: actions/checkout@v3
Expand All @@ -667,10 +673,10 @@ jobs:
name: indigo-python
path: dist/
- name: Install latest indigo version
run: pip install ${GITHUB_WORKSPACE}/dist/epam.indigo-*manylinux1_x86_64.whl
run: pip install ${GITHUB_WORKSPACE}/dist/epam.indigo-*manylinux1_x86_64.whl --break-system-packages
working-directory: bingo/bingo-elastic/python
- name: Install dev dependencies
run: pip install ".[dev]"
run: pip install ".[dev]" --break-system-packages
working-directory: bingo/bingo-elastic/python
- name: Setup elasticsearch
run: docker run -d -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "indices.query.bool.max_clause_count=4096" docker.elastic.co/elasticsearch/elasticsearch:7.16.2
Expand All @@ -679,7 +685,7 @@ jobs:
- name: Build wheel
working-directory: bingo/bingo-elastic/python
run: |
pip install ".[async]"
pip install ".[async]" --break-system-packages
python setup.py bdist_wheel
cp dist/*.whl ${GITHUB_WORKSPACE}/dist/
- name: Run pylint
Expand Down Expand Up @@ -1000,7 +1006,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: '3.9'
- name: Git fetch tags
run: |
git config --global --add safe.directory '*'
Expand Down Expand Up @@ -1036,7 +1042,7 @@ jobs:
docker run --rm -d -p 5432:5432 -e "POSTGRES_PASSWORD=password" -v /home:/home epmlsop/bingo-postgres:${{ matrix.postgres_major_version }}-latest
- name: Install dev dependencies
run: |
pip install -r bingo/tests/requirements.txt
pip install -r bingo/tests/requirements.txt --break-system-packages
- name: Run Bingo tests
run: |
export PYTHONPATH=${{ github.workspace }}/bingo/bingo-elastic/python
Expand Down
2 changes: 1 addition & 1 deletion api/tests/integration/common/rendering/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def average_hash_and_sizes(self):
self.image = Image.open(self.image_path)
width, height = self.image.size
image = self.image.resize(
(self.hash_size, self.hash_size), Image.ANTIALIAS
(self.hash_size, self.hash_size), Image.LANCZOS
)
# image.show()
allchannelpixels = [
Expand Down
2 changes: 2 additions & 0 deletions api/tests/integration/ref/rendering/render_reactions.py.out
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ issue 2457 wrong chiral label position
issue_2457.png rendering status: OK
issue 2444 wrong arrow and plus width
issue_2444.png rendering status: OK
issue 2512 two short equilibrium half arrows
issue_2512.png rendering status: OK
141 changes: 141 additions & 0 deletions api/tests/integration/tests/rendering/reactions/issue_2512.ket
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
{
"root": {
"nodes": [
{
"$ref": "mol0"
},
{
"$ref": "mol1"
},
{
"type": "arrow",
"data": {
"mode": "unbalanced-equilibrium-filled-half-triangle",
"pos": [
{
"x": 13.700000000000001,
"y": -7.95,
"z": 0
},
{
"x": 14.700000000000001,
"y": -7.95,
"z": 0
}
]
}
}
],
"connections": [],
"templates": []
},
"mol0": {
"type": "molecule",
"atoms": [
{
"label": "C",
"location": [
12.549374214363931,
-8.432470415521406,
0
]
},
{
"label": "C",
"location": [
13.55062578563607,
-8.432470415521406,
0
]
},
{
"label": "C",
"location": [
13.050050188048687,
-7.567529584478595,
0
]
}
],
"bonds": [
{
"type": 1,
"atoms": [
0,
1
]
},
{
"type": 1,
"atoms": [
1,
2
]
},
{
"type": 1,
"atoms": [
2,
0
]
}
],
"stereoFlagPosition": {
"x": 13.55062578563607,
"y": 6.567529584478595,
"z": 0
}
},
"mol1": {
"type": "molecule",
"atoms": [
{
"label": "C",
"location": [
14.774374214363931,
-8.482470415521407,
0
]
},
{
"label": "C",
"location": [
15.77562578563607,
-8.482470415521407,
0
]
},
{
"label": "C",
"location": [
15.275050188048686,
-7.6175295844785955,
0
]
}
],
"bonds": [
{
"type": 1,
"atoms": [
0,
1
]
},
{
"type": 1,
"atoms": [
1,
2
]
},
{
"type": 1,
"atoms": [
2,
0
]
}
]
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions api/tests/integration/tests/rendering/render_reactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ def renderRxnfile(filename, outfile):
renderer.renderToFile(rxn, joinPathPy("out/" + png_fname, __file__))
print(checkImageSimilarity(png_fname))

print("issue 2512 two short equilibrium half arrows")
indigo.resetOptions()
indigo.setOption("ignore-stereochemistry-errors", "true")
indigo.setOption("render-background-color", "255, 255, 255")
indigo.setOption("render-output-format", "png")
fname = "issue_2512"
png_fname = fname + ".png"
ket_fname = joinPathPy("reactions/%s.ket" % fname, __file__)
rxn = indigo.loadReactionFromFile(ket_fname)
renderer.renderToFile(rxn, joinPathPy("out/" + png_fname, __file__))
print(checkImageSimilarity(png_fname))

if isIronPython():
renderer.Dispose()
indigo.Dispose()
2 changes: 1 addition & 1 deletion bingo/bingo-elastic/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
extras_require={
"async": ["elasticsearch[async]==7.16.2"],
"dev": [
'pylint==2.17.7; python_version=="3.7"',
'pylint==2.17.7; python_version=="3.9"',
'pylint==3.1.0; python_version>="3.10"',
"pytest",
"wheel",
Expand Down
13 changes: 11 additions & 2 deletions core/render2d/src/render_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1337,11 +1337,20 @@ void RenderContext::drawEquillibriumHalf(const Vec2f& p1, const Vec2f& p2, const
n.negate();
pa.addScaled(n, headwidth);
pb.addScaled(n, headwidth);
const float default_shift = headsize * 2.0f;
float shift = default_shift;
if ((len - shift * 2.0f) < default_shift)
{
if (len < default_shift * 2.0f)
shift = len / 4.0f; // too short arrow - shift will be 1/4 of arrow length, short part - 1/2
else
shift = (len - default_shift) / 2.0f; // short part of arrow will be headsize*2
}
if (is_unbalanced)
pa.addScaled(d, headsize * 2);
pa.addScaled(d, shift);
d.negate();
if (is_unbalanced)
pb.addScaled(d, headsize * 2);
pb.addScaled(d, shift);
drawHalfArrowHeader(pa, d, width, headwidth * width_scale, headsize, arrow_type);
drawBar(pb, pa, width, margin);
checkPathNonEmpty();
Expand Down
6 changes: 3 additions & 3 deletions utils/indigo-service/backend/service/tests/api/indigo_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def test_headers_wrong(self):
"ValidationError: {'input_format': ['Must be one of: %s']}"
% formats
)
self.assertEquals(
self.assertEqual(
expected_text,
result.text,
)
Expand All @@ -502,7 +502,7 @@ def test_headers_wrong(self):
"ValidationError: {'output_format': ['Must be one of: %s']}"
% formats
)
self.assertEquals(
self.assertEqual(
expected_text,
result.text,
)
Expand Down Expand Up @@ -2163,7 +2163,7 @@ def test_calculate(self):
# )
self.assertEqual(200, result.status_code)
result_data = json.loads(result.text)
self.assertEquals("16.0424604", result_data["molecular-weight"])
self.assertEqual("16.0424604", result_data["molecular-weight"])

def test_calculate_components_mol(self):
headers, data = self.get_headers(
Expand Down
Loading
Loading