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

Add inspector for supercapacitor. #242

Merged
merged 8 commits into from
Dec 8, 2016
Merged

Conversation

Rombur
Copy link
Collaborator

@Rombur Rombur commented Dec 6, 2016

I have a problem with matplotlib so I can't run any tests... I will use the PR to run the tests, so don't merge this.

@dalg24
Copy link
Collaborator

dalg24 commented Dec 6, 2016

Somewhere in your test please pass an equivalent circuit to the inspector and make sure in throws the appropriate exception.

@codecov-io
Copy link

codecov-io commented Dec 6, 2016

Current coverage is 93.42% (diff: 95.83%)

Merging #242 into master will increase coverage by <.01%

@@             master       #242   diff @@
==========================================
  Files            72         72          
  Lines          4999       5017    +18   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           4670       4687    +17   
- Misses          329        330     +1   
  Partials          0          0          
Diff Coverage File Path
••••••••• 92% ...on/source/wrappers/energy_storage_device_wrappers.cc
•••••••••• 100% ...thon/source/wrappers/export_energy_storage_device.cc
•••••••••• 100% python/test/test_energy_storage_device_wrappers.py
•••••••••• 100% cpp/source/deal.II/supercapacitor.templates.h

Sunburst

Powered by Codecov. Last update d4bf68d...a2e319f

@codecov-io
Copy link

Current coverage is 93.42% (diff: 96.29%)

Merging #242 into master will increase coverage by <.01%

@@             master       #242   diff @@
==========================================
  Files            72         72          
  Lines          4999       5020    +21   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           4670       4690    +20   
- Misses          329        330     +1   
  Partials          0          0          
Diff Coverage File Path
••••••••• 92% ...on/source/wrappers/energy_storage_device_wrappers.cc
•••••••••• 100% cpp/source/deal.II/supercapacitor.templates.h
•••••••••• 100% ...thon/source/wrappers/export_energy_storage_device.cc
•••••••••• 100% python/test/test_energy_storage_device_wrappers.py

Sunburst

Powered by Codecov. Last update d4bf68d...8f60fbf

@codecov-io
Copy link

codecov-io commented Dec 6, 2016

Current coverage is 93.64% (diff: 100%)

Merging #242 into master will increase coverage by 0.22%

@@             master       #242   diff @@
==========================================
  Files            72         72          
  Lines          4999       5051    +52   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           4670       4730    +60   
+ Misses          329        321     -8   
  Partials          0          0          
Diff Coverage File Path
•••••••••• 100% ...thon/source/wrappers/export_energy_storage_device.cc
•••••••••• 100% python/test/test_energy_storage_device_wrappers.py
•••••••••• 100% ...on/source/wrappers/energy_storage_device_wrappers.cc
•••••••••• 100% cpp/source/deal.II/geometry.templates.h
•••••••••• 100% cpp/test/test_geometry.cc
•••••••••• 100% cpp/source/deal.II/supercapacitor.templates.h

Sunburst

Powered by Codecov. Last update cfa1df9...8b9ba78

@Rombur Rombur force-pushed the inspector branch 2 times, most recently from 33c0188 to 720e48f Compare December 7, 2016 20:31
@Rombur Rombur changed the title [WIP] Add inspector for supercapacitor. Add inspector for supercapacitor. Dec 7, 2016
@Rombur
Copy link
Collaborator Author

Rombur commented Dec 7, 2016

OK this is ready for review.

@Rombur
Copy link
Collaborator Author

Rombur commented Dec 7, 2016

You should check that the docker compose works for you.

if (supercapacitor == nullptr)
{
std::bad_cast exception;
throw exception;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw std::bad_cast();
Please comment and explain why you had to throw the exception yourself.

geometry->get_triangulation();
write_mesh("output_test_geometry_2.vtu", geometry->get_triangulation());
const unsigned int n_cells = 1536;
BOOST_CHECK(n_cells == triangulation->n_active_cells());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you annotate to say that the test just constructs the geom and that you just check by hand the number of cells?

}
else
throw std::runtime_error("Unknown inspector type");

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you use a loop here

for inspector : {2d ,3d}
    try
        device.inspect
        break
    catch bad_cast
if caught bad_cast each time throw a runtime exception

@@ -4,6 +4,9 @@
namespace pycap
{

// Macro to enable default arguments
BOOST_PYTHON_FUNCTION_OVERLOADS(inspect_overloads, inspect, 1, 2)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to document what is the default value for the string argument?

device = EnergyStorageDevice(ptree)
# data = device.inspect('postprocessor')
# self.assertTrue(isinstance(data, dict))
# self.assertEqual(len(data), 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may want to test this.

@Rombur
Copy link
Collaborator Author

Rombur commented Dec 8, 2016

Ready for re-review.

device = EnergyStorageDevice(ptree)
data = device.inspect('postprocessor')
self.assertTrue(isinstance(data, dict))
self.assertEqual(len(data), 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't want to check that a .vtu file has been created here?

Copy link
Collaborator

@dalg24 dalg24 Dec 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, empty dictionaries evaluate to False in Python so you could do self.assert(not data).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may use os.path.isfile(path) to check that the file has been created.

inspectors.push_back(std::shared_ptr<cap::EnergyStorageDeviceInspector> (
new cap::SuperCapacitorInspector<2>()));
inspectors.push_back(std::shared_ptr<cap::EnergyStorageDeviceInspector> (
new cap::SuperCapacitorInspector<3>()));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good place for std::make_shared but you don't need to change it.

@@ -59,6 +59,20 @@ def test_inspect_device(self):
self.assertTrue(key in data)
print(data)

def test_postprocessor_inspect(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized we forgot to do self.assertRaises(RuntimeError, device.inspect, 'invalid')

@Rombur
Copy link
Collaborator Author

Rombur commented Dec 8, 2016

Done

@dalg24 dalg24 merged commit 6b79139 into ORNL-CEES:master Dec 8, 2016
@dalg24 dalg24 removed the need review label Dec 8, 2016
@dalg24 dalg24 mentioned this pull request Dec 8, 2016
@Rombur Rombur deleted the inspector branch December 8, 2016 20:40
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.

None yet

3 participants