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

Conversion to/from pathlib.Path in python bindings now rejects openstudio.Path #5133

Closed
jmarrec opened this issue Mar 29, 2024 · 0 comments · Fixed by #5170
Closed

Conversion to/from pathlib.Path in python bindings now rejects openstudio.Path #5133

jmarrec opened this issue Mar 29, 2024 · 0 comments · Fixed by #5170

Comments

@jmarrec
Copy link
Collaborator

jmarrec commented Mar 29, 2024

Issue overview

I messed something up in #4917

Current Behavior

openstudio.Path is not accepted anymore in python bindings.

Expected Behavior

Steps to Reproduce

In [1]: from pathlib import Path

In [2]: import openstudio

In [4]: m = openstudio.model.Model()

In [5]: m.save('model.osm', True)
Out[5]: True

In [6]: m.save(Path('model.osm'), True)
Out[6]: True

In [7]: m.save(openstudio.toPath('model.osm'), True)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[7], line 1
----> 1 m.save(openstudio.toPath('model.osm'), True)

File ~/Virtualenvs/py39/lib/python3.9/site-packages/openstudio/openstudioutilitiesidf.py:1997, in Workspace.save(self, p, overwrite)
   1996 def save(self, p, overwrite=False):
-> 1997     return _openstudioutilitiesidf.Workspace_save(self, p, overwrite)

TypeError: Wrong number or type of arguments for overloaded function 'Workspace_save'.
  Possible C/C++ prototypes are:
    openstudio::Workspace::save(openstudio::path const &,bool)
    openstudio::Workspace::save(openstudio::path const &)

Possible Solution

Details

Environment

Some additional details about your environment for this issue (if relevant):

  • Platform (Operating system, version): any, python
  • Version of OpenStudio (if using an intermediate build, include SHA): 3.7.0

Context

https://unmethours.com/question/98612/why-does-modelsavepath-fail-with-path-an-openstudiopath/

@jmarrec jmarrec self-assigned this Apr 25, 2024
jmarrec added a commit that referenced this issue Apr 25, 2024
jmarrec added a commit that referenced this issue Apr 25, 2024
Technically speaking, the typecheck is pointless, but whatever...
typecheck is used for overloading
jmarrec added a commit that referenced this issue Apr 25, 2024
Fix #5133 - Conversion to/from pathlib.Path in python bindings now rejects openstudio.Path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant