-
Notifications
You must be signed in to change notification settings - Fork 388
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
Fix #6720 - Objects with different names will trigger a "Duplicate Name" Error in JSON #7036
Fix #6720 - Objects with different names will trigger a "Duplicate Name" Error in JSON #7036
Conversation
Using std::less in json.hpp for object_comparator makes t
@jmarrec could you pull develop into this branch and see if the test failures were due to a CI thing or if this branch actually breaks everything? |
@Myoldmopar done. Even though I push to my remote, any maintainer has write access to it so feel free to do that kind of stuff. If that's easier I could push to NREL/EnergyPlus in the future instead if you prefer (but that increases the attention needed to delete merge branches though in order to not clutter everything). |
@jmarrec so this is causing lots of issues. Our CI bots are failing (panicking on Linux...) due to bad allocations as they run out of memory. Something has gone very awry with this. I need to close this PR so that our CI machines don't continue to try to run. @mjwitte this is the cause of the memory issue I saw which caused me to ramp down the number of processors on the Linux machine. I'll be ramping it back up now... |
Oh, I kinda left that open-ended. @jmarrec please continue to investigate this, but again, I'm closing this PR so our CI machines won't continue trying to build it. |
@Myoldmopar I caught a tiny mistake in the alphanum stuff (my bad, copy paste error). Could we try the linux CI bots again? |
CI is slightly happier with this branch now 🙃 👍 I'll take a look at this one today. |
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.
The changes are appropriate in the alphanum library and there are good unit tests for this bug.
third_party/doj/alphanum.hpp
Outdated
|
||
/* $Header: /code/doj/alphanum.hpp,v 1.3 2008/01/28 23:06:47 doj Exp $ */ | ||
|
||
|
||
// MODIFIED: Julien Marrec, EffiBEM, on 2018-10-26 to avoids "n_001" being recognized as the same as "n_01" |
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.
Typically we haven't been adding attribution/bug issue comments like this in new E+ code and especially in third party libraries.
}; | ||
|
||
// This all works just fine | ||
test("Standard insulation"); |
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.
Interesting use of lambda's in the unit test. Seems like it might be overkill for this unit test, but I can think of other unit tests where this approach may come in handy for sure.
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.
@jmarrec I'm going to push a comment-only commit and merge this in. Thanks!
// Add the first material to it | ||
root[obj_name][name1] = mat1; | ||
|
||
auto test = [=](std::string search_name) { |
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.
@jmarrec it seems odd to put a lambda in here as opposed to making another function, but it's OK with me.
third_party/doj/alphanum.hpp
Outdated
|
||
/* $Header: /code/doj/alphanum.hpp,v 1.3 2008/01/28 23:06:47 doj Exp $ */ | ||
|
||
|
||
// MODIFIED: Julien Marrec, EffiBEM, on 2018-10-26 to avoids "n_001" being recognized as the same as "n_01" |
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.
@jmarrec it's important to track our changes to third_party libraries, but I don't like comments as the mechanism. These can easily get overridden when we bring in a new version of the library. I'm going to transform this comment into the start of a new file at third_party/PATCHES.md
where we'll keep track of all the changes we make to third_party libraries.
I’m still learning the E+ coding style so please continue to flag unusual stuff like this (and please excuse said unusual stuff, I don’t do it on purpose!). As for the use of lambda here, it’s a short code block that wouldn’t be used by any other test (but I hate repeating myself) so I thought a lambda made sense here. (And I guess I could have cleaned it up a bit though) |
Pull request overview
Fix #6720 duplicate name json
Issue was a problem in doj/alphanum.hpp when you have leading zeros. Basically it computes a number for the left side, and another for right side, and compares that. But that means "01" and "001" end up being the same, so it reports them as being equal. Adding a clause where when diff is zero, you also check the length of the left and right sides, and potentially return that.
Added unit tests, that fail without the fix (see https://github.com/jmarrec/EnergyPlus/tree/Do_Not_Publish/6720_UnitTestOnly) and work with it.
Rationale for leading zeroes
I had to made a choice for the case where you have leading zeroes as I couldn't really find any information online: I assume that if you have two strings,
"n_001"
and"n_1"
, I assume you want"n_001" < "n_1"
(behavior is easy to change if you disagree)Work Checklist
Add to this list or remove from it as applicable. This is a simple templated set of guidelines.
Review Checklist
This will not be exhaustively relevant to every PR.