Skip to content

Commit 1924ec0

Browse files
Updated mobject.py, test_copy.py, and conftest.py, from os to pathlib Path (#535)
Co-authored-by: kolibril13 <[email protected]>
1 parent 4693af3 commit 1924ec0

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

manim/mobject/mobject.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import copy
99
import itertools as it
1010
import operator as op
11-
import os
1211
import random
1312
import sys
1413

14+
from pathlib import Path
1515
from colour import Color
1616
import numpy as np
1717

@@ -199,7 +199,7 @@ def show(self, camera=None):
199199

200200
def save_image(self, name=None):
201201
self.get_image().save(
202-
os.path.join(file_writer_config["video_dir"], (name or str(self)) + ".png")
202+
Path(file_writer_config["video_dir"]).joinpath((name or str(self)) + ".png")
203203
)
204204

205205
def copy(self):

tests/test_copy.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import os
1+
from pathlib import Path
22
from manim import Mobject, BraceLabel, file_writer_config
33

44

@@ -20,11 +20,11 @@ def test_bracelabel_copy(tmp_path):
2020
# For this test to work, we need to tweak some folders temporarily
2121
original_text_dir = file_writer_config["text_dir"]
2222
original_tex_dir = file_writer_config["tex_dir"]
23-
mediadir = os.path.join(tmp_path, "deepcopy")
24-
file_writer_config["text_dir"] = os.path.join(mediadir, "Text")
25-
file_writer_config["tex_dir"] = os.path.join(mediadir, "Tex")
23+
mediadir = Path(tmp_path) / "deepcopy"
24+
file_writer_config["text_dir"] = str(mediadir.joinpath("Text"))
25+
file_writer_config["tex_dir"] = str(mediadir.joinpath("Tex"))
2626
for el in ["text_dir", "tex_dir"]:
27-
os.makedirs(file_writer_config[el])
27+
Path(file_writer_config[el]).mkdir(parents=True)
2828

2929
# Before the refactoring of Mobject.copy(), the class BraceLabel was the
3030
# only one to have a non-trivial definition of copy. Here we test that it
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import pytest
2-
import os
32

3+
from pathlib import Path
44

55
from manim import file_writer_config
66

77

88
@pytest.fixture
99
def manim_cfg_file():
10-
return os.path.join(os.path.dirname(__file__), "manim.cfg")
10+
return str(Path(__file__).parent / "manim.cfg")
1111

1212

1313
@pytest.fixture
1414
def simple_scenes_path():
15-
return os.path.join(os.path.dirname(__file__), "simple_scenes.py")
15+
return str(Path(__file__).parent / "simple_scenes.py")

0 commit comments

Comments
 (0)