mdolab / baseclasses Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
There should be a way (via inheritance) to access and store the version of the inherited class instance. This can then be used in printing to make clear what version of the specific solver is.
There are two cases where we can do better
object
which can be either a single string or a list of strings. Example here. The easiest thing to do would be to force it to be a list, so the user must wrap single strings as a list. Or we can do some sort of fancier data typing if we want.Say you have a dictionary in the reference file, and use root_add_dict
for training/testing. If the reference dictionary is a superset of the dictionary generated from testing, then the test is considered to pass, since we just loop over the generated dictionary keys, rather than the reference dictionary keys.
Imagine if the reference JSON file contained the following dictionary
{'a':1, 'b':2, 'c':3}
and the dictionary generated by the test is
{'a':1, 'b':2}
root_add_dict
will consider the test to be successful.
The test should fail.
Now that we are all using Python 3, I don't think this is needed anymore. However, I want to know the motivation for this since ADflow is currently using this. Can I just remove the call in there? Perhaps @JustinSGray knows?
We don't have any explanation for people who want to write tests and use BaseRegTest
.
Example usage can be found in many of our repos, such as pyGeo and IDWarp. Complex use cases involving inherited test classes (e.g. ADflow) should also be mentioned.
Often if you want to be able to read the iteration printout of the pyAeroStructure MDA you have to suppress the iteration printing of the aero and structural solvers which can make it hard to diagnose problems. To help with this we should implement the ability to redirect the output from the 3 different solvers to 3 different files.
Previously, I implemented this in pyAeroStructure using multipoint's redirectIO
method, but it was bespoke and not extensible to other combinations of solvers. You can see the implementation here
Instead we should add redirectIO
functionality to our 3 solver types so they each can take a stdoutFile
argument.
We should aim to implement something like _setSTDOut
in the BaseSolver class so it can be inherited by each solver and then add in calls to it in the right places (e.g in __call__
, evalFunctions
etc) in each solver.
The CaseInsensitive
containers are not properly formatted when printed with pprint
. This bug was introduced with the ABC implementation in #51. I realized this because the ADflow options dictionary is now printed in one massive line instead of having line breaks. The same bug applies to both CaseInsensitiveDict
and CaseInsensitiveSet
.
Here is a MWE for CaseInsensitiveDict
:
from baseclasses.utils import CaseInsensitiveDict
from pprint import pprint
sensitive = {"b-longstring": 2, "a-longstring": 1, "c-longstring": 3, "e-longstring": 5, "d-longstring": 4}
insensitive = CaseInsensitiveDict(sensitive)
pprint(sensitive)
pprint(insensitive)
>>> pprint(sensitive)
{'a-longstring': 1,
'b-longstring': 2,
'c-longstring': 3,
'd-longstring': 4,
'e-longstring': 5}
>>> pprint(insensitive)
{'b-longstring': 2, 'a-longstring': 1, 'c-longstring': 3, 'e-longstring': 5, 'd-longstring': 4}
>>> pprint(sensitive)
{'a-longstring': 1,
'b-longstring': 2,
'c-longstring': 3,
'd-longstring': 4,
'e-longstring': 5}
>>> pprint(insensitive)
{'a-longstring': 1,
'b-longstring': 2,
'c-longstring': 3,
'd-longstring': 4,
'e-longstring': 5}
This repo barely has any tests. Some classes are well tested while others have zero tests whatsoever. In particular, more unit tests would be welcome. For reference, our test coverage is only 26%.
Currently, keys are cast to lower case on initialization and subsequent addition. We can instead keep those as they are, and just change the string comparison so that they are case insensitive. We should do the same thing for sets also.
Come up with a way during solver initialization to specify combination of options which are incompatible with each other.
In order to make this general, maybe use a tuple approach?
incompatibleOptions = [({"option1": "value1"}, {"option2": "value2"}), ...]
Similar to the reasoning presented in mdolab/pygeo#85. It would be useful to import BaseSolver
without importing mpi4py
. The problem occurs in the __init__.py
where BaseRegTest
is imported. The no-mpi branch removes the problematic line
This is a backward compatibility breaking change, but a potential fix is to remove the import BaseRegTest
from the __init__.py
Similar to the list of choices, we should also allow for sets. This would be useful for things like monitorVariables
in ADflow, where we want the default options to list out all the possible values. The user options would then be checked that it is a subset of the full set. This would also allow for a description of each value in the options table.
One question is whether these values should be ordered. For safety under parallel execution, we probably want to cast the final set (after error checking) into a sorted list, in case the solvers expect a list to iterate over.
For pretty much all the repos, we just promote all classes (and some functions too) to the top level using the root __init__
file. This "flat" structure works fine for simple repos, i.e. those with a single python wrapper file (IDwarp, pyHyp, etc.). But for more complex packages I think we should probably change this and create submodules, i.e. subdirectories with __init__
files in them.
However, if we do this we probably want to reorganize the __init__
files a bit. I see several approaches:
__init__
files empty, and explicitly import everything using the "full" path. Pro: very explicit. Con: very verbose/redundant__init__
file of the directory that contains the object. Pro: imports are nicer (from baseclasses.solvers import BaseSolver
). Con: have to decide what to promote, effectively designing the API.I am personally in favour of 2) but happy to have a discussion on this. Regardless, this will break backwards compatibility so we have to be careful. There are probably other repos out there that could benefit from this type of reorganization.
Questions:
Andrew from AERO740 found that when xref
, not xRef
is passed into AeroProblem()
, the initialization is just fine even though nothing is happening.
I think baseclasses should return an error.
__init__()
to list out all the kwargs.I am open to hearing other approaches too.
Something like
ap = AeroProblem(args=args, unsupportedArg=randomValue)
or rather
ap = AeroProblem(xref=0.5)
does not return an error that you're not setting xRef
as intended
…
Does not throw an error for unsupported keyword arguments in AeroProblem instantiation.
…
Throw an error for unsupported keyword argument
We should have a general way of handling option changes after instantiation
__call__
or equivalent should print the new modified optionsA declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.