Last active
June 27, 2021 17:10
-
-
Save mocquin/fbe0010a4b02ff0e4000ba933b2c8464 to your computer and use it in GitHub Desktop.
numpy_w
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
class Physical(): | |
def __init__(self, value, unit=""): | |
self.value = value # store the numerical value as a plain numpy array | |
self.unit = unit | |
def __repr__(self): | |
return f"<Physical:({self.value}, {self.unit})" | |
def __str__(self): | |
return f"{self.value} {self.unit}" | |
weights = Physical(np.array([55.6, 45.7, 80.3]), "kilogram") | |
print(weights) # [55.6 45.7 80.3] kilogram |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment