-
Notifications
You must be signed in to change notification settings - Fork 440
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
Renovate Dimension object #2953
Conversation
I had to write some code recently using the Dimension object and I was thinking that it would be useful to support initialization from a list, for example:
This is particularly useful when working with Slices to avoid doing this:
I think it might already be supported on the python side. Another useful thing would be to have direct access to the underlying std::vector object, or const iterators for it. That way, one could use Dimensions in loops more naturally. I was wondering, since you are modifying the class, would you be able to implement these changes as well? |
1519672
to
23fa005
Compare
I could look into it, but I have other priorities for the next couple of months. I am also yet to receive any feedback/reviews on the changes pushed so far, so I would prefer to have the commits of this PR to be about refactoring only. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable to me, though I'm not a big user of Dimension
and will defer to others. This would be a good time to get the deprecation warnings in, so the fns can be removed by 1.10. Are there any Python bindings that hit the deprecated fns? I think we could inject runtime depr warnings in python_helpers.py. The downside of the c-side warnings is that one only sees them when compiling.
I don't think so? They are not used in
Perhaps, but I delayed it because
|
Looks like export_mints.cc only, so you've got that covered, thanks.
Sounds fair. Two cycles may be good for the deprecation warning, as plugin devs like clear warnings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes. I requested some changes, some of which should be propagated to both the .h and .cc files.
…mension.cc, weaken deprecation messages
Co-authored-by: fevangelista <francesco.evangelista@emory.edu>
forgot to remove the constructor const qualifiers after updating the dimension .h and .cc
8dd48b5
to
6802ec5
Compare
Description
This PR aims to improve the Dimension object in various ways, by adding machine-readable (for eg. VSCode) docstrings, adding const to arguments, replacing
int
withsize_t
to matchstd::vector::operator[](std::size_t)
and cautiously deprecating member functions that deal with pointers.Not only are pointers more error-prone, they are currently involved in some strange interaction between
Dimension
andMatrix
objects, resulting in awkward roundabout initialization/construction that I hope to untangle before Psi4 1.11? (1.11, or maybe 1.12?).Please let me know if you feel the three deprecations in this PR would be too disruptive or otherwise undesirable, this PR is very much a "request for comments".
User API & Changelog headlines
Dimension
objects (Dimension& operator=(const int*)
) is being deprecated. Unless someone speaks up, 1.10 may be the last release to have it.Dimension
objects (operator int*()
andoperator const int*() const
) are being deprecated. Unless someone speaks up, 1.10 may be the last release to have them.Dimension
are now usingsize_t
instead ofint
for indexing:−
Dimension::Dimension(int, const std::string&)
is nowDimension::Dimension(size_t, const std::string&)
−
void Dimension::init(int, const std::string&)
is nowvoid Dimension::init(size_t, const std::string&)
−
int Dimension::n() const
is nowsize_t Dimension::n() const
−
int& Dimension::operator[](int)
is nowint& Dimension::operator[](size_t)
−
const int& Dimension::operator[](int) const
is nowconst int& Dimension::operator[](size_t) const
−
const int& Dimension::get(int) const
is nowconst int& Dimension::get(size_t) const
−
void Dimension::set(int, int)
is nowvoid Dimension::set(size_t, int)
Dev notes & details
dimension.h
to improve suggestions offered by IDEs like VSCodesize_t
is now used instead ofint
when dealing with array indexing. Python bindings have been updated to reflect the change in constructor arguments.const
where possibleDimension& operator=(int*)
,operator int*()
andoperator const int*() const
Checklist
Status