Code Monkey home page Code Monkey logo

Comments (8)

leeping avatar leeping commented on July 4, 2024

from geometric.

dgasmith avatar dgasmith commented on July 4, 2024

Can you use:

if isinstance(constraint, str):
    ...
elif isinstance(constraint, (tuple, list)):
    ...
else:
   raise TypeError(...)

from geometric.

leeping avatar leeping commented on July 4, 2024

I think that could work - @yudongqiu , any thoughts?

Thanks,

  • Lee-Ping

from geometric.

yudongqiu avatar yudongqiu commented on July 4, 2024

I think list of tuples can work, dictionary may also work, the main thing is we need to be careful that it fully reproduces the original functionality.

from geometric.

leeping avatar leeping commented on July 4, 2024

Currently, an example of the constraints input string looks like this:

$freeze
xyz 1-5

$set
angle 2 1 5 110.0

# A comment
$scan
distance 2 1 1.0 1.2 3 # Another comment
dihedral 1 5 6 7 110.0 150.0 3

This corresponds to a dictionary that looks like this:

{ 
  'freeze' : [('xyz', '1-5')], 
  'set'    : [('angle', '2', '1', '5', '110.0')], 
  'scan'   : [('distance', '2', '1', '1.0', '1.2', '3'), 
              ('dihedral', '1', '5', '6', '7', '110.0', '150.0', '3')] 
}

I think we can easily have the JSON constraint input be a dictionary like the one above. It's much easier if we require all of the elements in each tuple to be "words" (i.e. strings without spaces). If so, all we need to do is write an extra function to convert the dictionary to the constraints input string and pass that to optimize.py::ParseConstraints() without modifying the latter.

from geometric.

leeping avatar leeping commented on July 4, 2024

I understand the alternative is to rewrite optimize.py::ParseConstraints() so that it supports multiple input types, but I don't see how that is possible without substantially restructuring it. That function is quite complicated because it supports simultaneous freezing / setting / scanning of various combinations of constraints.

from geometric.

yudongqiu avatar yudongqiu commented on July 4, 2024

@leeping Thanks a lot for the clear specs of the new constraints input format. I will implement that and make a PR soon.

from geometric.

leeping avatar leeping commented on July 4, 2024

Addressed in PR #27 .

from geometric.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.