Skip to content

Add pathlib support to Database reading#545

Merged
bocklund merged 2 commits intopycalphad:developfrom
bocklund:database-pathlib
Jul 14, 2024
Merged

Add pathlib support to Database reading#545
bocklund merged 2 commits intopycalphad:developfrom
bocklund:database-pathlib

Conversation

@bocklund
Copy link
Collaborator

Enables the following behavior:

from pathlib import Path
from pycalphad import Workspace
wks = Workspace()
wks.database = Path("dat/Fe-C.dat")

Closes #544

We test this by changing the tests that usually wrap files() output (a PosixPath) in a str() to make a string-like path. We remove this behavior in several tests.

This also changes some tests (test_unspecified_format_from_string and test_unspecified_format_from_file) to be more in line with what I interpreted to be the spirit of the tests: passing database strings (not strings for the paths to the databases) to Database.from_string or Database.from_file should fail if a format is not specified.

bocklund added 2 commits July 14, 2024 13:30
…ests

test_unspecified_format_from_string was testing from_string on a filepath, which probably makes less sense than on a Database

same thing in test_unspecified_format_from_file
@bocklund bocklund requested a review from richardotis July 14, 2024 20:38
@codecov
Copy link

codecov bot commented Jul 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.62%. Comparing base (8595b84) to head (921d6ca).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #545   +/-   ##
========================================
  Coverage    91.62%   91.62%           
========================================
  Files           60       60           
  Lines         9918     9924    +6     
========================================
+ Hits          9087     9093    +6     
  Misses         831      831           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bocklund bocklund merged commit b9b5509 into pycalphad:develop Jul 14, 2024
@bocklund bocklund deleted the database-pathlib branch July 14, 2024 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support pathlib.Path for Database construction

2 participants