Git Product home page Git Product logo

spatial-sites's People

Contributors

aplowman avatar

spatial-sites's Issues

Prevent reassignment of labelled coordinate attributes like `x`, `y`, `z`

s1 = Sites(coords=..., labels=...)

After instantiation, s1.coords[0] == s1.x

Currently, we can reassign the default coordinate attributes like: s1.x = 0, after which s1.x no longer refers to the same thing as s1.coords[0]. So to avoid this, prevent reassignment of s1.x and similar attributes.

[WIP] Methods and properties for initial beta version

For Sites objects: s1, s2:

Addition-like

Add a vector to all site coordinates (vector must have correct shape):

  • s1 += vector
  • s1' = s1 + vector == vector + s1
  • s1.translate(vector)

Combining multiple Sites objects to increase the number of coordinates (all Sites objects must have the same labels defined):

  • s1 += s2
  • s1' = s1 + s2 != s2 + s1
  • s1' = Sites.concatenate([s1, s2, ...])

Subtraction-like

Subtract a vector from all site coordinates (vector must have correct shape):

  • s1 -= vector
  • s1' = s1 - vector != vector - s1
  • s1.translate(-vector)

Removing coordinates according to some condition(s):

  • Remove coordinates based on a label condition: s1.remove(species='Zr')
  • Remove coordinates based on coordinate positions s1.remove(s1.x > 0.5)

Multiplication-like

Scaling coordinates by a scalar number:

  • s1' = s1 * number == number * s1
  • s1 *= number

Transform coordinates according to a linear operator (matrix), mat (what are the conditions on mat with respect to the dimension and basis attributes?):

  • Allowed only if vector_direction == column:
    • s1' = mat @ s1
  • Allowed only if vector_direction == row:
    • s1' = s1 @ mat
    • s1 @= mat
  • Some form of outer product multiplication; e.g. applying one set of sites at each site in another set (would need to think about bases). Would this use __mul__ or __matmul__? This became s1.tile(s2).

Division-like

Scaling coordinates by a scalar number (number must be non-zero):

  • s1' = s1 / number
  • s1 /= number

Get a subset of coordinates

  • Get coordinates based on label value: coords = s1.whose(label_name=label_value)
    • Note s1.whose(label_name=label_value) is the same as s1.sites[:, s.label_name== label_value] (if vector_direction == column)
  • Get coordinate indices based on label value coords_idx = s1.index(label_name=label_value)
  • Get coordinates based on coordinate positions coords = s1.where(s1.x <= 0.1)

Comparison

  • Equality (==) should check coordinates and labels are equivalent (or to within a small tolerance)
  • Other comparison operators (<, <=, >, >=):
    • Between two Sites, just pass directly to the corresponding Numpy methods
    • Between a Sites and a number or array, compare the self.coords with the number/array

Properties

  • Geometric centre: s1.centroid
  • Bounding box (orthogonal; assuming standard basis): s1.bounding_box

Add/remove label objects

  • s1.add_labels(label_name_1=(..., ...), label_name_2=(..., ...), ...)
  • s1.remove_labels('label_name_1', 'label_name_2', ...)

Other

  • Copy: s1' = s1.copy()
  • Rotate about point: s1.rotate(origin, [rot_mat, quaternion])
  • Get all x/y/z/nth coordinate components: s1.get_components(component_idx)
  • Add x/y/z attributes

Make `Sites` iterable

Each index into a Sites object should return a SingleSite object with similar attributes to the parent object.

Allow limited "fancy-indexing" like in Numpy

Consider a sites object:

s1 = Sites(coords=..., labels=...)`

We should be able to make a new sites object that contains a subset of the sites in the original object by using an integer or boolean index array:

s2 = s1[[1, 7, 2]]

I don't think there is a need for multi-dimensional indexing in this manner.

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.